00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file vidaliawindow.h 00024 * \version $Id: vidaliawindow.h 1238 2006-09-25 17:50:57Z edmanm $ 00025 * \brief Common superclass for all Vidalia windows 00026 */ 00027 00028 #ifndef _VIDALIAWINDOW_H 00029 #define _VIDALIAWINDOW_H 00030 00031 #include <QString> 00032 #include <QWidget> 00033 #include <QVariant> 00034 #include <QMainWindow> 00035 #include <config/vidaliasettings.h> 00036 00037 00038 class VidaliaWindow : public QMainWindow 00039 { 00040 Q_OBJECT 00041 00042 public: 00043 /** Default constructor. */ 00044 VidaliaWindow(QString name, QWidget *parent = 0, Qt::WFlags flags = 0); 00045 /** Destructor. */ 00046 ~VidaliaWindow(); 00047 00048 /** Associates a shortcut key sequence with a slot. */ 00049 void setShortcut(QString shortcut, const char *slot); 00050 /** Saves the size and location of the window. */ 00051 void saveWindowState(); 00052 /** Restores the last size and location of the window. */ 00053 void restoreWindowState(); 00054 00055 /** Gets the saved value of a property associated with this window object. 00056 * If no value was saved, the default value is returned. */ 00057 QVariant getSetting(QString name, QVariant defaultValue); 00058 /** Saves a value associated with a setting name for this window object. */ 00059 void saveSetting(QString name, QVariant value); 00060 00061 public slots: 00062 /** Overloaded QWidget::close() method. Saves the window state and closes 00063 * the window. Returns true if the window was closed. */ 00064 bool close(); 00065 /** Overloaded QWidget::show(). */ 00066 void show(); 00067 00068 private: 00069 QString _name; /**< Name associated with this window. */ 00070 VidaliaSettings* _settings; /**< Object used to store window properties */ 00071 bool _previouslyShown; /**< True if show() has been called for this window. */ 00072 }; 00073 00074 #endif 00075