Mercurial > hg > octave-nkf
comparison libgui/src/m-editor/file-editor.cc @ 19518:2b708273548d gui-release
button order in dialog for creating a non-existing file (bug #43537)
* file-editor.cc (request_open_file): use custom buttons named create and cancel
in dialog asking whether to create a new file or notice
* octave-qt-link.cc (do_prompt_new_edit_file): use buttons named create and
cancel and set appropriate roles in order to get a correct button ordering
depending on the platform
author | Torsten <ttl@justmail.de> |
---|---|
date | Sat, 08 Nov 2014 16:45:13 +0100 |
parents | 9582fad68730 |
children | ed0df431631b |
comparison
equal
deleted
inserted
replaced
19517:5fb4505b84ff | 19518:2b708273548d |
---|---|
402 msgBox->show (); | 402 msgBox->show (); |
403 } | 403 } |
404 else | 404 else |
405 { | 405 { |
406 // File does not exist, should it be crated? | 406 // File does not exist, should it be crated? |
407 bool create_file = true; | |
407 QMessageBox *msgBox; | 408 QMessageBox *msgBox; |
408 int answer; | |
409 QSettings *settings = resource_manager::get_settings (); | 409 QSettings *settings = resource_manager::get_settings (); |
410 if (settings->value ("editor/create_new_file", false).toBool ()) | 410 |
411 { | 411 if (!settings->value ("editor/create_new_file", false).toBool ()) |
412 answer = QMessageBox::Yes; | |
413 } | |
414 else | |
415 { | 412 { |
416 msgBox = new QMessageBox (QMessageBox::Question, | 413 msgBox = new QMessageBox (QMessageBox::Question, |
417 tr ("Octave Editor"), | 414 tr ("Octave Editor"), |
418 tr ("File\n%1\ndoes not exist. " | 415 tr ("File\n%1\ndoes not exist. " |
419 "Do you want to create it?").arg (openFileName), | 416 "Do you want to create it?").arg (openFileName), |
420 QMessageBox::Yes | 417 QMessageBox::NoButton,0); |
421 | QMessageBox::No, 0); | 418 QPushButton *create_button = |
422 | 419 msgBox->addButton (tr ("Create"), QMessageBox::YesRole); |
423 msgBox->setAttribute (Qt::WA_DeleteOnClose); | 420 msgBox->addButton (tr ("Cancel"), QMessageBox::RejectRole); |
424 answer = msgBox->exec (); | 421 msgBox->setDefaultButton (create_button); |
422 msgBox->exec (); | |
423 | |
424 QAbstractButton *clicked_button = msgBox->clickedButton (); | |
425 if (clicked_button != create_button) | |
426 create_file = false; | |
427 | |
428 delete msgBox; | |
425 } | 429 } |
426 | 430 |
427 if (answer == QMessageBox::Yes) | 431 if (create_file) |
428 { | 432 { |
429 // create the file and call the editor again | 433 // create the file and call the editor again |
430 QFile file (openFileName); | 434 QFile file (openFileName); |
431 if (!file.open (QIODevice::WriteOnly)) | 435 if (!file.open (QIODevice::WriteOnly)) |
432 { | 436 { |