//create Menu Bar
QMenuBar*mb;
hl->setMenuBar(mb=new QMenuBar);
- mb->setNativeMenuBar(false);
QMenu*m=mb->addMenu(tr("&Profile"));
m->addAction(tr("&New Profile..."),this,SLOT(newProfile()));
m->addAction(tr("&Delete Profile"),this,SLOT(deleteProfile()));
//create Menu Bar
QMenuBar*mb;
vl->setMenuBar(mb=new QMenuBar);
- mb->setNativeMenuBar(false);
QMenu*m=mb->addMenu(tr("&File"));
m->addAction(tr("&Exit"),this,SLOT(close()));
m=mb->addMenu(tr("&Configure"));
m_changed=false;
QMenuBar*mb=menuBar();
- mb->setNativeMenuBar(false);
QMenu *m=mb->addMenu(tr("&Order"));
m_res2order=m->addAction(tr("&Order..."),this,SLOT(createOrder()));
m_cancel=m->addAction(tr("C&ancel Order..."),this,SLOT(cancelOrder()));
<file>arrowup.png</file>
<file>arrowdown.png</file>
<file>arrowdiag.png</file>
+ <file>separator.png</file>
</qresource>
</RCC>
connect(&rtimer,SIGNAL(timeout()),this,SLOT(refreshData()));
//menu
- QMenuBar*mb=menuBar();
- mb->setNativeMenuBar(false);
- QMenu*m=mb->addMenu(tr("&Window"));
+ QMenu*m=addMenu(tr("&Window"));
m->addAction(tr("&Close"),this,SLOT(close()));
//tabs
updateShipping();
}
-QMenuBar*MCartTab::menu()
+QList<QMenu*>MCartTab::menu()
{
- QMenuBar*mb=new QMenuBar;
- mb->setNativeMenuBar(false);
- QMenu*m=mb->addMenu(tr("Ca&rt"));
+ QList<QMenu*>ret;
+ QMenu*m=new QMenu(tr("Ca&rt"));
+ ret<<m;
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()));
m->addAction(tr("&Abort Shopping"),this,SLOT(initCart()));
m->addSeparator();
m->addAction(tr("&Update Shipping Options"),this,SLOT(updateShipping()));
- return mb;
+ return ret;
}
MCartTab::~MCartTab()
MCartTab(QString);
/**creates the menu for this tab*/
- QMenuBar*menu();
+ QList<QMenu*>menu();
/**destructs the tab*/
~MCartTab();
tm->start(10000);
}
-QMenuBar* MEntranceTab::menu() const
+QList<QMenu*> MEntranceTab::menu() const
{
- QMenuBar *mb=new QMenuBar;
- mb->setNativeMenuBar(false);
- QMenu*m=mb->addMenu("&Entrance");
+ QList<QMenu*>ret;
+ QMenu*m=new QMenu("&Entrance");
+ ret<<m;
m->addAction("&Configure...",this,SLOT(configure()));
m->addAction("&Recheck events",this,SLOT(initialize()));
- return mb;
+ return ret;
}
/**while the object lives the tab handed to it is disabled, it automatically reenables when the disable object dies; it also refocuses the scan line*/
#include <QDateTime>
#include <QWidget>
-class QMenuBar;
+class QMenu;
class QComboBox;
class QLabel;
class QLineEdit;
MEntranceTab(QString);
///creates a menu for the entrance tab
- QMenuBar*menu()const;
+ QList<QMenu*>menu()const;
public slots:
/**initializes the tab
\param force if true an update is forced, if false the update is only done if the last update has been more than an hour in the past*/
}
}
-QMenuBar*MEventsTab::menu()
+QList<QMenu*>MEventsTab::menu()
{
//menu
- QMenuBar*mb=new QMenuBar;
- mb->setNativeMenuBar(false);
- QMenu*m=mb->addMenu(tr("&Event"));
+ QList<QMenu*>ret;
+ QMenu*m=new QMenu(tr("&Event"));
+ ret<<m;
m->addAction(tr("&Update Event List"),this,SLOT(updateEvents()))
->setEnabled(req->hasRight(req->RGetAllEvents));
m->addAction(tr("&Show/Edit details..."),this,SLOT(editEvent()))
m->addSeparator();
m->addAction(tr("&Edit Price Categories..."),this,SLOT(editPriceCat()));
- return mb;
+ return ret;
}
MEventsTab(QString);
/**create menu for this tab*/
- QMenuBar*menu();
+ QList<QMenu*>menu();
/**destruct events list tab*/
~MEventsTab();
}
//menu
- QMenuBar*mb=menuBar();
- mb->setNativeMenuBar(false);
- QMenu*m=mb->addMenu(tr("&Session"));
+ QMenu*m=addMenu(tr("&Session"));
m->addAction(tr("&Re-Login"),this,SLOT(relogin()));
m->addAction(tr("Change my &Password"),this,SLOT(setMyPassword()))
->setEnabled(req->hasRight(req->RChangeMyPassword));
m->addSeparator();
m->addAction(tr("&Close Session"),this,SLOT(close()));
//menus not connected to any specific tab...
- m=mb->addMenu(tr("&Actions"));
+ m=addMenu(tr("&Actions"));
m->addAction(tr("&Show all customers"),this,SLOT(customerMgmt()));
QMenu*m2=m->addMenu(tr("Tickets and &Vouchers"));
setWindowTitle(QString());
//menu
- 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);
- leftmenu->setNativeMenuBar(false);
- 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->setNativeMenuBar(false);
-
- rightmenu->addMenu(helpmenu=MApplication::helpMenu());
-
- QWidget*nm;
- nullmenu=middlemenu->addWidget(nm=new QWidget);
- nm->setBackgroundRole(QPalette::Button);
+ QMenuBar*mb=menuBar();
+ leftseparator=mb->addAction("|");
+ leftseparator->setIcon(QIcon(":/separator.png"));
+ leftseparator->setEnabled(false);
+ helpseparator=mb->addAction("|");
+ helpseparator->setIcon(QIcon(":/separator.png"));
+ helpseparator->setEnabled(false);
+ mb->addMenu(helpmenu=MApplication::helpMenu());
//tabs
setCentralWidget(tabw=new QTabWidget);
void MTabWin::tabChanged(int idx)
{
if(idx<0)idx=tabw->currentIndex();
- if(tabmenu.contains(idx))
- middlemenu->setCurrentIndex(tabmenu[idx]);
- else
- middlemenu->setCurrentIndex(nullmenu);
+ QList<int>tabs=tabmenu.keys();
+ for(int i=0;i<tabs.size();i++){
+ for(int j=0;j<tabmenu[tabs[i]].size();j++){
+ tabmenu[tabs[i]][j]->menuAction()->setVisible(tabs[i]==idx);
+ }
+ }
}
-void MTabWin::addTab(QWidget* tw, QString title, QMenuBar* menu)
+void MTabWin::addTab(QWidget* tw, QString title, QList<QMenu*> menu)
{
int idx=tabw->addTab(tw,title);
- if(menu){
- int midx=middlemenu->addWidget(menu);
- tabmenu.insert(idx,midx);
+ tabmenu.insert(idx,menu);
+ QMenuBar*mb=menuBar();
+ for(int i=menu.size()-1;i>=0;i--){
+ mb->insertMenu(helpseparator,menu[i]);
}
}
-QMenuBar* MTabWin::menuBar() const
+QMenu* MTabWin::addMenu(QString l)
{
- return leftMenu();
+ QMenu*m;
+ menuBar()->insertMenu(leftseparator,m=new QMenu(l));
+ return m;
}
+
QWidget* MTabWin::currentTab() const
{
return tabw->currentWidget();
public slots:
///add a tab
- virtual void addTab(QWidget*tab,QString title,QMenuBar*menu=0);
+ virtual void addTab(QWidget*tab,QString title,QList<QMenu*>menu=QList<QMenu*>());
+
+ ///add a menu to the left
+ virtual QMenu* addMenu(QString);
- ///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);
private:
//widgets
QTabWidget*tabw;
- QMap<int,int>tabmenu;
- int nullmenu;
- QStackedWidget*middlemenu;
- QMenuBar*leftmenu,*rightmenu;
+ QMap<int,QList<QMenu*> >tabmenu;
+ QPointer<QAction>helpseparator,leftseparator;
QPointer<QMenu>helpmenu;
};
{
//menu
QMenuBar*mb=menuBar();
- mb->setNativeMenuBar(false);
QMenu*m=mb->addMenu(tr("&File"));
m->addAction(tr("&Open File..."),this,SLOT(openFile()))
->setShortcut(QKeySequence(Qt::Key_Control|Qt::Key_O));