GNU Octave  4.0.0
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-2015 John W. Eaton
4 Copyright (C) 2011-2015 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 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 
28 #include <QApplication>
29 #include <QPushButton>
30 #include <QHBoxLayout>
31 #include <QVBoxLayout>
32 
33 #ifdef __WIN32__
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 
51 
53  : QWidget (wizard),
54  title (new QLabel (tr ("Welcome to Octave!"), this)),
55  message (new QLabel (this)),
56  logo (make_octave_logo (this)),
57  next (new QPushButton (tr ("Next"), this)),
58  cancel (new QPushButton (tr ("Cancel"), this))
59 {
60  QFont ft;
61  ft.setPointSize (20);
62  title->setFont (ft);
63 
64  message->setText
65  (tr ("<html><body>\n"
66  "<p>You seem to be using the Octave graphical interface for the first time on this computer.\n"
67  "Click 'Next' to create a configuration file and launch Octave.</p>\n"
68  "<p>The configuration file is stored in<br>%1.</p>\n"
69  "</body></html>").
71  message->setWordWrap (true);
72  message->setMinimumWidth (400);
73 
74  QVBoxLayout *message_layout = new QVBoxLayout;
75 
76  message_layout->addWidget (title);
77  message_layout->addWidget (message);
78 
79  QHBoxLayout *message_and_logo = new QHBoxLayout;
80 
81  message_and_logo->addLayout (message_layout);
82  message_and_logo->addStretch (10);
83  message_and_logo->addWidget (logo, 0, Qt::AlignTop);
84 
85  QHBoxLayout *button_bar = new QHBoxLayout;
86 
87  button_bar->addStretch (10);
88  button_bar->addWidget (next);
89  button_bar->addWidget (cancel);
90 
91  QVBoxLayout *page_layout = new QVBoxLayout (this);
92  setLayout (page_layout);
93 
94  page_layout->addLayout (message_and_logo);
95  page_layout->addStretch (10);
96  page_layout->addLayout (button_bar);
97 
98  next->setDefault (true);
99  next->setFocus ();
100 
101  connect (next, SIGNAL (clicked ()), wizard, SLOT (next_page ()));
102  connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
103 }
104 
105 
106 
108  : QWidget (wizard),
109  title (new QLabel (tr ("Community News"), this)),
110  message (new QLabel (this)),
111  checkbox (new QCheckBox (this)),
112  checkbox_message (new QLabel (this)),
113  logo (make_octave_logo (this)),
114  previous (new QPushButton (tr ("Previous"), this)),
115  next (new QPushButton (tr ("Next"), this)),
116  cancel (new QPushButton (tr ("Cancel"), this))
117 {
118  QFont ft;
119  ft.setPointSize (20);
120  title->setFont (ft);
121 
122  message->setText
123  (tr ("<html><body>\n"
124  "<p>When the Octave GUI starts, it will check the Octave web site for current news and information about the Octave community.\n"
125  "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"
126  "<p>You may also view the news by selecting the \"Community News\" item in the \"Help\" menu in the GUI, or by visiting\n"
127  "<a href=\"http://octave.org/community-news.html\">http://octave.org/community-news.html</a>.</p>\n"
128  "</body></html>"));
129  message->setWordWrap (true);
130  message->setMinimumWidth (400);
131  message->setOpenExternalLinks (true);
132 
133  QVBoxLayout *message_layout = new QVBoxLayout;
134 
135  message_layout->addWidget (title);
136  message_layout->addWidget (message);
137 
138  QHBoxLayout *message_and_logo = new QHBoxLayout;
139 
140  message_and_logo->addLayout (message_layout);
141  message_and_logo->addStretch (10);
142  message_and_logo->addWidget (logo, 0, Qt::AlignTop);
143 
144  QHBoxLayout *checkbox_layout = new QHBoxLayout;
145 
146  checkbox->setCheckState (Qt::Checked);
147 
148  checkbox_message->setText
149  (tr ("<html><head>\n"
150  "<style>\n"
151  "a:link { text-decoration: underline; color: #0000ff; }\n"
152  "</style>\n"
153  "<head/><body>\n"
154  "<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"
155  "</body></html>"));
156  checkbox_message->setWordWrap (true);
157  checkbox_message->setOpenExternalLinks (true);
158  checkbox_message->setMinimumWidth (500);
159 
160  checkbox_layout->addWidget (checkbox, 0, Qt::AlignTop);
161  checkbox_layout->addSpacing (20);
162  checkbox_layout->addWidget (checkbox_message, 0, Qt::AlignTop);
163  checkbox_layout->addStretch (10);
164 
165  QVBoxLayout *message_logo_and_checkbox = new QVBoxLayout;
166 
167  message_logo_and_checkbox->addLayout (message_and_logo);
168  message_logo_and_checkbox->addSpacing (20);
169  message_logo_and_checkbox->addLayout (checkbox_layout);
170 
171  QHBoxLayout *button_bar = new QHBoxLayout;
172 
173  button_bar->addStretch (10);
174  button_bar->addWidget (previous);
175  button_bar->addWidget (next);
176  button_bar->addWidget (cancel);
177 
178  QVBoxLayout *page_layout = new QVBoxLayout (this);
179  setLayout (page_layout);
180 
181  page_layout->addLayout (message_logo_and_checkbox);
182  page_layout->addStretch (10);
183  page_layout->addLayout (button_bar);
184 
185  next->setDefault (true);
186  next->setFocus ();
187 
188  connect (checkbox, SIGNAL (stateChanged (int)),
189  wizard, SLOT (handle_web_connect_option (int)));
190 
191  connect (previous, SIGNAL (clicked ()), wizard, SLOT (previous_page ()));
192  connect (next, SIGNAL (clicked ()), wizard, SLOT (next_page ()));
193  connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
194 }
195 
196 
198  : QWidget (wizard),
199  title (new QLabel (tr ("Enjoy!"), this)),
200  message (new QLabel (this)),
201  logo (make_octave_logo (this)),
202  links (new QLabel (this)),
203  previous (new QPushButton (tr ("Previous"), this)),
204  finish (new QPushButton (tr ("Finish"), this)),
205  cancel (new QPushButton (tr ("Cancel"), this))
206 {
207  QFont ft;
208  ft.setPointSize (20);
209  title->setFont (ft);
210 
211  message->setText
212  (tr ("<html><body>\n"
213  "<p>We hope you find Octave to be a useful tool.</p>\n"
214  "<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"
215  "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"
216  "</body></html>"));
217  message->setWordWrap (true);
218  message->setMinimumWidth (400);
219  message->setOpenExternalLinks (true);
220 
221  QVBoxLayout *message_layout = new QVBoxLayout;
222 
223  message_layout->addWidget (title);
224  message_layout->addWidget (message);
225 
226  QHBoxLayout *message_and_logo = new QHBoxLayout;
227 
228  message_and_logo->addLayout (message_layout);
229  message_and_logo->addStretch (10);
230  message_and_logo->addWidget (logo, 0, Qt::AlignTop);
231 
232  links->setText
233  (tr ("<html><head>\n"
234  "<style>\n"
235  "a:link { text-decoration: underline; color: #0000ff; }\n"
236  "</style>\n"
237  "<head/><body>\n"
238  "<p>For more information about Octave:</p>\n"
239  "<ul>\n"
240  "<li>Visit <a href=\"http://octave.org\">http://octave.org</a> (opens in external browser)</li>\n"
241  "<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"
242  "<li>Open the documentation browser of the Octave GUI with the help menu</li>\n"
243  "</ul>\n"
244  "</body></html>"));
245  links->setWordWrap (true);
246  links->setOpenExternalLinks (true);
247 
248  QHBoxLayout *button_bar = new QHBoxLayout;
249 
250  button_bar->addStretch (10);
251  button_bar->addWidget (previous);
252  button_bar->addWidget (finish);
253  button_bar->addWidget (cancel);
254 
255  QVBoxLayout *page_layout = new QVBoxLayout (this);
256  setLayout (page_layout);
257 
258  page_layout->addLayout (message_and_logo);
259  page_layout->addSpacing (20);
260  page_layout->addWidget (links);
261  page_layout->addStretch (10);
262  page_layout->addLayout (button_bar);
263 
264  finish->setDefault (true);
265  finish->setFocus ();
266 
267  connect (previous, SIGNAL (clicked ()), wizard, SLOT (previous_page ()));
268  connect (finish, SIGNAL (clicked ()), wizard, SLOT (accept ()));
269  connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
270 }
271 
272 
274  : QDialog (p), page_ctor_list (), page_list_iterator (),
275  current_page (initial_page::create (this)),
276  allow_web_connect_state (true)
277 {
281 
283 
284  setWindowTitle (tr ("Welcome to GNU Octave"));
285 
286  setEnabled (true);
287  resize (600, 480);
288  setMinimumSize (QSize (600, 480));
289 
290  show_page ();
291 
292 #ifdef __WIN32__
293  // HACK to forceshow of dialog if started minimized
294  ShowWindow((HWND)winId(), SW_SHOWNORMAL);
295 #endif
296 }
297 
298 void
300 {
301  allow_web_connect_state = state == Qt::Checked;
302 }
303 
304 void
306 {
307  delete current_page;
308  delete layout ();
309 
310  current_page = (*page_list_iterator) (this);
311 
312  QVBoxLayout *new_layout = new QVBoxLayout ();
313  setLayout (new_layout);
314 
315  new_layout->addWidget (current_page);
316 }
317 
318 void
320 {
322 
323  show_page ();
324 }
325 
326 void
328 {
330 
331  show_page ();
332 }
333 
334 void
336 {
337  // Create default settings file.
338 
340 
341  QSettings *settings = resource_manager::get_settings ();
342 
343  if (settings)
344  {
345  settings->setValue ("news/allow_web_connection",
347 
348  settings->sync ();
349  }
350 
351  QDialog::accept ();
352 }
void next_page(void)
QList< page_creator_fptr > page_ctor_list
QPushButton * cancel
static uint32_t state[624]
Definition: randmtzig.c:188
QWidget * current_page
static QString get_settings_file(void)
final_page(welcome_wizard *wizard)
QPushButton * finish
QLabel * title
void previous_page(void)
void message(const char *name, const char *fmt,...)
Definition: error.cc:380
static QWidget * create(welcome_wizard *wizard)
welcome_wizard(QWidget *parent=0)
static uint32_t * next
Definition: randmtzig.c:187
QLabel * title
static QLabel * make_octave_logo(QWidget *p=0, int height=100)
QPushButton * next
QList< page_creator_fptr >::iterator page_list_iterator
initial_page(welcome_wizard *wizard)
static QSettings * get_settings(void)
double arg(double x)
Definition: lo-mappers.h:37
QPushButton * previous
void handle_web_connect_option(int state)
QLabel * message
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)