From e88275f98faf8a829389a7fc7ecd852589181d36 Mon Sep 17 00:00:00 2001 From: konrad Date: Fri, 31 Dec 2010 14:19:53 +0000 Subject: [PATCH] move ACL win to tab win, some minor touch ups git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@698 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/mwin/aclwin.cpp | 25 +++++++++---------------- src/mwin/aclwin.h | 7 +++---- src/mwin/overview.cpp | 40 ++++++++++++++++++++-------------------- src/mwin/tabwin.cpp | 21 ++++++++++++++++++--- src/mwin/tabwin.h | 3 +++ 5 files changed, 53 insertions(+), 43 deletions(-) diff --git a/src/mwin/aclwin.cpp b/src/mwin/aclwin.cpp index 8978cb9..af15d0b 100644 --- a/src/mwin/aclwin.cpp +++ b/src/mwin/aclwin.cpp @@ -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); } } diff --git a/src/mwin/aclwin.h b/src/mwin/aclwin.h index 8c05d9e..fc1fd7e 100644 --- a/src/mwin/aclwin.h +++ b/src/mwin/aclwin.h @@ -17,12 +17,14 @@ #include #include +#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 QPointerinstance; - //the profile associated with this session - QString profilekey; //widgets - QTabWidget*tab; MUserTab*usertab; MHostTab*hosttab; MRoleTab*roletab; diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index 1d31f84..bf49c12 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -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 diff --git a/src/mwin/tabwin.cpp b/src/mwin/tabwin.cpp index 1143b31..64c72ea 100644 --- a/src/mwin/tabwin.cpp +++ b/src/mwin/tabwin.cpp @@ -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()); +} + diff --git a/src/mwin/tabwin.h b/src/mwin/tabwin.h index 02b2643..8bf9f49 100644 --- a/src/mwin/tabwin.h +++ b/src/mwin/tabwin.h @@ -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; -- 1.7.2.5