GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
welcome-wizard.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2011-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include <QApplication>
31#include <QDesktopWidget>
32#include <QHBoxLayout>
33#include <QPushButton>
34#include <QVBoxLayout>
35
36#if defined (OCTAVE_USE_WINDOWS_API)
37 #define WIN32_LEAN_AND_MEAN
38 #include <windows.h>
39#endif
40
41#include "gui-preferences-nr.h"
42#include "octave-qobject.h"
43#include "welcome-wizard.h"
44
45namespace octave
46{
47 static QLabel *
48 make_octave_logo (QWidget *p = nullptr, int height = 100)
49 {
50 QLabel *logo = new QLabel (p);
51 QPixmap logo_pixmap (":/actions/icons/logo.png");
52 logo->setPixmap (logo_pixmap.scaledToHeight (height));
53 return logo;
54 };
55
57 : QDialog (p), m_octave_qobj (oct_qobj), m_page_ctor_list (),
58 m_page_list_iterator (),
59 m_current_page (initial_page::create (oct_qobj, this)),
60 m_allow_web_connect_state (false),
61 m_max_height (0), m_max_width (0)
62 {
66
68
69 setWindowTitle (tr ("Welcome to GNU Octave"));
70
71 setEnabled (true);
72
73 setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
74
75 // Create all pages for pre-setting the minimal required size for all pages
76 show_page ();
77 adjust_size ();
78 next_page ();
79 adjust_size ();
80 next_page ();
81 adjust_size ();
82 // now go back to the first page
85
86 // Set the size determined above
87 resize (m_max_width, m_max_height);
88
89#if defined (OCTAVE_USE_WINDOWS_API)
90 // HACK to forceshow of dialog if started minimized
91 ShowWindow (reinterpret_cast<HWND> (winId ()), SW_SHOWNORMAL);
92#endif
93 }
94
96 {
97 // Get adjusted size for the current page
98 adjustSize ();
99 QSize sz = size ();
100
101 // Update the max. size of the three pages if required
102
103 if (sz.height () > m_max_height)
104 m_max_height = sz.height ();
105
106 if (sz.width () > m_max_width)
107 m_max_width = sz.width ();
108 }
109
111 {
112 m_allow_web_connect_state = state == Qt::Checked;
113 }
114
116 {
117 delete m_current_page;
118 delete layout ();
119
120 m_current_page = (*m_page_list_iterator) (m_octave_qobj, this);
121
122 QVBoxLayout *new_layout = new QVBoxLayout ();
123 setLayout (new_layout);
124
125 new_layout->addWidget (m_current_page);
126 }
127
129 {
131
132 show_page ();
133 }
134
136 {
138
139 show_page ();
140 }
141
143 {
144 // Create default settings file.
145
147 rmgr.reload_settings ();
148
150
151 if (settings)
152 {
155
156 settings->sync ();
157 }
158
159 QDialog::accept ();
160 }
161
163 : QWidget (wizard),
164 m_title (new QLabel (tr ("Welcome to Octave!"), this)),
165 m_message (new QLabel (this)),
166 m_logo (make_octave_logo (this)),
167 m_next (new QPushButton (tr ("Next"), this)),
168 m_cancel (new QPushButton (tr ("Cancel"), this))
169 {
170 QFont ft;
171 ft.setPointSize (20);
172 m_title->setFont (ft);
173
174 resource_manager& rmgr = oct_qobj.get_resource_manager ();
175
176 m_message->setText
177 (tr ("<html><body>\n"
178 "<p>You seem to be using the Octave graphical interface for the first time on this computer.\n"
179 "Click 'Next' to create a configuration file and launch Octave.</p>\n"
180 "<p>The configuration file is stored in<br>%1.</p>\n"
181 "</body></html>").
182 arg (rmgr.get_settings_file ()));
183 m_message->setWordWrap (true);
184 m_message->setMinimumWidth (400);
185
186 QVBoxLayout *message_layout = new QVBoxLayout;
187
188 message_layout->addWidget (m_title);
189 message_layout->addWidget (m_message);
190
191 QHBoxLayout *message_and_logo = new QHBoxLayout;
192
193 message_and_logo->addLayout (message_layout);
194 message_and_logo->addStretch (10);
195 message_and_logo->addWidget (m_logo, 0, Qt::AlignTop);
196
197 QHBoxLayout *button_bar = new QHBoxLayout;
198
199 button_bar->addStretch (10);
200 button_bar->addWidget (m_next);
201 button_bar->addWidget (m_cancel);
202
203 QVBoxLayout *page_layout = new QVBoxLayout (this);
204 setLayout (page_layout);
205
206 page_layout->addLayout (message_and_logo);
207 page_layout->addStretch (10);
208 page_layout->addSpacing (20);
209 page_layout->addLayout (button_bar);
210
211 setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
212
213 m_next->setDefault (true);
214 m_next->setFocus ();
215
216 connect (m_next, &QPushButton::clicked, wizard, &welcome_wizard::next_page);
217 connect (m_cancel, &QPushButton::clicked, wizard, &welcome_wizard::reject);
218 }
219
221 welcome_wizard *wizard)
222 : QWidget (wizard),
223 m_title (new QLabel (tr ("Community News"), this)),
224 m_message (new QLabel (this)),
225 m_checkbox (new QCheckBox (this)),
226 m_checkbox_message (new QLabel (this)),
227 m_logo (make_octave_logo (this)),
228 m_previous (new QPushButton (tr ("Previous"), this)),
229 m_next (new QPushButton (tr ("Next"), this)),
230 m_cancel (new QPushButton (tr ("Cancel"), this))
231 {
232 QFont ft;
233 ft.setPointSize (20);
234 m_title->setFont (ft);
235
236 m_message->setText
237 (tr ("<html><body>\n"
238 "<p>When Octave starts, it will optionally check the Octave web site for current news and information about the Octave community.\n"
239 "The check will happen at most once each day and news will only be displayed if there is something new since the last time you viewed the news.</p>\n"
240 "<p>You may also view the news by selecting the \"Community News\" item in the \"Help\" menu, or by visiting\n"
241 "<a href=\"https://octave.org/community-news.html\">https://octave.org/community-news.html</a>.</p>\n"
242 "</body></html>"));
243 m_message->setWordWrap (true);
244 m_message->setMinimumWidth (400);
245 m_message->setOpenExternalLinks (true);
246
247 QVBoxLayout *message_layout = new QVBoxLayout;
248
249 message_layout->addWidget (m_title);
250 message_layout->addWidget (m_message);
251
252 QHBoxLayout *message_and_logo = new QHBoxLayout;
253
254 message_and_logo->addLayout (message_layout);
255 message_and_logo->addStretch (10);
256 message_and_logo->addWidget (m_logo, 0, Qt::AlignTop);
257
258 QHBoxLayout *checkbox_layout = new QHBoxLayout;
259
260 bool allow_connection = nr_allow_connection.def.toBool ();
261 if (allow_connection)
262 m_checkbox->setCheckState (Qt::Checked);
263 else
264 m_checkbox->setCheckState (Qt::Unchecked);
265
266 m_checkbox_message->setText
267 (tr ("<html><head>\n"
268 "</head><body>\n"
269 "<p>Allow Octave to connect to the Octave web site when it starts to display current news and information about the Octave community.</p>\n"
270 "</body></html>"));
271 m_checkbox_message->setWordWrap (true);
272 m_checkbox_message->setOpenExternalLinks (true);
273 m_checkbox_message->setMinimumWidth (500);
274
275 checkbox_layout->addWidget (m_checkbox, 0, Qt::AlignTop);
276 checkbox_layout->addSpacing (20);
277 checkbox_layout->addWidget (m_checkbox_message, 0, Qt::AlignTop);
278 checkbox_layout->addStretch (10);
279
280 QVBoxLayout *message_logo_and_checkbox = new QVBoxLayout;
281
282 message_logo_and_checkbox->addLayout (message_and_logo);
283 message_logo_and_checkbox->addSpacing (20);
284 message_logo_and_checkbox->addLayout (checkbox_layout);
285
286 QHBoxLayout *button_bar = new QHBoxLayout;
287
288 button_bar->addStretch (10);
289 button_bar->addWidget (m_previous);
290 button_bar->addWidget (m_next);
291 button_bar->addWidget (m_cancel);
292
293 QVBoxLayout *page_layout = new QVBoxLayout (this);
294 setLayout (page_layout);
295
296 page_layout->addLayout (message_logo_and_checkbox);
297 page_layout->addStretch (10);
298 page_layout->addSpacing (20);
299 page_layout->addLayout (button_bar);
300
301 setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
302
303 m_next->setDefault (true);
304 m_next->setFocus ();
305
306 connect (m_checkbox, &QCheckBox::stateChanged,
308
309 connect (m_previous, &QPushButton::clicked, wizard, &welcome_wizard::previous_page);
310 connect (m_next, &QPushButton::clicked, wizard, &welcome_wizard::next_page);
311 connect (m_cancel, &QPushButton::clicked, wizard, &welcome_wizard::reject);
312 }
313
315 : QWidget (wizard),
316 m_title (new QLabel (tr ("Enjoy!"), this)),
317 m_message (new QLabel (this)),
318 m_logo (make_octave_logo (this)),
319 m_links (new QLabel (this)),
320 m_previous (new QPushButton (tr ("Previous"), this)),
321 m_finish (new QPushButton (tr ("Finish"), this)),
322 m_cancel (new QPushButton (tr ("Cancel"), this))
323 {
324 QFont ft;
325 ft.setPointSize (20);
326 m_title->setFont (ft);
327
328 m_message->setText
329 (tr ("<html><body>\n"
330 "<p>We hope you find Octave to be a useful tool.</p>\n"
331 "<p>If you encounter problems, there are a number of ways to get help, including commercial support options, a mailing list, a wiki, and other community-based support channels.\n"
332 "You can find more information about each of these by visiting <a href=\"https://octave.org/support.html\">https://octave.org/support.html</a> (opens in external browser).</p>\n"
333 "</body></html>"));
334 m_message->setWordWrap (true);
335 m_message->setMinimumWidth (400);
336 m_message->setOpenExternalLinks (true);
337
338 QVBoxLayout *message_layout = new QVBoxLayout;
339
340 message_layout->addWidget (m_title);
341 message_layout->addWidget (m_message);
342
343 QHBoxLayout *message_and_logo = new QHBoxLayout;
344
345 message_and_logo->addLayout (message_layout);
346 message_and_logo->addStretch (10);
347 message_and_logo->addWidget (m_logo, 0, Qt::AlignTop);
348
349 m_links->setText
350 (tr ("<html><head>\n"
351 "</head><body>\n"
352 "<p>For more information about Octave:</p>\n"
353 "<ul>\n"
354 "<li>Visit <a href=\"https://octave.org\">https://octave.org</a> (opens in external browser)</li>\n"
355 "<li>Get the documentation online as <a href=\"https://www.gnu.org/software/octave/doc/interpreter/index.html\">html</a>- or <a href=\"https://www.gnu.org/software/octave/octave.pdf\">pdf</a>-document (opens in external browser)</li>\n"
356 "<li>Open the documentation browser of the Octave GUI with the help menu</li>\n"
357 "</ul>\n"
358 "</body></html>"));
359 m_links->setWordWrap (true);
360 m_links->setOpenExternalLinks (true);
361
362 QHBoxLayout *button_bar = new QHBoxLayout;
363
364 button_bar->addStretch (10);
365 button_bar->addWidget (m_previous);
366 button_bar->addWidget (m_finish);
367 button_bar->addWidget (m_cancel);
368
369 QVBoxLayout *page_layout = new QVBoxLayout (this);
370 setLayout (page_layout);
371
372 page_layout->addLayout (message_and_logo);
373 page_layout->addSpacing (20);
374 page_layout->addWidget (m_links);
375 page_layout->addStretch (10);
376 page_layout->addSpacing (20);
377 page_layout->addLayout (button_bar);
378
379 setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
380
381 m_finish->setDefault (true);
382 m_finish->setFocus ();
383
384 connect (m_previous, &QPushButton::clicked,
386 connect (m_finish, &QPushButton::clicked, wizard, &welcome_wizard::accept);
387 connect (m_cancel, &QPushButton::clicked, wizard, &welcome_wizard::reject);
388 }
389}
Base class for Octave interfaces that use Qt.
resource_manager & get_resource_manager(void)
QPushButton * m_cancel
QPushButton * m_previous
final_page(base_qobject &oct_qobj, welcome_wizard *wizard)
QPushButton * m_finish
static QWidget * create(base_qobject &oct_qobj, welcome_wizard *wizard)
initial_page(base_qobject &oct_qobj, welcome_wizard *wizard)
QPushButton * m_cancel
QPushButton * m_next
static QWidget * create(base_qobject &oct_qobj, welcome_wizard *wizard)
gui_settings * get_settings(void) const
setup_community_news(base_qobject &oct_qobj, welcome_wizard *wizard)
static QWidget * create(base_qobject &oct_qobj, welcome_wizard *wizard)
QList< page_creator_fptr > m_page_ctor_list
QList< page_creator_fptr >::iterator m_page_list_iterator
void handle_web_connect_option(int state)
base_qobject & m_octave_qobj
welcome_wizard(base_qobject &oct_qobj, QWidget *parent=nullptr)
const gui_pref nr_allow_connection("news/allow_web_connection", QVariant(false))
static uint32_t state[624]
Definition: randmtzig.cc:192
static QLabel * make_octave_logo(QWidget *p=nullptr, int height=100)
const QString key
const QVariant def