aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2011-07-03 11:13:48 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2011-07-03 11:13:48 +0000
commit26e900705f9c00b0775be0910fd0ae056328d550 (patch)
treecba26f3c5d302db134fa0d5ba0b5174d610f60cb /src
parentd184b2acecd3a7437ca78a163411d50f6935e55f (diff)
downloadqmmp-26e900705f9c00b0775be0910fd0ae056328d550.tar.gz
qmmp-26e900705f9c00b0775be0910fd0ae056328d550.tar.bz2
qmmp-26e900705f9c00b0775be0910fd0ae056328d550.zip
some api changes
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2261 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-rw-r--r--src/plugins/General/mpris/mpris1/rootobject.cpp4
-rw-r--r--src/plugins/General/mpris/mpris2/root2object.cpp3
-rw-r--r--src/plugins/General/statusicon/statusicon.cpp2
-rw-r--r--src/plugins/Ui/skinned/mainwindow.cpp3
-rw-r--r--src/plugins/Ui/skinned/pluginitem.cpp5
-rw-r--r--src/qmmpui/general.cpp50
-rw-r--r--src/qmmpui/general.h13
-rw-r--r--src/qmmpui/uihelper.cpp42
-rw-r--r--src/qmmpui/uihelper.h12
9 files changed, 71 insertions, 63 deletions
diff --git a/src/plugins/General/mpris/mpris1/rootobject.cpp b/src/plugins/General/mpris/mpris1/rootobject.cpp
index 7c4267d08..2c97897a9 100644
--- a/src/plugins/General/mpris/mpris1/rootobject.cpp
+++ b/src/plugins/General/mpris/mpris1/rootobject.cpp
@@ -20,7 +20,7 @@
#include <QDBusMetaType>
#include <QDBusArgument>
-
+#include <qmmpui/uihelper.h>
#include <qmmp/qmmp.h>
#include "rootobject.h"
@@ -71,5 +71,5 @@ Version RootObject::MprisVersion()
void RootObject::Quit()
{
- QMetaObject::invokeMethod(parent(), "exit");
+ UiHelper::instance()->exit();
}
diff --git a/src/plugins/General/mpris/mpris2/root2object.cpp b/src/plugins/General/mpris/mpris2/root2object.cpp
index 1f964272e..3e0d2f5b4 100644
--- a/src/plugins/General/mpris/mpris2/root2object.cpp
+++ b/src/plugins/General/mpris/mpris2/root2object.cpp
@@ -27,6 +27,7 @@
#include <qmmp/inputsource.h>
#include <qmmp/inputsourcefactory.h>
#include <qmmp/metadatamanager.h>
+#include <qmmpui/uihelper.h>
#include "root2object.h"
Root2Object::Root2Object(QObject *parent) : QDBusAbstractAdaptor(parent)
@@ -82,7 +83,7 @@ QStringList Root2Object::supportedUriSchemes() const
void Root2Object::Quit()
{
- QMetaObject::invokeMethod(parent(), "exit");
+ UiHelper::instance()->exit();
}
void Root2Object::Raise(){}
diff --git a/src/plugins/General/statusicon/statusicon.cpp b/src/plugins/General/statusicon/statusicon.cpp
index 28b765e19..6191ee725 100644
--- a/src/plugins/General/statusicon/statusicon.cpp
+++ b/src/plugins/General/statusicon/statusicon.cpp
@@ -70,7 +70,7 @@ StatusIcon::StatusIcon(QObject *parent)
menu->addAction(nextIcon, tr("Next"), m_player, SLOT(next()));
menu->addAction(previousIcon, tr("Previous"), m_player, SLOT(previous()));
menu->addSeparator();
- menu->addAction(tr("Exit"), this, SLOT(exit()));
+ menu->addAction(tr("Exit"), UiHelper::instance(), SLOT(exit()));
m_tray->setContextMenu(menu);
connect (m_core, SIGNAL(metaDataChanged ()), SLOT(showMetaData()));
connect (m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(setState(Qmmp::State)));
diff --git a/src/plugins/Ui/skinned/mainwindow.cpp b/src/plugins/Ui/skinned/mainwindow.cpp
index 5e54fc1a1..3c025484c 100644
--- a/src/plugins/Ui/skinned/mainwindow.cpp
+++ b/src/plugins/Ui/skinned/mainwindow.cpp
@@ -66,12 +66,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
new ActionManager();
- //prepare libqmmp and libqmmpui libraries for playing
m_player = MediaPlayer::instance();
m_core = SoundCore::instance();
m_pl_manager = PlayListManager::instance();
- //additional featuries
- //new PlaylistParser(this);
m_generalHandler = UiHelper::instance();
//user interface
diff --git a/src/plugins/Ui/skinned/pluginitem.cpp b/src/plugins/Ui/skinned/pluginitem.cpp
index 0f2679bb0..57daf7dc0 100644
--- a/src/plugins/Ui/skinned/pluginitem.cpp
+++ b/src/plugins/Ui/skinned/pluginitem.cpp
@@ -130,7 +130,6 @@ void PluginItem::showAbout(QWidget *parent)
default:
;
}
-
}
void PluginItem::showSettings(QWidget *parent)
@@ -153,7 +152,7 @@ void PluginItem::showSettings(QWidget *parent)
Visual::showSettings(static_cast<VisualFactory *>(m_factory), parent);
break;
case PluginItem::GENERAL:
- UiHelper::instance()->showSettings(static_cast<GeneralFactory *>(m_factory), parent);
+ General::showSettings(static_cast<GeneralFactory *>(m_factory), parent);
break;
default:
;
@@ -180,7 +179,7 @@ void PluginItem::setEnabled(bool enabled)
Visual::setEnabled(static_cast<VisualFactory *>(m_factory), enabled);
break;
case PluginItem::GENERAL:
- UiHelper::instance()->setEnabled(static_cast<GeneralFactory *>(m_factory), enabled);
+ General::setEnabled(static_cast<GeneralFactory *>(m_factory), enabled);
break;
default:
;
diff --git a/src/qmmpui/general.cpp b/src/qmmpui/general.cpp
index ebe462715..8b2b36f22 100644
--- a/src/qmmpui/general.cpp
+++ b/src/qmmpui/general.cpp
@@ -27,6 +27,8 @@
QList<GeneralFactory*> *General::m_factories = 0;
QStringList General::m_files;
+QMap <GeneralFactory*, General*> *General::m_generals = 0;
+QObject *General::m_parent = 0;
void General::checkFactories()
{
@@ -69,6 +71,23 @@ General::General(QObject *parent)
General::~General()
{}
+void General::create(QObject *parent)
+{
+ if(m_generals)
+ return;
+ m_generals = new QMap <GeneralFactory*, General*>();
+ m_parent = parent;
+ checkFactories();
+ foreach(GeneralFactory* factory, *General::factories())
+ {
+ if (General::isEnabled(factory))
+ {
+ General *general = factory->create(parent);
+ m_generals->insert(factory, general);
+ }
+ }
+}
+
QList<GeneralFactory*> *General::factories()
{
checkFactories();
@@ -99,6 +118,37 @@ void General::setEnabled(GeneralFactory* factory, bool enable)
else
genList.removeAll(name);
settings.setValue("General/enabled_plugins", genList);
+ if(!m_generals)
+ return;
+
+
+ if (enable == m_generals->keys().contains(factory))
+ return;
+ if (enable)
+ {
+ General *general = factory->create(m_parent);
+ m_generals->insert(factory, general);
+ }
+ else
+ {
+ delete m_generals->value(factory);
+ m_generals->remove(factory);
+ }
+}
+
+void General::showSettings(GeneralFactory* factory, QWidget* parentWidget)
+{
+ QDialog *dialog = factory->createConfigDialog(parentWidget);
+ if (!dialog)
+ return;
+
+ if (m_generals && dialog->exec() == QDialog::Accepted && m_generals->keys().contains(factory))
+ {
+ delete m_generals->value(factory);
+ General *general = factory->create(m_parent);
+ m_generals->insert(factory, general);
+ }
+ dialog->deleteLater();
}
bool General::isEnabled(GeneralFactory* factory)
diff --git a/src/qmmpui/general.h b/src/qmmpui/general.h
index 96d69b72a..6afd75517 100644
--- a/src/qmmpui/general.h
+++ b/src/qmmpui/general.h
@@ -42,6 +42,11 @@ public:
*/
~General();
/*!
+ * Prepares general plugins for usage.
+ * @param parent Parent object.
+ */
+ static void create(QObject *parent);
+ /*!
* Returns a list of the loaded general plugin factories.
*/
static QList<GeneralFactory*> *factories();
@@ -56,6 +61,12 @@ public:
*/
static void setEnabled(GeneralFactory* factory, bool enable = true);
/*!
+ * Shows configuration dialog and updates settings automatically.
+ * @param factory General plugin factory.
+ * @param parentWidget Parent widget.
+ */
+ static void showSettings(GeneralFactory* factory, QWidget* parentWidget);
+ /*!
* Returns \b true if general plugin is enabled, otherwise returns \b false
* @param factory General plugin factory.
*/
@@ -68,6 +79,8 @@ private:
static QList<GeneralFactory*> *m_factories;
static QStringList m_files;
static void checkFactories();
+ static QMap <GeneralFactory*, General*> *m_generals;
+ static QObject *m_parent;
};
#endif
diff --git a/src/qmmpui/uihelper.cpp b/src/qmmpui/uihelper.cpp
index 5448725aa..158bab3c5 100644
--- a/src/qmmpui/uihelper.cpp
+++ b/src/qmmpui/uihelper.cpp
@@ -34,52 +34,12 @@ UiHelper::UiHelper(QObject *parent)
m_instance = this;
m_toolsMenu = 0;
m_playlistMenu = 0;
- GeneralFactory* factory;
- foreach(factory, *General::factories())
- {
- if (General::isEnabled(factory))
- {
- General *general = factory->create(parent);
- m_generals.insert(factory, general);
- }
- }
+ General::create(parent);
}
UiHelper::~UiHelper()
{}
-void UiHelper::setEnabled(GeneralFactory* factory, bool enable)
-{
- if (enable == m_generals.keys().contains(factory))
- return;
- if (enable)
- {
- General *general = factory->create(parent());
- m_generals.insert(factory, general);
- }
- else
- {
- delete m_generals.value(factory);
- m_generals.remove(factory);
- }
- General::setEnabled(factory, enable);
-}
-
-void UiHelper::showSettings(GeneralFactory* factory, QWidget* parentWidget)
-{
- QDialog *dialog = factory->createConfigDialog(parentWidget);
- if (!dialog)
- return;
-
- if (dialog->exec() == QDialog::Accepted && m_generals.keys().contains(factory))
- {
- delete m_generals.value(factory);
- General *general = factory->create(parent());
- m_generals[factory] = general;
- }
- dialog->deleteLater();
-}
-
bool UiHelper::visibilityControl()
{
GeneralFactory* factory;
diff --git a/src/qmmpui/uihelper.h b/src/qmmpui/uihelper.h
index a44fd22f7..efc623bb7 100644
--- a/src/qmmpui/uihelper.h
+++ b/src/qmmpui/uihelper.h
@@ -57,18 +57,6 @@ public:
PLAYLIST_MENU /*!< playlist context menu */
};
/*!
- * Sets whether the general plugin is enabled.
- * @param factory General plugin factory.
- * @param enable Plugin enable state (\b true - enable, \b false - disable)
- */
- void setEnabled(GeneralFactory* factory, bool enable);
- /*!
- * Shows configuration dialog and updates settings automatically.
- * @param factory General plugin factory.
- * @param parentWidget Parent widget.
- */
- void showSettings(GeneralFactory* factory, QWidget* parentWidget);
- /*!
* Returns \b true if one of the general plugin can change visibility, otherwise returns \b false
*/
bool visibilityControl();