# HG changeset patch # User John W. Eaton # Date 1384574265 18000 # Node ID f87a7e16171095476b741ac72f57f2d56e65daa8 # Parent 8c23f844bd30f9fb16bee30d1ce1054d6ddc71d1 * welcome-wizard.h, welcome-wizard.cc: Rewrite. diff -r 8c23f844bd30 -r f87a7e161710 libgui/src/welcome-wizard.cc --- a/libgui/src/welcome-wizard.cc Fri Nov 15 22:21:05 2013 -0500 +++ b/libgui/src/welcome-wizard.cc Fri Nov 15 22:57:45 2013 -0500 @@ -26,105 +26,342 @@ #endif #include +#include +#include +#include #include #include -#include -#include #include "welcome-wizard.h" #include "resource-manager.h" +static QLabel * +make_octave_logo (QWidget *p = 0, int height = 100) +{ + QLabel *logo = new QLabel (p); + QPixmap logo_pixmap (":/actions/icons/logo.png"); + logo->setPixmap (logo_pixmap.scaledToHeight (height)); + return logo; +}; + +class initial_page : public QWidget +{ +public: + + initial_page (welcome_wizard *wizard) + : QWidget (wizard), + title (new QLabel (tr ("Welcome to Octave!"), this)), + message (new QLabel (this)), + logo (make_octave_logo (this)), + next (new QPushButton (tr ("Next"), this)), + cancel (new QPushButton (tr ("Cancel"), this)) + { + QFont ft; + ft.setPointSize (20); + title->setFont (ft); + + message->setText + (tr ("\n" + "

You seem to be using the Octave graphical interface for the first time on this computer.\n" + "Click 'Next' to create a configuration file and launch Octave.

\n" + "

The configuration file is stored in %1. If that file exists, you will not see this dialog when Octave starts.

\n" + ""). + arg (resource_manager::get_settings_file ())); + message->setWordWrap (true); + message->setMinimumWidth (400); + + QVBoxLayout *message_layout = new QVBoxLayout; + + message_layout->addWidget (title); + message_layout->addWidget (message); + + QHBoxLayout *message_and_logo = new QHBoxLayout; + + message_and_logo->addLayout (message_layout); + message_and_logo->addStretch (10); + message_and_logo->addWidget (logo, 0, Qt::AlignTop); + + QHBoxLayout *button_bar = new QHBoxLayout; + + button_bar->addStretch (10); + button_bar->addWidget (next); + button_bar->addWidget (cancel); + + QVBoxLayout *page_layout = new QVBoxLayout (this); + setLayout (page_layout); + + page_layout->addLayout (message_and_logo); + page_layout->addStretch (10); + page_layout->addLayout (button_bar); + + next->setDefault (true); + next->setFocus (); + + connect (next, SIGNAL (clicked ()), wizard, SLOT (next_page ())); + connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ())); + } + + ~initial_page (void) { } + + static QWidget * + create (welcome_wizard *wizard) { return new initial_page (wizard); } + +private: + + QLabel *title; + QLabel *message; + QLabel *logo; + QPushButton *next; + QPushButton *cancel; +}; + +class setup_community_news : public QWidget +{ +public: + + setup_community_news (welcome_wizard *wizard) + : QWidget (wizard), + title (new QLabel (tr ("Community News"), this)), + message (new QLabel (this)), + checkbox (new QCheckBox (this)), + checkbox_message (new QLabel (this)), + logo (make_octave_logo (this)), + previous (new QPushButton (tr ("Previous"), this)), + next (new QPushButton (tr ("Next"), this)), + cancel (new QPushButton (tr ("Cancel"), this)) + { + QFont ft; + ft.setPointSize (20); + title->setFont (ft); + + message->setText + (tr ("\n" + "

When the Octave GUI starts, it will check the Octave web site for current news and information about the Octave community.\n" + "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.

\n" + "

You may also view the news by selecting the \"Community News\" item in the \"Help\" menu in the GUI, or by visiting\n" + "http://octave.org/community-news.html.

\n" + "")); + message->setWordWrap (true); + message->setMinimumWidth (400); + message->setOpenExternalLinks (true); + + QVBoxLayout *message_layout = new QVBoxLayout; + + message_layout->addWidget (title); + message_layout->addWidget (message); + + QHBoxLayout *message_and_logo = new QHBoxLayout; + + message_and_logo->addLayout (message_layout); + message_and_logo->addStretch (10); + message_and_logo->addWidget (logo, 0, Qt::AlignTop); + + QHBoxLayout *checkbox_layout = new QHBoxLayout; + + checkbox->setCheckState (Qt::Checked); + + checkbox_message->setText + (tr ("\n" + "\n" + "\n" + "

