Vidalia  0.3.1
VidaliaTab.cpp
Go to the documentation of this file.
1 #include "VidaliaTab.h"
2 #include "Vidalia.h"
3 
4 VidaliaTab::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. */
21 VidaliaTab::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. */
27 void
28 VidaliaTab::saveSetting(QString prop, QVariant value)
29 {
30  _settings->setValue(prop, value);
31 }
32 
33 /** Associates a shortcut key sequence with a slot. */
34 void
35 VidaliaTab::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. */
43 void
45 {
46  if (e->type() == QEvent::LanguageChange) {
47  retranslateUi();
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. */
56 void
58 {
59  /* The default retranslateUi() implementation does nothing */
60 }
61 
62 void
64 {
65  _onTop = top;
66 }
67 
68 void
69 VidaliaTab::closeEvent(QCloseEvent *event)
70 {
71  event->ignore();
72  emit closeTab();
73 }
74 
void saveSetting(QString name, QVariant value)
Definition: VidaliaTab.cpp:28
stop errmsg QVariant
virtual void setValue(const QString &key, const QVariant &val)
Definition: VSettings.cpp:61
void setOnTop(bool top)
Definition: VidaliaTab.cpp:63
virtual void changeEvent(QEvent *e)
Definition: VidaliaTab.cpp:44
QVariant getSetting(QString name, QVariant defaultValue)
Definition: VidaliaTab.cpp:21
bool _onTop
Definition: VidaliaTab.h:66
virtual void retranslateUi()
Definition: VidaliaTab.cpp:57
void closeTab()
virtual void closeEvent(QCloseEvent *event)
Definition: VidaliaTab.cpp:69
virtual QVariant value(const QString &key, const QVariant &defaultVal=QVariant()) const
Definition: VSettings.cpp:53
void setShortcut(const QString &shortcut, const char *slot)
Definition: VidaliaTab.cpp:35
VSettings * _settings
Definition: VidaliaTab.h:70
VidaliaTab(const QString &title, const QString &name="", QWidget *parent=0)
Definition: VidaliaTab.cpp:4
#define vApp
Definition: Vidalia.h:37