Mercurial > octave
diff libgui/src/octave-qt-link.cc @ 21311:718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
* octave-qt-link.cc (do_debug_cd_or_addpath_error): Back out 65827e9cccb8
to use uiwidget_creator instead of QMessageBox.
* file_editor_tab.cc (handle_context_menu_break_condition):
Validate condition using bp_table::condition_valid, to allow
file_in_path to be called from a callback.jo
* debug.{cc,h} (condition_valid): make member method, not static function.
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Thu, 11 Feb 2016 19:59:32 +1100 |
parents | fc6a9bd59094 |
children | 062c65569ad7 |
line wrap: on
line diff
--- a/libgui/src/octave-qt-link.cc Sun Feb 14 13:16:05 2016 +1100 +++ b/libgui/src/octave-qt-link.cc Thu Feb 11 19:59:32 2016 +1100 @@ -44,6 +44,7 @@ #include "resource-manager.h" +#include <unistd.h> octave_qt_link::octave_qt_link (QWidget *p) : octave_link (), main_thread (new QThread ()), command_interpreter (new octave_interpreter ()) @@ -387,31 +388,46 @@ QString qdir = QString::fromStdString (dir); QString qfile = QString::fromStdString (file); + QString msg + = (addpath_option + ? tr ("The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path.").arg (qfile).arg (qdir) + : tr ("The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2.").arg (qfile).arg (qdir)); - QMessageBox msgBox; + QString title = tr ("Change Directory or Add Directory to Load Path"); - msgBox.setText ("File not in load path"); - QPushButton *cd_btn = msgBox.addButton (tr ("Change Directory"), - QMessageBox::YesRole); + QString cd_txt = tr ("Change Directory"); + QString addpath_txt = tr ("Add Directory to Load Path"); + QString cancel_txt = tr ("Cancel"); - QPushButton *addpath_btn = 0; + QStringList btn; + QStringList role; + btn << cd_txt; + role << "YesRole"; if (addpath_option) { - msgBox.setInformativeText (tr ("The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path.").arg (qfile).arg (qdir)); - addpath_btn = msgBox.addButton (tr ("Add Directory to Load Path"), - QMessageBox::AcceptRole); - } - else - { - msgBox.setInformativeText (tr ("The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2.").arg (qfile).arg (qdir)); - } - msgBox.setStandardButtons (QMessageBox::Cancel); + btn << addpath_txt; + role << "AcceptRole"; + } + btn << cancel_txt; + role << "RejectRole"; + + // Lock mutex before signaling. + uiwidget_creator.mutex.lock (); + + uiwidget_creator.signal_dialog (msg, title, "quest", btn, cancel_txt, role); - msgBox.exec (); + // Wait while the user is responding to message box. + uiwidget_creator.waitcondition.wait (&uiwidget_creator.mutex); + + // The GUI has sent a signal and the thread has been awakened. - if (msgBox.clickedButton () == cd_btn) - retval = 1; - else if (msgBox.clickedButton () == addpath_btn) + QString result = uiwidget_creator.get_dialog_button (); + + uiwidget_creator.mutex.unlock (); + + if (result == cd_txt) + retval = 1; + else if (result == addpath_txt) retval = 2; return retval;