Allow Octave to connect to the Octave web site when it starts to display current news and information about the Octave community.

\n" + "")); + checkbox_message->setWordWrap (true); + checkbox_message->setOpenExternalLinks (true); + checkbox_message->setMinimumWidth (500); + + checkbox_layout->addWidget (checkbox, 0, Qt::AlignTop); + checkbox_layout->addSpacing (20); + checkbox_layout->addWidget (checkbox_message, 0, Qt::AlignTop); + checkbox_layout->addStretch (10); + + QVBoxLayout *message_logo_and_checkbox = new QVBoxLayout; + + message_logo_and_checkbox->addLayout (message_and_logo); + message_logo_and_checkbox->addSpacing (20); + message_logo_and_checkbox->addLayout (checkbox_layout); + + QHBoxLayout *button_bar = new QHBoxLayout; + + button_bar->addStretch (10); + button_bar->addWidget (previous); + button_bar->addWidget (next); + button_bar->addWidget (cancel); + + QVBoxLayout *page_layout = new QVBoxLayout (this); + setLayout (page_layout); + + page_layout->addLayout (message_logo_and_checkbox); + page_layout->addStretch (10); + page_layout->addLayout (button_bar); + + next->setDefault (true); + next->setFocus (); + + connect (previous, SIGNAL (clicked ()), wizard, SLOT (previous_page ())); + connect (next, SIGNAL (clicked ()), wizard, SLOT (next_page ())); + connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ())); + } + + ~setup_community_news (void) { } + + static QWidget * + create (welcome_wizard *wizard) { return new setup_community_news (wizard); } + +private: + + QLabel *title; + QLabel *message; + QCheckBox *checkbox; + QLabel *checkbox_message; + QLabel *logo; + QPushButton *previous; + QPushButton *next; + QPushButton *cancel; +}; + +class final_page : public QWidget +{ +public: + + final_page (welcome_wizard *wizard) + : QWidget (wizard), + title (new QLabel (tr ("Enjoy!"), this)), + message (new QLabel (this)), + logo (make_octave_logo (this)), + links (new QLabel (this)), + previous (new QPushButton (tr ("Previous"), this)), + finish (new QPushButton (tr ("Finish"), this)), + cancel (new QPushButton (tr ("Cancel"), this)) + { + QFont ft; + ft.setPointSize (20); + title->setFont (ft); + + message->setText + (tr ("\n" + "

We hope you find Octave to be a useful tool.

\n" + "

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" + "You can find more information about each of these by visiting http://octave.org/support.html (opens in external browser).

\n" + "")); + message->setWordWrap (true); + message->setMinimumWidth (400); + message->setOpenExternalLinks (true); + + QVBoxLayout *message_layout = new QVBoxLayout; + + message_layout->addWidget (title); + message_layout->addWidget (message); + + QHBoxLayout *message_and_logo = new QHBoxLayout; + + message_and_logo->addLayout (message_layout); + message_and_logo->addStretch (10); + message_and_logo->addWidget (logo, 0, Qt::AlignTop); + + links->setText + (tr ("\n" + "\n" + "\n" + "

For more information about Octave:

\n" + "
    \n" + "
  • Visit http://octave.org (opens in external browser)
  • \n" + "
  • Get the documentation online as html- or pdf-document (opens in external browser)
  • \n" + "
  • Open the documentation browser of the Octave GUI with the help menu
  • \n" + "
