annotate libgui/src/dialog.cc @ 30564:796f54d4ddbf stable

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