GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
welcome-wizard.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2013-2017 John W. Eaton
4 Copyright (C) 2011-2016 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 the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 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 <http://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 = 0, 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 
52  : QWidget (wizard),
53  title (new QLabel (tr ("Welcome to Octave!"), this)),
54  message (new QLabel (this)),
55  logo (make_octave_logo (this)),
56  next (new QPushButton (tr ("Next"), this)),
57  cancel (new QPushButton (tr ("Cancel"), this))
58 {
59  QFont ft;
60  ft.setPointSize (20);
61  title->setFont (ft);
62 
63  message->setText
64  (tr ("<html><body>\n"
65  "<p>You seem to be using the Octave graphical interface for the first time on this computer.\n"
66  "Click 'Next' to create a configuration file and launch Octave.</p>\n"
67  "<p>The configuration file is stored in<br>%1.</p>\n"
68  "</body></html>").
70  message->setWordWrap (true);
71  message->setMinimumWidth (400);
72 
73  QVBoxLayout *message_layout = new QVBoxLayout;
74 
75  message_layout->addWidget (title);
76  message_layout->addWidget (message);
77 
78  QHBoxLayout *message_and_logo = new QHBoxLayout;
79 
80  message_and_logo->addLayout (message_layout);
81  message_and_logo->addStretch (10);
82  message_and_logo->addWidget (logo, 0, Qt::AlignTop);
83 
84  QHBoxLayout *button_bar = new QHBoxLayout;
85 
86  button_bar->addStretch (10);
87  button_bar->addWidget (next);
88  button_bar->addWidget (cancel);
89 
90  QVBoxLayout *page_layout = new QVBoxLayout (this);
91  setLayout (page_layout);
92 
93  page_layout->addLayout (message_and_logo);
94  page_layout->addStretch (10);
95  page_layout->addLayout (button_bar);
96 
97  next->setDefault (true);
98  next->setFocus ();
99 
100  connect (next, SIGNAL (clicked ()), wizard, SLOT (next_page ()));
101  connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
102 }
103 
105  : QWidget (wizard),
106  title (new QLabel (tr ("Community News"), this)),
107  message (new QLabel (this)),
108  checkbox (new QCheckBox (this)),
109  checkbox_message (new QLabel (this)),
110  logo (make_octave_logo (this)),
111  previous (new QPushButton (tr ("Previous"), this)),
112  next (new QPushButton (tr ("Next"), this)),
113  cancel (new QPushButton (tr ("Cancel"), this))
114 {
115  QFont ft;
116  ft.setPointSize (20);
117  title->setFont (ft);
118 
119  message->setText
120  (tr ("<html><body>\n"
121  "<p>When the Octave GUI starts, it will check the Octave web site for current news and information about the Octave community.\n"
122  "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"
123  "<p>You may also view the news by selecting the \"Community News\" item in the \"Help\" menu in the GUI, or by visiting\n"
124  "<a href=\"http://octave.org/community-news.html\">http://octave.org/community-news.html</a>.</p>\n"
125  "</body></html>"));
126  message->setWordWrap (true);
127  message->setMinimumWidth (400);
128  message->setOpenExternalLinks (true);
129 
130  QVBoxLayout *message_layout = new QVBoxLayout;
131 
132  message_layout->addWidget (title);
133  message_layout->addWidget (message);
134 
135  QHBoxLayout *message_and_logo = new QHBoxLayout;
136 
137  message_and_logo->addLayout (message_layout);
138  message_and_logo->addStretch (10);
139  message_and_logo->addWidget (logo, 0, Qt::AlignTop);
140 
141  QHBoxLayout *checkbox_layout = new QHBoxLayout;
142 
143  checkbox->setCheckState (Qt::Checked);
144 
145  checkbox_message->setText
146  (tr ("<html><head>\n"
147  "<style>\n"
148  "a:link { text-decoration: underline; color: #0000ff; }\n"
149  "</style>\n"
150  "<head/><body>\n"
151  "<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"
152  "</body></html>"));
153  checkbox_message->setWordWrap (true);
154  checkbox_message->setOpenExternalLinks (true);
155  checkbox_message->setMinimumWidth (500);
156 
157  checkbox_layout->addWidget (checkbox, 0, Qt::AlignTop);
158  checkbox_layout->addSpacing (20);
159  checkbox_layout->addWidget (checkbox_message, 0, Qt::AlignTop);
160  checkbox_layout->addStretch (10);
161 
162  QVBoxLayout *message_logo_and_checkbox = new QVBoxLayout;
163 
164  message_logo_and_checkbox->addLayout (message_and_logo);
165  message_logo_and_checkbox->addSpacing (20);
166  message_logo_and_checkbox->addLayout (checkbox_layout);
167 
168  QHBoxLayout *button_bar = new QHBoxLayout;
169 
170  button_bar->addStretch (10);
171  button_bar->addWidget (previous);
172  button_bar->addWidget (next);
173  button_bar->addWidget (cancel);
174 
175  QVBoxLayout *page_layout = new QVBoxLayout (this);
176  setLayout (page_layout);
177 
178  page_layout->addLayout (message_logo_and_checkbox);
179  page_layout->addStretch (10);
180  page_layout->addLayout (button_bar);
181 
182  next->setDefault (true);
183  next->setFocus ();
184 
185  connect (checkbox, SIGNAL (stateChanged (int)),
186  wizard, SLOT (handle_web_connect_option (int)));
187 
188  connect (previous, SIGNAL (clicked ()), wizard, SLOT (previous_page ()));
189  connect (next, SIGNAL (clicked ()), wizard, SLOT (next_page ()));
190  connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
191 }
192 
194  : QWidget (wizard),
195  title (new QLabel (tr ("Enjoy!"), this)),
196  message (new QLabel (this)),
197  logo (make_octave_logo (this)),
198  links (new QLabel (this)),
199  previous (new QPushButton (tr ("Previous"), this)),
200  finish (new QPushButton (tr ("Finish"), this)),
201  cancel (new QPushButton (tr ("Cancel"), this))
202 {
203  QFont ft;
204  ft.setPointSize (20);
205  title->setFont (ft);
206 
207  message->setText
208  (tr ("<html><body>\n"
209  "<p>We hope you find Octave to be a useful tool.</p>\n"
210  "<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"
211  "You can find more information about each of these by visiting <a href=\"http://octave.org/support.html\">http://octave.org/support.html</a> (opens in external browser).</p>\n"
212  "</body></html>"));
213  message->setWordWrap (true);
214  message->setMinimumWidth (400);
215  message->setOpenExternalLinks (true);
216 
217  QVBoxLayout *message_layout = new QVBoxLayout;
218 
219  message_layout->addWidget (title);
220  message_layout->addWidget (message);
221 
222  QHBoxLayout *message_and_logo = new QHBoxLayout;
223 
224  message_and_logo->addLayout (message_layout);
225  message_and_logo->addStretch (10);
226  message_and_logo->addWidget (logo, 0, Qt::AlignTop);
227 
228  links->setText
229  (tr ("<html><head>\n"
230  "<style>\n"
231  "a:link { text-decoration: underline; color: #0000ff; }\n"
232  "</style>\n"
233  "<head/><body>\n"
234  "<p>For more information about Octave:</p>\n"
235  "<ul>\n"
236  "<li>Visit <a href=\"http://octave.org\">http://octave.org</a> (opens in external browser)</li>\n"
237  "<li>Get the documentation online as <a href=\"http://www.gnu.org/software/octave/doc/interpreter/index.html\">html</a>- or <a href=\"http://www.gnu.org/software/octave/octave.pdf\">pdf</span></a>-document (opens in external browser)</li>\n"
238  "<li>Open the documentation browser of the Octave GUI with the help menu</li>\n"
239  "</ul>\n"
240  "</body></html>"));
241  links->setWordWrap (true);
242  links->setOpenExternalLinks (true);
243 
244  QHBoxLayout *button_bar = new QHBoxLayout;
245 
246  button_bar->addStretch (10);
247  button_bar->addWidget (previous);
248  button_bar->addWidget (finish);
249  button_bar->addWidget (cancel);
250 
251  QVBoxLayout *page_layout = new QVBoxLayout (this);
252  setLayout (page_layout);
253 
254  page_layout->addLayout (message_and_logo);
255  page_layout->addSpacing (20);
256  page_layout->addWidget (links);
257  page_layout->addStretch (10);
258  page_layout->addLayout (button_bar);
259 
260  finish->setDefault (true);
261  finish->setFocus ();
262 
263  connect (previous, SIGNAL (clicked ()), wizard, SLOT (previous_page ()));
264  connect (finish, SIGNAL (clicked ()), wizard, SLOT (accept ()));
265  connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
266 }
267 
269  : QDialog (p), page_ctor_list (), page_list_iterator (),
270  current_page (initial_page::create (this)),
271  allow_web_connect_state (true)
272 {
276 
278 
279  setWindowTitle (tr ("Welcome to GNU Octave"));
280 
281  setEnabled (true);
282  resize (600, 480);
283  setMinimumSize (QSize (600, 480));
284 
285  show_page ();
286 
287 #if defined (OCTAVE_USE_WINDOWS_API)
288  // HACK to forceshow of dialog if started minimized
289  ShowWindow((HWND)winId(), SW_SHOWNORMAL);
290 #endif
291 }
292 
293 void
295 {
296  allow_web_connect_state = state == Qt::Checked;
297 }
298 
299 void
301 {
302  delete current_page;
303  delete layout ();
304 
305  current_page = (*page_list_iterator) (this);
306 
307  QVBoxLayout *new_layout = new QVBoxLayout ();
308  setLayout (new_layout);
309 
310  new_layout->addWidget (current_page);
311 }
312 
313 void
315 {
317 
318  show_page ();
319 }
320 
321 void
323 {
325 
326  show_page ();
327 }
328 
329 void
331 {
332  // Create default settings file.
333 
335 
336  QSettings *settings = resource_manager::get_settings ();
337 
338  if (settings)
339  {
340  settings->setValue ("news/allow_web_connection",
342 
343  settings->sync ();
344  }
345 
346  QDialog::accept ();
347 }
void next_page(void)
QList< page_creator_fptr > page_ctor_list
QPushButton * cancel
QWidget * current_page
static QString get_settings_file(void)
final_page(welcome_wizard *wizard)
octave_value arg
Definition: pr-output.cc:3440
QPushButton * finish
QLabel * title
void previous_page(void)
void message(const char *name, const char *fmt,...)
Definition: error.cc:430
static QWidget * create(welcome_wizard *wizard)
welcome_wizard(QWidget *parent=0)
QLabel * title
static uint32_t * next
Definition: randmtzig.cc:183
static QLabel * make_octave_logo(QWidget *p=0, int height=100)
QPushButton * next
QList< page_creator_fptr >::iterator page_list_iterator
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
initial_page(welcome_wizard *wizard)
static QSettings * get_settings(void)
static uint32_t state[624]
Definition: randmtzig.cc:184
QPushButton * previous
void handle_web_connect_option(int state)
QLabel * message
p
Definition: lu.cc:138
QLabel * logo
void show_page(void)
QPushButton * previous
bool allow_web_connect_state
static QWidget * create(welcome_wizard *wizard)
QPushButton * cancel
QPushButton * cancel
QLabel * links
void accept(void)
QLabel * message
QLabel * logo
setup_community_news(welcome_wizard *wizard)
static void reload_settings(void)
static QWidget * create(welcome_wizard *wizard)