Vidalia  0.3.1
ConfigPage.h
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file ConfigPage.h
13 ** \brief Pure-virtual class for a configuration page
14 */
15 
16 #ifndef _CONFIGPAGE_H
17 #define _CONFIGPAGE_H
18 
19 #include <QWidget>
20 
21 
22 class ConfigPage : public QWidget
23 {
24  Q_OBJECT
25 
26 public:
27  /** Default Constructor */
28  ConfigPage(QWidget *parent = 0, const QString title = QString())
29  : QWidget(parent), _title(title) {}
30 
31  /** Returns the title of this configuration page. */
32  QString title() const { return _title; }
33 
34  /** Pure virtual method. Subclassed pages load their config settings here. */
35  virtual void load() = 0;
36  /** Pure virtual method. Subclassed pages save their config settings here
37  * and return true if everything was saved successfully. */
38  virtual bool save(QString &errmsg) = 0;
39 
40  /** Subclassed pages can overload this method to return true if they
41  * contain settings that have been modified since they were last applied to
42  * Tor. The default implementation always returns false. */
43  virtual bool changedSinceLastApply() {
44  return false;
45  }
46  /** Subclassed pages can overload this method to apply any settings to
47  * Tor that have been modified since they were last applied (e.g., the
48  * changes were made while Tor was not running). Returns true if the changes
49  * were applied successfully. */
50  virtual bool apply(QString &errmsg) {
51  Q_UNUSED(errmsg);
52  return true;
53  }
54  /** Subclassed pages can overload this method to revert any cancelled
55  * settings. */
56  virtual void revert() {}
57 
58  virtual void retranslateUi() {}
59 
60 signals:
61  /** Signal emitted when a ConfigPage requests help information on a given
62  * <b>topic</b>. */
63  void helpRequested(const QString &topic);
64 
65 private:
66  QString _title; /**< Title of this configuration page. */
67 };
68 
69 #endif
70 
virtual void load()=0
virtual void revert()
Definition: ConfigPage.h:56
virtual bool save(QString &errmsg)=0
virtual bool apply(QString &errmsg)
Definition: ConfigPage.h:50
ConfigPage(QWidget *parent=0, const QString title=QString())
Definition: ConfigPage.h:28
void helpRequested(const QString &topic)
QString _title
Definition: ConfigPage.h:66
virtual bool changedSinceLastApply()
Definition: ConfigPage.h:43
QString title() const
Definition: ConfigPage.h:32
virtual void retranslateUi()
Definition: ConfigPage.h:58