Vidalia 0.3.1
VidaliaTab.cpp
Go to the documentation of this file.
1#include "VidaliaTab.h"
2#include "Vidalia.h"
3
4VidaliaTab::VidaliaTab(const QString &title, const QString &name, QWidget *parent)
5 : QWidget(parent), _title(title)
6{
7 _settings = NULL;
8 if(!name.isEmpty())
9 _settings = new VSettings(name);
10}
11
13{
14 if(_settings)
15 delete _settings;
16}
17
18/** Gets the saved value of a property associated with this window object.
19 * If no value was saved, the default value is returned. */
21VidaliaTab::getSetting(QString setting, QVariant defaultValue)
22{
23 return _settings->value(setting, defaultValue);
24}
25
26/** Saves a value associated with a property name for this window object. */
27void
29{
30 _settings->setValue(prop, value);
31}
32
33/** Associates a shortcut key sequence with a slot. */
34void
35VidaliaTab::setShortcut(const QString &shortcut, const char *slot)
36{
37 vApp->createShortcut(QKeySequence(shortcut), this, this, slot);
38}
39
40/** Reimplement the windows' changeEvent() method to check if the event
41 * is a QEvent::LanguageChange event. If so, call retranslateUi(), which
42 * subclasses of VidaliaWindow can reimplement to update their UI. */
43void
45{
46 if (e->type() == QEvent::LanguageChange) {
48 e->accept();
49 return;
50 }
51 QWidget::changeEvent(e);
52}
53
54/** Called when the user wants to change the currently visible language.
55 * Subclasses can reimplement this to update their UI. */
56void
58{
59 /* The default retranslateUi() implementation does nothing */
60}
61
62void
64{
65 _onTop = top;
66}
67
68void
69VidaliaTab::closeEvent(QCloseEvent *event)
70{
71 event->ignore();
72 emit closeTab();
73}
74
stop errmsg QVariant
#define vApp
Definition: Vidalia.h:37
virtual void setValue(const QString &key, const QVariant &val)
Definition: VSettings.cpp:61
virtual QVariant value(const QString &key, const QVariant &defaultVal=QVariant()) const
Definition: VSettings.cpp:53
void closeTab()
QVariant getSetting(QString name, QVariant defaultValue)
Definition: VidaliaTab.cpp:21
VidaliaTab(const QString &title, const QString &name="", QWidget *parent=0)
Definition: VidaliaTab.cpp:4
void saveSetting(QString name, QVariant value)
Definition: VidaliaTab.cpp:28
void setOnTop(bool top)
Definition: VidaliaTab.cpp:63
virtual void retranslateUi()
Definition: VidaliaTab.cpp:57
virtual void closeEvent(QCloseEvent *event)
Definition: VidaliaTab.cpp:69
bool _onTop
Definition: VidaliaTab.h:66
virtual void changeEvent(QEvent *e)
Definition: VidaliaTab.cpp:44
void setShortcut(const QString &shortcut, const char *slot)
Definition: VidaliaTab.cpp:35
VSettings * _settings
Definition: VidaliaTab.h:70