start refactoring menus and tabs
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Thu, 30 Dec 2010 14:11:06 +0000 (14:11 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Thu, 30 Dec 2010 14:11:06 +0000 (14:11 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@697 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

15 files changed:
src/dialogs/backupdlg.cpp [new file with mode: 0644]
src/dialogs/backupdlg.h [new file with mode: 0644]
src/dialogs/dialogs.pri
src/dialogs/wizard.cpp
src/mwin/aclwin.cpp [moved from src/dialogs/aclwin.cpp with 100% similarity]
src/mwin/aclwin.h [moved from src/dialogs/aclwin.h with 100% similarity]
src/mwin/carttab.cpp
src/mwin/carttab.h
src/mwin/eventstab.cpp
src/mwin/eventstab.h
src/mwin/mwin.pri
src/mwin/overview.cpp
src/mwin/overview.h
src/mwin/tabwin.cpp [new file with mode: 0644]
src/mwin/tabwin.h [new file with mode: 0644]

diff --git a/src/dialogs/backupdlg.cpp b/src/dialogs/backupdlg.cpp
new file mode 100644 (file)
index 0000000..483abcc
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// 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);
+}
diff --git a/src/dialogs/backupdlg.h b/src/dialogs/backupdlg.h
new file mode 100644 (file)
index 0000000..0f43e73
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// C++ Interface: overview
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2011
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#ifndef MAGICSMOKE_BACKUPDLG_H
+#define MAGICSMOKE_BACKUPDLG_H
+
+#include <QDialog>
+
+#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
index 944c269..2f57877 100644 (file)
@@ -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
 
index 875334c..daf11ab 100644 (file)
@@ -19,6 +19,7 @@
 #include <QStackedLayout>
 #include <QPushButton>
 #include <QSignalMapper>
+#include <QMenu>
 
 MWizard::MWizard(MOverview* parent, Qt::WindowFlags f)
        :QDialog(parent, f),m_parent(parent)
similarity index 100%
rename from src/dialogs/aclwin.cpp
rename to src/mwin/aclwin.cpp
similarity index 100%
rename from src/dialogs/aclwin.h
rename to src/mwin/aclwin.h
index c24ea38..da74017 100644 (file)
@@ -25,6 +25,7 @@
 #include <QFrame>
 #include <QLabel>
 #include <QMenu>
+#include <QMenuBar>
 #include <QMessageBox>
 #include <QPushButton>
 #include <QSettings>
@@ -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()
index a1a0c6a..a94bcce 100644 (file)
@@ -50,7 +50,7 @@ class MCartTab:public QWidget
                MCartTab(QString);
                
                /**creates the menu for this tab*/
-               QMenu*menu();
+               QMenuBar*menu();
                
                /**destructs the tab*/
                ~MCartTab();
index c42ca40..2c747f2 100644 (file)
@@ -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;
 }
 
 
index f44b813..aaeefff 100644 (file)
@@ -41,7 +41,7 @@ class MEventsTab:public QWidget
                MEventsTab(QString);
                
                /**create menu for this tab*/
-               QMenu*menu();
+               QMenuBar*menu();
                
                /**destruct events list tab*/
                ~MEventsTab();
index 8ec9504..e4d6f49 100644 (file)
@@ -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 \
index 5855eef..1d31f84 100644 (file)
@@ -17,6 +17,7 @@
 #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()));
@@ -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);
-}
index 42f4872..01e80ef 100644 (file)
@@ -19,6 +19,8 @@
 #include <QMainWindow>
 #include <QTimer>
 
+#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 (file)
index 0000000..1143b31
--- /dev/null
@@ -0,0 +1,136 @@
+//
+// 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;
+}
diff --git a/src/mwin/tabwin.h b/src/mwin/tabwin.h
new file mode 100644 (file)
index 0000000..02b2643
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// C++ Interface: overview
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2011
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#ifndef MAGICSMOKE_TABWIN_H
+#define MAGICSMOKE_TABWIN_H
+
+#include <QMainWindow>
+#include <QMap>
+#include <QPointer>
+#include <QTimer>
+
+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;
+               QMap<int,int>tabmenu;
+               int nullmenu;
+               QStackedWidget*middlemenu;
+               QMenuBar*leftmenu,*rightmenu;
+               QPointer<QMenu>helpmenu;
+};
+
+#endif