From e07b7d3361ab8d3d92959c8d057a682d6b7d9ef6 Mon Sep 17 00:00:00 2001 From: konrad Date: Thu, 30 Dec 2010 14:11:06 +0000 Subject: [PATCH] start refactoring menus and tabs git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@697 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/dialogs/aclwin.cpp | 98 ---------------------------- src/dialogs/aclwin.h | 50 --------------- src/dialogs/backupdlg.cpp | 89 ++++++++++++++++++++++++++ src/dialogs/backupdlg.h | 41 ++++++++++++ src/dialogs/dialogs.pri | 8 +- src/dialogs/wizard.cpp | 1 + src/mwin/aclwin.cpp | 98 ++++++++++++++++++++++++++++ src/mwin/aclwin.h | 50 +++++++++++++++ src/mwin/carttab.cpp | 8 ++- src/mwin/carttab.h | 2 +- src/mwin/eventstab.cpp | 7 +- src/mwin/eventstab.h | 2 +- src/mwin/mwin.pri | 4 + src/mwin/overview.cpp | 155 ++++++++++++--------------------------------- src/mwin/overview.h | 23 +------ src/mwin/tabwin.cpp | 136 +++++++++++++++++++++++++++++++++++++++ src/mwin/tabwin.h | 74 +++++++++++++++++++++ 17 files changed, 553 insertions(+), 293 deletions(-) delete mode 100644 src/dialogs/aclwin.cpp delete mode 100644 src/dialogs/aclwin.h create mode 100644 src/dialogs/backupdlg.cpp create mode 100644 src/dialogs/backupdlg.h create mode 100644 src/mwin/aclwin.cpp create mode 100644 src/mwin/aclwin.h create mode 100644 src/mwin/tabwin.cpp create mode 100644 src/mwin/tabwin.h diff --git a/src/dialogs/aclwin.cpp b/src/dialogs/aclwin.cpp deleted file mode 100644 index 8978cb9..0000000 --- a/src/dialogs/aclwin.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// -// C++ Implementation: acldialog -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2010-2011 -// -// Copyright: See README/COPYING.GPL files that come with this distribution -// -// - - -#include "acltabs.h" -#include "msinterface.h" -#include "main.h" - -#include "aclwin.h" - -#include -#include -#include -#include -#include -#include -#include -#include - - -QPointerMAclWindow::instance; - -void MAclWindow::showWindow(QWidget*p) -{ - if(instance.isNull()){ - instance=new MAclWindow(p); - } - if(!instance->isVisible())instance->show(); - if(instance->isMinimized())instance->showNormal(); - instance->activateWindow(); - instance->raise(); -} - -MAclWindow::MAclWindow(QWidget*par) - :QMainWindow(par) -{ - profilekey=req->profileId(); - setAttribute(Qt::WA_DeleteOnClose); - setWindowTitle(tr("MagicSmoke ACL Editor [%1@%2]") .arg(req->currentUser()) .arg(QSettings().value("profiles/"+profilekey+"/name").toString())); - - rtimer.setInterval(QSettings().value("profiles/"+profilekey+"/refresh",300).toInt()*1000); - rtimer.start(); - connect(&rtimer,SIGNAL(timeout()),this,SLOT(refreshData())); - - //menu - QMenuBar*mb=menuBar(); - QMenu*m=mb->addMenu(tr("&Window")); - m->addAction(tr("&Close"),this,SLOT(close())); - - //tabs - setCentralWidget(tab=new QTabWidget); - //user tab - tab->addTab(usertab=new MUserTab(profilekey),tr("Users")); - //role tab - tab->addTab(roletab=new MRoleTab(profilekey),tr("Roles")); - //host tab - tab->addTab(hosttab=new MHostTab(profilekey),tr("Hosts")); - //flags tab - tab->addTab(flagtab=new MFlagTab(profilekey),tr("Flags")); - - mb->addMenu(MApplication::helpMenu()); - - //status bar - statusBar()->setSizeGripEnabled(true); - - //unused tab disabling... - if(!req->hasRight(req->RGetAllUsers)){ - tab->setTabEnabled(tab->indexOf(usertab),false); - } - if(!req->hasRight(req->RGetAllHosts)){ - tab->setTabEnabled(tab->indexOf(hosttab),false); - } - if(!req->hasRight(req->RGetAllRoles)){ - tab->setTabEnabled(tab->indexOf(roletab),false); - } -} - - -void MAclWindow::refreshData() -{ - QSettings set; - set.beginGroup("profiles/"+profilekey); - if(set.value("refreshUsers",false).toBool() && req->hasRight(req->RGetAllUsers)) - usertab->updateUsers(); - if(set.value("refreshHosts",false).toBool() && req->hasRight(req->RGetAllHosts)) - hosttab->updateHosts(); - if(set.value("refreshRoles",false).toBool() && req->hasRight(req->RGetAllRoles)) - roletab->updateRoles(); -} diff --git a/src/dialogs/aclwin.h b/src/dialogs/aclwin.h deleted file mode 100644 index 8c05d9e..0000000 --- a/src/dialogs/aclwin.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// C++ Interface: acldialog -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2010-2011 -// -// Copyright: See README/COPYING.GPL files that come with this distribution -// -// - -#ifndef MAGICSMOKE_ACLWIN_H -#define MAGICSMOKE_ACLWIN_H - -#include -#include -#include - -class MUserTab; -class MHostTab; -class MRoleTab; -class MFlagTab; - -class MAclWindow:public QMainWindow -{ - Q_OBJECT - public: - static void showWindow(QWidget*); - - private slots: - void refreshData(); - private: - MAclWindow(QWidget*); - - static QPointerinstance; - - //the profile associated with this session - QString profilekey; - //widgets - QTabWidget*tab; - MUserTab*usertab; - MHostTab*hosttab; - MRoleTab*roletab; - MFlagTab*flagtab; - //refresh timers - QTimer rtimer; -}; - -#endif diff --git a/src/dialogs/backupdlg.cpp b/src/dialogs/backupdlg.cpp new file mode 100644 index 0000000..483abcc --- /dev/null +++ b/src/dialogs/backupdlg.cpp @@ -0,0 +1,89 @@ +// +// C++ Implementation: overview +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2007-2011 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#include "backupdlg.h" + +#include "centbox.h" +#include "msinterface.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +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); +} diff --git a/src/dialogs/backupdlg.h b/src/dialogs/backupdlg.h new file mode 100644 index 0000000..0f43e73 --- /dev/null +++ b/src/dialogs/backupdlg.h @@ -0,0 +1,41 @@ +// +// C++ Interface: overview +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2007-2011 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#ifndef MAGICSMOKE_BACKUPDLG_H +#define MAGICSMOKE_BACKUPDLG_H + +#include + +#include "tabwin.h" + +class QCheckBox; +class QLineEdit; +class QSpinBox; + +/**Helper class for Backup settings*/ +class MBackupDialog:public QDialog +{ + Q_OBJECT + public: + MBackupDialog(QWidget*,QString); + + private slots: + void getpath(); + void save(); + private: + QLineEdit*lpath; + QSpinBox*interv,*gener; + QCheckBox*autob; + QString profilekey; +}; + +#endif diff --git a/src/dialogs/dialogs.pri b/src/dialogs/dialogs.pri index 944c269..2f57877 100644 --- a/src/dialogs/dialogs.pri +++ b/src/dialogs/dialogs.pri @@ -9,11 +9,11 @@ HEADERS += \ dialogs/checkdlg.h \ dialogs/passwdchg.h \ dialogs/pricecatdlg.h \ - dialogs/aclwin.h \ dialogs/flagedit.h \ dialogs/wizard.h \ dialogs/orderauditdlg.h \ - dialogs/orderauditdlg_p.h + dialogs/orderauditdlg_p.h \ + dialogs/backupdlg.h SOURCES += \ dialogs/configdialog.cpp \ @@ -26,10 +26,10 @@ SOURCES += \ dialogs/checkdlg.cpp \ dialogs/passwdchg.cpp \ dialogs/pricecatdlg.cpp \ - dialogs/aclwin.cpp \ dialogs/flagedit.cpp \ dialogs/wizard.cpp \ - dialogs/orderauditdlg.cpp + dialogs/orderauditdlg.cpp \ + dialogs/backupdlg.cpp RESOURCES += dialogs/dialogfiles.qrc diff --git a/src/dialogs/wizard.cpp b/src/dialogs/wizard.cpp index 875334c..daf11ab 100644 --- a/src/dialogs/wizard.cpp +++ b/src/dialogs/wizard.cpp @@ -19,6 +19,7 @@ #include #include #include +#include MWizard::MWizard(MOverview* parent, Qt::WindowFlags f) :QDialog(parent, f),m_parent(parent) diff --git a/src/mwin/aclwin.cpp b/src/mwin/aclwin.cpp new file mode 100644 index 0000000..8978cb9 --- /dev/null +++ b/src/mwin/aclwin.cpp @@ -0,0 +1,98 @@ +// +// C++ Implementation: acldialog +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2010-2011 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + + +#include "acltabs.h" +#include "msinterface.h" +#include "main.h" + +#include "aclwin.h" + +#include +#include +#include +#include +#include +#include +#include +#include + + +QPointerMAclWindow::instance; + +void MAclWindow::showWindow(QWidget*p) +{ + if(instance.isNull()){ + instance=new MAclWindow(p); + } + if(!instance->isVisible())instance->show(); + if(instance->isMinimized())instance->showNormal(); + instance->activateWindow(); + instance->raise(); +} + +MAclWindow::MAclWindow(QWidget*par) + :QMainWindow(par) +{ + profilekey=req->profileId(); + setAttribute(Qt::WA_DeleteOnClose); + setWindowTitle(tr("MagicSmoke ACL Editor [%1@%2]") .arg(req->currentUser()) .arg(QSettings().value("profiles/"+profilekey+"/name").toString())); + + rtimer.setInterval(QSettings().value("profiles/"+profilekey+"/refresh",300).toInt()*1000); + rtimer.start(); + connect(&rtimer,SIGNAL(timeout()),this,SLOT(refreshData())); + + //menu + QMenuBar*mb=menuBar(); + QMenu*m=mb->addMenu(tr("&Window")); + m->addAction(tr("&Close"),this,SLOT(close())); + + //tabs + setCentralWidget(tab=new QTabWidget); + //user tab + tab->addTab(usertab=new MUserTab(profilekey),tr("Users")); + //role tab + tab->addTab(roletab=new MRoleTab(profilekey),tr("Roles")); + //host tab + tab->addTab(hosttab=new MHostTab(profilekey),tr("Hosts")); + //flags tab + tab->addTab(flagtab=new MFlagTab(profilekey),tr("Flags")); + + mb->addMenu(MApplication::helpMenu()); + + //status bar + statusBar()->setSizeGripEnabled(true); + + //unused tab disabling... + if(!req->hasRight(req->RGetAllUsers)){ + tab->setTabEnabled(tab->indexOf(usertab),false); + } + if(!req->hasRight(req->RGetAllHosts)){ + tab->setTabEnabled(tab->indexOf(hosttab),false); + } + if(!req->hasRight(req->RGetAllRoles)){ + tab->setTabEnabled(tab->indexOf(roletab),false); + } +} + + +void MAclWindow::refreshData() +{ + QSettings set; + set.beginGroup("profiles/"+profilekey); + if(set.value("refreshUsers",false).toBool() && req->hasRight(req->RGetAllUsers)) + usertab->updateUsers(); + if(set.value("refreshHosts",false).toBool() && req->hasRight(req->RGetAllHosts)) + hosttab->updateHosts(); + if(set.value("refreshRoles",false).toBool() && req->hasRight(req->RGetAllRoles)) + roletab->updateRoles(); +} diff --git a/src/mwin/aclwin.h b/src/mwin/aclwin.h new file mode 100644 index 0000000..8c05d9e --- /dev/null +++ b/src/mwin/aclwin.h @@ -0,0 +1,50 @@ +// +// C++ Interface: acldialog +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2010-2011 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#ifndef MAGICSMOKE_ACLWIN_H +#define MAGICSMOKE_ACLWIN_H + +#include +#include +#include + +class MUserTab; +class MHostTab; +class MRoleTab; +class MFlagTab; + +class MAclWindow:public QMainWindow +{ + Q_OBJECT + public: + static void showWindow(QWidget*); + + private slots: + void refreshData(); + private: + MAclWindow(QWidget*); + + static QPointerinstance; + + //the profile associated with this session + QString profilekey; + //widgets + QTabWidget*tab; + MUserTab*usertab; + MHostTab*hosttab; + MRoleTab*roletab; + MFlagTab*flagtab; + //refresh timers + QTimer rtimer; +}; + +#endif diff --git a/src/mwin/carttab.cpp b/src/mwin/carttab.cpp index c24ea38..da74017 100644 --- a/src/mwin/carttab.cpp +++ b/src/mwin/carttab.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -133,9 +134,10 @@ MCartTab::MCartTab(QString pk) updateShipping(); } -QMenu*MCartTab::menu() +QMenuBar*MCartTab::menu() { - QMenu*m=new QMenu(tr("Ca&rt")); + QMenuBar*mb=new QMenuBar; + QMenu*m=mb->addMenu(tr("Ca&rt")); m->addAction(tr("Add &Ticket"),this,SLOT(cartAddTicket())); m->addAction(tr("Add &Voucher"),this,SLOT(cartAddVoucher())); m->addAction(tr("Add &Shop-Item"),this,SLOT(cartAddItem())); @@ -143,7 +145,7 @@ QMenu*MCartTab::menu() m->addAction(tr("&Abort Shopping"),this,SLOT(initCart())); m->addSeparator(); m->addAction(tr("&Update Shipping Options"),this,SLOT(updateShipping())); - return m; + return mb; } MCartTab::~MCartTab() diff --git a/src/mwin/carttab.h b/src/mwin/carttab.h index a1a0c6a..a94bcce 100644 --- a/src/mwin/carttab.h +++ b/src/mwin/carttab.h @@ -50,7 +50,7 @@ class MCartTab:public QWidget MCartTab(QString); /**creates the menu for this tab*/ - QMenu*menu(); + QMenuBar*menu(); /**destructs the tab*/ ~MCartTab(); diff --git a/src/mwin/eventstab.cpp b/src/mwin/eventstab.cpp index c42ca40..2c747f2 100644 --- a/src/mwin/eventstab.cpp +++ b/src/mwin/eventstab.cpp @@ -83,10 +83,11 @@ MEventsTab::MEventsTab(QString pk) } } -QMenu*MEventsTab::menu() +QMenuBar*MEventsTab::menu() { //menu - QMenu*m=new QMenu(tr("&Event")); + QMenuBar*mb=new QMenuBar; + QMenu*m=mb->addMenu(tr("&Event")); m->addAction(tr("&Update Event List"),this,SLOT(updateEvents())) ->setEnabled(req->hasRight(req->RGetAllEvents)); m->addAction(tr("&Show/Edit details..."),this,SLOT(editEvent())) @@ -101,7 +102,7 @@ QMenu*MEventsTab::menu() m->addSeparator(); m->addAction(tr("&Edit Price Categories..."),this,SLOT(editPriceCat())); - return m; + return mb; } diff --git a/src/mwin/eventstab.h b/src/mwin/eventstab.h index f44b813..aaeefff 100644 --- a/src/mwin/eventstab.h +++ b/src/mwin/eventstab.h @@ -41,7 +41,7 @@ class MEventsTab:public QWidget MEventsTab(QString); /**create menu for this tab*/ - QMenu*menu(); + QMenuBar*menu(); /**destruct events list tab*/ ~MEventsTab(); diff --git a/src/mwin/mwin.pri b/src/mwin/mwin.pri index 8ec9504..e4d6f49 100644 --- a/src/mwin/mwin.pri +++ b/src/mwin/mwin.pri @@ -1,5 +1,7 @@ HEADERS += \ + mwin/tabwin.h \ mwin/overview.h \ + mwin/aclwin.h \ mwin/eventstab.h \ mwin/carttab.h \ mwin/orderstab.h \ @@ -7,7 +9,9 @@ HEADERS += \ mwin/acltabs.h SOURCES += \ + mwin/tabwin.cpp \ mwin/overview.cpp \ + mwin/aclwin.cpp \ mwin/eventstab.cpp \ mwin/carttab.cpp \ mwin/orderstab.cpp \ diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index 5855eef..1d31f84 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -17,6 +17,7 @@ #include "shipping.h" #include "templatedlg.h" #include "wizard.h" +#include "backupdlg.h" #include "aclwin.h" #include "carttab.h" @@ -52,10 +53,8 @@ #include 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())); @@ -86,55 +85,26 @@ MOverview::MOverview(QString pk) 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(); @@ -142,25 +112,45 @@ MOverview::MOverview(QString pk) ->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())); @@ -189,7 +179,7 @@ MOverview::~MOverview() void MOverview::switchToCartTab() { - tab->setCurrentWidget(carttab); + setCurrentTab(carttab); } void MOverview::relogin() @@ -223,10 +213,10 @@ void MOverview::editShipping() 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(); } @@ -585,64 +575,3 @@ void MOverview::wizardMode() 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); -} diff --git a/src/mwin/overview.h b/src/mwin/overview.h index 42f4872..01e80ef 100644 --- a/src/mwin/overview.h +++ b/src/mwin/overview.h @@ -19,6 +19,8 @@ #include #include +#include "tabwin.h" + class QAction; class QCheckBox; class QComboBox; @@ -40,7 +42,7 @@ class MUserTab; class MHostTab; /**Main Overview Window*/ -class MOverview:public QMainWindow +class MOverview:public MTabWin { Q_OBJECT public: @@ -110,9 +112,7 @@ class MOverview:public QMainWindow private: friend class MWizard; //the profile associated with this session - QString profilekey; //widgets - QTabWidget*tab; MEventsTab*eventtab; MCartTab*carttab; MOrdersTab*ordertab; @@ -121,21 +121,4 @@ class MOverview:public QMainWindow QTimer rtimer,baktimer; }; -/**Helper class for Backup settings*/ -class MBackupDialog:public QDialog -{ - Q_OBJECT - public: - MBackupDialog(QWidget*,QString); - - private slots: - void getpath(); - void save(); - private: - QLineEdit*lpath; - QSpinBox*interv,*gener; - QCheckBox*autob; - QString profilekey; -}; - #endif diff --git a/src/mwin/tabwin.cpp b/src/mwin/tabwin.cpp new file mode 100644 index 0000000..1143b31 --- /dev/null +++ b/src/mwin/tabwin.cpp @@ -0,0 +1,136 @@ +// +// C++ Implementation: overview +// +// Description: +// +// +// Author: Konrad Rosenbaum , (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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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; +} diff --git a/src/mwin/tabwin.h b/src/mwin/tabwin.h new file mode 100644 index 0000000..02b2643 --- /dev/null +++ b/src/mwin/tabwin.h @@ -0,0 +1,74 @@ +// +// C++ Interface: overview +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2007-2011 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#ifndef MAGICSMOKE_TABWIN_H +#define MAGICSMOKE_TABWIN_H + +#include +#include +#include +#include + +class QTabWidget; +class QStackedWidget; + +class MSInterface; + +/**Main Overview Window*/ +class MTabWin:public QMainWindow +{ + Q_OBJECT + public: + /**construct the window with web-request/session handler and QSettings-key for current profile*/ + MTabWin(QString,QWidget*parent=0); + ~MTabWin(); + protected slots: + /**generic check which tab is active*/ + virtual void tabChanged(int tabid=-1); + + public slots: + ///add a tab + virtual void addTab(QWidget*tab,QString title,QMenuBar*menu=0); + + ///returns a pointer to the left menu bar (normally session/window) + QMenuBar*leftMenu()const{return leftmenu;} + ///returns a pointer to the right menu bar (normally help) + QMenuBar*rightMenu()const{return rightmenu;} + ///returns a pointer to the help menu + QMenu*helpMenu()const; + + ///alias for leftMenu, overrides QMainWindow::menuBar() + QMenuBar*menuBar()const; + + ///enables/disables a tab + void setTabEnabled(QWidget*,bool); + + ///returns the current tab + QWidget* currentTab()const; + + ///set the current tab + void setCurrentTab(QWidget*); + + protected: + //the profile associated with this session + QString profilekey; + private: + //widgets + QTabWidget*tabw; + QMaptabmenu; + int nullmenu; + QStackedWidget*middlemenu; + QMenuBar*leftmenu,*rightmenu; + QPointerhelpmenu; +}; + +#endif -- 1.7.2.5