\n" + "")); + links->setWordWrap (true); + links->setOpenExternalLinks (true); + + QHBoxLayout *button_bar = new QHBoxLayout; + + button_bar->addStretch (10); + button_bar->addWidget (previous); + button_bar->addWidget (finish); + button_bar->addWidget (cancel); + + QVBoxLayout *page_layout = new QVBoxLayout (this); + setLayout (page_layout); + + page_layout->addLayout (message_and_logo); + page_layout->addSpacing (20); + page_layout->addWidget (links); + page_layout->addStretch (10); + page_layout->addLayout (button_bar); + + finish->setDefault (true); + finish->setFocus (); + + connect (previous, SIGNAL (clicked ()), wizard, SLOT (previous_page ())); + connect (finish, SIGNAL (clicked ()), wizard, SLOT (accept ())); + connect (cancel, SIGNAL (clicked ()), wizard, SLOT (reject ())); + } + + ~final_page (void) { } + + static QWidget * + create (welcome_wizard *wizard) { return new final_page (wizard); } + +private: + + QLabel *title; + QLabel *message; + QLabel *logo; + QLabel *links; + QPushButton *previous; + QPushButton *finish; + QPushButton *cancel; +}; + welcome_wizard::welcome_wizard (QWidget *p) - : QDialog (p) + : QDialog (p), page_ctor_list (), page_list_iterator (), + current_page (initial_page::create (this)) { + page_ctor_list.push_back (initial_page::create); + page_ctor_list.push_back (setup_community_news::create); + page_ctor_list.push_back (final_page::create); + + page_list_iterator = page_ctor_list.begin (); + setWindowTitle (tr ("Welcome to GNU Octave")); setEnabled (true); resize (600, 480); setMinimumSize (QSize (600, 480)); - - QVBoxLayout *page_layout = new QVBoxLayout (this); - setLayout (page_layout); - - QHBoxLayout *message_and_logo = new QHBoxLayout; - - QVBoxLayout *message = new QVBoxLayout; - - QLabel *title = new QLabel (tr ("Welcome to Octave!")); - QFont ft; - ft.setPointSize (20); - title->setFont (ft); - - QLabel *msg_1 = new QLabel ( - tr ("You seem to be using the Octave graphical interface for the first time on this computer. Click 'Finish' to write a configuration file and launch Octave.")); - msg_1->setWordWrap (true); + show_page (); +} - QString msg_2_text = QString (tr ("The configuration file is stored in %1. " - "If that file exists, you will not see " - "this dialog again when Octave starts."). - arg (resource_manager::get_settings_file ())); - QLabel *msg_2 = new QLabel (msg_2_text); - msg_2->setWordWrap (true); - - message->addWidget (title); - message->addWidget (msg_1); - message->addWidget (msg_2); +void +welcome_wizard::show_page (void) +{ + delete current_page; + delete layout (); - QSpacerItem *logo_filler = new QSpacerItem (40, 20, QSizePolicy::Expanding, - QSizePolicy::Minimum); + current_page = (*page_list_iterator) (this); - QLabel *logo = new QLabel; - QPixmap logo_pixmap (":/actions/icons/logo.png"); - logo->setPixmap (logo_pixmap.scaledToHeight (150)); - - message_and_logo->addLayout (message); - message_and_logo->addItem (logo_filler); - message_and_logo->addWidget (logo); + QVBoxLayout *new_layout = new QVBoxLayout (); + setLayout (new_layout); - QLabel *links = new QLabel - (tr ("\n" - "\n" - "\n" - "

For more information about Octave:

\n" - "
    \n" - "
  • Visit http://octave.org
  • \n" - "
  • Get the documentation online in html or pdf format
  • \n" - "
  • Open the documentation browser from the help menu
  • \n" - "
\n" - ""), - this); - links->setWordWrap (true); - links->setOpenExternalLinks (true); + new_layout->addWidget (current_page); +} - QSpacerItem *hfill = new QSpacerItem (40, 20, QSizePolicy::Expanding, - QSizePolicy::Minimum); - - QPushButton *finish_button = new QPushButton; - finish_button->setText (tr ("Finish")); +void +welcome_wizard::previous_page (void) +{ + --page_list_iterator; - QPushButton *cancel_button = new QPushButton; - cancel_button->setText (tr ("Cancel")); - - QSpacerItem *vspace = new QSpacerItem (20, 40, QSizePolicy::Minimum); - - QHBoxLayout *button_bar = new QHBoxLayout; - - button_bar->addItem (hfill); - button_bar->addWidget (finish_button); - button_bar->addWidget (cancel_button); + show_page (); +} - QSpacerItem *vfill = new QSpacerItem (20, 40, QSizePolicy::Minimum, - QSizePolicy::Expanding); +void +welcome_wizard::next_page (void) +{ + ++page_list_iterator; - page_layout->addLayout (message_and_logo); - page_layout->addWidget (links); - page_layout->addItem (vspace); - page_layout->addLayout (button_bar); - page_layout->addItem (vfill); - - connect (finish_button, SIGNAL (clicked ()), this, SLOT (accept ())); - connect (cancel_button, SIGNAL (clicked ()), this, SLOT (reject ())); + show_page (); } diff -r 8c23f844bd30 -r f87a7e161710 libgui/src/welcome-wizard.h --- a/libgui/src/welcome-wizard.h Fri Nov 15 22:21:05 2013 -0500 +++ b/libgui/src/welcome-wizard.h Fri Nov 15 22:57:45 2013 -0500 @@ -32,9 +32,23 @@ public: + typedef QWidget *(*page_creator_fptr) (welcome_wizard *wizard); + welcome_wizard (QWidget *parent = 0); ~welcome_wizard (void) { } + +private: + + QList page_ctor_list; + QList::iterator page_list_iterator; + QWidget *current_page; + +private slots: + + void show_page (void); + void previous_page (void); + void next_page (void); }; #endif // WELCOMEWIZARD_H