diff options
Diffstat (limited to 'src/qmmpui')
| -rw-r--r-- | src/qmmpui/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/qmmpui/commandlinemanager.cpp | 4 | ||||
| -rw-r--r-- | src/qmmpui/general.cpp | 5 | ||||
| -rw-r--r-- | src/qmmpui/general.h | 15 | ||||
| -rw-r--r-- | src/qmmpui/qmmpui.pro | 12 | ||||
| -rw-r--r-- | src/qmmpui/uihelper.cpp (renamed from src/qmmpui/generalhandler.cpp) | 44 | ||||
| -rw-r--r-- | src/qmmpui/uihelper.h (renamed from src/qmmpui/generalhandler.h) | 27 |
7 files changed, 47 insertions, 66 deletions
diff --git a/src/qmmpui/CMakeLists.txt b/src/qmmpui/CMakeLists.txt index f4692e4fd..0f7884c23 100644 --- a/src/qmmpui/CMakeLists.txt +++ b/src/qmmpui/CMakeLists.txt @@ -24,7 +24,7 @@ link_directories(${CMAKE_CURRENT_BINARY_DIR}/../qmmp) SET(libqmmpui_SRCS general.cpp - generalhandler.cpp + uihelper.cpp playlistparser.cpp commandlinemanager.cpp filedialog.cpp @@ -46,7 +46,7 @@ SET(libqmmpui_SRCS SET(libqmmpui_MOC_HDRS generalfactory.h general.h - generalhandler.h + uihelper.h playlistparser.h playlistformat.h commandlinemanager.h @@ -72,7 +72,7 @@ SET(libqmmpui_MOC_HDRS SET(libqmmpui_DEVEL_HDRS generalfactory.h general.h - generalhandler.h + uihelper.h playlistformat.h playlistparser.h commandlinemanager.h diff --git a/src/qmmpui/commandlinemanager.cpp b/src/qmmpui/commandlinemanager.cpp index fde1da6d4..e4e8dfab1 100644 --- a/src/qmmpui/commandlinemanager.cpp +++ b/src/qmmpui/commandlinemanager.cpp @@ -26,7 +26,7 @@ #include <iostream> #include <qmmp/qmmp.h> #include <qmmp/soundcore.h> -#include <qmmpui/generalhandler.h> +#include <qmmpui/uihelper.h> #include <qmmpui/mediaplayer.h> #include "commandlinemanager.h" @@ -70,7 +70,7 @@ void CommandLineManager::checkOptions() QString CommandLineManager::executeCommand(const QString& opt_str, const QStringList &args) { checkOptions(); - if(!GeneralHandler::instance() || !SoundCore::instance() || !MediaPlayer::instance()) + if(!UiHelper::instance() || !SoundCore::instance() || !MediaPlayer::instance()) { qWarning("CommandLineManager: player objects are not created"); return QString(); diff --git a/src/qmmpui/general.cpp b/src/qmmpui/general.cpp index 2c9bef7c4..ebe462715 100644 --- a/src/qmmpui/general.cpp +++ b/src/qmmpui/general.cpp @@ -69,11 +69,6 @@ General::General(QObject *parent) General::~General() {} -void General::exit() -{ - emit exitCalled(); -} - QList<GeneralFactory*> *General::factories() { checkFactories(); diff --git a/src/qmmpui/general.h b/src/qmmpui/general.h index 4c80c3de1..96d69b72a 100644 --- a/src/qmmpui/general.h +++ b/src/qmmpui/general.h @@ -61,21 +61,6 @@ public: */ static bool isEnabled(GeneralFactory* factory); -signals: - /*! - * Emitted when exit() slot is called. - */ - void exitCalled(); - /*! - * Emitted when toggleVisibility() slot is called. - */ - void toggleVisibilityCalled(); - -public slots: - /*! - * Tells the player to exit. - */ - void exit(); private: QMap <uint, QString> m_strValues; diff --git a/src/qmmpui/qmmpui.pro b/src/qmmpui/qmmpui.pro index b5fa05251..01bda0ae2 100644 --- a/src/qmmpui/qmmpui.pro +++ b/src/qmmpui/qmmpui.pro @@ -20,7 +20,6 @@ VERSION = $$QMMP_VERSION unix:target.path = $$LIB_DIR HEADERS += general.h \ generalfactory.h \ - generalhandler.h \ playlistformat.h \ playlistparser.h \ commandlinemanager.h \ @@ -40,9 +39,9 @@ HEADERS += general.h \ metadataformatter.h \ templateeditor.h \ uifactory.h \ - uiloader.h + uiloader.h \ + uihelper.h SOURCES += general.cpp \ - generalhandler.cpp \ playlistparser.cpp \ commandlinemanager.cpp \ filedialog.cpp \ @@ -58,7 +57,8 @@ SOURCES += general.cpp \ playlistmanager.cpp \ metadataformatter.cpp \ templateeditor.cpp \ - uiloader.cpp + uiloader.cpp \ + uihelper.cpp FORMS += forms/detailsdialog.ui \ forms/tageditor.ui \ forms/templateeditor.ui @@ -81,7 +81,6 @@ TRANSLATIONS = translations/libqmmpui_ru.ts \ unix { devel.files += general.h \ generalfactory.h \ - generalhandler.h \ playlistformat.h \ playlistparser.h \ commandlinemanager.h \ @@ -96,7 +95,8 @@ unix { metadataformatter.h \ templateeditor.h \ uifactory.h \ - uiloader.h + uiloader.h \ + uihelper.h devel.path = /include/qmmpui INSTALLS += target \ devel diff --git a/src/qmmpui/generalhandler.cpp b/src/qmmpui/uihelper.cpp index 5494b4d22..5448725aa 100644 --- a/src/qmmpui/generalhandler.cpp +++ b/src/qmmpui/uihelper.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2010 by Ilya Kotov * + * Copyright (C) 2008-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -22,16 +22,13 @@ #include <QMenu> #include <QWidget> #include <QAction> - #include "general.h" #include "generalfactory.h" -#include "commandlinemanager.h" - -#include "generalhandler.h" +#include "uihelper.h" -GeneralHandler *GeneralHandler::m_instance = 0; +UiHelper *UiHelper::m_instance = 0; -GeneralHandler::GeneralHandler(QObject *parent) +UiHelper::UiHelper(QObject *parent) : QObject(parent) { m_instance = this; @@ -43,25 +40,21 @@ GeneralHandler::GeneralHandler(QObject *parent) if (General::isEnabled(factory)) { General *general = factory->create(parent); - connect (general, SIGNAL(toggleVisibilityCalled()), SIGNAL(toggleVisibilityCalled())); - connect (general, SIGNAL(exitCalled()), SIGNAL(exitCalled())); m_generals.insert(factory, general); } } } -GeneralHandler::~GeneralHandler() +UiHelper::~UiHelper() {} -void GeneralHandler::setEnabled(GeneralFactory* factory, bool enable) +void UiHelper::setEnabled(GeneralFactory* factory, bool enable) { if (enable == m_generals.keys().contains(factory)) return; if (enable) { General *general = factory->create(parent()); - connect (general, SIGNAL(toggleVisibilityCalled()), SIGNAL(toggleVisibilityCalled())); - connect (general, SIGNAL(exitCalled()), SIGNAL(exitCalled())); m_generals.insert(factory, general); } else @@ -72,7 +65,7 @@ void GeneralHandler::setEnabled(GeneralFactory* factory, bool enable) General::setEnabled(factory, enable); } -void GeneralHandler::showSettings(GeneralFactory* factory, QWidget* parentWidget) +void UiHelper::showSettings(GeneralFactory* factory, QWidget* parentWidget) { QDialog *dialog = factory->createConfigDialog(parentWidget); if (!dialog) @@ -82,14 +75,12 @@ void GeneralHandler::showSettings(GeneralFactory* factory, QWidget* parentWidget { delete m_generals.value(factory); General *general = factory->create(parent()); - connect (general, SIGNAL(toggleVisibilityCalled()), SIGNAL(toggleVisibilityCalled())); - connect (general, SIGNAL(exitCalled()), SIGNAL(exitCalled())); m_generals[factory] = general; } dialog->deleteLater(); } -bool GeneralHandler::visibilityControl() +bool UiHelper::visibilityControl() { GeneralFactory* factory; foreach(factory, *General::factories()) @@ -100,7 +91,7 @@ bool GeneralHandler::visibilityControl() return false; } -void GeneralHandler::addAction(QAction *action, MenuType type) +void UiHelper::addAction(QAction *action, MenuType type) { connect(action, SIGNAL(destroyed (QObject *)), SLOT(removeAction(QObject*))); switch ((int) type) @@ -119,7 +110,7 @@ void GeneralHandler::addAction(QAction *action, MenuType type) } } -void GeneralHandler::removeAction(QAction *action) +void UiHelper::removeAction(QAction *action) { m_toolsActions.removeAll(action); if (m_toolsMenu) @@ -129,7 +120,7 @@ void GeneralHandler::removeAction(QAction *action) m_playlistMenu->removeAction(action); } -QList<QAction *> GeneralHandler::actions(MenuType type) +QList<QAction *> UiHelper::actions(MenuType type) { if (type == TOOLS_MENU) return m_toolsActions; @@ -137,7 +128,7 @@ QList<QAction *> GeneralHandler::actions(MenuType type) return m_playlistActions; } -QMenu *GeneralHandler::createMenu(MenuType type, const QString &title, QWidget *parent) +QMenu *UiHelper::createMenu(MenuType type, const QString &title, QWidget *parent) { switch ((int) type) { @@ -163,17 +154,22 @@ QMenu *GeneralHandler::createMenu(MenuType type, const QString &title, QWidget * return 0; } -void GeneralHandler::toggleVisibility() +void UiHelper::toggleVisibility() { emit toggleVisibilityCalled(); } -GeneralHandler* GeneralHandler::instance() +void UiHelper::exit() +{ + emit exitCalled(); +} + +UiHelper* UiHelper::instance() { return m_instance; } -void GeneralHandler::removeAction(QObject *action) +void UiHelper::removeAction(QObject *action) { removeAction((QAction *) action); } diff --git a/src/qmmpui/generalhandler.h b/src/qmmpui/uihelper.h index 209652434..a44fd22f7 100644 --- a/src/qmmpui/generalhandler.h +++ b/src/qmmpui/uihelper.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2010 by Ilya Kotov * + * Copyright (C) 2008-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -17,8 +17,8 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef GENERALHANDLER_H -#define GENERALHANDLER_H +#ifndef UiHelper_H +#define UiHelper_H #include <QObject> #include <QMap> @@ -30,13 +30,12 @@ class QAction; class QMenu; class QWidget; class General; -class Control; class GeneralFactory; -/*! @brief The GeneralHandler class provides simple api to access general and command line plugins. +/*! @brief The UiHelper class provides simple api to access general plugins and some gui features. * @author Ilya Kotov <forkotov02@hotmail.ru> */ -class GeneralHandler : public QObject +class UiHelper : public QObject { Q_OBJECT public: @@ -44,11 +43,11 @@ public: * Object constructor, * @param parent Parent object */ - GeneralHandler(QObject *parent = 0); + UiHelper(QObject *parent = 0); /*! * Destructor */ - ~GeneralHandler(); + ~UiHelper(); /*! * Enum of menu type */ @@ -96,13 +95,19 @@ public: */ QMenu *createMenu(MenuType type, const QString &title = QString(), QWidget *parent = 0); /*! + * Returns a pointer to the object's instance. + */ + static UiHelper* instance(); + +public slots: + /*! * Toggles player window visibility. */ void toggleVisibility(); /*! - * Returns a pointer to the object's instance. + * Tells the player to exit. */ - static GeneralHandler* instance(); + void exit(); signals: /*! @@ -125,7 +130,7 @@ private: QList <QAction*> m_playlistActions; QPointer<QMenu> m_toolsMenu; QPointer<QMenu> m_playlistMenu; - static GeneralHandler* m_instance; + static UiHelper* m_instance; }; #endif |
