From: konrad Date: Sat, 23 Oct 2010 19:09:29 +0000 (+0000) Subject: wob: GetMyRights now includes flags as info field X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=b3a8f0282520e3d8e77fdec192065874271a138e;p=web%2Fkonrad%2Fsmoke.git wob: GetMyRights now includes flags as info field wizard: make permanent widgets scripted msiface: make more info available to scripts scripts: add some docu git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@608 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/dialogs/wizard.cpp b/src/dialogs/wizard.cpp index a43e03e..3b3cc1c 100644 --- a/src/dialogs/wizard.cpp +++ b/src/dialogs/wizard.cpp @@ -24,22 +24,18 @@ MWizard::MWizard(MOverview* parent, Qt::WindowFlags f) :QDialog(parent, f),m_parent(parent) { setWindowTitle(tr("Wizard")); + + m_top=m_bottom=m_left=m_right=0; + //main layout QVBoxLayout*vl; - QHBoxLayout*hl; - setLayout(vl=new QVBoxLayout); - vl->addLayout(m_stack=new QStackedLayout,1); - //bottom buttons - vl->addLayout(hl=new QHBoxLayout); - hl->addStretch(1); - QPushButton*p; - hl->addWidget(p=new QPushButton(tr("Start Over"))); - connect(p,SIGNAL(clicked()),this,SLOT(gotoStart())); - hl->addWidget(p=new QPushButton(tr("Close Wizard"))); - connect(p,SIGNAL(clicked()),this,SLOT(accept())); - hl->addWidget(p=new QPushButton(tr("Exit"))); - connect(p,SIGNAL(clicked()),this,SLOT(accept())); - connect(p,SIGNAL(clicked()),parent,SLOT(close())); + setLayout(m_mainlayout=new QGridLayout); + m_mainlayout->addLayout(m_stack=new QStackedLayout,1,1); + m_mainlayout->setColumnStretch(1,1); + m_mainlayout->setRowStretch(1,1); + QMargins mrg=m_stack->contentsMargins(); + m_mainlayout->setContentsMargins(0,0,0,0); + m_stack->setContentsMargins(mrg); //page: start QWidget*w; @@ -98,3 +94,27 @@ QWidget* MWizard::pageWidget(int pg) { return m_stack->widget(pg); } + +void MWizard::setBottomWidget(QWidget* w) +{ + if(m_bottom)delete m_bottom; + m_mainlayout->addWidget(m_bottom=w,2,0,1,3); +} + +void MWizard::setTopWidget(QWidget* w) +{ + if(m_top)delete m_top; + m_mainlayout->addWidget(m_top=w,0,0,1,3); +} + +void MWizard::setLeftWidget(QWidget* w) +{ + if(m_left)delete m_left; + m_mainlayout->addWidget(m_left=w,1,0); +} + +void MWizard::setRightWidget(QWidget* w) +{ + if(m_right)delete m_right; + m_mainlayout->addWidget(m_right=w,1,2); +} diff --git a/src/dialogs/wizard.h b/src/dialogs/wizard.h index 9e054f6..e7dd51f 100644 --- a/src/dialogs/wizard.h +++ b/src/dialogs/wizard.h @@ -15,6 +15,7 @@ #include +class QGridLayout; class QSignalMapper; class QVBoxLayout; class QStackedLayout; @@ -34,13 +35,19 @@ class MWizard:public QDialog void gotoPage(int); QWidget* pageWidget(int); QPushButton* modeButton(int); + void setTopWidget(QWidget*); + void setBottomWidget(QWidget*); + void setRightWidget(QWidget*); + void setLeftWidget(QWidget*); private: MOverview*m_parent; MScriptEngine*m_jseng; QStackedLayout*m_stack; QVBoxLayout*m_modelayout; + QGridLayout*m_mainlayout; QSignalMapper*m_modemap; + QWidget*m_top,*m_bottom,*m_left,*m_right; int m_startid; }; diff --git a/src/iface/msinterface.cpp b/src/iface/msinterface.cpp index d01aa70..344b166 100644 --- a/src/iface/msinterface.cpp +++ b/src/iface/msinterface.cpp @@ -79,6 +79,7 @@ bool MSInterface::login(QString username,QString passwd) Right x=stringToRight(rsl[i]); if(x!=NoRight)userrights<(MInterface::instance());} /**returns the name of the current user*/ - QString currentUser()const{return m_uname;} + Q_INVOKABLE QString currentUser()const{return m_uname;} /**returns the name used for the host in this session*/ - QString hostName()const{return m_host;} + Q_INVOKABLE QString hostName()const{return m_host;} /**returns whether the user is part of this role*/ Q_INVOKABLE bool hasRole(QString s)const{return userroles.contains(s);} @@ -53,21 +53,24 @@ class MSInterface:public MInterface /**returns whether the user has a particular right*/ Q_INVOKABLE bool hasRight(Right)const; + ///returns whether the user has a particular flag + Q_INVOKABLE bool hasFlag(QString f)const{return userflags.contains(f);} + /**returns the directory where to store data retrieved from the server*/ - QString dataDir()const; + Q_INVOKABLE QString dataDir()const; /**returns the group in which to find settings in QSettings, this group can be used by any class that accesses the profile*/ - QString settingsGroup()const; + Q_INVOKABLE QString settingsGroup()const; /**returns the group where central profile settings are stored, this group is read-only for anything but the configuration dialog*/ - QString configSettingsGroup()const; + Q_INVOKABLE QString configSettingsGroup()const; /**checks the server for compatibility*/ bool checkServer(); /**returns the current session ID*/ - QString sessionId()const{return m_sessid;} + Q_INVOKABLE QString sessionId()const{return m_sessid;} /**returns the branch/trunk part of the repository*/ - static QString repoPart(); + Q_INVOKABLE static QString repoPart(); /**returns default headers, ie. session ID*/ virtual QMap headers(QString)const; @@ -80,6 +83,15 @@ class MSInterface:public MInterface /**returns the profile ID of this session*/ QString profileId()const{return profileid;} + + ///return all rights of the current user + QList allRights()const{return userrights;} + + ///return all roles of the current user + QStringList allRoles()const{return userroles;} + + ///return all flags of the current user + QStringList allFlags()const{return userflags;} public slots: /**logs into the server, returns true on success*/ @@ -98,7 +110,7 @@ class MSInterface:public MInterface private: QString profileid,m_sessid,m_uname,m_passwd,m_host,m_hostkey; mutable QListuserrights; - mutable QStringList userroles; + mutable QStringList userroles,userflags; QByteArray servertranslation; MSslExceptions*sslexcept; bool didsslerror; diff --git a/src/script/init.js b/src/script/init.js index 2b17c6a..456715f 100644 --- a/src/script/init.js +++ b/src/script/init.js @@ -1,3 +1,14 @@ +//init.js + +// This script is executed whenever a script engine starts up. +// Use it to load whatever extensions you often need or to shift things around +// in the environment... + //initialize environment + +// loads wrappers for the QtCore classes importExtension("qt.core"); +// loads wrappers for the QtGui classes (depends on qt.core being loaded first) importExtension("qt.gui"); + +// other relevant extensions are: qt.xml qt.xmlpatterns qt.network diff --git a/src/script/startup.js b/src/script/startup.js index 117cb33..ba81be9 100644 --- a/src/script/startup.js +++ b/src/script/startup.js @@ -1,2 +1,8 @@ -//startup code -mainWindow.wizardMode(); \ No newline at end of file +//startup.js + +// this startup code is executed as soon as the main window is initialized and visible; +// the engine executing it does not stay open + +// this example code switches to the wizard if the user has the _useWizard flag set +if(wob.interface.hasFlag("_useWizard")) + mainWindow.wizardMode(); diff --git a/src/script/wizard.js b/src/script/wizard.js index f1b8329..ff88f60 100644 --- a/src/script/wizard.js +++ b/src/script/wizard.js @@ -1,3 +1,67 @@ +//wizard.js +// +// This script is executed when the wizard starts. +// The engine stays active until the wizard is closed, you can use it to schedule +// actions and/or to react to GUI events. + +// The wizard contains a stack of pages that can be used create functionality for the user. +// The start page is controlled by the wizard itself, it contains buttons that start work flows. +// Around this stack there are four areas wher you can put widgets that are permanently visible. + +// The methods are: +// wizard.addMode("text") -> adds a button to the start page and an initial +// page for that work flow, it return the page ID of that initial page +// wizard.addPage() -> adds a page and returns its ID +// wizard.pageWidget(ID) -> returns the QWidget for the given page ID +// wizard.modeButton(ID) -> returns the QPushButton for the given mode, the +// ID supplied to it is the return value of addMode +// wizard.gotoStart() -> switches to the start page +// wizard.gotoPage(ID) -> switches to the given page, ID is the return value +// of addMode or addPage +// wizard.setTopWidget(widget) -> sets the top permanent widget +// wizard.setBottomWidget(widget) -> sets the bottom permanent widget +// wizard.setLeftWidget(widget) -> sets the left permanent widget +// wizard.setRightWidget(widget) -> sets the right permanent widget +// there are more methods: all the slots of QDialog are available + +// The wizard layout looks roughly like this: +// ____________________________________ +// | Wizard Title Bar [x] +// +----------------------------------+ +// | top permanent widget | +// +------+--------------------+------+ +// | left | wizard pages |right | +// | perm.| |perm. | +// |widget| |widget| +// . . . +// | | | | +// +------+--------------------+------+ +// | bottom permanent widget | +// +----------------------------------+ + +////////// +//lower buttons, those are always visible +function createButtons() +{ + var w=new QWidget; + wizard.setBottomWidget(w); + var hl; + var p; + w.setLayout(hl=new QHBoxLayout); + hl.addWidget(p=new QPushButton("Debug"),0,0); + p.clicked.connect(function(){debugger;}); + hl.addStretch(1); + hl.addWidget(p=new QPushButton("Start Over"),0,0); + p.clicked.connect(wizard.gotoStart); + hl.addWidget(p=new QPushButton("Close Wizard"),0,0); + p.clicked.connect(wizard.accept); + hl.addWidget(p=new QPushButton("Exit"),0,0); + p.clicked.connect(wizard.accept); + p.clicked.connect(mainWindow.close); +} +createButtons(); + +////////// //example ticket sale wizard function startSale() { @@ -25,7 +89,10 @@ function startSale() } startSale(); +////////// //dump built in scripts + +//you used this to dump these scripts.... ;-) var dumpbtn; var dumppath; var dumplog; @@ -78,6 +145,6 @@ startDump(); wizard.gotoStart(); -//wizard.show(); - -//debugger \ No newline at end of file +///////// +//uncomment this line if you want to force the debugger visible +//debugger diff --git a/wob/transact/user.wolf b/wob/transact/user.wolf index 5f6e32e..dbf62a6 100644 --- a/wob/transact/user.wolf +++ b/wob/transact/user.wolf @@ -46,9 +46,10 @@ - + +