transform menus to be more mac compatible
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Wed, 23 Feb 2011 20:15:56 +0000 (20:15 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Wed, 23 Feb 2011 20:15:56 +0000 (20:15 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@730 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

16 files changed:
src/dialogs/configdialog.cpp
src/dialogs/login.cpp
src/dialogs/orderwin.cpp
src/images/files.qrc
src/images/separator.png [new file with mode: 0644]
src/mwin/aclwin.cpp
src/mwin/carttab.cpp
src/mwin/carttab.h
src/mwin/entrancetab.cpp
src/mwin/entrancetab.h
src/mwin/eventstab.cpp
src/mwin/eventstab.h
src/mwin/overview.cpp
src/mwin/tabwin.cpp
src/mwin/tabwin.h
src/templates/ticketedit.cpp

index 4c60af5..2b54711 100644 (file)
@@ -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()));
index c31e5b8..f389c51 100644 (file)
@@ -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"));
index 64fc160..c71f9d9 100644 (file)
@@ -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()));
index 754ca34..24bb789 100644 (file)
@@ -9,5 +9,6 @@ See COPYING.GPL for details. -->
         <file>arrowup.png</file>
         <file>arrowdown.png</file>
         <file>arrowdiag.png</file>
+        <file>separator.png</file>
     </qresource>
 </RCC>
diff --git a/src/images/separator.png b/src/images/separator.png
new file mode 100644 (file)
index 0000000..ea92843
Binary files /dev/null and b/src/images/separator.png differ
index f3fe337..dc59254 100644 (file)
@@ -51,9 +51,7 @@ MAclWindow::MAclWindow(QWidget*par)
        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
index 943d412..0329b41 100644 (file)
@@ -134,11 +134,11 @@ MCartTab::MCartTab(QString pk)
        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()));
@@ -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()
index a94bcce..d177975 100644 (file)
@@ -50,7 +50,7 @@ class MCartTab:public QWidget
                MCartTab(QString);
                
                /**creates the menu for this tab*/
-               QMenuBar*menu();
+               QList<QMenu*>menu();
                
                /**destructs the tab*/
                ~MCartTab();
index 1421928..4377fd4 100644 (file)
@@ -85,14 +85,14 @@ MEntranceTab::MEntranceTab(QString pk)
        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*/
index 013c70d..ab25294 100644 (file)
@@ -16,7 +16,7 @@
 #include <QDateTime>
 #include <QWidget>
 
-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;
+               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*/
index e6e9b7b..8ba0e67 100644 (file)
@@ -83,12 +83,12 @@ MEventsTab::MEventsTab(QString pk)
        }
 }
 
-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()))
@@ -103,7 +103,7 @@ QMenuBar*MEventsTab::menu()
        m->addSeparator();
        m->addAction(tr("&Edit Price Categories..."),this,SLOT(editPriceCat()));
        
-       return mb;
+       return ret;
 }
 
 
index aaeefff..3de1149 100644 (file)
@@ -41,7 +41,7 @@ class MEventsTab:public QWidget
                MEventsTab(QString);
                
                /**create menu for this tab*/
-               QMenuBar*menu();
+               QList<QMenu*>menu();
                
                /**destruct events list tab*/
                ~MEventsTab();
index d6b4531..fd8703e 100644 (file)
@@ -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"));
index fb92e41..c7591c6 100644 (file)
@@ -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);
+       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();
index 8bf9f49..9ad3590 100644 (file)
@@ -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,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);
                
@@ -67,10 +63,8 @@ class MTabWin:public QMainWindow
        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;
 };
 
index eacee75..bb655f3 100644 (file)
@@ -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));