move ACL win to tab win, some minor touch ups
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 31 Dec 2010 14:19:53 +0000 (14:19 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 31 Dec 2010 14:19:53 +0000 (14:19 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@698 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/mwin/aclwin.cpp
src/mwin/aclwin.h
src/mwin/overview.cpp
src/mwin/tabwin.cpp
src/mwin/tabwin.h

index 8978cb9..af15d0b 100644 (file)
@@ -41,11 +41,10 @@ void MAclWindow::showWindow(QWidget*p)
 }
 
 MAclWindow::MAclWindow(QWidget*par)
-       :QMainWindow(par)
+       :MTabWin(req->profileId(),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()));
+       setWindowTitle(tr("ACL Editor"));
        
        rtimer.setInterval(QSettings().value("profiles/"+profilekey+"/refresh",300).toInt()*1000);
        rtimer.start();
@@ -57,30 +56,24 @@ MAclWindow::MAclWindow(QWidget*par)
        m->addAction(tr("&Close"),this,SLOT(close()));
        
        //tabs
-       setCentralWidget(tab=new QTabWidget);
        //user tab
-       tab->addTab(usertab=new MUserTab(profilekey),tr("Users"));
+       addTab(usertab=new MUserTab(profilekey),tr("Users"));
        //role tab
-       tab->addTab(roletab=new MRoleTab(profilekey),tr("Roles"));
+       addTab(roletab=new MRoleTab(profilekey),tr("Roles"));
        //host tab
-       tab->addTab(hosttab=new MHostTab(profilekey),tr("Hosts"));
+       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);
+       addTab(flagtab=new MFlagTab(profilekey),tr("Flags"));
        
        //unused tab disabling...
        if(!req->hasRight(req->RGetAllUsers)){
-               tab->setTabEnabled(tab->indexOf(usertab),false);
+               setTabEnabled(usertab,false);
        }
        if(!req->hasRight(req->RGetAllHosts)){
-               tab->setTabEnabled(tab->indexOf(hosttab),false);
+               setTabEnabled(hosttab,false);
        }
        if(!req->hasRight(req->RGetAllRoles)){
-               tab->setTabEnabled(tab->indexOf(roletab),false);
+               setTabEnabled(roletab,false);
        }
 }
 
index 8c05d9e..fc1fd7e 100644 (file)
 #include <QPointer>
 #include <QTimer>
 
+#include "tabwin.h"
+
 class MUserTab;
 class MHostTab;
 class MRoleTab;
 class MFlagTab;
 
-class MAclWindow:public QMainWindow
+class MAclWindow:public MTabWin
 {
        Q_OBJECT
        public:
@@ -35,10 +37,7 @@ class MAclWindow:public QMainWindow
                
                static QPointer<MAclWindow>instance;
        
-               //the profile associated with this session
-               QString profilekey;
                //widgets
-               QTabWidget*tab;
                MUserTab*usertab;
                MHostTab*hosttab;
                MRoleTab*roletab;
index 1d31f84..bf49c12 100644 (file)
@@ -81,36 +81,36 @@ MOverview::MOverview(QString pk)
        m->addSeparator();
        m->addAction(tr("Switch to Wizard..."),this,SLOT(wizardMode()));
        m->addSeparator();
-       m->addAction(tr("&Edit Templates..."),this,SLOT(editTemplates()));
-       m->addAction(tr("&Update Templates Now"),req,SLOT(updateTemplates()));
-       m->addSeparator();
        m->addAction(tr("&Close Session"),this,SLOT(close()));
        //menus not connected to any specific tab...
        m=mb->addMenu(tr("&Actions"));
-       m->addSeparator()->setText(tr("Customer"));
-       m->addAction(tr("&Show all customers"),this,SLOT(customerMgmt()));
+       QMenu*m2=m->addMenu(tr("&Customer"));
+       m2->addAction(tr("&Show all customers"),this,SLOT(customerMgmt()));
        
-       m->addSeparator()->setText(tr("Tickets/Vouchers"));
-       m->addAction(tr("Return &ticket or voucher..."),this,SLOT(ticketReturn()))
+       m2=m->addMenu(tr("Tickets and &Vouchers"));
+       m2->addAction(tr("Return &ticket or voucher..."),this,SLOT(ticketReturn()))
         ->setEnabled(req->RReturnTicketVoucher);
-       m->addSeparator();
-       m->addAction(tr("&Deduct from voucher..."),this,SLOT(deductVoucher()));
-       m->addAction(tr("&Empty voucher..."),this,SLOT(emptyVoucher()));
-       m->addSeparator()->setText(tr("Shipping"));
+       m2->addSeparator();
+       m2->addAction(tr("&Deduct from voucher..."),this,SLOT(deductVoucher()));
+       m2->addAction(tr("&Empty voucher..."),this,SLOT(emptyVoucher()));
        m->addAction(tr("Edit &Shipping Options..."),this,SLOT(editShipping()));
        
-       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()));
+       m2=m->addMenu(tr("&Templates"));
+       m2->addAction(tr("&Edit Templates..."),this,SLOT(editTemplates()));
+       m2->addAction(tr("&Update Templates Now"),req,SLOT(updateTemplates()));
+
+       m2=m->addMenu(tr("C&onfiguration"));
+       m2->addAction(tr("&Auto-Refresh settings..."),this,SLOT(setRefresh()));
+       m2->addAction(tr("&Server Access settings..."),this,SLOT(webSettings()));
+       m2->addAction(tr("&Display settings..."),this,SLOT(displaySettings()));
        
