[tor-commits] [vidalia/alpha] Add missing files

chiiph at torproject.org chiiph at torproject.org
Mon Apr 2 16:55:16 UTC 2012


commit d82d738850715a3b58e6014c037effd20f7a7e1a
Author: Tomás Touceda <chiiph at torproject.org>
Date:   Mon Apr 2 13:55:00 2012 -0300

    Add missing files
---
 src/vidalia/FirstRunWizard.cpp |  151 ++++++++++++++++++++++++++++++++++++++++
 src/vidalia/FirstRunWizard.h   |   66 +++++++++++++++++
 2 files changed, 217 insertions(+), 0 deletions(-)

diff --git a/src/vidalia/FirstRunWizard.cpp b/src/vidalia/FirstRunWizard.cpp
new file mode 100644
index 0000000..5e59d7a
--- /dev/null
+++ b/src/vidalia/FirstRunWizard.cpp
@@ -0,0 +1,151 @@
+/*
+**  This file is part of Vidalia, and is subject to the license terms in the
+**  LICENSE file, found in the top level directory of this distribution. If you
+**  did not receive the LICENSE file with this file, you may obtain it from the
+**  Vidalia source package distributed by the Vidalia Project at
+**  http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
+**  including this file, may be copied, modified, propagated, or distributed
+**  except according to the terms described in the LICENSE file.
+*/
+
+/*
+** \file FirstRunWizard.cpp
+** \brief Wizard for the first time Vidalia is executed under certain circumstances
+*/
+
+#include "FirstRunWizard.h"
+#include "MainWindow.h"
+#include "AdvancedPage.h"
+#include "NetworkPage.h"
+#include "VMessageBox.h"
+
+#include <QtGui>
+
+FirstRunWizard::FirstRunWizard(QWidget *parent, bool withPanic, bool withNetwork)
+  : _withPanic(withPanic), _withNetwork(withNetwork), QWizard(parent),
+    _panicPage(0), _ap(0), _networkPage(0), _np(0)
+{
+  createPages();
+}
+
+FirstRunWizard::~FirstRunWizard()
+{
+  if(_ap) delete _ap;
+  if(_np) delete _np;
+}
+
+void
+FirstRunWizard::handleNext()
+{
+  QString errmsg;
+
+  switch(currentId()) {
+  case IntroPageID:
+  case PanicPageID:
+    next();
+    break;
+  case NetworkPageID:
+    if(_ap->save(errmsg)) {
+      next();
+    } else {
+      VMessageBox::warning(0, tr("There was a problem saving your Panic settings"),
+                           tr("Error: %1").arg(errmsg),
+                           VMessageBox::Ok|VMessageBox::Default);
+    }
+  case DonePageID:
+    if(_np->save(errmsg) and _np->apply(errmsg)) {
+      next();
+    } else {
+      back();
+      VMessageBox::warning(0, tr("There was a problem saving your network settings"),
+                           tr("Error: %1").arg(errmsg),
+                           VMessageBox::Ok|VMessageBox::Default);
+    }
+  }
+}
+
+void
+FirstRunWizard::createPages()
+{
+  QPushButton *bt = new QPushButton("Continue");
+  setButton(QWizard::NextButton, bt);
+  disconnect(bt, 0, 0, 0);
+  connect(bt, SIGNAL(clicked()),
+          this, SLOT(handleNext()));
+
+  _introPage = new QWizardPage;
+  _introPage->setTitle(tr("Welcome to Vidalia"));
+
+  QLabel *label = new QLabel(tr("Welcome to Vidalia, the Tor Controller. "
+                                "This wizard will guide you through the first "
+                                "run configuration, please <b>read the directions "
+                                "carefully.</b>"));
+  label->setWordWrap(true);
+
+  QVBoxLayout *layout = new QVBoxLayout;
+  layout->addWidget(label);
+  _introPage->setLayout(layout);
+
+  setPage(IntroPageID, _introPage);
+
+  _panicPage = new QWizardPage;
+  _panicPage->setTitle(tr("Panic! configuration"));
+  label = new QLabel(tr("You have the Panic! button enabled. This "
+                        "means that you will have a button on the "
+                        "main toolbar that will allow you to remove "
+                        "Vidalia and all its components quickly.\n"
+                        "<b>WARNING:</b> This will also remove your "
+                        "bookmarks and everything you save inside "
+                        "the configured path.\n\n"
+                        "If you would like to disable this feature, "
+                        "please uncheck where it says \"Enable panic\" and "
+                        "click \"%1\"").arg(buttonText(QWizard::NextButton)));
+  label->setWordWrap(true);
+
+  _ap = new AdvancedPage();
+  _ap->hideGroup(AdvancedPage::Control);
+  _ap->hideGroup(AdvancedPage::ConfigurationFile);
+  _ap->hideGroup(AdvancedPage::DataDirectory);
+  _ap->load();
+
+  layout = new QVBoxLayout;
+  layout->addWidget(label);
+  layout->addWidget(_ap);
+  _panicPage->setLayout(layout);
+
+  if(_withPanic)
+    setPage(PanicPageID, _panicPage);
+
+  _networkPage = new QWizardPage;
+  _networkPage->setTitle(tr("Network configuration"));
+  label = new QLabel(tr("You should configure your network now. Please "
+                        "provide the bridges to use or uncheck the option.\n\n"
+                        "If you would like to change these settings, "
+                        "please edit the values and click \"%1\"")
+                     .arg(buttonText(QWizard::NextButton)));
+  label->setWordWrap(true);
+
+  _np = new NetworkPage();
+  _np->load();
+
+  layout = new QVBoxLayout;
+  layout->addWidget(label);
+  layout->addWidget(_np);
+  _networkPage->setLayout(layout);
+
+  if(_withNetwork)
+    setPage(NetworkPageID, _networkPage);
+
+  _donePage = new QWizardPage;
+  _donePage->setTitle(tr("That's it!"));
+
+  label = new QLabel(tr("We hope you enjoy using Tor! Consider becoming a Relay, "
+                                "read more here: https://torproject.org/relay"));
+  label->setWordWrap(true);
+
+  layout = new QVBoxLayout;
+  layout->addWidget(label);
+  _donePage->setLayout(layout);
+
+  setPage(DonePageID, _donePage);
+}
diff --git a/src/vidalia/FirstRunWizard.h b/src/vidalia/FirstRunWizard.h
new file mode 100644
index 0000000..437fff8
--- /dev/null
+++ b/src/vidalia/FirstRunWizard.h
@@ -0,0 +1,66 @@
+/*
+**  This file is part of Vidalia, and is subject to the license terms in the
+**  LICENSE file, found in the top level directory of this distribution. If you
+**  did not receive the LICENSE file with this file, you may obtain it from the
+**  Vidalia source package distributed by the Vidalia Project at
+**  http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
+**  including this file, may be copied, modified, propagated, or distributed
+**  except according to the terms described in the LICENSE file.
+*/
+
+/*
+** \file FirstRunWizard.cpp
+** \brief Wizard for the first time Vidalia is executed under certain circumstances
+*/
+
+#ifndef FIRSTRUNWIZARD_H
+#define FIRSTRUNWIZARD_H
+
+class QWizardPage;
+class MainWindow;
+class AdvancedPage;
+class NetworkPage;
+
+#include <QWizard>
+
+class FirstRunWizard : public QWizard
+{
+  Q_OBJECT
+
+ public:
+  /** Default constructor */
+  FirstRunWizard(QWidget *parent = 0,
+                 bool withPanic = false,
+                 bool withNetwork = false);
+  /** Default destructor */
+  virtual ~FirstRunWizard();
+
+ public slots:
+  /** Slot that handles the transition between pages */
+  void handleNext();
+
+ private:
+  /** Ids for the pages */
+  enum IDs {
+    IntroPageID = 0,
+    PanicPageID,
+    NetworkPageID,
+    DonePageID
+  };
+
+  /** Wizard pages */
+  QWizardPage *_introPage, *_panicPage;
+  QWizardPage *_networkPage, *_donePage;
+  QPushButton *_btnNext;
+  /** Boolean values that identify the pages to display */
+  bool _withPanic, _withNetwork;
+
+  /** Configuration pages that will be used in the wizard */
+  AdvancedPage *_ap;
+  NetworkPage *_np;
+
+  /** Called at the beginning. It creates the whole wizard */
+  void createPages();
+};
+
+#endif



More information about the tor-commits mailing list