GNU Octave  4.4.1
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) 2013-2018 John W. Eaton
4 Copyright (C) 2011-2018 Jacob Dawid
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if defined (HAVE_CONFIG_H)
25 # include "config.h"
26 #endif
27 
28 #include <QApplication>
29 #include <QPushButton>
30 #include <QHBoxLayout>
31 #include <QVBoxLayout>
32 
33 #if defined (OCTAVE_USE_WINDOWS_API)
34  #define WIN32_LEAN_AND_MEAN
35  #include <windows.h>
36 #endif
37 
38 #include "welcome-wizard.h"
39 #include "resource-manager.h"
40 
41 static QLabel *
42 make_octave_logo (QWidget *p = nullptr, int height = 100)
43 {
44  QLabel *logo = new QLabel (p);
45  QPixmap logo_pixmap (":/actions/icons/logo.png");
46  logo->setPixmap (logo_pixmap.scaledToHeight (height));
47  return logo;
48 };
49 
50 namespace octave
51 {
53  : QDialog (p), m_page_ctor_list (), m_page_list_iterator (),
54  m_current_page (initial_page::create (this)),
55  m_allow_web_connect_state (false)
56  {
60 
62 
63  setWindowTitle (tr ("Welcome to GNU Octave"));
64 
65  setEnabled (true);
66  resize (600, 480);
67  setMinimumSize (QSize (600, 480));
68 
69  show_page ();
70 
71 #if defined (OCTAVE_USE_WINDOWS_API)
72  // HACK to forceshow of dialog if started minimized
73  ShowWindow (reinterpret_cast<HWND> (winId ()), SW_SHOWNORMAL);
74 #endif
75  }
76 
78  {
79  m_allow_web_connect_state = state == Qt::Checked;
80  }
81 
83  {
84  delete m_current_page;
85  delete layout ();
86 
87  m_current_page = (*m_page_list_iterator) (this);
88 
89  QVBoxLayout *new_layout = new QVBoxLayout ();
90  setLayout (new_layout);
91 
92  new_layout->addWidget (m_current_page);
93  }
94 
96  {
98 
99  show_page ();
100  }
101 
103  {
105 
106  show_page ();
107  }
108 
110  {
111  // Create default settings file.
112 
114 
115  QSettings *settings = resource_manager::get_settings ();
116 
117  if (settings)
118  {
119  settings->setValue ("news/allow_web_connection",
121 
122  settings->sync ();
123  }
124 
125  QDialog::accept ();
126  }
127 
129  : QWidget (wizard),
130  m_title (new QLabel (tr ("Welcome to Octave!"), this)),
131  m_message (new QLabel (this)),
132  m_logo (make_octave_logo (this)),
133  m_next (new QPushButton (tr ("Next"), this)),
134  m_cancel (new QPushButton (tr ("Cancel"), this))
135  {
136  QFont ft;
137  ft.setPointSize (20);
138  m_title->setFont (ft);
139 
140  m_message->setText
141  (tr ("<html><body>\n"
142  "<p>You seem to be using the Octave graphical interface for the first time on this computer.\n"
143  "Click 'Next' to create a configuration file and launch Octave.</p>\n"
144  "<p>The configuration file is stored in<br>%1.</p>\n"
145  "</body></html>").
147  m_message->setWordWrap (true);
148  m_message->setMinimumWidth (400);
149 
150  QVBoxLayout *message_layout = new QVBoxLayout;
151 
152  message_layout->addWidget (m_title);
153  message_layout->addWidget (m_message);
154 
155  QHBoxLayout *message_and_logo = new QHBoxLayout;
156 
157  message_and_logo->addLayout (message_layout);
158  message_and_logo->addStretch (10);
159  message_and_logo->addWidget (m_logo, 0, Qt::AlignTop);
160 
161  QHBoxLayout *button_bar = new QHBoxLayout;
162 
163  button_bar->addStretch (10);
164  button_bar->addWidget (m_next);
165  button_bar->addWidget (m_cancel);
166 
167  QVBoxLayout *page_layout = new QVBoxLayout (this);
168  setLayout (page_layout);
169 
170  page_layout->addLayout (message_and_logo);
171  page_layout->addStretch (10);
172  page_layout->addLayout (button_bar);
173 
174  m_next->setDefault (true);
175  m_next->setFocus ();
176 
177  connect (m_next, SIGNAL (clicked ()), wizard, SLOT (next_page ()));
178  connect (m_cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
179  }
180 
182  : QWidget (wizard),
183  m_title (new QLabel (tr ("Community News"), this)),
184  m_message (new QLabel (this)),
185  m_checkbox (new QCheckBox (this)),
186  m_checkbox_message (new QLabel (this)),
187  m_logo (make_octave_logo (this)),
188  m_previous (new QPushButton (tr ("Previous"), this)),
189  m_next (new QPushButton (tr ("Next"), this)),
190  m_cancel (new QPushButton (tr ("Cancel"), this))
191  {
192  QFont ft;
193  ft.setPointSize (20);
194  m_title->setFont (ft);
195 
196  m_message->setText
197  (tr ("<html><body>\n"
198  "<p>When Octave starts, it will optionally check the Octave web site for current news and information about the Octave community.\n"
199  "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"
200  "<p>You may also view the news by selecting the \"Community News\" item in the \"Help\" menu, or by visiting\n"
201  "<a href=\"https://octave.org/community-news.html\">https://octave.org/community-news.html</a>.</p>\n"
202  "</body></html>"));
203  m_message->setWordWrap (true);
204  m_message->setMinimumWidth (400);
205  m_message->setOpenExternalLinks (true);
206 
207  QVBoxLayout *message_layout = new QVBoxLayout;
208 
209  message_layout->addWidget (m_title);
210  message_layout->addWidget (m_message);
211 
212  QHBoxLayout *message_and_logo = new QHBoxLayout;
213 
214  message_and_logo->addLayout (message_layout);
215  message_and_logo->addStretch (10);
216  message_and_logo->addWidget (m_logo, 0, Qt::AlignTop);
217 
218  QHBoxLayout *checkbox_layout = new QHBoxLayout;
219 
220  // FIXME: Synchronize the initial state of this checkbox with the default
221  // value of "news/allow_web_connection" stored elsewhere.
222  m_checkbox->setCheckState (Qt::Unchecked);
223 
224  m_checkbox_message->setText
225  (tr ("<html><head>\n"
226  "<style>\n"
227  "a:link { text-decoration: underline; color: #0000ff; }\n"
228  "</style>\n"
229  "<head/><body>\n"
230  "<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"
231  "</body></html>"));
232  m_checkbox_message->setWordWrap (true);
233  m_checkbox_message->setOpenExternalLinks (true);
234  m_checkbox_message->setMinimumWidth (500);
235 
236  checkbox_layout->addWidget (m_checkbox, 0, Qt::AlignTop);
237  checkbox_layout->addSpacing (20);
238  checkbox_layout->addWidget (m_checkbox_message, 0, Qt::AlignTop);
239  checkbox_layout->addStretch (10);
240 
241  QVBoxLayout *message_logo_and_checkbox = new QVBoxLayout;
242 
243  message_logo_and_checkbox->addLayout (message_and_logo);
244  message_logo_and_checkbox->addSpacing (20);
245  message_logo_and_checkbox->addLayout (checkbox_layout);
246 
247  QHBoxLayout *button_bar = new QHBoxLayout;
248 
249  button_bar->addStretch (10);
250  button_bar->addWidget (m_previous);
251  button_bar->addWidget (m_next);
252  button_bar->addWidget (m_cancel);
253 
254  QVBoxLayout *page_layout = new QVBoxLayout (this);
255  setLayout (page_layout);
256 
257  page_layout->addLayout (message_logo_and_checkbox);
258  page_layout->addStretch (10);
259  page_layout->addLayout (button_bar);
260 
261  m_next->setDefault (true);
262  m_next->setFocus ();
263 
264  connect (m_checkbox, SIGNAL (stateChanged (int)),
265  wizard, SLOT (handle_web_connect_option (int)));
266 
267  connect (m_previous, SIGNAL (clicked ()), wizard, SLOT (previous_page ()));
268  connect (m_next, SIGNAL (clicked ()), wizard, SLOT (next_page ()));
269  connect (m_cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
270  }
271 
273  : QWidget (wizard),
274  m_title (new QLabel (tr ("Enjoy!"), this)),
275  m_message (new QLabel (this)),
276  m_logo (make_octave_logo (this)),
277  m_links (new QLabel (this)),
278  m_previous (new QPushButton (tr ("Previous"), this)),
279  m_finish (new QPushButton (tr ("Finish"), this)),
280  m_cancel (new QPushButton (tr ("Cancel"), this))
281  {
282  QFont ft;
283  ft.setPointSize (20);
284  m_title->setFont (ft);
285 
286  m_message->setText
287  (tr ("<html><body>\n"
288  "<p>We hope you find Octave to be a useful tool.</p>\n"
289  "<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"
290  "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"
291  "</body></html>"));
292  m_message->setWordWrap (true);
293  m_message->setMinimumWidth (400);
294  m_message->setOpenExternalLinks (true);
295 
296  QVBoxLayout *message_layout = new QVBoxLayout;
297 
298  message_layout->addWidget (m_title);
299  message_layout->addWidget (m_message);
300 
301  QHBoxLayout *message_and_logo = new QHBoxLayout;
302 
303  message_and_logo->addLayout (message_layout);
304  message_and_logo->addStretch (10);
305  message_and_logo->addWidget (m_logo, 0, Qt::AlignTop);
306 
307  m_links->setText
308  (tr ("<html><head>\n"
309  "<style>\n"
310  "a:link { text-decoration: underline; color: #0000ff; }\n"
311  "</style>\n"
312  "<head/><body>\n"
313  "<p>For more information about Octave:</p>\n"
314  "<ul>\n"
315  "<li>Visit <a href=\"https://octave.org\">https://octave.org</a> (opens in external browser)</li>\n"
316  "<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</span></a>-document (opens in external browser)</li>\n"
317  "<li>Open the documentation browser of the Octave GUI with the help menu</li>\n"
318  "</ul>\n"
319  "</body></html>"));
320  m_links->setWordWrap (true);
321  m_links->setOpenExternalLinks (true);
322 
323  QHBoxLayout *button_bar = new QHBoxLayout;
324 
325  button_bar->addStretch (10);
326  button_bar->addWidget (m_previous);
327  button_bar->addWidget (m_finish);
328  button_bar->addWidget (m_cancel);
329 
330  QVBoxLayout *page_layout = new QVBoxLayout (this);
331  setLayout (page_layout);
332 
333  page_layout->addLayout (message_and_logo);
334  page_layout->addSpacing (20);
335  page_layout->addWidget (m_links);
336  page_layout->addStretch (10);
337  page_layout->addLayout (button_bar);
338 
339  m_finish->setDefault (true);
340  m_finish->setFocus ();
341 
342  connect (m_previous, SIGNAL (clicked ()), wizard, SLOT (previous_page ()));
343  connect (m_finish, SIGNAL (clicked ()), wizard, SLOT (accept ()));
344  connect (m_cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
345  }
346 }
static QWidget * create(welcome_wizard *wizard)
static QWidget * create(welcome_wizard *wizard)
welcome_wizard(QWidget *parent=nullptr)
static QLabel * make_octave_logo(QWidget *p=nullptr, int height=100)
QPushButton * m_previous
QPushButton * m_finish
octave_value arg
Definition: pr-output.cc:3244
QPushButton * m_next
QList< page_creator_fptr >::iterator m_page_list_iterator
initial_page(welcome_wizard *wizard)
QPushButton * m_cancel
QPushButton * m_cancel
is false
Definition: cellfun.cc:400
static QString get_settings_file(void)
QList< page_creator_fptr > m_page_ctor_list
static void reload_settings(void)
returns the type of the matrix and caches it for future use Called with more than one the function will not attempt to guess the type if it is still unknown This is useful for debugging purposes The possible matrix types depend on whether the matrix is full or and can be one of the following able sis tem and mark type as unknown tem as the structure of the matrix explicitly gives this(Sparse matrices only) tem code
Definition: matrix_type.cc:120
static uint32_t state[624]
Definition: randmtzig.cc:183
setup_community_news(welcome_wizard *wizard)
static QWidget * create(welcome_wizard *wizard)
final_page(welcome_wizard *wizard)
void handle_web_connect_option(int state)
p
Definition: lu.cc:138
static QSettings * get_settings(void)