From d60d5448a078ce73d0587e74636843ad12022d31 Mon Sep 17 00:00:00 2001 From: konrad Date: Wed, 23 Feb 2011 20:15:56 +0000 Subject: [PATCH] transform menus to be more mac compatible git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@730 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/dialogs/configdialog.cpp | 1 - src/dialogs/login.cpp | 1 - src/dialogs/orderwin.cpp | 1 - src/images/files.qrc | 1 + src/images/separator.png | Bin 0 -> 221 bytes src/mwin/aclwin.cpp | 4 +-- src/mwin/carttab.cpp | 10 +++--- src/mwin/carttab.h | 2 +- src/mwin/entrancetab.cpp | 10 +++--- src/mwin/entrancetab.h | 4 +- src/mwin/eventstab.cpp | 10 +++--- src/mwin/eventstab.h | 2 +- src/mwin/overview.cpp | 6 +--- src/mwin/tabwin.cpp | 59 +++++++++++++++++------------------------- src/mwin/tabwin.h | 18 ++++-------- src/templates/ticketedit.cpp | 1 - 16 files changed, 53 insertions(+), 77 deletions(-) create mode 100644 src/images/separator.png diff --git a/src/dialogs/configdialog.cpp b/src/dialogs/configdialog.cpp index 4c60af5..2b54711 100644 --- a/src/dialogs/configdialog.cpp +++ b/src/dialogs/configdialog.cpp @@ -57,7 +57,6 @@ MConfigDialog::MConfigDialog() //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())); diff --git a/src/dialogs/login.cpp b/src/dialogs/login.cpp index c31e5b8..f389c51 100644 --- a/src/dialogs/login.cpp +++ b/src/dialogs/login.cpp @@ -39,7 +39,6 @@ MLogin::MLogin() //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")); diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index 64fc160..c71f9d9 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -86,7 +86,6 @@ MOrderWindow::MOrderWindow(QWidget*par,const MOOrder&o) 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())); diff --git a/src/images/files.qrc b/src/images/files.qrc index 754ca34..24bb789 100644 --- a/src/images/files.qrc +++ b/src/images/files.qrc @@ -9,5 +9,6 @@ See COPYING.GPL for details. --> arrowup.png arrowdown.png arrowdiag.png + separator.png diff --git a/src/images/separator.png b/src/images/separator.png new file mode 100644 index 0000000000000000000000000000000000000000..ea928431d20d5005a7d8df12210c27ebec978a92 GIT binary patch literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QjEnx?oJHr&dIz4a@dl*-CY>| zgW!U_%O?XxI14-?iy0WWg+Z8+Vb&Z8pdfpRr>`sfZ6`;xTgNlt=z-kOf} z7q>F3R-UP{`PLl1PL7@iJ!Uo@34;%!0cx76PoLbsetNativeMenuBar(false); - QMenu*m=mb->addMenu(tr("&Window")); + QMenu*m=addMenu(tr("&Window")); m->addAction(tr("&Close"),this,SLOT(close())); //tabs diff --git a/src/mwin/carttab.cpp b/src/mwin/carttab.cpp index 943d412..0329b41 100644 --- a/src/mwin/carttab.cpp +++ b/src/mwin/carttab.cpp @@ -134,11 +134,11 @@ MCartTab::MCartTab(QString pk) updateShipping(); } -QMenuBar*MCartTab::menu() +QListMCartTab::menu() { - QMenuBar*mb=new QMenuBar; - mb->setNativeMenuBar(false); - QMenu*m=mb->addMenu(tr("Ca&rt")); + QListret; + QMenu*m=new QMenu(tr("Ca&rt")); + ret<addAction(tr("Add &Ticket"),this,SLOT(cartAddTicket())); m->addAction(tr("Add &Voucher"),this,SLOT(cartAddVoucher())); m->addAction(tr("Add &Shop-Item"),this,SLOT(cartAddItem())); @@ -146,7 +146,7 @@ QMenuBar*MCartTab::menu() 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() diff --git a/src/mwin/carttab.h b/src/mwin/carttab.h index a94bcce..d177975 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*/ - QMenuBar*menu(); + QListmenu(); /**destructs the tab*/ ~MCartTab(); diff --git a/src/mwin/entrancetab.cpp b/src/mwin/entrancetab.cpp index 1421928..4377fd4 100644 --- a/src/mwin/entrancetab.cpp +++ b/src/mwin/entrancetab.cpp @@ -85,14 +85,14 @@ MEntranceTab::MEntranceTab(QString pk) tm->start(10000); } -QMenuBar* MEntranceTab::menu() const +QList MEntranceTab::menu() const { - QMenuBar *mb=new QMenuBar; - mb->setNativeMenuBar(false); - QMenu*m=mb->addMenu("&Entrance"); + QListret; + QMenu*m=new QMenu("&Entrance"); + ret<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*/ diff --git a/src/mwin/entrancetab.h b/src/mwin/entrancetab.h index 013c70d..ab25294 100644 --- a/src/mwin/entrancetab.h +++ b/src/mwin/entrancetab.h @@ -16,7 +16,7 @@ #include #include -class QMenuBar; +class QMenu; class QComboBox; class QLabel; class QLineEdit; @@ -34,7 +34,7 @@ class MEntranceTab:public QWidget MEntranceTab(QString); ///creates a menu for the entrance tab - QMenuBar*menu()const; + QListmenu()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*/ diff --git a/src/mwin/eventstab.cpp b/src/mwin/eventstab.cpp index e6e9b7b..8ba0e67 100644 --- a/src/mwin/eventstab.cpp +++ b/src/mwin/eventstab.cpp @@ -83,12 +83,12 @@ MEventsTab::MEventsTab(QString pk) } } -QMenuBar*MEventsTab::menu() +QListMEventsTab::menu() { //menu - QMenuBar*mb=new QMenuBar; - mb->setNativeMenuBar(false); - QMenu*m=mb->addMenu(tr("&Event")); + QListret; + QMenu*m=new QMenu(tr("&Event")); + ret<addAction(tr("&Update Event List"),this,SLOT(updateEvents())) ->setEnabled(req->hasRight(req->RGetAllEvents)); m->addAction(tr("&Show/Edit details..."),this,SLOT(editEvent())) @@ -103,7 +103,7 @@ QMenuBar*MEventsTab::menu() m->addSeparator(); m->addAction(tr("&Edit Price Categories..."),this,SLOT(editPriceCat())); - return mb; + return ret; } diff --git a/src/mwin/eventstab.h b/src/mwin/eventstab.h index aaeefff..3de1149 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*/ - QMenuBar*menu(); + QListmenu(); /**destruct events list tab*/ ~MEventsTab(); diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index d6b4531..fd8703e 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -73,9 +73,7 @@ MOverview::MOverview(QString pk) } //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)); @@ -84,7 +82,7 @@ MOverview::MOverview(QString pk) 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")); diff --git a/src/mwin/tabwin.cpp b/src/mwin/tabwin.cpp index fb92e41..c7591c6 100644 --- a/src/mwin/tabwin.cpp +++ b/src/mwin/tabwin.cpp @@ -60,31 +60,14 @@ MTabWin::MTabWin(QString pk,QWidget*parent) 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); @@ -103,26 +86,32 @@ 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); + QListtabs=tabmenu.keys(); + for(int i=0;imenuAction()->setVisible(tabs[i]==idx); + } + } } -void MTabWin::addTab(QWidget* tw, QString title, QMenuBar* menu) +void MTabWin::addTab(QWidget* tw, QString title, QList 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(); diff --git a/src/mwin/tabwin.h b/src/mwin/tabwin.h index 8bf9f49..9ad3590 100644 --- a/src/mwin/tabwin.h +++ b/src/mwin/tabwin.h @@ -37,18 +37,14 @@ class MTabWin:public QMainWindow public slots: ///add a tab - virtual void addTab(QWidget*tab,QString title,QMenuBar*menu=0); + virtual void addTab(QWidget*tab,QString title,QListmenu=QList()); + + ///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); @@ -67,10 +63,8 @@ class MTabWin:public QMainWindow private: //widgets QTabWidget*tabw; - QMaptabmenu; - int nullmenu; - QStackedWidget*middlemenu; - QMenuBar*leftmenu,*rightmenu; + QMap >tabmenu; + QPointerhelpseparator,leftseparator; QPointerhelpmenu; }; diff --git a/src/templates/ticketedit.cpp b/src/templates/ticketedit.cpp index eacee75..bb655f3 100644 --- a/src/templates/ticketedit.cpp +++ b/src/templates/ticketedit.cpp @@ -164,7 +164,6 @@ MTicketEditor::MTicketEditor(QWidget* parent, Qt::WindowFlags f): QMainWindow(pa { //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)); -- 1.7.2.5