Vidalia  0.3.1
VidaliaTabPrototype.cpp
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file VidaliaTabPrototype.cpp
13 ** \brief Prototype for VidaliaTab class
14 */
15 
16 #include "VidaliaTabPrototype.h"
17 
19  : QObject(parent)
20 {}
21 
22 QScriptValue
23 VidaliaTabPrototype::constructor(QScriptContext *context, QScriptEngine *engine)
24 {
25  if((context->argumentCount() > 2) or (context->argumentCount() < 1))
26  return QScriptValue(QScriptValue::NullValue);
27 
28  QString title = "";
29  QString name = "";
30 
31  title = qscriptvalue_cast<QString>(context->argument(0));
32  if(context->argumentCount() > 1)
33  name = qscriptvalue_cast<QString>(context->argument(1));
34 
35  return engine->newQObject(new VidaliaTab(title, name), QScriptEngine::ScriptOwnership);
36 }
37 
38 int
40 {
41  return qMetaTypeId<VidaliaTab *>();
42 }
43 
44 QString
46 {
47  return QString("VidaliaTab");
48 }
49 
50 void
52 {
53  VidaliaTab *obj = qscriptvalue_cast<VidaliaTab *>(thisObject());
54 
55  if(obj)
56  obj->setLayout(layout);
57 }
58 
59 QVariant
61 {
62  VidaliaTab *obj = qscriptvalue_cast<VidaliaTab *>(thisObject());
63 
64  if(obj)
65  return obj->getSetting(name, defaultValue);
66 }
67 
68 void
70 {
71  VidaliaTab *obj = qscriptvalue_cast<VidaliaTab *>(thisObject());
72 
73  if(obj)
74  obj->saveSetting(name, value);
75 }
void saveSetting(QString name, QVariant value)
Definition: VidaliaTab.cpp:28
stop errmsg QVariant
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine)
VidaliaTabPrototype(QObject *parent=0)
Q_INVOKABLE void setLayout(QLayout *layout)
Q_INVOKABLE QVariant getSetting(QString name, QVariant defaultValue)
QVariant getSetting(QString name, QVariant defaultValue)
Definition: VidaliaTab.cpp:21
Q_INVOKABLE void saveSetting(QString name, QVariant value)