Mercurial > octave
annotate libgui/src/dialog.cc @ 31626:9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
* dialog.h, dialog.cc (QUIWidgetCreator::m_octave_qobj):
Delete unnecessary data member.
(QUIWidgetCreator::QUIWidgetCreator, MessageDialog::MessageDialog,
ListDialog::ListDialog, InputDialog::InputDialog,
FileDialog::FileDialog): Eliminate base_qobject argument.
Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 03 Dec 2022 01:00:04 -0500 |
parents | ad014fc78bd6 |
children | 431f80aba37a |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
3 // Copyright (C) 2013-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21613
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21213
diff
changeset
|
27 # include "config.h" |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
26617
diff
changeset
|
30 #include <QFileInfo> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
26617
diff
changeset
|
31 #include <QListView> |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <QString> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <QStringList> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include <QStringListModel> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 // Could replace most of these with #include <QtGui> |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
26617
diff
changeset
|
36 #include <QGridLayout> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
26617
diff
changeset
|
37 #include <QGroupBox> |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include <QHBoxLayout> |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
26617
diff
changeset
|
39 #include <QLabel> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
26617
diff
changeset
|
40 #include <QMessageBox> |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include <QPushButton> |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
26617
diff
changeset
|
42 #include <QVBoxLayout> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
26617
diff
changeset
|
43 |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
26617
diff
changeset
|
44 #include "dialog.h" |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
45 #include "gui-preferences-global.h" |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
46 #include "gui-settings.h" |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
48 namespace octave |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 { |
31626
9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
50 QUIWidgetCreator::QUIWidgetCreator () |
9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
51 : QObject (), m_dialog_result (-1), m_dialog_button (), |
9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
52 m_string_list (), m_list_index (), m_path_name () |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
53 { |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
54 connect (this, &QUIWidgetCreator::create_dialog, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
55 this, &QUIWidgetCreator::handle_create_dialog); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
56 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
57 connect (this, &QUIWidgetCreator::create_listview, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
58 this, &QUIWidgetCreator::handle_create_listview); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
59 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
60 connect (this, &QUIWidgetCreator::create_inputlayout, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
61 this, &QUIWidgetCreator::handle_create_inputlayout); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
62 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
63 connect (this, &QUIWidgetCreator::create_filedialog, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
64 this, &QUIWidgetCreator::handle_create_filedialog); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
65 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
67 QString QUIWidgetCreator::rm_amp (const QString& text) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
68 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
69 QString text_wo_amp = text; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
70 text_wo_amp.replace (QRegExp ("&(\\w)"), "\\1"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
71 return text_wo_amp; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
72 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
73 |
27552 | 74 QString QUIWidgetCreator::message_dialog (const QString& message, |
75 const QString& title, | |
76 const QString& icon, | |
77 const QStringList& buttons, | |
78 const QString& defbutton, | |
79 const QStringList& role) | |
80 { | |
81 QMutexLocker autolock (&m_mutex); | |
82 | |
83 // Store button text before a window-manager adds accelerators. | |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
84 |
27552 | 85 m_button_list = buttons; |
86 | |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
87 // Use the last button in the list as the reject result, i.e., when |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
88 // no button is pressed such as in the case of the upper right close |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
89 // tab. |
27552 | 90 if (! buttons.isEmpty ()) |
91 m_dialog_button = buttons.last (); | |
92 | |
93 QString xicon = icon; | |
94 if (xicon.isEmpty ()) | |
95 xicon = "none"; | |
96 | |
97 emit create_dialog (message, title, xicon, buttons, defbutton, role); | |
98 | |
99 // Wait while the user is responding to message box. | |
100 wait (); | |
101 | |
102 // The GUI has sent a signal and the thread has been awakened. | |
103 return m_dialog_button; | |
104 }; | |
105 | |
106 QPair<QIntList, int> | |
107 QUIWidgetCreator::list_dialog (const QStringList& list, const QString& mode, | |
108 int wd, int ht, const QList<int>& initial, | |
109 const QString& name, | |
110 const QStringList& prompt, | |
111 const QString& ok_string, | |
112 const QString& cancel_string) | |
113 { | |
114 if (list.isEmpty ()) | |
115 return QPair<QIntList, int> (); | |
116 | |
117 QMutexLocker autolock (&m_mutex); | |
118 | |
119 emit create_listview (list, mode, wd, ht, initial, name, | |
120 prompt, ok_string, cancel_string); | |
121 | |
122 // Wait while the user is responding to message box. | |
123 wait (); | |
124 | |
125 // The GUI has sent a signal and the thread has been awakened. | |
126 return QPair<QIntList, int> (m_list_index, m_dialog_result); | |
127 }; | |
128 | |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
129 // Create a message dialog with specified string, buttons and |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
130 // decorative text. |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
131 |
27552 | 132 QStringList QUIWidgetCreator::input_dialog (const QStringList& prompt, |
133 const QString& title, | |
134 const QFloatList& nr, | |
135 const QFloatList& nc, | |
136 const QStringList& defaults) | |
137 { | |
138 if (prompt.isEmpty ()) | |
139 return QStringList (); | |
140 | |
141 QMutexLocker autolock (&m_mutex); | |
142 | |
143 emit create_inputlayout (prompt, title, nr, nc, defaults); | |
144 | |
145 // Wait while the user is responding to message box. | |
146 wait (); | |
147 | |
148 // The GUI has sent a signal and the thread has been awakened. | |
149 return m_string_list; | |
150 }; | |
151 | |
152 QStringList QUIWidgetCreator::file_dialog (const QStringList& filters, | |
153 const QString& title, | |
154 const QString& filename, | |
155 const QString& dirname, | |
156 const QString& multimode) | |
157 { | |
158 QMutexLocker autolock (&m_mutex); | |
159 | |
160 emit create_filedialog (filters, title, filename, dirname, multimode); | |
161 | |
162 // Wait while the user is responding to dialog. | |
163 wait (); | |
164 | |
165 // The GUI has sent a signal and the thread has been awakened. | |
166 // Add all the file dialog results to a string list. | |
167 QStringList retval; | |
168 retval << m_string_list | |
169 << m_path_name | |
170 << QString::number (m_dialog_result); | |
171 | |
172 return retval; | |
173 } | |
174 | |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
175 void QUIWidgetCreator::handle_create_dialog (const QString& message, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
176 const QString& title, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
177 const QString& icon, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
178 const QStringList& button, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
179 const QString& defbutton, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
180 const QStringList& role) |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
181 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
182 MessageDialog *message_dialog |
31626
9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
183 = new MessageDialog (message, title, icon, button, defbutton, role); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
184 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
185 connect (message_dialog, &MessageDialog::buttonClicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
186 this, &QUIWidgetCreator::dialog_button_clicked); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
187 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
188 message_dialog->setAttribute (Qt::WA_DeleteOnClose); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
189 message_dialog->show (); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
190 } |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
191 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
192 void QUIWidgetCreator::dialog_button_clicked (QAbstractButton *button) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
193 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
194 // button is NULL when dialog is closed. |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
195 if (button) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
196 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
197 // Check for a matching button text while ignoring accelerators |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
198 // because the window manager may have added one in the passed |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
199 // button. |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
200 |
25544
15460ae5462d
fix crash when closing uiwidget_creator dialog by x-button or Alt+F4 (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25342
diff
changeset
|
201 QString text_clean = rm_amp (button->text ()); |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
202 |
25544
15460ae5462d
fix crash when closing uiwidget_creator dialog by x-button or Alt+F4 (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25342
diff
changeset
|
203 for (int i = 0; i < m_button_list.count (); i++) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
204 { |
25544
15460ae5462d
fix crash when closing uiwidget_creator dialog by x-button or Alt+F4 (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25342
diff
changeset
|
205 if (rm_amp (m_button_list.at (i)) == text_clean) |
15460ae5462d
fix crash when closing uiwidget_creator dialog by x-button or Alt+F4 (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25342
diff
changeset
|
206 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
207 // Text w/o extra accelerator. |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
208 m_dialog_button = m_button_list.at (i); |
25544
15460ae5462d
fix crash when closing uiwidget_creator dialog by x-button or Alt+F4 (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25342
diff
changeset
|
209 break; |
15460ae5462d
fix crash when closing uiwidget_creator dialog by x-button or Alt+F4 (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25342
diff
changeset
|
210 } |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
211 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
212 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
214 // The value should always be 1 for the Octave functions. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
215 m_dialog_result = 1; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
217 // Wake up Octave process so that it continues. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
218 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
219 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
221 // Create a list dialog with specified list, initially selected, mode, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
222 // view size and decorative text. |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
223 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
224 void QUIWidgetCreator::handle_create_listview (const QStringList& list, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
225 const QString& mode, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
226 int wd, int ht, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
227 const QIntList& initial, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
228 const QString& name, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
229 const QStringList& prompt, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
230 const QString& ok_string, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
231 const QString& cancel_string) |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
232 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
233 ListDialog *list_dialog |
31626
9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
234 = new ListDialog (list, mode, wd, ht, initial, |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
235 name, prompt, ok_string, cancel_string); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
236 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
237 connect (list_dialog, &ListDialog::finish_selection, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
238 this, &QUIWidgetCreator::list_select_finished); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
239 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
240 list_dialog->setAttribute (Qt::WA_DeleteOnClose); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
241 list_dialog->show (); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
242 } |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
243 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
244 void QUIWidgetCreator::list_select_finished (const QIntList& selected, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
245 int button_pressed) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
246 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
247 // Store the value so that builtin functions can retrieve. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
248 |
27549
5189bfa8ad2a
eliminate unnecessary use of pointers
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
249 m_list_index = selected; |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
250 m_dialog_result = button_pressed; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
252 // Wake up Octave process so that it continues. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
253 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
254 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
256 // Create an input dialog with specified prompts and defaults, title |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
257 // and row/column size specifications. |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
258 |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
259 void QUIWidgetCreator::handle_create_inputlayout (const QStringList& prompt, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
260 const QString& title, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
261 const QFloatList& nr, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
262 const QFloatList& nc, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
263 const QStringList& defaults) |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
264 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
265 InputDialog *input_dialog |
31626
9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
266 = new InputDialog (prompt, title, nr, nc, defaults); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
267 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
268 connect (input_dialog, &InputDialog::finish_input, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
269 this, &QUIWidgetCreator::input_finished); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
270 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
271 input_dialog->setAttribute (Qt::WA_DeleteOnClose); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
272 input_dialog->show (); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
273 } |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
274 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
275 void QUIWidgetCreator::input_finished (const QStringList& input, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
276 int button_pressed) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
277 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
278 // Store the value so that builtin functions can retrieve. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
279 |
27549
5189bfa8ad2a
eliminate unnecessary use of pointers
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
280 m_string_list = input; |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
281 m_dialog_result = button_pressed; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
283 // Wake up Octave process so that it continues. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
284 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
285 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
287 void QUIWidgetCreator::handle_create_filedialog (const QStringList& filters, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
288 const QString& title, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
289 const QString& filename, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
290 const QString& dirname, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
291 const QString& multimode) |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
292 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
293 FileDialog *file_dialog |
31626
9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
294 = new FileDialog (filters, title, filename, dirname, multimode); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
295 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
296 connect (file_dialog, &FileDialog::finish_input, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
297 this, &QUIWidgetCreator::filedialog_finished); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
298 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
299 file_dialog->setAttribute (Qt::WA_DeleteOnClose); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
300 file_dialog->show (); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
301 } |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
302 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
303 void QUIWidgetCreator::filedialog_finished (const QStringList& files, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
304 const QString& path, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
305 int filterindex) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
306 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
307 // Store the value so that builtin functions can retrieve. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
308 |
27549
5189bfa8ad2a
eliminate unnecessary use of pointers
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
309 m_string_list = files; |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
310 m_dialog_result = filterindex; |
27549
5189bfa8ad2a
eliminate unnecessary use of pointers
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
311 m_path_name = path; |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
312 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
313 // Wake up Octave process so that it continues. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
314 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
315 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
316 |
31626
9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
317 MessageDialog::MessageDialog (const QString& message, |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
318 const QString& title, const QString& qsicon, |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
319 const QStringList& qsbutton, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
320 const QString& defbutton, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
321 const QStringList& role) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
322 : QMessageBox (QMessageBox::NoIcon, title.isEmpty () ? " " : title, |
29050
ce849f006568
avoid deprecated QFlags<T>::QFlags(QFlags<T>::Zero) constructor
John W. Eaton <jwe@octave.org>
parents:
28570
diff
changeset
|
323 message) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
324 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
325 // Create a NonModal message. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
326 setWindowModality (Qt::NonModal); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
328 // Interpret the icon string, because enumeration QMessageBox::Icon can't |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
329 // easily be made to pass through a signal. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
330 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
331 QMessageBox::Icon eicon = QMessageBox::NoIcon; |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
332 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
333 if (qsicon == "error") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
334 eicon = QMessageBox::Critical; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
335 else if (qsicon == "warn") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
336 eicon = QMessageBox::Warning; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
337 else if (qsicon == "help") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
338 eicon = QMessageBox::Information; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
339 else if (qsicon == "quest") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
340 eicon = QMessageBox::Question; |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
341 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
342 setIcon (eicon); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
343 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
344 int N = (qsbutton.size () < role.size () ? qsbutton.size () : role.size ()); |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
345 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
346 if (N == 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
347 addButton (QMessageBox::Ok); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
348 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
349 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
350 for (int i = 0; i < N; i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
351 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
352 // Interpret the button role string, because enumeration |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
353 // QMessageBox::ButtonRole can't be made to pass through a |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
354 // signal. |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
355 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
356 QString srole = role.at (i); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
357 QMessageBox::ButtonRole erole = QMessageBox::InvalidRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
358 if (srole == "ResetRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
359 erole = QMessageBox::ResetRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
360 else if (srole == "YesRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
361 erole = QMessageBox::YesRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
362 else if (srole == "NoRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
363 erole = QMessageBox::NoRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
364 else if (srole == "RejectRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
365 erole = QMessageBox::RejectRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
366 else if (srole == "AcceptRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
367 erole = QMessageBox::AcceptRole; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
368 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
369 QPushButton *pbutton = addButton (qsbutton.at (i), erole); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
370 if (qsbutton.at (i) == defbutton) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
371 setDefaultButton (pbutton); |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
372 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
373 // Make the last button the button pressed when <esc> key activated. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
374 if (i == N-1) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
375 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
376 // FIXME: Why define and then immediately test value? |
16626
4adf3c4bd80b
GUI compilation fixes for MSVC.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16582
diff
changeset
|
377 #define ACTIVE_ESCAPE 1 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
378 #if ACTIVE_ESCAPE |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
379 setEscapeButton (pbutton); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
380 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
381 setEscapeButton (0); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
382 #endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
383 #undef ACTIVE_ESCAPE |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
384 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
385 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
386 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
387 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
388 |
31626
9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
389 ListDialog::ListDialog (const QStringList& list, |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
390 const QString& mode, int wd, int ht, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
391 const QList<int>& initial, const QString& title, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
392 const QStringList& prompt, |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
393 const QString& ok_string, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
394 const QString& cancel_string) |
29550
8dd0fca2a3d9
where possible, use default destructors in GUI classes
John W. Eaton <jwe@octave.org>
parents:
29542
diff
changeset
|
395 : QDialog (), m_model (new QStringListModel (list, this)) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
396 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
397 QListView *view = new QListView; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
398 view->setModel (m_model); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
399 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
400 if (mode == "single") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
401 view->setSelectionMode (QAbstractItemView::SingleSelection); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
402 else if (mode == "multiple") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
403 view->setSelectionMode (QAbstractItemView::ExtendedSelection); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
404 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
405 view->setSelectionMode (QAbstractItemView::NoSelection); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
406 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
407 selector = view->selectionModel (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
408 int i = 0; |
25342
416856765a55
be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
409 for (auto it = initial.begin (); it != initial.end (); it++) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
410 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
411 QModelIndex idx = m_model->index (initial.value (i++) - 1, 0, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
412 QModelIndex ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
413 selector->select (idx, QItemSelectionModel::Select); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
414 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
415 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
416 bool fixed_layout = false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
417 if (wd > 0 && ht > 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
418 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
419 view->setFixedSize (wd, ht); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
420 fixed_layout = true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
421 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
423 view->setEditTriggers (QAbstractItemView::NoEditTriggers); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
424 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
425 QVBoxLayout *listLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
426 if (! prompt.isEmpty ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
427 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
428 // For now, assume html-like Rich Text. May be incompatible |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
429 // with something down the road, but just testing capability. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
430 QString prompt_string; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
431 for (int j = 0; j < prompt.length (); j++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
432 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
433 if (j > 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
434 // FIXME: Why define and then immediately test value? |
16626
4adf3c4bd80b
GUI compilation fixes for MSVC.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16582
diff
changeset
|
435 #define RICH_TEXT 1 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
436 #if RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
437 prompt_string.append ("<br>"); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
438 #else |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
439 prompt_string.append ("\n"); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
440 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
441 prompt_string.append (prompt.at (j)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
442 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
443 QLabel *plabel = new QLabel (prompt_string); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
444 #if RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
445 plabel->setTextFormat (Qt::RichText); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
446 #endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
447 #undef RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
448 listLayout->addWidget (plabel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
449 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
450 listLayout->addWidget (view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
451 QPushButton *select_all = new QPushButton (tr ("Select All")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
452 select_all->setVisible (mode == "multiple"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
453 listLayout->addWidget (select_all); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
454 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
455 QPushButton *buttonOk = new QPushButton (ok_string); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
456 QPushButton *buttonCancel = new QPushButton (cancel_string); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
457 QHBoxLayout *buttonsLayout = new QHBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
458 buttonsLayout->addStretch (1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
459 buttonsLayout->addWidget (buttonOk); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
460 buttonsLayout->addWidget (buttonCancel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
461 buttonOk->setDefault (true); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
462 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
463 QVBoxLayout *mainLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
464 mainLayout->addLayout (listLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
465 mainLayout->addSpacing (12); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
466 mainLayout->addLayout (buttonsLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
467 setLayout (mainLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
468 if (fixed_layout) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
469 layout ()->setSizeConstraint (QLayout::SetFixedSize); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
470 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
471 // If empty, make blank rather than use default OS behavior. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
472 setWindowTitle (title.isEmpty () ? " " : title); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
473 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
474 connect (select_all, &QPushButton::clicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
475 view, &QListView::selectAll); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
476 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
477 connect (buttonOk, &QPushButton::clicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
478 this, &ListDialog::buttonOk_clicked); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
479 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
480 connect (buttonCancel, &QPushButton::clicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
481 this, &ListDialog::buttonCancel_clicked); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
482 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
483 connect (view, &QListView::doubleClicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
484 this, &ListDialog::item_double_clicked); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
485 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
486 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
487 void ListDialog::buttonOk_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
488 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
489 // Store information about what button was pressed so that builtin |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
490 // functions can retrieve. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
491 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
492 QModelIndexList selected_index = selector->selectedIndexes (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
493 QIntList selected_int; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
494 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
495 for (int i = 0; i < selected_index.size (); i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
496 selected_int << selected_index.at (i).row () + 1; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
497 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
498 emit finish_selection (selected_int, 1); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
499 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
500 done (QDialog::Accepted); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
501 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
502 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
503 void ListDialog::buttonCancel_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
504 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
505 // Store information about what button was pressed so that builtin |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
506 // functions can retrieve. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
507 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
508 QIntList empty; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
509 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
510 emit finish_selection (empty, 0); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
511 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
512 done (QDialog::Rejected); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
513 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
514 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
515 void ListDialog::reject (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
516 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
517 buttonCancel_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
518 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
519 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
520 void ListDialog::item_double_clicked (const QModelIndex&) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
521 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
522 buttonOk_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
523 } |
20505
dd327c0909b0
listdlg: Make appearance and behavior more Matlab compatible (bug #46026)
Mike Miller <mtmiller@octave.org>
parents:
20230
diff
changeset
|
524 |
31626
9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
525 InputDialog::InputDialog (const QStringList& prompt, |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
526 const QString& title, const QFloatList& nr, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
527 const QFloatList& nc, const QStringList& defaults) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
528 : QDialog () |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
529 { |
24808
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
530 |
16626
4adf3c4bd80b
GUI compilation fixes for MSVC.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16582
diff
changeset
|
531 #define LINE_EDIT_FOLLOWS_PROMPT 0 |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
532 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
533 #if LINE_EDIT_FOLLOWS_PROMPT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
534 // Prompt on left followed by input on right. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
535 QGridLayout *promptInputLayout = new QGridLayout; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
537 // Prompt aligned above input. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
538 QVBoxLayout *promptInputLayout = new QVBoxLayout; |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
540 int N_gridrows = prompt.size (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
541 for (int i = 0; i < N_gridrows; i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
542 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
543 QLabel *label = new QLabel (prompt.at (i)); |
24808
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
544 QLineEdit *line_edit = new QLineEdit (); |
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
545 if (i < defaults.size ()) |
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
546 line_edit->setText (defaults.at (i)); |
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
547 if (i < nr.size () && nr.at (i) > 0) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
548 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
549 QSize qsize = line_edit->sizeHint (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
550 int intval = qsize.height () * nr.at (i); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
551 line_edit->setFixedHeight (intval); |
24808
abfd4fc1b977
Add boundary tests on QLists associated with Qt inputdlg() routine (bug #53209).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
24718
diff
changeset
|
552 if (i < nc.size () && nc.at (i) > 0) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
553 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
554 intval = qsize.height () * nc.at (i) / 2; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
555 line_edit->setFixedWidth (intval); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
556 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
557 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
558 input_line << line_edit; |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
559 #if LINE_EDIT_FOLLOWS_PROMPT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
560 promptInputLayout->addWidget (label, i + 1, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
561 promptInputLayout->addWidget (line_edit, i + 1, 1); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
562 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
563 promptInputLayout->addWidget (label); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
564 promptInputLayout->addWidget (line_edit); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
565 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
566 } |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
567 #undef LINE_EDIT_FOLLOWS_PROMPT |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
568 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
569 QPushButton *buttonOk = new QPushButton ("OK"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
570 QPushButton *buttonCancel = new QPushButton ("Cancel"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
571 QHBoxLayout *buttonsLayout = new QHBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
572 buttonsLayout->addStretch (1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
573 buttonsLayout->addWidget (buttonOk); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
574 buttonsLayout->addWidget (buttonCancel); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
575 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
576 QVBoxLayout *mainLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
577 mainLayout->addLayout (promptInputLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
578 mainLayout->addSpacing (12); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
579 mainLayout->addLayout (buttonsLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
580 setLayout (mainLayout); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
581 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
582 // If empty, make blank rather than use default OS behavior. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
583 setWindowTitle (title.isEmpty () ? " " : title); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
584 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
585 connect (buttonOk, &QPushButton::clicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
586 this, &InputDialog::buttonOk_clicked); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
587 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
588 connect (buttonCancel, &QPushButton::clicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
589 this, &InputDialog::buttonCancel_clicked); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
590 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
592 void InputDialog::buttonOk_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
593 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
594 // Store information about what button was pressed so that builtin |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
595 // functions can retrieve. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
596 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
597 QStringList string_result; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
598 for (int i = 0; i < input_line.size (); i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
599 string_result << input_line.at (i)->text (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
600 emit finish_input (string_result, 1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
601 done (QDialog::Accepted); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
602 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
603 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
604 void InputDialog::buttonCancel_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
605 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
606 // Store information about what button was pressed so that builtin |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
607 // functions can retrieve. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
608 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
609 QStringList empty; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
610 emit finish_input (empty, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
611 done (QDialog::Rejected); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
612 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
613 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
614 void InputDialog::reject (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
615 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
616 buttonCancel_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
617 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
618 |
31626
9034cf663768
eliminate unnecessary base_qobject object from GUI dialog classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
619 FileDialog::FileDialog (const QStringList& name_filters, |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
620 const QString& title, const QString& filename, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
621 const QString& dirname, const QString& multimode) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
622 : QFileDialog () |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
623 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
624 // Create a NonModal message. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
625 setWindowModality (Qt::NonModal); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
626 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
627 setWindowTitle (title.isEmpty () ? " " : title); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
628 setDirectory (dirname); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
629 |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
25952
diff
changeset
|
630 // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved. |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
631 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
632 gui_settings settings; |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
633 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
634 if (! settings.value (global_use_native_dialogs).toBool ()) |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
25952
diff
changeset
|
635 setOption(QFileDialog::DontUseNativeDialog); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
636 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
637 if (multimode == "on") // uigetfile multiselect=on |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
638 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
639 setFileMode (QFileDialog::ExistingFiles); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
640 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
641 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
642 else if (multimode == "create") // uiputfile |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
643 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
644 setFileMode (QFileDialog::AnyFile); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
645 setAcceptMode (QFileDialog::AcceptSave); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
646 setOption (QFileDialog::DontConfirmOverwrite, false); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
647 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
648 else if (multimode == "dir") // uigetdir |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
649 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
650 setFileMode (QFileDialog::Directory); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
651 setOption (QFileDialog::ShowDirsOnly, true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
652 setOption (QFileDialog::HideNameFilterDetails, true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
653 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
654 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
655 else // uigetfile multiselect=off |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
656 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
657 setFileMode (QFileDialog::ExistingFile); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
658 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
659 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
660 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
661 setNameFilters (name_filters); |
16581
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
662 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
663 selectFile (filename); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
664 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
665 connect (this, &FileDialog::accepted, this, &FileDialog::acceptSelection); |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
666 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
667 connect (this, &FileDialog::rejected, this, &FileDialog::rejectSelection); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
668 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
669 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
670 void FileDialog::rejectSelection (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
671 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
672 QStringList empty; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
673 emit finish_input (empty, "", 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
674 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
675 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
676 void FileDialog::acceptSelection (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
677 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
678 QStringList string_result; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
679 QString path; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
680 int idx = 1; |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
681 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
682 string_result = selectedFiles (); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
683 |
25951 | 684 if (testOption (QFileDialog::ShowDirsOnly) && string_result.size () > 0) |
685 path = string_result[0]; | |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
686 else |
25951 | 687 path = directory ().absolutePath (); |
18607
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
688 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
689 // Matlab expects just the filename, whereas the file dialog gave us |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
690 // full path names, so fix it. |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
691 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
692 for (int i = 0; i < string_result.size (); i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
693 string_result[i] = QFileInfo (string_result[i]).fileName (); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
694 |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
695 // If not showing only dirs, add end slash for the path component. |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
696 if (testOption (QFileDialog::ShowDirsOnly) == false) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
697 path += '/'; |
18404
6ebd37faae5f
Add path separator to end of uigetfile path (Bug #41367)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
698 |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
699 // Convert to native slashes. |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
700 path = QDir::toNativeSeparators (path); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
701 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
702 QStringList name_filters = nameFilters (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
703 idx = name_filters.indexOf (selectedNameFilter ()) + 1; |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
704 |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
705 // Send the selected info. |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
706 emit finish_input (string_result, path, idx); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
707 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
708 } |