Vidalia 0.2.15
|
00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 00007 ** including this file, may be copied, modified, propagated, or distributed 00008 ** except according to the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file VidaliaWindow.h 00013 ** \brief Common superclass for all Vidalia windows 00014 */ 00015 00016 #ifndef _VIDALIAWINDOW_H 00017 #define _VIDALIAWINDOW_H 00018 00019 #include "VSettings.h" 00020 00021 #include <QString> 00022 #include <QWidget> 00023 #include <QVariant> 00024 #include <QMainWindow> 00025 00026 00027 class VidaliaWindow : public QMainWindow 00028 { 00029 Q_OBJECT 00030 00031 public: 00032 /** Default constructor. */ 00033 VidaliaWindow(const QString &name, QWidget *parent = 0, 00034 Qt::WFlags flags = 0); 00035 /** Destructor. */ 00036 ~VidaliaWindow(); 00037 00038 /** Associates a shortcut key sequence with a slot. */ 00039 void setShortcut(const QString &shortcut, const char *slot); 00040 /** Saves the size and location of the window. */ 00041 void saveWindowState(); 00042 /** Restores the last size and location of the window. */ 00043 void restoreWindowState(); 00044 00045 /** Gets the saved value of a property associated with this window object. 00046 * If no value was saved, the default value is returned. */ 00047 QVariant getSetting(QString name, QVariant defaultValue); 00048 /** Saves a value associated with a setting name for this window object. */ 00049 void saveSetting(QString name, QVariant value); 00050 00051 protected: 00052 /** Reimplement the windows' changeEvent() method to check if the event 00053 * is a QEvent::LanguageChange event. If so, call retranslateUi(), which 00054 * subclasses of VidaliaWindow can reimplement to update their UI. */ 00055 virtual void changeEvent(QEvent *e); 00056 /** Called when the user wants to change the currently visible language. */ 00057 virtual void retranslateUi(); 00058 00059 public slots: 00060 /** Shows or hides this window. */ 00061 virtual void setVisible(bool visible); 00062 /** Show this window. This method really just exists for subclasses to 00063 * override, since QMainWindow::show() is non-virtual. */ 00064 virtual void showWindow() { QMainWindow::show(); } 00065 00066 signals: 00067 /** Emitted when a VidaliaWindow requests help information on the specified 00068 * <b>topic</b>. */ 00069 void helpRequested(const QString &topic); 00070 00071 private: 00072 QString _name; /**< Name associated with this window. */ 00073 VSettings* _settings; /**< Object used to store window properties */ 00074 }; 00075 00076 #endif 00077