-       m->addSeparator()->setText(tr("Administration"));
-       m->addAction(tr("&User Administration..."),this,SLOT(aclWindow()))
+       m2=m->addMenu(tr("&Administration"));
+       m2->addAction(tr("&User Administration..."),this,SLOT(aclWindow()))
         ->setEnabled(req->hasRight(req->RGetAllUsers) || req->hasRight(req->RGetAllHosts) || req->hasRight(req->RGetAllRoles));
-       m->addSeparator();
-       m->addAction(tr("Backup &Settings..."),this,SLOT(backupSettings()))
+       m2->addSeparator();
+       m2->addAction(tr("Backup &Settings..."),this,SLOT(backupSettings()))
         ->setEnabled(req->hasRight(req->RBackup));
-       m->addAction(tr("&Backup now..."),this,SLOT(doBackup()))
+       m2->addAction(tr("&Backup now..."),this,SLOT(doBackup()))
         ->setEnabled(req->hasRight(req->RBackup));
        
        //make sure webrequest knows its settings
index 1143b31..64c72ea 100644 (file)
@@ -57,26 +57,32 @@ MTabWin::MTabWin(QString pk,QWidget*parent)
 {
        profilekey=pk;
        setAttribute(Qt::WA_DeleteOnClose);
-       setWindowTitle("MagicSmoke: "+req->currentUser()+"@"+QSettings().value("profiles/"+pk+"/name").toString());
+       setWindowTitle(QString());
        
        //menu
-       QWidget*mmb=new QWidget;
+       QFrame*mmb=new QFrame;
        setMenuWidget(mmb);
        QHBoxLayout*hl;
        mmb->setLayout(hl=new QHBoxLayout);
+       mmb->setBackgroundRole(QPalette::Button);
+       mmb->setFrameStyle(QFrame::StyledPanel|QFrame::Plain);
        hl->setMargin(0);
+       hl->setContentsMargins(0,0,0,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);
+       middlemenu->setContentsMargins(0,0,0,0);
        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);
+       QWidget*nm;
+       nullmenu=middlemenu->addWidget(nm=new QWidget);
+       nm->setBackgroundRole(QPalette::Button);
        
        //tabs
        setCentralWidget(tabw=new QTabWidget);
@@ -134,3 +140,12 @@ QMenu* MTabWin::helpMenu() const
 {
        return helpmenu;
 }
+
+void MTabWin::setWindowTitle(const QString& t)
+{
+       QString nt;
+       if(t=="")nt="MagicSmoke: ";
+       else nt="MagicSmoke "+t+": ";
+       QMainWindow::setWindowTitle(nt+ req->currentUser()+ "@"+ QSettings().value("profiles/"+ profilekey+ "/name").toString());
+}
+
index 02b2643..8bf9f49 100644 (file)
@@ -58,6 +58,9 @@ class MTabWin:public QMainWindow
                ///set the current tab
                void setCurrentTab(QWidget*);
                
+               ///overrides QWidget::setWindowTitle(const QString&) - adds basic session info
+               void setWindowTitle(const QString&);
+               
        protected:
                //the profile associated with this session
                QString profilekey;