--- /dev/null
+//
+// C++ Implementation: overview
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2011
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#include "backupdlg.h"
+
+#include "centbox.h"
+#include "msinterface.h"
+
+#include <QBoxLayout>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDebug>
+#include <QFile>
+#include <QFileDialog>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMenu>
+#include <QPushButton>
+#include <QSettings>
+#include <QSpinBox>
+
+
+MBackupDialog::MBackupDialog(QWidget*par,QString pk)
+ :QDialog(par),profilekey(pk)
+{
+ QSettings set;
+ set.beginGroup("profiles/"+profilekey);
+ QString path=set.value("backupfile",req->dataDir()+"/backup").toString();
+ int gens=set.value("backupgenerations",3).toInt();
+ int tm=set.value("backupinterval",0).toInt();
+ //dialog
+ setWindowTitle(tr("Backup Settings"));
+ QGridLayout*gl;
+ QHBoxLayout*hl;
+ setLayout(gl=new QGridLayout);
+ QPushButton*p;
+ gl->addWidget(new QLabel(tr("Backup File:")),0,0);
+ gl->addWidget(lpath=new QLineEdit(path),0,1);
+ gl->addWidget(p=new QPushButton(tr("...")),0,2);
+ connect(p,SIGNAL(clicked()),this,SLOT(getpath()));
+
+ gl->addWidget(new QLabel(tr("Generations to keep:")),1,0);
+ gl->addWidget(gener=new QSpinBox,1,1,1,2);
+ gener->setRange(1,16);
+ gener->setValue(gens);
+
+ gl->addWidget(new QLabel(tr("Automatic Backup:")),2,0);
+ gl->addWidget(autob=new QCheckBox,2,1,1,2);
+ autob->setChecked(tm>0);
+
+ gl->addWidget(new QLabel(tr("Interval in days:")),3,0);
+ gl->addWidget(interv=new QSpinBox,3,1,1,2);
+ interv->setRange(1,24);
+ interv->setValue(tm>0?tm:1);
+
+ gl->setRowMinimumHeight(4,15);
+ gl->addLayout(hl=new QHBoxLayout,5,0,1,3);
+ hl->addStretch(10);
+ hl->addWidget(p=new QPushButton(tr("&OK")));
+ connect(p,SIGNAL(clicked()),this,SLOT(accept()));
+ connect(p,SIGNAL(clicked()),this,SLOT(save()));
+ hl->addWidget(p=new QPushButton(tr("&Cancel")));
+ connect(p,SIGNAL(clicked()),this,SLOT(reject()));
+}
+
+void MBackupDialog::getpath()
+{
+ QString path=QFileDialog::getSaveFileName(this,tr("Backup File"),lpath->text());
+ if(path!="")lpath->setText(path);
+}
+
+void MBackupDialog::save()
+{
+ QSettings set;
+ set.beginGroup("profiles/"+profilekey);
+ set.setValue("backupfile",lpath->text());
+ set.setValue("backupgenerations",gener->value());
+ set.setValue("backupinterval",autob->isChecked()?interv->value():0);
+}
#include "shipping.h"
#include "templatedlg.h"
#include "wizard.h"
+#include "backupdlg.h"
#include "aclwin.h"
#include "carttab.h"
#include <QTabWidget>
MOverview::MOverview(QString pk)
+ :MTabWin(pk)
{
- profilekey=pk;
- setAttribute(Qt::WA_DeleteOnClose);
- setWindowTitle("MagicSmoke: "+req->currentUser()+"@"+QSettings().value("profiles/"+pk+"/name").toString());
rtimer.setInterval(QSettings().value("profiles/"+pk+"/refresh",300).toInt()*1000);
rtimer.start();
connect(&rtimer,SIGNAL(timeout()),this,SLOT(refreshData()));
m->addAction(tr("&Update Templates Now"),req,SLOT(updateTemplates()));
m->addSeparator();
m->addAction(tr("&Close Session"),this,SLOT(close()));
- //continued below tabs...
-
- //make sure webrequest knows its settings
- webSettings(false);
-
- //tabs
- setCentralWidget(tab=new QTabWidget);
- connect(tab,SIGNAL(currentChanged(int)),this,SLOT(tabChanged(int)));
-
- //Event tab
- tab->addTab(eventtab=new MEventsTab(pk),tr("Events"));
- mb->addMenu(eventtab->menu());
-
- //Shopping Cart Tab
- tab->addTab(carttab=new MCartTab(pk),tr("Shopping Cart"));
- connect(eventtab,SIGNAL(eventOrderTicket()),carttab,SLOT(eventOrderTicket()));
- mb->addMenu(carttab->menu());
- connect(carttab,SIGNAL(eventModel()),eventtab,SLOT(eventModel()),Qt::DirectConnection);
- connect(carttab,SIGNAL(currentEventId()),eventtab,SLOT(currentEventId()),Qt::DirectConnection);
- connect(carttab,SIGNAL(currentEventTitle()),eventtab,SLOT(currentEventTitle()),Qt::DirectConnection);
- connect(carttab,SIGNAL(currentEventStart()),eventtab,SLOT(currentEventStart()),Qt::DirectConnection);
- connect(carttab,SIGNAL(requestFocus()),this,SLOT(switchToCartTab()));
-
- //Order List Tab
- tab->addTab(ordertab=new MOrdersTab(pk),tr("Order List"));
- connect(ordertab,SIGNAL(eventModel()),eventtab,SLOT(eventModel()),Qt::DirectConnection);
-
- //Entrance Control Tab
- tab->addTab(entrancetab=new MEntranceTab(pk),tr("Entrance"));
-
//menus not connected to any specific tab...
- m=mb->addMenu(tr("&Customer"));
+ m=mb->addMenu(tr("&Actions"));
+ m->addSeparator()->setText(tr("Customer"));
m->addAction(tr("&Show all customers"),this,SLOT(customerMgmt()));
- m=mb->addMenu(tr("&Misc"));
+ m->addSeparator()->setText(tr("Tickets/Vouchers"));
m->addAction(tr("Return &ticket or voucher..."),this,SLOT(ticketReturn()))
->setEnabled(req->RReturnTicketVoucher);
m->addSeparator();
- m->addAction(tr("Edit &Shipping Options..."),this,SLOT(editShipping()));
- m->addSeparator();
m->addAction(tr("&Deduct from voucher..."),this,SLOT(deductVoucher()));
m->addAction(tr("&Empty voucher..."),this,SLOT(emptyVoucher()));
+ m->addSeparator()->setText(tr("Shipping"));
+ m->addAction(tr("Edit &Shipping Options..."),this,SLOT(editShipping()));
- m=mb->addMenu(tr("C&onfigure"));
+ m->addSeparator()->setText(tr("Configuration"));
m->addAction(tr("&Auto-Refresh settings..."),this,SLOT(setRefresh()));
m->addAction(tr("&Server Access settings..."),this,SLOT(webSettings()));
m->addAction(tr("&Display settings..."),this,SLOT(displaySettings()));
- m=mb->addMenu(tr("&Admin"));
+ m->addSeparator()->setText(tr("Administration"));
m->addAction(tr("&User Administration..."),this,SLOT(aclWindow()))
->setEnabled(req->hasRight(req->RGetAllUsers) || req->hasRight(req->RGetAllHosts) || req->hasRight(req->RGetAllRoles));
m->addSeparator();
->setEnabled(req->hasRight(req->RBackup));
m->addAction(tr("&Backup now..."),this,SLOT(doBackup()))
->setEnabled(req->hasRight(req->RBackup));
-
- mb->addMenu(MApplication::helpMenu());
- //status bar
- QStatusBar *sb=statusBar();
- sb->setSizeGripEnabled(true);
- sb->addPermanentWidget(new MServerClock);
+ //make sure webrequest knows its settings
+ webSettings(false);
+
+ //Event tab
+ eventtab=new MEventsTab(pk);
+ addTab(eventtab,tr("Events"),eventtab->menu());
+ //Shopping Cart Tab
+ carttab=new MCartTab(pk);
+ addTab(carttab,tr("Shopping Cart"),carttab->menu());
+ connect(eventtab,SIGNAL(eventOrderTicket()),carttab,SLOT(eventOrderTicket()));
+ connect(carttab,SIGNAL(eventModel()), eventtab,SLOT(eventModel()), Qt::DirectConnection);
+ connect(carttab,SIGNAL(currentEventId()), eventtab,SLOT(currentEventId()), Qt::DirectConnection);
+ connect(carttab,SIGNAL(currentEventTitle()), eventtab,SLOT(currentEventTitle()), Qt::DirectConnection);
+ connect(carttab,SIGNAL(currentEventStart()), eventtab,SLOT(currentEventStart()), Qt::DirectConnection);
+ connect(carttab,SIGNAL(requestFocus()), this,SLOT(switchToCartTab()));
+
+ //Order List Tab
+ addTab(ordertab=new MOrdersTab(pk),tr("Order List"));
+ connect(ordertab,SIGNAL(eventModel()), eventtab,SLOT(eventModel()), Qt::DirectConnection);
+
+ //Entrance Control Tab
+ addTab(entrancetab=new MEntranceTab(pk),tr("Entrance"));
+
+
//unused tab disabling...
if(!req->hasRight(req->RGetAllEvents)){
eventtab->setEnabled(false);
- tab->setTabEnabled(tab->indexOf(eventtab),false);
+ setTabEnabled(eventtab,false);
}
if(!req->hasRight(req->RCreateOrder)&&!req->hasRight(req->RCreateReservation)){
- tab->setTabEnabled(tab->indexOf(carttab),false);
+ setTabEnabled(carttab,false);
}
if(!req->hasRight(req->RGetOrderList)){
- tab->setTabEnabled(tab->indexOf(ordertab),false);
+ setTabEnabled(ordertab,false);
}
+ //make sure correct menu is displayed
+ tabChanged(-1);
//run init script
QTimer::singleShot(0,this,SLOT(runStartupScript()));
void MOverview::switchToCartTab()
{
- tab->setCurrentWidget(carttab);
+ setCurrentTab(carttab);
}
void MOverview::relogin()
carttab->updateShipping();
}
-void MOverview::tabChanged(int /*idx*/)
+void MOverview::tabChanged(int idx)
{
-// qDebug("tab index %i",idx);
- QWidget*w=tab->currentWidget();
+ MTabWin::tabChanged(idx);
+ QWidget*w=currentTab();
if(w==entrancetab){
entrancetab->initialize();
}
wiz.exec();
show();
}
-
-
-/**********************************************/
-
-MBackupDialog::MBackupDialog(QWidget*par,QString pk)
- :QDialog(par),profilekey(pk)
-{
- QSettings set;
- set.beginGroup("profiles/"+profilekey);
- QString path=set.value("backupfile",req->dataDir()+"/backup").toString();
- int gens=set.value("backupgenerations",3).toInt();
- int tm=set.value("backupinterval",0).toInt();
- //dialog
- setWindowTitle(tr("Backup Settings"));
- QGridLayout*gl;
- QHBoxLayout*hl;
- setLayout(gl=new QGridLayout);
- QPushButton*p;
- gl->addWidget(new QLabel(tr("Backup File:")),0,0);
- gl->addWidget(lpath=new QLineEdit(path),0,1);
- gl->addWidget(p=new QPushButton(tr("...")),0,2);
- connect(p,SIGNAL(clicked()),this,SLOT(getpath()));
-
- gl->addWidget(new QLabel(tr("Generations to keep:")),1,0);
- gl->addWidget(gener=new QSpinBox,1,1,1,2);
- gener->setRange(1,16);
- gener->setValue(gens);
-
- gl->addWidget(new QLabel(tr("Automatic Backup:")),2,0);
- gl->addWidget(autob=new QCheckBox,2,1,1,2);
- autob->setChecked(tm>0);
-
- gl->addWidget(new QLabel(tr("Interval in days:")),3,0);
- gl->addWidget(interv=new QSpinBox,3,1,1,2);
- interv->setRange(1,24);
- interv->setValue(tm>0?tm:1);
-
- gl->setRowMinimumHeight(4,15);
- gl->addLayout(hl=new QHBoxLayout,5,0,1,3);
- hl->addStretch(10);
- hl->addWidget(p=new QPushButton(tr("&OK")));
- connect(p,SIGNAL(clicked()),this,SLOT(accept()));
- connect(p,SIGNAL(clicked()),this,SLOT(save()));
- hl->addWidget(p=new QPushButton(tr("&Cancel")));
- connect(p,SIGNAL(clicked()),this,SLOT(reject()));
-}
-
-void MBackupDialog::getpath()
-{
- QString path=QFileDialog::getSaveFileName(this,tr("Backup File"),lpath->text());
- if(path!="")lpath->setText(path);
-}
-
-void MBackupDialog::save()
-{
- QSettings set;
- set.beginGroup("profiles/"+profilekey);
- set.setValue("backupfile",lpath->text());
- set.setValue("backupgenerations",gener->value());
- set.setValue("backupinterval",autob->isChecked()?interv->value():0);
-}
--- /dev/null
+//
+// C++ Implementation: overview
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2011
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#include "customerdlg.h"
+#include "main.h"
+#include "msinterface.h"
+#include "passwdchg.h"
+#include "shipping.h"
+#include "templatedlg.h"
+#include "wizard.h"
+
+#include "aclwin.h"
+#include "carttab.h"
+#include "entrancetab.h"
+#include "eventstab.h"
+#include "orderstab.h"
+#include "overview.h"
+
+#include "centbox.h"
+#include "sclock.h"
+
+#include "jsengine.h"
+
+#include <TimeStamp>
+
+#include <QBoxLayout>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDebug>
+#include <QFile>
+#include <QFileDialog>
+#include <QGroupBox>
+#include <QInputDialog>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QSettings>
+#include <QSpinBox>
+#include <QStackedWidget>
+#include <QStatusBar>
+#include <QTabWidget>
+
+MTabWin::MTabWin(QString pk,QWidget*parent)
+ :QMainWindow(parent)
+{
+ profilekey=pk;
+ setAttribute(Qt::WA_DeleteOnClose);
+ setWindowTitle("MagicSmoke: "+req->currentUser()+"@"+QSettings().value("profiles/"+pk+"/name").toString());
+
+ //menu
+ QWidget*mmb=new QWidget;
+ setMenuWidget(mmb);
+ QHBoxLayout*hl;
+ mmb->setLayout(hl=new QHBoxLayout);
+ hl->setMargin(0);
+ hl->addWidget(leftmenu=new QMenuBar,0);
+ QFrame*frm;
+ hl->addWidget(frm=new QFrame,0);
+ frm->setFrameStyle(QFrame::VLine|QFrame::Sunken);
+ hl->addWidget(middlemenu=new QStackedWidget,1);
+ hl->addWidget(frm=new QFrame,0);
+ frm->setFrameStyle(QFrame::VLine|QFrame::Sunken);
+ hl->addWidget(rightmenu=new QMenuBar,0);
+
+ rightmenu->addMenu(helpmenu=MApplication::helpMenu());
+
+ nullmenu=middlemenu->addWidget(new QWidget);
+
+ //tabs
+ setCentralWidget(tabw=new QTabWidget);
+ connect(tabw,SIGNAL(currentChanged(int)), this,SLOT(tabChanged(int)));
+
+ //status bar
+ QStatusBar *sb=statusBar();
+ sb->setSizeGripEnabled(true);
+ sb->addPermanentWidget(new MServerClock);
+}
+
+MTabWin::~MTabWin()
+{
+}
+
+void MTabWin::tabChanged(int idx)
+{
+ if(idx<0)idx=tabw->currentIndex();
+ if(tabmenu.contains(idx))
+ middlemenu->setCurrentIndex(tabmenu[idx]);
+ else
+ middlemenu->setCurrentIndex(nullmenu);
+}
+
+void MTabWin::addTab(QWidget* tw, QString title, QMenuBar* menu)
+{
+ int idx=tabw->addTab(tw,title);
+ if(menu){
+ int midx=middlemenu->addWidget(menu);
+ tabmenu.insert(idx,midx);
+ }
+}
+
+QMenuBar* MTabWin::menuBar() const
+{
+ return leftMenu();
+}
+
+QWidget* MTabWin::currentTab() const
+{
+ return tabw->currentWidget();
+}
+
+void MTabWin::setCurrentTab(QWidget* w)
+{
+ tabw->setCurrentWidget(w);
+}
+
+void MTabWin::setTabEnabled(QWidget* w, bool e)
+{
+ tabw->setTabEnabled(tabw->indexOf(w),e);
+}
+
+QMenu* MTabWin::helpMenu() const
+{
+ return helpmenu;
+}