Mercurial > octave
diff libgui/src/dialog.h @ 24718:ea1c88bd4430
move more GUI classes inside octave namespace
* color-picker.cc, color-picker.h, dialog.cc, dialog.h,
documentation-dock-widget.cc, documentation-dock-widget.h,
external-editor-interface.cc, external-editor-interface.h,
octave-cmd.cc, octave-cmd.h, octave-qt-link.cc, octave-qt-link.h,
qtinfo/webinfo.cc, qtinfo/webinfo.h, resource-manager.cc,
resource-manager.h, shortcut-manager.cc, shortcut-manager.h,
tab-bar.cc, tab-bar.h, welcome-wizard.cc, welcome-wizard.h: Move class
declarations and definitions inside octave namespace.
* thread-manager.h, thread-manager.cc (octave::thread_manager):
Rename from octave_thread_manager. Change all uses.
(octave::base_thread_manager): Rename from
octave_base_thread_manager. Change all uses.
* color-picker.h: Provide temporary using decl for
octave::color_picker to import it into the global namespace.
* resource-manager.h: Likewise, for octave::resource_manager.
* shortcut-manager.h: Likewise, for octave::shortcut_manager.
* tab-bar.h: Likewise, for octave::tab_bar.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Feb 2018 16:14:26 -0500 |
parents | c24b536df5d4 |
children | 6652d3823428 |
line wrap: on
line diff
--- a/libgui/src/dialog.h Fri Feb 09 14:52:29 2018 -0500 +++ b/libgui/src/dialog.h Fri Feb 09 16:14:26 2018 -0500 @@ -40,239 +40,243 @@ // Defined for purposes of sending QList<float> as part of signal. typedef QList<float> QFloatList; - -class QUIWidgetCreator : public QObject +namespace octave { - Q_OBJECT + class QUIWidgetCreator : public QObject + { + Q_OBJECT + + public: -public: + QUIWidgetCreator (void); + + ~QUIWidgetCreator (void); + + public: + + QString rm_amp (const QString& text); - QUIWidgetCreator (void); - - ~QUIWidgetCreator (void); + void signal_dialog (const QString& message, const QString& title, + const QString& icon, const QStringList& button, + const QString& defbutton, const QStringList& role) + { + // Store button text before a window-manager adds accelerators + m_button_list = button; -public: + // Use the last button in the list as the reject result, i.e., when no + // button is pressed such as in the case of the upper right close tab. + if (! button.isEmpty ()) + m_dialog_button = button.last (); - QString rm_amp (const QString& text); + QString xicon = icon; + if (xicon.isEmpty ()) + xicon = "none"; - void signal_dialog (const QString& message, const QString& title, - const QString& icon, const QStringList& button, - const QString& defbutton, const QStringList& role) - { - // Store button text before a window-manager adds accelerators - m_button_list = button; + emit create_dialog (message, title, xicon, button, defbutton, role); + }; + + int get_dialog_result (void) { return m_dialog_result; } + + QString get_dialog_button (void) { return m_dialog_button; } + + bool signal_listview (const QStringList& list, const QString& mode, + int wd, int ht, const QList<int>& initial, + const QString& name, const QStringList& prompt, + const QString& ok_string, + const QString& cancel_string) + { + if (list.isEmpty ()) + return false; - // Use the last button in the list as the reject result, i.e., when no - // button is pressed such as in the case of the upper right close tab. - if (! button.isEmpty ()) - m_dialog_button = button.last (); + emit create_listview (list, mode, wd, ht, initial, name, + prompt, ok_string, cancel_string); + + return true; + }; + + const QIntList * get_list_index (void) { return m_list_index; } - QString xicon = icon; - if (xicon.isEmpty ()) - xicon = "none"; + bool signal_inputlayout (const QStringList& prompt, const QString& title, + const QFloatList& nr, const QFloatList& nc, + const QStringList& defaults) + { + if (prompt.isEmpty ()) + return false; + + emit create_inputlayout (prompt, title, nr, nc, defaults); - emit create_dialog (message, title, xicon, button, defbutton, role); - }; + return true; + }; + + const QStringList * get_string_list (void) { return m_string_list; } - int get_dialog_result (void) { return m_dialog_result; } + bool signal_filedialog (const QStringList& filters, const QString& title, + const QString& filename, const QString& dirname, + const QString& multimode) + { + emit create_filedialog (filters, title, filename, dirname, multimode); + return true; + } - QString get_dialog_button (void) { return m_dialog_button; } + const QString * get_dialog_path (void) { return m_path_name; } - bool signal_listview (const QStringList& list, const QString& mode, - int wd, int ht, const QList<int>& initial, - const QString& name, const QStringList& prompt, - const QString& ok_string, const QString& cancel_string) - { - if (list.isEmpty ()) - return false; + void lock (void) { m_mutex.lock (); } + void wait (void) { m_waitcondition.wait (&m_mutex); } + void unlock (void) { m_mutex.unlock (); } + void wake_all (void) { m_waitcondition.wakeAll (); } + + signals: + + void create_dialog (const QString&, const QString&, const QString&, + const QStringList&, const QString&, const QStringList&); + + void create_listview (const QStringList&, const QString&, int, int, + const QIntList&, const QString&, const QStringList&, + const QString&, const QString&); + + void create_inputlayout (const QStringList&, const QString&, + const QFloatList&, const QFloatList&, + const QStringList&); - emit create_listview (list, mode, wd, ht, initial, name, - prompt, ok_string, cancel_string); + void create_filedialog (const QStringList& filters, const QString& title, + const QString& filename, const QString& dirname, + const QString& multimode); + public slots: + + void dialog_button_clicked (QAbstractButton *button); - return true; - }; + void list_select_finished (const QIntList& selected, int button_pressed); + + void input_finished (const QStringList& input, int button_pressed); - const QIntList * get_list_index (void) { return m_list_index; } + void filedialog_finished (const QStringList& files, const QString& path, + int filterindex); + + private: - bool signal_inputlayout (const QStringList& prompt, const QString& title, - const QFloatList& nr, const QFloatList& nc, - const QStringList& defaults) - { - if (prompt.isEmpty ()) - return false; + int m_dialog_result; + QString m_dialog_button; + + // A copy of the dialogs button texts + QStringList m_button_list; - emit create_inputlayout (prompt, title, nr, nc, defaults); + // The list could conceivably be big. Not sure how things are + // stored internally, so keep off of the stack. + QStringList *m_string_list; + QIntList *m_list_index; - return true; + QString *m_path_name; + + // GUI objects cannot be accessed in the non-GUI thread. However, + // signals can be sent to slots across threads with proper + // synchronization. Hence, the use of QWaitCondition. + QMutex m_mutex; + QWaitCondition m_waitcondition; }; - const QStringList * get_string_list (void) { return m_string_list; } - - bool signal_filedialog (const QStringList& filters, const QString& title, - const QString& filename, const QString& dirname, - const QString& multimode) - { - emit create_filedialog (filters, title, filename, dirname, multimode); - return true; - } - - const QString * get_dialog_path (void) { return m_path_name; } - - void lock (void) { m_mutex.lock (); } - void wait (void) { m_waitcondition.wait (&m_mutex); } - void unlock (void) { m_mutex.unlock (); } - void wake_all (void) { m_waitcondition.wakeAll (); } - -signals: + extern QUIWidgetCreator uiwidget_creator; - void create_dialog (const QString&, const QString&, const QString&, - const QStringList&, const QString&, const QStringList&); - - void create_listview (const QStringList&, const QString&, int, int, - const QIntList&, const QString&, const QStringList&, - const QString&, const QString&); - - void create_inputlayout (const QStringList&, const QString&, - const QFloatList&, const QFloatList&, - const QStringList&); + class MessageDialog : public QMessageBox + { + Q_OBJECT - void create_filedialog (const QStringList& filters, const QString& title, - const QString& filename, const QString& dirname, - const QString& multimode); -public slots: - - void dialog_button_clicked (QAbstractButton *button); - - void list_select_finished (const QIntList& selected, int button_pressed); - - void input_finished (const QStringList& input, int button_pressed); + public: - void filedialog_finished (const QStringList& files, const QString& path, - int filterindex); - -private: - - int m_dialog_result; - QString m_dialog_button; + explicit MessageDialog (const QString& message, const QString& title, + const QString& icon, const QStringList& button, + const QString& defbutton, + const QStringList& role); - // A copy of the dialogs button texts - QStringList m_button_list; - - // The list could conceivably be big. Not sure how things are - // stored internally, so keep off of the stack. - QStringList *m_string_list; - QIntList *m_list_index; - - QString *m_path_name; + private: - // GUI objects cannot be accessed in the non-GUI thread. However, - // signals can be sent to slots across threads with proper - // synchronization. Hence, the use of QWaitCondition. - QMutex m_mutex; - QWaitCondition m_waitcondition; -}; - -extern QUIWidgetCreator uiwidget_creator; + void closeEvent (QCloseEvent *) + { + // Reroute the close tab to a button click so there is only a single + // route to waking the wait condition. + emit buttonClicked (nullptr); + } + }; -class MessageDialog : public QMessageBox -{ - Q_OBJECT - -public: - - explicit MessageDialog (const QString& message, const QString& title, - const QString& icon, const QStringList& button, - const QString& defbutton, - const QStringList& role); - -private: - - void closeEvent (QCloseEvent *) + class ListDialog : public QDialog { - // Reroute the close tab to a button click so there is only a single - // route to waking the wait condition. - emit buttonClicked (nullptr); - } -}; + Q_OBJECT + + QItemSelectionModel *selector; + + public: -class ListDialog : public QDialog -{ - Q_OBJECT - - QItemSelectionModel *selector; + explicit ListDialog (const QStringList& list, const QString& mode, + int width, int height, const QList<int>& initial, + const QString& name, const QStringList& prompt, + const QString& ok_string, + const QString& cancel_string); -public: + ~ListDialog (void); - explicit ListDialog (const QStringList& list, const QString& mode, - int width, int height, const QList<int>& initial, - const QString& name, const QStringList& prompt, - const QString& ok_string, const QString& cancel_string); + signals: + + void finish_selection (const QIntList&, int); - ~ListDialog (void); + public slots: -signals: + void buttonOk_clicked (void); - void finish_selection (const QIntList&, int); + void buttonCancel_clicked (void); -public slots: + void reject (void); - void buttonOk_clicked (void); + void item_double_clicked (const QModelIndex&); - void buttonCancel_clicked (void); + private: - void reject (void); + QAbstractItemModel *m_model; + }; - void item_double_clicked (const QModelIndex&); + class InputDialog : public QDialog + { + Q_OBJECT -private: - - QAbstractItemModel *m_model; -}; + QList<QLineEdit *> input_line; -class InputDialog : public QDialog -{ - Q_OBJECT + public: - QList<QLineEdit *> input_line; + explicit InputDialog (const QStringList& prompt, const QString& title, + const QFloatList& nr, const QFloatList& nc, + const QStringList& defaults); -public: + signals: - explicit InputDialog (const QStringList& prompt, const QString& title, - const QFloatList& nr, const QFloatList& nc, - const QStringList& defaults); + void finish_input (const QStringList&, int); -signals: + public slots: - void finish_input (const QStringList&, int); - -public slots: + void buttonOk_clicked (void); - void buttonOk_clicked (void); + void buttonCancel_clicked (void); - void buttonCancel_clicked (void); + void reject (void); + }; - void reject (void); -}; + class FileDialog : public QFileDialog + { + Q_OBJECT -class FileDialog : public QFileDialog -{ - Q_OBJECT + public: -public: + explicit FileDialog (const QStringList& filters, + const QString& title, const QString& filename, + const QString& dirname, const QString& multimode); - explicit FileDialog (const QStringList& filters, - const QString& title, const QString& filename, - const QString& dirname, const QString& multimode); + signals: -signals: + void finish_input (const QStringList&, const QString&, int); + + private slots: - void finish_input (const QStringList&, const QString&, int); - -private slots: + void acceptSelection (void); - void acceptSelection (void); - - void rejectSelection (void); -}; + void rejectSelection (void); + }; +} #endif