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 2362 2008-02-29 04:30:11Z edmanm $ 00014 ** \brief Common superclass for all Vidalia windows 00015 */ 00016 00017 #ifndef _VIDALIAWINDOW_H 00018 #define _VIDALIAWINDOW_H 00019 00020 #include <QString> 00021 #include <QWidget> 00022 #include <QVariant> 00023 #include <QMainWindow> 00024 #include <vsettings.h> 00025 00026 00027 class VidaliaWindow : public QMainWindow 00028 { 00029 Q_OBJECT 00030 00031 public: 00032 /** Default constructor. */ 00033 VidaliaWindow(QString name, QWidget *parent = 0, Qt::WFlags flags = 0); 00034 /** Destructor. */ 00035 ~VidaliaWindow(); 00036 00037 /** Associates a shortcut key sequence with a slot. */ 00038 void setShortcut(QString shortcut, const char *slot); 00039 /** Saves the size and location of the window. */ 00040 void saveWindowState(); 00041 /** Restores the last size and location of the window. */ 00042 void restoreWindowState(); 00043 00044 /** Gets the saved value of a property associated with this window object. 00045 * If no value was saved, the default value is returned. */ 00046 QVariant getSetting(QString name, QVariant defaultValue); 00047 /** Saves a value associated with a setting name for this window object. */ 00048 void saveSetting(QString name, QVariant value); 00049 00050 public slots: 00051 /** Shows or hides this window. */ 00052 virtual void setVisible(bool visible); 00053 /** Show this window. This method really just exists for subclasses to 00054 * override, since QMainWindow::show() is non-virtual. */ 00055 virtual void showWindow() { QMainWindow::show(); } 00056 00057 signals: 00058 /** Emitted when a VidaliaWindow requests help information on the specified 00059 * <b>topic</b>. */ 00060 void helpRequested(const QString &topic); 00061 00062 private: 00063 QString _name; /**< Name associated with this window. */ 00064 VSettings* _settings; /**< Object used to store window properties */ 00065 }; 00066 00067 #endif 00068