diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-01-12 19:02:25 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-01-12 19:02:25 +0000 |
| commit | 903b18a193ea4a647b0ac2eaf8698e5c6b3bff7a (patch) | |
| tree | 976de1e4031a232700d9c38fb24aec7288825f47 /src/qmmpui/generalhandler.cpp | |
| parent | 3cc0b2fa0f81e2ee09c3ae3d92d31c88ac5b9b6b (diff) | |
| download | qmmp-903b18a193ea4a647b0ac2eaf8698e5c6b3bff7a.tar.gz qmmp-903b18a193ea4a647b0ac2eaf8698e5c6b3bff7a.tar.bz2 qmmp-903b18a193ea4a647b0ac2eaf8698e5c6b3bff7a.zip | |
menu support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@741 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui/generalhandler.cpp')
| -rw-r--r-- | src/qmmpui/generalhandler.cpp | 91 |
1 files changed, 69 insertions, 22 deletions
diff --git a/src/qmmpui/generalhandler.cpp b/src/qmmpui/generalhandler.cpp index b371b8253..a7876173e 100644 --- a/src/qmmpui/generalhandler.cpp +++ b/src/qmmpui/generalhandler.cpp @@ -19,6 +19,10 @@ ***************************************************************************/ #include <QDialog> +#include <QMenu> +#include <QWidget> +#include <QAction> + #include "general.h" #include "generalfactory.h" #include "commandlinemanager.h" @@ -31,15 +35,9 @@ GeneralHandler::GeneralHandler(QObject *parent) : QObject(parent) { m_instance = this; - /*m_left = 0; - m_right = 0; - m_time = 0; - m_state = General::Stopped;*/ + m_toolsMenu = 0; + m_playlistMenu = 0; GeneralFactory* factory; - //m_control = new Control(this); - /*connect(m_control, SIGNAL(commandCalled(uint)), SLOT(processCommand(uint))); - connect(m_control, SIGNAL(seekCalled(int)), SIGNAL(seekCalled(int))); - connect(m_control, SIGNAL(volumeChanged(int, int)), SIGNAL(volumeChanged(int, int)));*/ foreach(factory, *General::generalFactories()) { if (General::isEnabled(factory)) @@ -67,13 +65,6 @@ void GeneralHandler::setEnabled(GeneralFactory* factory, bool enable) connect (general, SIGNAL(toggleVisibilityCalled()), SIGNAL(toggleVisibilityCalled())); connect (general, SIGNAL(exitCalled()), SIGNAL(exitCalled())); m_generals.insert(factory, general); - //general->setVolume(m_left, m_right); - /*if (m_state != General::Stopped) - { - general->setState(m_state); - general->setSongInfo(m_songInfo); - general->setTime(m_time); - }*/ } else { @@ -96,12 +87,6 @@ void GeneralHandler::showSettings(GeneralFactory* factory, QWidget* parentWidget connect (general, SIGNAL(toggleVisibilityCalled()), SIGNAL(toggleVisibilityCalled())); connect (general, SIGNAL(exitCalled()), SIGNAL(exitCalled())); m_generals[factory] = general; - /*general->setVolume(m_left, m_right); - if (m_state != General::Stopped) - { - general->setState(m_state); - general->setSongInfo(m_songInfo); - }*/ } dialog->deleteLater(); } @@ -119,10 +104,72 @@ bool GeneralHandler::visibilityControl() void GeneralHandler::executeCommand(const QString &opt_str) { - if(CommandLineManager::hasOption(opt_str)) + if (CommandLineManager::hasOption(opt_str)) m_commandLineManager->executeCommand(opt_str); } +void GeneralHandler::addAction(QAction *action, MenuType type) +{ + switch ((int) type) + { + case TOOLS_MENU: + if (!m_toolsActions.contains(action)) + m_toolsActions.append(action); + if (m_toolsMenu && !m_toolsMenu->actions ().contains(action)) + m_toolsMenu->addAction(action); + break; + case PLAYLIST_MENU: + if (!m_playlistActions.contains(action)) + m_playlistActions.append(action); + if (m_playlistMenu && !m_playlistMenu->actions ().contains(action)) + m_playlistMenu->addAction(action); + } +} + +void GeneralHandler::removeAction(QAction *action) +{ + m_toolsActions.removeAll(action); + if (m_toolsMenu) + m_toolsMenu->removeAction(action); + m_playlistActions.removeAll(action); + if (m_playlistMenu) + m_playlistMenu->removeAction(action); +} + +QList<QAction *> GeneralHandler::actions(MenuType type) +{ + if (type == TOOLS_MENU) + return m_toolsActions; + else + return m_playlistActions; +} + +QMenu *GeneralHandler::createMenu(MenuType type, const QString &title, QWidget *parent) +{ + switch ((int) type) + { + case TOOLS_MENU: + if (!m_toolsMenu) + { + m_toolsMenu = new QMenu(title, parent); + m_toolsMenu->addActions(m_toolsActions); + } + else + m_toolsMenu->setTitle(title); + return m_toolsMenu.data(); + case PLAYLIST_MENU: + if (!m_playlistMenu) + { + m_playlistMenu = new QMenu(title, parent); + m_playlistMenu->addActions(m_toolsActions); + } + else + m_playlistMenu->setTitle(title); + return m_playlistMenu.data(); + } + return 0; +} + GeneralHandler* GeneralHandler::instance() { return m_instance; |
