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