GNU Octave  3.8.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 John W. Eaton
4 Copyright (C) 2011-2013 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 #include "welcome-wizard.h"
34 #include "resource-manager.h"
35 
36 static QLabel *
37 make_octave_logo (QWidget *p = 0, int height = 100)
38 {
39  QLabel *logo = new QLabel (p);
40  QPixmap logo_pixmap (":/actions/icons/logo.png");
41  logo->setPixmap (logo_pixmap.scaledToHeight (height));
42  return logo;
43 };
44 
45 
46 
48  : QWidget (wizard),
49  title (new QLabel (tr ("Welcome to Octave!"), this)),
50  message (new QLabel (this)),
51  logo (make_octave_logo (this)),
52  next (new QPushButton (tr ("Next"), this)),
53  cancel (new QPushButton (tr ("Cancel"), this))
54  {
55  QFont ft;
56  ft.setPointSize (20);
57  title->setFont (ft);
58 
59  message->setText
60  (tr ("<html><body>\n"
61  "<p>You seem to be using the Octave graphical interface for the first time on this computer.\n"
62  "Click 'Next' to create a configuration file and launch Octave.</p>\n"
63  "<p>The configuration file is stored in %1. If that file exists, you will not see this dialog when Octave starts.</p>\n"
64  "</body></html>").
66  message->setWordWrap (true);
67  message->setMinimumWidth (400);
68 
69  QVBoxLayout *message_layout = new QVBoxLayout;
70 
71  message_layout->addWidget (title);
72  message_layout->addWidget (message);
73 
74  QHBoxLayout *message_and_logo = new QHBoxLayout;
75 
76  message_and_logo->addLayout (message_layout);
77  message_and_logo->addStretch (10);
78  message_and_logo->addWidget (logo, 0, Qt::AlignTop);
79 
80  QHBoxLayout *button_bar = new QHBoxLayout;
81 
82  button_bar->addStretch (10);
83  button_bar->addWidget (next);
84  button_bar->addWidget (cancel);
85 
86  QVBoxLayout *page_layout = new QVBoxLayout (this);
87  setLayout (page_layout);
88 
89  page_layout->addLayout (message_and_logo);
90  page_layout->addStretch (10);
91  page_layout->addLayout (button_bar);
92 
93  next->setDefault (true);
94  next->setFocus ();
95 
96  connect (next, SIGNAL (clicked ()), wizard, SLOT (next_page ()));
97  connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
98  }
99 
100 
101 
103  : QWidget (wizard),
104  title (new QLabel (tr ("Community News"), this)),
105  message (new QLabel (this)),
106  checkbox (new QCheckBox (this)),
107  checkbox_message (new QLabel (this)),
108  logo (make_octave_logo (this)),
109  previous (new QPushButton (tr ("Previous"), this)),
110  next (new QPushButton (tr ("Next"), this)),
111  cancel (new QPushButton (tr ("Cancel"), this))
112  {
113  QFont ft;
114  ft.setPointSize (20);
115  title->setFont (ft);
116 
117  message->setText
118  (tr ("<html><body>\n"
119  "<p>When the Octave GUI starts, it will check the Octave web site for current news and information about the Octave community.\n"
120  "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"
121  "<p>You may also view the news by selecting the \"Community News\" item in the \"Help\" menu in the GUI, or by visiting\n"
122  "<a href=\"http://octave.org/community-news.html\">http://octave.org/community-news.html</a>.</p>\n"
123  "</body></html>"));
124  message->setWordWrap (true);
125  message->setMinimumWidth (400);
126  message->setOpenExternalLinks (true);
127 
128  QVBoxLayout *message_layout = new QVBoxLayout;
129 
130  message_layout->addWidget (title);
131  message_layout->addWidget (message);
132 
133  QHBoxLayout *message_and_logo = new QHBoxLayout;
134 
135  message_and_logo->addLayout (message_layout);
136  message_and_logo->addStretch (10);
137  message_and_logo->addWidget (logo, 0, Qt::AlignTop);
138 
139  QHBoxLayout *checkbox_layout = new QHBoxLayout;
140 
141  checkbox->setCheckState (Qt::Checked);
142 
143  checkbox_message->setText
144  (tr ("<html><head>\n"
145  "<style>\n"
146  "a:link { text-decoration: underline; color: #0000ff; }\n"
147  "</style>\n"
148  "<head/><body>\n"
149  "<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"
150  "</body></html>"));
151  checkbox_message->setWordWrap (true);
152  checkbox_message->setOpenExternalLinks (true);
153  checkbox_message->setMinimumWidth (500);
154 
155  checkbox_layout->addWidget (checkbox, 0, Qt::AlignTop);
156  checkbox_layout->addSpacing (20);
157  checkbox_layout->addWidget (checkbox_message, 0, Qt::AlignTop);
158  checkbox_layout->addStretch (10);
159 
160  QVBoxLayout *message_logo_and_checkbox = new QVBoxLayout;
161 
162  message_logo_and_checkbox->addLayout (message_and_logo);
163  message_logo_and_checkbox->addSpacing (20);
164  message_logo_and_checkbox->addLayout (checkbox_layout);
165 
166  QHBoxLayout *button_bar = new QHBoxLayout;
167 
168  button_bar->addStretch (10);
169  button_bar->addWidget (previous);
170  button_bar->addWidget (next);
171  button_bar->addWidget (cancel);
172 
173  QVBoxLayout *page_layout = new QVBoxLayout (this);
174  setLayout (page_layout);
175 
176  page_layout->addLayout (message_logo_and_checkbox);
177  page_layout->addStretch (10);
178  page_layout->addLayout (button_bar);
179 
180  next->setDefault (true);
181  next->setFocus ();
182 
183  connect (checkbox, SIGNAL (stateChanged (int)),
184  wizard, SLOT (handle_web_connect_option (int)));
185 
186  connect (previous, SIGNAL (clicked ()), wizard, SLOT (previous_page ()));
187  connect (next, SIGNAL (clicked ()), wizard, SLOT (next_page ()));
188  connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
189  }
190 
191 
193  : QWidget (wizard),
194  title (new QLabel (tr ("Enjoy!"), this)),
195  message (new QLabel (this)),
196  logo (make_octave_logo (this)),
197  links (new QLabel (this)),
198  previous (new QPushButton (tr ("Previous"), this)),
199  finish (new QPushButton (tr ("Finish"), this)),
200  cancel (new QPushButton (tr ("Cancel"), this))
201  {
202  QFont ft;
203  ft.setPointSize (20);
204  title->setFont (ft);
205 
206  message->setText
207  (tr ("<html><body>\n"
208  "<p>We hope you find Octave to be a useful tool.</p>\n"
209  "<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 commnity-based support channels.\n"
210  "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"
211  "</body></html>"));
212  message->setWordWrap (true);
213  message->setMinimumWidth (400);
214  message->setOpenExternalLinks (true);
215 
216  QVBoxLayout *message_layout = new QVBoxLayout;
217 
218  message_layout->addWidget (title);
219  message_layout->addWidget (message);
220 
221  QHBoxLayout *message_and_logo = new QHBoxLayout;
222 
223  message_and_logo->addLayout (message_layout);
224  message_and_logo->addStretch (10);
225  message_and_logo->addWidget (logo, 0, Qt::AlignTop);
226 
227  links->setText
228  (tr ("<html><head>\n"
229  "<style>\n"
230  "a:link { text-decoration: underline; color: #0000ff; }\n"
231  "</style>\n"
232  "<head/><body>\n"
233  "<p>For more information about Octave:</p>\n"
234  "<ul>\n"
235  "<li>Visit <a href=\"http://octave.org\">http://octave.org</a> (opens in external browser)</li>\n"
236  "<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"
237  "<li>Open the documentation browser of the Octave GUI with the help menu</li>\n"
238  "</ul>\n"
239  "</body></html>"));
240  links->setWordWrap (true);
241  links->setOpenExternalLinks (true);
242 
243  QHBoxLayout *button_bar = new QHBoxLayout;
244 
245  button_bar->addStretch (10);
246  button_bar->addWidget (previous);
247  button_bar->addWidget (finish);
248  button_bar->addWidget (cancel);
249 
250  QVBoxLayout *page_layout = new QVBoxLayout (this);
251  setLayout (page_layout);
252 
253  page_layout->addLayout (message_and_logo);
254  page_layout->addSpacing (20);
255  page_layout->addWidget (links);
256  page_layout->addStretch (10);
257  page_layout->addLayout (button_bar);
258 
259  finish->setDefault (true);
260  finish->setFocus ();
261 
262  connect (previous, SIGNAL (clicked ()), wizard, SLOT (previous_page ()));
263  connect (finish, SIGNAL (clicked ()), wizard, SLOT (accept ()));
264  connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ()));
265  }
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 
288 void
290 {
291  allow_web_connect_state = state == Qt::Checked;
292 }
293 
294 void
296 {
297  delete current_page;
298  delete layout ();
299 
300  current_page = (*page_list_iterator) (this);
301 
302  QVBoxLayout *new_layout = new QVBoxLayout ();
303  setLayout (new_layout);
304 
305  new_layout->addWidget (current_page);
306 }
307 
308 void
310 {
312 
313  show_page ();
314 }
315 
316 void
318 {
320 
321  show_page ();
322 }
323 
324 void
326 {
327  // Create default settings file.
328 
330 
331  QSettings *settings = resource_manager::get_settings ();
332 
333  if (settings)
334  {
335  settings->setValue ("news/allow_web_connection",
337 
338  settings->sync ();
339  }
340 
341  QDialog::accept ();
342 }