Mercurial > octave
annotate libgui/src/dialog.cc @ 26376:00f796120a6d stable
maint: Update copyright dates in all source files.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 02 Jan 2019 16:32:43 -0500 |
parents | 1002b49ce7b3 |
children | 98afb8bbd1f6 |
rev | line source |
---|---|
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26096
diff
changeset
|
3 Copyright (C) 2013-2019 John W. Eaton |
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26096
diff
changeset
|
4 Copyright (C) 2013-2019 Daniel J. Sebald |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 This file is part of Octave. |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24016
diff
changeset
|
8 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24016
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
11 (at your option) any later version. |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
16 GNU General Public License for more details. |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24016
diff
changeset
|
20 <https://www.gnu.org/licenses/>. |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 */ |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21613
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21213
diff
changeset
|
25 # 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
|
26 #endif |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #include "dialog.h" |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
25952
diff
changeset
|
29 #include "resource-manager.h" |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <QString> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <QStringList> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <QStringListModel> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include <QListView> |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
35 #include <QFileInfo> |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 // Could replace most of these with #include <QtGui> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include <QMessageBox> |
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> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include <QVBoxLayout> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include <QPushButton> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include <QGroupBox> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include <QGridLayout> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include <QLabel> |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
45 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
|
46 { |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
47 QUIWidgetCreator uiwidget_creator; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
48 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
49 QUIWidgetCreator::QUIWidgetCreator (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
50 : QObject (), m_dialog_result (-1), m_dialog_button (), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
51 m_string_list (new QStringList ()), m_list_index (new QIntList ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
52 m_path_name (new QString ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
53 { } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
55 QUIWidgetCreator::~QUIWidgetCreator (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
56 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
57 delete m_string_list; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
58 delete m_list_index; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
59 delete m_path_name; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
60 } |
24586
c24b536df5d4
functionality of ui dialogs not affected by inserted accelerators (#bug 52853)
Torsten <mttl@mailbox.org>
parents:
24534
diff
changeset
|
61 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
62 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
|
63 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
64 QString text_wo_amp = text; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
65 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
|
66 return text_wo_amp; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
67 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
68 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
69 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
|
70 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
71 // Wait for link thread to go to sleep state. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
72 lock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
73 |
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
|
74 if (button) // button is NULL when dialog is closed |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
75 { |
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
|
76 // Check for a matching button text while ignoring accelerators because |
15460ae5462d
fix crash when closing uiwidget_creator dialog by x-button or Alt+F4 (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25342
diff
changeset
|
77 // the window manager may have added one in the passed button |
15460ae5462d
fix crash when closing uiwidget_creator dialog by x-button or Alt+F4 (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25342
diff
changeset
|
78 QString text_clean = rm_amp (button->text ()); |
15460ae5462d
fix crash when closing uiwidget_creator dialog by x-button or Alt+F4 (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25342
diff
changeset
|
79 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
|
80 { |
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
|
81 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
|
82 { |
15460ae5462d
fix crash when closing uiwidget_creator dialog by x-button or Alt+F4 (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25342
diff
changeset
|
83 m_dialog_button = m_button_list.at (i); // text w/o extra accelerator |
15460ae5462d
fix crash when closing uiwidget_creator dialog by x-button or Alt+F4 (bug #54231)
Torsten <mttl@mailbox.org>
parents:
25342
diff
changeset
|
84 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
|
85 } |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
86 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
87 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
89 // 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
|
90 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
|
91 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
92 unlock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
93 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
94 // 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
|
95 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
96 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
98 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
|
99 int button_pressed) |
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 // Wait for link thread to go to sleep state. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
102 lock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
103 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
104 // Store the value so that builtin functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
105 *m_list_index = selected; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
106 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
|
107 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
108 unlock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
109 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
110 // 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
|
111 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
112 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
114 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
|
115 int button_pressed) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
116 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
117 // Wait for link thread to go to sleep state. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
118 lock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
119 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
120 // Store the value so that builtin functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
121 *m_string_list = input; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
122 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
|
123 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
124 unlock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
125 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
126 // 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
|
127 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
128 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
130 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
|
131 const QString& path, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
132 int filterindex) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
133 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
134 // Wait for link thread to go to sleep state. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
135 lock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
136 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
137 // Store the value so that builtin functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
138 *m_string_list = files; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
139 m_dialog_result = filterindex; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
140 *m_path_name = path; |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
141 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
142 unlock (); |
20091
89d843d6de14
Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
20081
diff
changeset
|
143 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
144 // 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
|
145 wake_all (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
146 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
147 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
148 MessageDialog::MessageDialog (const QString& message, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
149 const QString& title, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
150 const QString& qsicon, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
151 const QStringList& qsbutton, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
152 const QString& defbutton, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
153 const QStringList& role) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
154 : QMessageBox (QMessageBox::NoIcon, title.isEmpty () ? " " : title, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
155 message, nullptr, nullptr) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
156 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
157 // Create a NonModal message. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
158 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
|
159 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
160 // 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
|
161 // easily be made to pass through a signal. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
162 QMessageBox::Icon eicon = QMessageBox::NoIcon; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
163 if (qsicon == "error") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
164 eicon = QMessageBox::Critical; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
165 else if (qsicon == "warn") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
166 eicon = QMessageBox::Warning; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
167 else if (qsicon == "help") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
168 eicon = QMessageBox::Information; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
169 else if (qsicon == "quest") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
170 eicon = QMessageBox::Question; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
171 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
|
172 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
173 int N = (qsbutton.size () < role.size () ? qsbutton.size () : role.size ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
174 if (N == 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
175 addButton (QMessageBox::Ok); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
176 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
177 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
178 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
|
179 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
180 // Interpret the button role string, because enumeration |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
181 // QMessageBox::ButtonRole can't be made to pass through a signal. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
182 QString srole = role.at (i); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
183 QMessageBox::ButtonRole erole = QMessageBox::InvalidRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
184 if (srole == "ResetRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
185 erole = QMessageBox::ResetRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
186 else if (srole == "YesRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
187 erole = QMessageBox::YesRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
188 else if (srole == "NoRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
189 erole = QMessageBox::NoRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
190 else if (srole == "RejectRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
191 erole = QMessageBox::RejectRole; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
192 else if (srole == "AcceptRole") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
193 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
|
194 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
195 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
|
196 if (qsbutton.at (i) == defbutton) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
197 setDefaultButton (pbutton); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
198 // 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
|
199 if (i == N-1) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
200 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
201 // 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
|
202 #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
|
203 #if ACTIVE_ESCAPE |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
204 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
|
205 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
206 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
|
207 #endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
208 #undef ACTIVE_ESCAPE |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
209 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
210 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
211 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
213 connect (this, SIGNAL (buttonClicked (QAbstractButton *)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
214 &uiwidget_creator, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
215 SLOT (dialog_button_clicked (QAbstractButton *))); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
216 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
218 ListDialog::ListDialog (const QStringList& list, const QString& mode, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
219 int wd, int ht, const QList<int>& initial, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
220 const QString& title, const QStringList& prompt, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
221 const QString& ok_string, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
222 const QString& cancel_string) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
223 : QDialog (), m_model (new QStringListModel (list)) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
224 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
225 QListView *view = new QListView; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
226 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
|
227 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
228 if (mode == "single") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
229 view->setSelectionMode (QAbstractItemView::SingleSelection); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
230 else if (mode == "multiple") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
231 view->setSelectionMode (QAbstractItemView::ExtendedSelection); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
232 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
233 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
|
234 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
235 selector = view->selectionModel (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
236 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
|
237 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
|
238 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
239 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
|
240 QModelIndex ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
241 selector->select (idx, QItemSelectionModel::Select); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
242 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
244 bool fixed_layout = false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
245 if (wd > 0 && ht > 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
246 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
247 view->setFixedSize (wd, ht); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
248 fixed_layout = true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
249 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
251 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
|
252 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
253 QVBoxLayout *listLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
254 if (! prompt.isEmpty ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
255 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
256 // 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
|
257 // 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
|
258 QString prompt_string; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
259 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
|
260 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
261 if (j > 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
262 // 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
|
263 #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
|
264 #if RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
265 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
|
266 #else |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
267 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
|
268 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
269 prompt_string.append (prompt.at (j)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
270 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
271 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
|
272 #if RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
273 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
|
274 #endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
275 #undef RICH_TEXT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
276 listLayout->addWidget (plabel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
277 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
278 listLayout->addWidget (view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
279 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
|
280 select_all->setVisible (mode == "multiple"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
281 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
|
282 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
283 QPushButton *buttonOk = new QPushButton (ok_string); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
284 QPushButton *buttonCancel = new QPushButton (cancel_string); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
285 QHBoxLayout *buttonsLayout = new QHBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
286 buttonsLayout->addStretch (1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
287 buttonsLayout->addWidget (buttonOk); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
288 buttonsLayout->addWidget (buttonCancel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
289 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
|
290 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
291 QVBoxLayout *mainLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
292 mainLayout->addLayout (listLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
293 mainLayout->addSpacing (12); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
294 mainLayout->addLayout (buttonsLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
295 setLayout (mainLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
296 if (fixed_layout) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
297 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
|
298 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
299 // 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
|
300 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
|
301 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
302 connect (select_all, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
303 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
|
304 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
305 connect (buttonOk, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
306 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
|
307 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
308 connect (buttonCancel, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
309 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
|
310 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
311 connect (this, SIGNAL (finish_selection (const QIntList&, int)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
312 &uiwidget_creator, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
313 SLOT (list_select_finished (const QIntList&, int))); |
20505
dd327c0909b0
listdlg: Make appearance and behavior more Matlab compatible (bug #46026)
Mike Miller <mtmiller@octave.org>
parents:
20230
diff
changeset
|
314 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
315 connect (view, SIGNAL (doubleClicked (const QModelIndex&)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
316 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
|
317 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
318 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
319 ListDialog::~ListDialog (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
320 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
321 delete m_model; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
322 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
323 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
324 void ListDialog::buttonOk_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
325 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
326 // 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
|
327 // functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
328 QModelIndexList selected_index = selector->selectedIndexes (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
329 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
|
330 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
331 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
|
332 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
|
333 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
334 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
|
335 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
336 done (QDialog::Accepted); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
337 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
338 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
339 void ListDialog::buttonCancel_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
340 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
341 // 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
|
342 // functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
343 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
|
344 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
345 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
|
346 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
347 done (QDialog::Rejected); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
348 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
349 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
350 void ListDialog::reject (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
351 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
352 buttonCancel_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
353 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
354 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
355 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
|
356 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
357 buttonOk_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
358 } |
20505
dd327c0909b0
listdlg: Make appearance and behavior more Matlab compatible (bug #46026)
Mike Miller <mtmiller@octave.org>
parents:
20230
diff
changeset
|
359 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
360 InputDialog::InputDialog (const QStringList& prompt, const QString& title, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
361 const QFloatList& nr, const QFloatList& nc, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
362 const QStringList& defaults) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
363 : QDialog () |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
364 { |
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
|
365 |
16626
4adf3c4bd80b
GUI compilation fixes for MSVC.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16582
diff
changeset
|
366 #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
|
367 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
368 #if LINE_EDIT_FOLLOWS_PROMPT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
369 // 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
|
370 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
|
371 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
372 // Prompt aligned above input. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
373 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
|
374 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
375 int N_gridrows = prompt.size (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
376 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
|
377 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
378 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
|
379 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
|
380 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
|
381 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
|
382 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
|
383 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
384 QSize qsize = line_edit->sizeHint (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
385 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
|
386 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
|
387 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
|
388 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
389 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
|
390 line_edit->setFixedWidth (intval); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
391 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
392 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
393 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
|
394 #if LINE_EDIT_FOLLOWS_PROMPT |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
395 promptInputLayout->addWidget (label, i + 1, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
396 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
|
397 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
398 promptInputLayout->addWidget (label); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
399 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
|
400 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
401 } |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16550
diff
changeset
|
402 #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
|
403 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
404 QPushButton *buttonOk = new QPushButton ("OK"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
405 QPushButton *buttonCancel = new QPushButton ("Cancel"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
406 QHBoxLayout *buttonsLayout = new QHBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
407 buttonsLayout->addStretch (1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
408 buttonsLayout->addWidget (buttonOk); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
409 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
|
410 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
411 QVBoxLayout *mainLayout = new QVBoxLayout; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
412 mainLayout->addLayout (promptInputLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
413 mainLayout->addSpacing (12); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
414 mainLayout->addLayout (buttonsLayout); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
415 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
|
416 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
417 // 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
|
418 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
|
419 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
420 connect (buttonOk, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
421 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
|
422 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
423 connect (buttonCancel, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
424 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
|
425 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
426 connect (this, SIGNAL (finish_input (const QStringList&, int)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
427 &uiwidget_creator, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
428 SLOT (input_finished (const QStringList&, int))); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
429 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
430 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
431 void InputDialog::buttonOk_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
432 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
433 // 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
|
434 // functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
435 QStringList string_result; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
436 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
|
437 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
|
438 emit finish_input (string_result, 1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
439 done (QDialog::Accepted); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
440 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
441 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
442 void InputDialog::buttonCancel_clicked (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
443 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
444 // 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
|
445 // functions can retrieve. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
446 QStringList empty; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
447 emit finish_input (empty, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
448 done (QDialog::Rejected); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
449 } |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
450 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
451 void InputDialog::reject (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
452 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
453 buttonCancel_clicked (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
454 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
455 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
456 FileDialog::FileDialog (const QStringList& name_filters, const QString& title, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
457 const QString& filename, const QString& dirname, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
458 const QString& multimode) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
459 : QFileDialog () |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
460 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
461 // Create a NonModal message. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
462 setWindowModality (Qt::NonModal); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
463 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
464 setWindowTitle (title.isEmpty () ? " " : title); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
465 setDirectory (dirname); |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
25952
diff
changeset
|
466 |
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
25952
diff
changeset
|
467 // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved. |
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
25952
diff
changeset
|
468 if (! resource_manager::get_settings ()->value ("use_native_file_dialogs", |
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
25952
diff
changeset
|
469 true).toBool ()) |
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
25952
diff
changeset
|
470 setOption(QFileDialog::DontUseNativeDialog); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
471 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
472 if (multimode == "on") // uigetfile multiselect=on |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
473 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
474 setFileMode (QFileDialog::ExistingFiles); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
475 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
476 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
477 else if (multimode == "create") // uiputfile |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
478 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
479 setFileMode (QFileDialog::AnyFile); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
480 setAcceptMode (QFileDialog::AcceptSave); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
481 setOption (QFileDialog::DontConfirmOverwrite, false); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
482 setConfirmOverwrite (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
483 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
484 else if (multimode == "dir") // uigetdir |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
485 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
486 setFileMode (QFileDialog::Directory); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
487 setOption (QFileDialog::ShowDirsOnly, true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
488 setOption (QFileDialog::HideNameFilterDetails, true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
489 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
490 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
491 else // uigetfile multiselect=off |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
492 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
493 setFileMode (QFileDialog::ExistingFile); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
494 setAcceptMode (QFileDialog::AcceptOpen); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
495 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
496 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
497 setNameFilters (name_filters); |
16581
fa4a035e0cf4
Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents:
16580
diff
changeset
|
498 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
499 selectFile (filename); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17400
diff
changeset
|
500 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
501 connect (this, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
502 SIGNAL (finish_input (const QStringList&, const QString&, int)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
503 &uiwidget_creator, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
504 SLOT (filedialog_finished (const QStringList&, const QString&, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
505 int))); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
506 connect (this, SIGNAL (accepted ()), this, SLOT (acceptSelection ())); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
507 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
|
508 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
509 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
510 void FileDialog::rejectSelection (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
511 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
512 QStringList empty; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
513 emit finish_input (empty, "", 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
514 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
515 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
516 void FileDialog::acceptSelection (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
517 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
518 QStringList string_result; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
519 QString path; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
520 int idx = 1; |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
521 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
522 string_result = selectedFiles (); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
523 |
25951 | 524 if (testOption (QFileDialog::ShowDirsOnly) && string_result.size () > 0) |
525 path = string_result[0]; | |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
526 else |
25951 | 527 path = directory ().absolutePath (); |
18607
40dce9423baa
uigetdir: return correct path name (Bug #42004)
John Donoghue <john.donoghue@ieee.org>
parents:
18405
diff
changeset
|
528 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
529 // 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
|
530 // full path names, so fix it. |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
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 < string_result.size (); i++) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
533 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
|
534 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
535 // if not showing only dirs, add end slash for the path component |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
536 if (testOption (QFileDialog::ShowDirsOnly) == false) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
537 path += '/'; |
18404
6ebd37faae5f
Add path separator to end of uigetfile path (Bug #41367)
John Donoghue <john.donoghue@ieee.org>
parents:
17790
diff
changeset
|
538 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
539 // convert to native slashes |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
540 path = QDir::toNativeSeparators (path); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
541 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
542 QStringList name_filters = nameFilters (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
543 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
|
544 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
545 // send the selected info |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24586
diff
changeset
|
546 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
|
547 } |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
16565
diff
changeset
|
548 } |