Vidalia  0.3.1
VidaliaWindow.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 VidaliaWindow.h
13 ** \brief Common superclass for all Vidalia windows
14 */
15 
16 #ifndef _VIDALIAWINDOW_H
17 #define _VIDALIAWINDOW_H
18 
19 #include "VSettings.h"
20 
21 #include <QString>
22 #include <QWidget>
23 #include <QVariant>
24 #include <QMainWindow>
25 
26 
27 class VidaliaWindow : public QMainWindow
28 {
29  Q_OBJECT
30 
31 public:
32  /** Default constructor. */
33  VidaliaWindow(const QString &name, QWidget *parent = 0,
34  Qt::WFlags flags = 0);
35  /** Destructor. */
37 
38  /** Associates a shortcut key sequence with a slot. */
39  void setShortcut(const QString &shortcut, const char *slot);
40  /** Saves the size and location of the window. */
41  void saveWindowState();
42  /** Restores the last size and location of the window. */
43  void restoreWindowState();
44 
45  /** Gets the saved value of a property associated with this window object.
46  * If no value was saved, the default value is returned. */
47  QVariant getSetting(QString name, QVariant defaultValue);
48  /** Saves a value associated with a setting name for this window object. */
49  void saveSetting(QString name, QVariant value);
50 
51 protected:
52  /** Reimplement the windows' changeEvent() method to check if the event
53  * is a QEvent::LanguageChange event. If so, call retranslateUi(), which
54  * subclasses of VidaliaWindow can reimplement to update their UI. */
55  virtual void changeEvent(QEvent *e);
56  /** Called when the user wants to change the currently visible language. */
57  virtual void retranslateUi();
58 
59 public slots:
60  /** Shows or hides this window. */
61  virtual void setVisible(bool visible);
62  /** Show this window. This method really just exists for subclasses to
63  * override, since QMainWindow::show() is non-virtual. */
64  virtual void showWindow() { QMainWindow::show(); }
65 
66 signals:
67  /** Emitted when a VidaliaWindow requests help information on the specified
68  * <b>topic</b>. */
69  void helpRequested(const QString &topic);
70 
71 private:
72  QString _name; /**< Name associated with this window. */
73  VSettings* _settings; /**< Object used to store window properties */
74 };
75 
76 #endif
77 
VidaliaWindow
Definition: VidaliaWindow.h:27
VidaliaWindow::_name
QString _name
Definition: VidaliaWindow.h:72
VidaliaWindow::saveWindowState
void saveWindowState()
Definition: VidaliaWindow.cpp:52
QVariant
stop errmsg QVariant
Definition: TorControlPrototype.cpp:180
VidaliaWindow::changeEvent
virtual void changeEvent(QEvent *e)
Definition: VidaliaWindow.cpp:133
VidaliaWindow::setVisible
virtual void setVisible(bool visible)
Definition: VidaliaWindow.cpp:110
VidaliaWindow::retranslateUi
virtual void retranslateUi()
Definition: VidaliaWindow.cpp:146
VSettings
Definition: VSettings.h:23
VSettings.h
VidaliaWindow::getSetting
QVariant getSetting(QString name, QVariant defaultValue)
Definition: VidaliaWindow.cpp:93
VidaliaWindow::~VidaliaWindow
~VidaliaWindow()
Definition: VidaliaWindow.cpp:37
VidaliaWindow::VidaliaWindow
VidaliaWindow(const QString &name, QWidget *parent=0, Qt::WFlags flags=0)
Definition: VidaliaWindow.cpp:28
VidaliaWindow::helpRequested
void helpRequested(const QString &topic)
VidaliaWindow::showWindow
virtual void showWindow()
Definition: VidaliaWindow.h:64
VidaliaWindow::_settings
VSettings * _settings
Definition: VidaliaWindow.h:73
VidaliaWindow::restoreWindowState
void restoreWindowState()
Definition: VidaliaWindow.cpp:64
VidaliaWindow::saveSetting
void saveSetting(QString name, QVariant value)
Definition: VidaliaWindow.cpp:100
VidaliaWindow::setShortcut
void setShortcut(const QString &shortcut, const char *slot)
Definition: VidaliaWindow.cpp:45