Mercurial > octave
annotate libgui/src/dialog.cc @ 28570:5322aed1304c
avoid deprecated Qt setConfirmOverwrite function
* dialog.cc (FileDialog::FileDialog): Don't use setConfirmOverwrite.
The option is already set with a call to setOption to set
DontConfirmOverwrite to false.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 13 Jul 2020 15:54:38 -0400 |
parents | 2813ac10ca1e |
children | ce849f006568 |
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 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 2013-2020 The Octave Project Developers |
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" |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
45 #include "octave-qobject.h" |
27805
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27643
diff
changeset
|
46 #include "gui-preferences-global.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 { |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
50 QUIWidgetCreator::QUIWidgetCreator (base_qobject& oct_qobj) |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
51 : QObject (), m_octave_qobj (oct_qobj), m_dialog_result (-1), |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
52 m_dialog_button (), 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 { |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
54 connect (this, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
55 SIGNAL (create_dialog (const QString&, const QString&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
56 const QString&, const QStringList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
57 const QString&, const QStringList&)), |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
58 this, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
59 SLOT (handle_create_dialog (const QString&, const QString&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
60 const QString&, const QStringList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
61 const QString&, const QStringList&))); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
62 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
63 connect (this, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
64 SIGNAL (create_listview (const QStringList&, const QString&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
65 int, int, const QIntList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
66 const QString&, const QStringList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
67 const QString&, const QString&)), |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
68 this, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
69 SLOT (handle_create_listview (const QStringList&, const QString&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
70 int, int, const QIntList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
71 const QString&, const QStringList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
72 const QString&, const QString&))); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
73 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
74 connect (this, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
75 SIGNAL (create_inputlayout (const QStringList&, const QString&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
76 const QFloatList&, const QFloatList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
77 const QStringList&)), |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
78 this, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
79 SLOT (handle_create_inputlayout (const QStringList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
80 const QString&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
81 const QFloatList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
82 const QFloatList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
83 const QStringList&))); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
84 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
85 connect (this, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
86 SIGNAL (create_filedialog (const QStringList&,const QString&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
87 const QString&, const QString&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
88 const QString&)), |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
89 this, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
90 SLOT (handle_create_filedialog (const QStringList&, const QString&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
91 const QString&, const QString&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
92 const QString&))); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
93 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
95 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
|
96 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
97 QString text_wo_amp = text; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
98 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
|
99 return text_wo_amp; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
100 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
101 |
27552 | 102 QString QUIWidgetCreator::message_dialog (const QString& message, |
103 const QString& title, | |
104 const QString& icon, | |
105 const QStringList& buttons, | |
106 const QString& defbutton, | |
107 const QStringList& role) | |
108 { | |
109 QMutexLocker autolock (&m_mutex); | |
110 | |
111 // 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
|
112 |
27552 | 113 m_button_list = buttons; |
114 | |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
115 // 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
|
116 // 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
|
117 // tab. |
27552 | 118 if (! buttons.isEmpty ()) |
119 m_dialog_button = buttons.last (); | |
120 | |
121 QString xicon = icon; | |
122 if (xicon.isEmpty ()) | |
123 xicon = "none"; | |
124 | |
125 emit create_dialog (message, title, xicon, buttons, defbutton, role); | |
126 | |
127 // Wait while the user is responding to message box. | |
128 wait (); | |
129 | |
130 // The GUI has sent a signal and the thread has been awakened. | |
131 return m_dialog_button; | |
132 }; | |
133 | |
134 QPair<QIntList, int> | |
135 QUIWidgetCreator::list_dialog (const QStringList& list, const QString& mode, | |
136 int wd, int ht, const QList<int>& initial, | |
137 const QString& name, | |
138 const QStringList& prompt, | |
139 const QString& ok_string, | |
140 const QString& cancel_string) | |
141 { | |
142 if (list.isEmpty ()) | |
143 return QPair<QIntList, int> (); | |
144 | |
145 QMutexLocker autolock (&m_mutex); | |
146 | |
147 emit create_listview (list, mode, wd, ht, initial, name, | |
148 prompt, ok_string, cancel_string); | |
149 | |
150 // Wait while the user is responding to message box. | |
151 wait (); | |
152 | |
153 // The GUI has sent a signal and the thread has been awakened. | |
154 return QPair<QIntList, int> (m_list_index, m_dialog_result); | |
155 }; | |
156 | |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
157 // 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
|
158 // 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
|
159 |
27552 | 160 QStringList QUIWidgetCreator::input_dialog (const QStringList& prompt, |
161 const QString& title, | |
162 const QFloatList& nr, | |
163 const QFloatList& nc, | |
164 const QStringList& defaults) | |
165 { | |
166 if (prompt.isEmpty ()) | |
167 return QStringList (); | |
168 | |
169 QMutexLocker autolock (&m_mutex); | |
170 | |
171 emit create_inputlayout (prompt, title, nr, nc, defaults); | |
172 | |
173 // Wait while the user is responding to message box. | |
174 wait (); | |
175 | |
176 // The GUI has sent a signal and the thread has been awakened. | |
177 return m_string_list; | |
178 }; | |
179 | |
180 QStringList QUIWidgetCreator::file_dialog (const QStringList& filters, | |
181 const QString& title, | |
182 const QString& filename, | |
183 const QString& dirname, | |
184 const QString& multimode) | |
185 { | |
186 QMutexLocker autolock (&m_mutex); | |
187 | |
188 emit create_filedialog (filters, title, filename, dirname, multimode); | |
189 | |
190 // Wait while the user is responding to dialog. | |
191 wait (); | |
192 | |
193 // The GUI has sent a signal and the thread has been awakened. | |
194 // Add all the file dialog results to a string list. | |
195 QStringList retval; | |
196 retval << m_string_list | |
197 << m_path_name | |
198 << QString::number (m_dialog_result); | |
199 | |
200 return retval; | |
201 } | |
202 | |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
210 MessageDialog *message_dialog |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
211 = new MessageDialog (m_octave_qobj, message, title, icon, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
212 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
|
213 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
214 connect (message_dialog, SIGNAL (buttonClicked (QAbstractButton *)), |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
215 this, SLOT (dialog_button_clicked (QAbstractButton *))); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
216 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
217 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
|
218 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
|
219 } |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
220 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
221 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
|
222 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
223 // button is NULL when dialog is closed. |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
224 if (button) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
225 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
226 // 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
|
227 // 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
|
228 // button. |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
229 |
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
|
230 QString text_clean = rm_amp (button->text ()); |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
231 |
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
|
232 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
|
233 { |
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
|
234 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
|
235 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
236 // Text w/o extra accelerator. |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
237 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
|
238 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
|
239 } |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
240 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
241 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
243 // 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
|
244 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
|
245 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
246 // 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
|
247 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
248 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
250 // 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
|
251 // 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
|
252 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
253 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
|
254 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
|
255 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
|
256 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
|
257 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
|
258 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
|
259 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
|
260 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
|
261 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
262 ListDialog *list_dialog |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
263 = new ListDialog (m_octave_qobj, list, mode, wd, ht, initial, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
264 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
|
265 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
266 connect (list_dialog, SIGNAL (finish_selection (const QIntList&, int)), |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
267 this, SLOT (list_select_finished (const QIntList&, int))); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
268 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
269 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
|
270 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
|
271 } |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
272 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
273 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
|
274 int button_pressed) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
275 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
276 // 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
|
277 |
27549
5189bfa8ad2a
eliminate unnecessary use of pointers
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
278 m_list_index = selected; |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
279 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
|
280 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
281 // 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
|
282 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
283 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
285 // 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
|
286 // and row/column size specifications. |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
287 |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
288 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
|
289 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
|
290 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
|
291 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
|
292 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
|
293 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
294 InputDialog *input_dialog |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
295 = new InputDialog (m_octave_qobj, 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
|
296 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
297 connect (input_dialog, SIGNAL (finish_input (const QStringList&, int)), |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
298 this, SLOT (input_finished (const QStringList&, int))); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
299 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
300 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
|
301 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
|
302 } |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
303 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
304 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
|
305 int button_pressed) |
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 = input; |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
310 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
|
311 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
312 // 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
|
313 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
314 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
315 |
27551
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 { |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
322 FileDialog *file_dialog |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
323 = new FileDialog (m_octave_qobj, filters, title, filename, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
324 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
|
325 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
326 connect (file_dialog, SIGNAL (finish_input (const QStringList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
327 const QString&, int)), |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
328 this, SLOT (filedialog_finished (const QStringList&, |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
329 const QString&, int))); |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
330 |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
331 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
|
332 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
|
333 } |
564bba235594
move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents:
27549
diff
changeset
|
334 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
335 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
|
336 const QString& path, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
337 int filterindex) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
338 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
339 // 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
|
340 |
27549
5189bfa8ad2a
eliminate unnecessary use of pointers
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
341 m_string_list = files; |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
342 m_dialog_result = filterindex; |
27549
5189bfa8ad2a
eliminate unnecessary use of pointers
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
343 m_path_name = path; |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
344 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
345 // 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
|
346 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
347 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
348 |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
349 MessageDialog::MessageDialog (base_qobject&, const QString& message, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
350 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
|
351 const QStringList& qsbutton, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
352 const QString& defbutton, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
353 const QStringList& role) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
354 : QMessageBox (QMessageBox::NoIcon, title.isEmpty () ? " " : title, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
355 message, nullptr, nullptr) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
356 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
357 // Create a NonModal message. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
358 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
|
359 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
360 // 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
|
361 // 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
|
362 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
363 QMessageBox::Icon eicon = QMessageBox::NoIcon; |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
364 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
365 if (qsicon == "error") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
366 eicon = QMessageBox::Critical; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
367 else if (qsicon == "warn") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
368 eicon = QMessageBox::Warning; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
369 else if (qsicon == "help") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
370 eicon = QMessageBox::Information; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
371 else if (qsicon == "quest") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
372 eicon = QMessageBox::Question; |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
373 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
374 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
|
375 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
376 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
|
377 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
378 if (N == 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
379 addButton (QMessageBox::Ok); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
380 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
381 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
382 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
|
383 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
384 // Interpret the button role string, because enumeration |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
385 // 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
|
386 // signal. |
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
387 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
388 QString srole = role.at (i); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
389 QMessageBox::ButtonRole erole = QMessageBox::InvalidRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
390 if (srole == "ResetRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
391 erole = QMessageBox::ResetRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
392 else if (srole == "YesRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
393 erole = QMessageBox::YesRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
394 else if (srole == "NoRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
395 erole = QMessageBox::NoRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
396 else if (srole == "RejectRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
397 erole = QMessageBox::RejectRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
398 else if (srole == "AcceptRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
399 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
|
400 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
401 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
|
402 if (qsbutton.at (i) == defbutton) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
403 setDefaultButton (pbutton); |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
404 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
405 // 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
|
406 if (i == N-1) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
407 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
408 // 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
|
409 #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
|
410 #if ACTIVE_ESCAPE |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
411 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
|
412 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
413 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
|
414 #endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
415 #undef ACTIVE_ESCAPE |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
416 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
417 } |
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 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
421 ListDialog::ListDialog (base_qobject&, const QStringList& list, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
422 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
|
423 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
|
424 const QStringList& prompt, |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
425 const QString& ok_string, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
426 const QString& cancel_string) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
427 : QDialog (), m_model (new QStringListModel (list)) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
428 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
429 QListView *view = new QListView; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
430 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
|
431 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
432 if (mode == "single") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
433 view->setSelectionMode (QAbstractItemView::SingleSelection); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
434 else if (mode == "multiple") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
435 view->setSelectionMode (QAbstractItemView::ExtendedSelection); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
436 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
437 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
|
438 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
439 selector = view->selectionModel (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
440 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
|
441 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
|
442 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
443 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
|
444 QModelIndex ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
445 selector->select (idx, QItemSelectionModel::Select); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
446 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
448 bool fixed_layout = false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
449 if (wd > 0 && ht > 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
450 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
451 view->setFixedSize (wd, ht); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
452 fixed_layout = true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
453 } |
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 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
|
456 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
457 QVBoxLayout *listLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
458 if (! prompt.isEmpty ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
459 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
460 // 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
|
461 // 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
|
462 QString prompt_string; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
463 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
|
464 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
465 if (j > 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
466 // 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
|
467 #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
|
468 #if RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
469 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
|
470 #else |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
471 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
|
472 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
473 prompt_string.append (prompt.at (j)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
474 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
475 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
|
476 #if RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
477 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
|
478 #endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
479 #undef RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
480 listLayout->addWidget (plabel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
481 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
482 listLayout->addWidget (view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
483 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
|
484 select_all->setVisible (mode == "multiple"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
485 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
|
486 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
487 QPushButton *buttonOk = new QPushButton (ok_string); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
488 QPushButton *buttonCancel = new QPushButton (cancel_string); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
489 QHBoxLayout *buttonsLayout = new QHBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
490 buttonsLayout->addStretch (1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
491 buttonsLayout->addWidget (buttonOk); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
492 buttonsLayout->addWidget (buttonCancel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
493 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
|
494 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
495 QVBoxLayout *mainLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
496 mainLayout->addLayout (listLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
497 mainLayout->addSpacing (12); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
498 mainLayout->addLayout (buttonsLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
499 setLayout (mainLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
500 if (fixed_layout) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
501 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
|
502 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
503 // 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
|
504 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
|
505 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
506 connect (select_all, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
507 view, SLOT (selectAll ())); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
508 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
509 connect (buttonOk, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
510 this, SLOT (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
|
511 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
512 connect (buttonCancel, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
513 this, SLOT (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
|
514 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
515 connect (view, SIGNAL (doubleClicked (const QModelIndex&)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
516 this, SLOT (item_double_clicked (const QModelIndex&))); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
517 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
518 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
519 ListDialog::~ListDialog (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
520 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
521 delete m_model; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
522 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
523 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
524 void ListDialog::buttonOk_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
525 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
526 // 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
|
527 // functions can retrieve. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
528 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
529 QModelIndexList selected_index = selector->selectedIndexes (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
530 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
|
531 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
532 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
|
533 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
|
534 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
535 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
|
536 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
537 done (QDialog::Accepted); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
538 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
540 void ListDialog::buttonCancel_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
541 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
542 // 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
|
543 // functions can retrieve. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
544 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
545 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
|
546 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
547 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
|
548 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
549 done (QDialog::Rejected); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
550 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
552 void ListDialog::reject (void) |
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 buttonCancel_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
555 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
556 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
557 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
|
558 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
559 buttonOk_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
560 } |
20505
dd327c0909b0
listdlg: Make appearance and behavior more Matlab compatible (bug #46026)
Mike Miller <mtmiller@octave.org>
parents:
20230
diff
changeset
|
561 |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
562 InputDialog::InputDialog (base_qobject&, const QStringList& prompt, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
563 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
|
564 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
|
565 : QDialog () |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
566 { |
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
|
567 |
16626
4adf3c4bd80b
GUI compilation fixes for MSVC.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16582
diff
changeset
|
568 #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
|
569 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
570 #if LINE_EDIT_FOLLOWS_PROMPT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
571 // 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
|
572 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
|
573 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
574 // Prompt aligned above input. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
575 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
|
576 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
577 int N_gridrows = prompt.size (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
578 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
|
579 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
580 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
|
581 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
|
582 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
|
583 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
|
584 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
|
585 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
586 QSize qsize = line_edit->sizeHint (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
587 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
|
588 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
|
589 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
|
590 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
591 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
|
592 line_edit->setFixedWidth (intval); |
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 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
595 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
|
596 #if LINE_EDIT_FOLLOWS_PROMPT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
597 promptInputLayout->addWidget (label, i + 1, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
598 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
|
599 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
600 promptInputLayout->addWidget (label); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
601 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
|
602 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
603 } |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
604 #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
|
605 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
606 QPushButton *buttonOk = new QPushButton ("OK"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
607 QPushButton *buttonCancel = new QPushButton ("Cancel"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
608 QHBoxLayout *buttonsLayout = new QHBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
609 buttonsLayout->addStretch (1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
610 buttonsLayout->addWidget (buttonOk); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
611 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
|
612 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
613 QVBoxLayout *mainLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
614 mainLayout->addLayout (promptInputLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
615 mainLayout->addSpacing (12); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
616 mainLayout->addLayout (buttonsLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
617 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
|
618 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
619 // 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
|
620 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
|
621 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
622 connect (buttonOk, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
623 this, SLOT (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
|
624 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
625 connect (buttonCancel, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
626 this, SLOT (buttonCancel_clicked ())); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
627 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
628 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
629 void InputDialog::buttonOk_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
630 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
631 // 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
|
632 // functions can retrieve. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
633 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
634 QStringList string_result; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
635 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
|
636 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
|
637 emit finish_input (string_result, 1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
638 done (QDialog::Accepted); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
639 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
640 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
641 void InputDialog::buttonCancel_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
642 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
643 // 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
|
644 // functions can retrieve. |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
645 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
646 QStringList empty; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
647 emit finish_input (empty, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
648 done (QDialog::Rejected); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
649 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
650 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
651 void InputDialog::reject (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
652 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
653 buttonCancel_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
654 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
655 |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
656 FileDialog::FileDialog (base_qobject& oct_qobj, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
657 const QStringList& name_filters, |
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
658 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
|
659 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
|
660 : QFileDialog () |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
661 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
662 // Create a NonModal message. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
663 setWindowModality (Qt::NonModal); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
664 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
665 setWindowTitle (title.isEmpty () ? " " : title); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
666 setDirectory (dirname); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
667 |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
25952
diff
changeset
|
668 // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved. |
27643
337132e66ec2
eliminate need for global access to resource manager in uiwidget objects
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
669 resource_manager& rmgr = oct_qobj.get_resource_manager (); |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27598
diff
changeset
|
670 gui_settings *settings = rmgr.get_settings (); |
28497
2813ac10ca1e
force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27923
diff
changeset
|
671 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
|
672 setOption(QFileDialog::DontUseNativeDialog); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
673 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
674 if (multimode == "on") // uigetfile multiselect=on |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
675 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
676 setFileMode (QFileDialog::ExistingFiles); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
677 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
678 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
679 else if (multimode == "create") // uiputfile |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
680 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
681 setFileMode (QFileDialog::AnyFile); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
682 setAcceptMode (QFileDialog::AcceptSave); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
683 setOption (QFileDialog::DontConfirmOverwrite, false); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
684 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
685 else if (multimode == "dir") // uigetdir |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
686 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
687 setFileMode (QFileDialog::Directory); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
688 setOption (QFileDialog::ShowDirsOnly, true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
689 setOption (QFileDialog::HideNameFilterDetails, true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
690 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
691 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
692 else // uigetfile multiselect=off |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
693 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
694 setFileMode (QFileDialog::ExistingFile); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
695 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
696 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
697 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
698 setNameFilters (name_filters); |
16581
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
699 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
700 selectFile (filename); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
701 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
702 connect (this, SIGNAL (accepted ()), this, SLOT (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
|
703 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
704 connect (this, SIGNAL (rejected ()), this, SLOT (rejectSelection ())); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
705 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
706 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
707 void FileDialog::rejectSelection (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
708 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
709 QStringList empty; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
710 emit finish_input (empty, "", 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
711 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
712 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
713 void FileDialog::acceptSelection (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
714 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
715 QStringList string_result; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
716 QString path; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
717 int idx = 1; |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
718 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
719 string_result = selectedFiles (); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
720 |
25951 | 721 if (testOption (QFileDialog::ShowDirsOnly) && string_result.size () > 0) |
722 path = string_result[0]; | |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
723 else |
25951 | 724 path = directory ().absolutePath (); |
18607
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
725 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
726 // 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
|
727 // full path names, so fix it. |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
728 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
729 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
|
730 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
|
731 |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
732 // 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
|
733 if (testOption (QFileDialog::ShowDirsOnly) == false) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
734 path += '/'; |
18404
6ebd37faae5f
Add path separator to end of uigetfile path (Bug #41367)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
735 |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
736 // Convert to native slashes. |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
737 path = QDir::toNativeSeparators (path); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
738 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
739 QStringList name_filters = nameFilters (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
740 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
|
741 |
27598
cf9fbfa04dd1
* dialog.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
27553
diff
changeset
|
742 // Send the selected info. |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
743 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
|
744 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
745 } |