From 803959759a66d01d44d9e07b38f4220a93e57a2c Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 19 Feb 2017 10:36:55 +0100 Subject: Added Menus and Globals --- beetplayer.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'beetplayer.cpp') diff --git a/beetplayer.cpp b/beetplayer.cpp index 4e4c532..5402b80 100644 --- a/beetplayer.cpp +++ b/beetplayer.cpp @@ -3,10 +3,13 @@ #include #include #include +#include +#include #include "beetplayer.h" #include "configurationdialog.h" #include "indexerwidget.h" +#include "globals.h" BeetPlayer::BeetPlayer(QWidget *parent, Qt::WindowFlags f) : QMainWindow(parent, f) { //general setup @@ -14,11 +17,17 @@ BeetPlayer::BeetPlayer(QWidget *parent, Qt::WindowFlags f) : QMainWindow(parent, setMinimumWidth(1024); setMinimumHeight(768); openDatabase(); + createGlobalActions(); //tabs mTab = new QTabWidget; IndexerWidget *indexer = new IndexerWidget; mTab->addTab(indexer, tr("Indexer")); + connect(mTab, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); + menuBar()->clear(); + foreach(QMenu* m, indexer->menus()){ + menuBar()->addMenu(m); + } //layout QHBoxLayout *mainLayout = new QHBoxLayout; @@ -26,6 +35,12 @@ BeetPlayer::BeetPlayer(QWidget *parent, Qt::WindowFlags f) : QMainWindow(parent, setCentralWidget(mTab); } +void BeetPlayer::tabChanged(int tab){ + if(tab == 0){ //replace with indexer + //do something;; + } +} + void BeetPlayer::openDatabase(){ QSettings s; QString dbhost = s.value("dbhost").toString(); @@ -49,3 +64,23 @@ void BeetPlayer::openDatabase(){ } } } + +void BeetPlayer::createGlobalActions(){ + QAction *quitA = new QAction(tr("Quit"), this); + quitA->setShortcut(tr("CTRL+Q")); + connect(quitA, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); + quitA->setData(Globals::QuitAction); + Globals::instance()->addAction(quitA); + QAction *configA = new QAction(QIcon(":/chastity_belt.png"), tr("Configure..."), this); + connect(configA, SIGNAL(triggered()), this, SLOT(configure())); + configA->setData(Globals::ConfigAction); + Globals::instance()->addAction(configA); +} + +void BeetPlayer::configure(){ + ConfigurationDialog w(this); + int res = w.exec(); + if(res == QDialog::Accepted){ + openDatabase(); + } +} -- cgit v1.2.3-70-g09d2