aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/General/dbuscontrol/dbuscontrol.cpp17
-rw-r--r--src/plugins/General/dbuscontrol/dbuscontrol.h8
-rw-r--r--src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp8
-rw-r--r--src/plugins/General/dbuscontrol/dbuscontrolfactory.h3
-rw-r--r--src/plugins/General/notifier/notifierfactory.cpp4
-rw-r--r--src/plugins/General/notifier/notifierfactory.h3
-rw-r--r--src/plugins/General/scrobbler/scrobblerfactory.cpp4
-rw-r--r--src/plugins/General/scrobbler/scrobblerfactory.h3
-rw-r--r--src/plugins/General/statusicon/statusicon.cpp18
-rw-r--r--src/plugins/General/statusicon/statusicon.h5
-rw-r--r--src/plugins/General/statusicon/statusiconfactory.cpp4
-rw-r--r--src/plugins/General/statusicon/statusiconfactory.h3
-rw-r--r--src/qmmpui/CMakeLists.txt2
-rw-r--r--src/qmmpui/control.cpp71
-rw-r--r--src/qmmpui/control.h63
-rw-r--r--src/qmmpui/general.cpp46
-rw-r--r--src/qmmpui/general.h29
-rw-r--r--src/qmmpui/generalfactory.h3
-rw-r--r--src/qmmpui/generalhandler.cpp38
-rw-r--r--src/qmmpui/generalhandler.h4
-rw-r--r--src/qmmpui/qmmpui.pro6
-rw-r--r--src/ui/mainwindow.cpp2
22 files changed, 218 insertions, 126 deletions
diff --git a/src/plugins/General/dbuscontrol/dbuscontrol.cpp b/src/plugins/General/dbuscontrol/dbuscontrol.cpp
index 1133cec7a..6cd766063 100644
--- a/src/plugins/General/dbuscontrol/dbuscontrol.cpp
+++ b/src/plugins/General/dbuscontrol/dbuscontrol.cpp
@@ -18,21 +18,25 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include <qmmpui/control.h>
+
#include "dbusadaptor.h"
#include "dbuscontrol.h"
-DBUSControl::DBUSControl(QObject *parent)
+DBUSControl::DBUSControl(Control *control, QObject *parent)
: General(parent)
{
- new DBUSAdaptor(this);
+ m_adaptor = new DBUSAdaptor(control);
QDBusConnection connection = QDBusConnection::sessionBus();
- connection.registerObject("/Qmmp", this);
+ connection.registerObject("/Qmmp", control);
connection.registerService("org.qmmp.dbus");
}
DBUSControl::~DBUSControl()
-{}
+{
+ delete m_adaptor;
+}
void DBUSControl::setState(const uint &state)
{
@@ -40,22 +44,19 @@ void DBUSControl::setState(const uint &state)
{
case General::Playing:
{
- //m_tray->setIcon(QIcon(":/tray_play.png"));
break;
}
case General::Paused:
{
- //m_tray->setIcon(QIcon(":/tray_pause.png"));
break;
}
case General::Stopped:
{
- //m_tray->setIcon(QIcon(":/tray_stop.png"));
break;
}
}
}
-void DBUSControl::setSongInfo(const SongInfo &song)
+void DBUSControl::setSongInfo(const SongInfo&)
{
}
diff --git a/src/plugins/General/dbuscontrol/dbuscontrol.h b/src/plugins/General/dbuscontrol/dbuscontrol.h
index 2d5f3c91a..a14c37759 100644
--- a/src/plugins/General/dbuscontrol/dbuscontrol.h
+++ b/src/plugins/General/dbuscontrol/dbuscontrol.h
@@ -23,6 +23,9 @@
#include <qmmpui/general.h>
+class Control;
+class DBUSAdaptor;
+
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
*/
@@ -31,13 +34,16 @@ class DBUSControl : public General
{
Q_OBJECT
public:
- DBUSControl(QObject *parent = 0);
+ DBUSControl(Control *control, QObject *parent = 0);
~DBUSControl();
void setState(const uint& state);
void setSongInfo(const SongInfo &song);
+private:
+ DBUSAdaptor *m_adaptor;
+
};
#endif
diff --git a/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp b/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp
index 704538b8b..912301bc7 100644
--- a/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp
+++ b/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp
@@ -33,12 +33,12 @@ const GeneralProperties DBUSControlFactory::properties() const
return properties;
}
-General *DBUSControlFactory::create(QObject *parent)
+General *DBUSControlFactory::create(Control *control, QObject *parent)
{
- return new DBUSControl(parent);
+ return new DBUSControl(control, parent);
}
-QDialog *DBUSControlFactory::createConfigDialog(QWidget *parent)
+QDialog *DBUSControlFactory::createConfigDialog(QWidget *)
{
return 0;
}
@@ -50,7 +50,7 @@ void DBUSControlFactory::showAbout(QWidget *parent)
tr("Writen by: Ilya Kotov <forkotov02@hotmail.ru>"));
}
-QTranslator *DBUSControlFactory::createTranslator(QObject *parent)
+QTranslator *DBUSControlFactory::createTranslator(QObject *)
{
return 0;
}
diff --git a/src/plugins/General/dbuscontrol/dbuscontrolfactory.h b/src/plugins/General/dbuscontrol/dbuscontrolfactory.h
index af06b30bc..bdd53feb1 100644
--- a/src/plugins/General/dbuscontrol/dbuscontrolfactory.h
+++ b/src/plugins/General/dbuscontrol/dbuscontrolfactory.h
@@ -27,6 +27,7 @@
#include <QTranslator>
#include <qmmpui/general.h>
+#include <qmmpui/control.h>
#include <qmmpui/generalfactory.h>
class DBUSControlFactory : public QObject, public GeneralFactory
@@ -35,7 +36,7 @@ Q_OBJECT
Q_INTERFACES(GeneralFactory);
public:
const GeneralProperties properties() const;
- General *create(QObject *parent);
+ General *create(Control *control, QObject *parent);
QDialog *createConfigDialog(QWidget *parent);
void showAbout(QWidget *parent);
QTranslator *createTranslator(QObject *parent);
diff --git a/src/plugins/General/notifier/notifierfactory.cpp b/src/plugins/General/notifier/notifierfactory.cpp
index 91e7eab17..17a667f0a 100644
--- a/src/plugins/General/notifier/notifierfactory.cpp
+++ b/src/plugins/General/notifier/notifierfactory.cpp
@@ -34,7 +34,7 @@ const GeneralProperties NotifierFactory::properties() const
return properties;
}
-General *NotifierFactory::create(QObject *parent)
+General *NotifierFactory::create(Control*, QObject *parent)
{
return new Notifier(parent);
}
@@ -51,7 +51,7 @@ void NotifierFactory::showAbout(QWidget *parent)
tr("Writen by: Ilya Kotov <forkotov02@hotmail.ru>"));
}
-QTranslator *NotifierFactory::createTranslator(QObject *parent)
+QTranslator *NotifierFactory::createTranslator(QObject*)
{
return 0;
}
diff --git a/src/plugins/General/notifier/notifierfactory.h b/src/plugins/General/notifier/notifierfactory.h
index 68c22bbde..84039ede6 100644
--- a/src/plugins/General/notifier/notifierfactory.h
+++ b/src/plugins/General/notifier/notifierfactory.h
@@ -28,6 +28,7 @@
#include <QDialog>
#include <qmmpui/general.h>
+#include <qmmpui/control.h>
#include <qmmpui/generalfactory.h>
class NotifierFactory : public QObject, public GeneralFactory
@@ -36,7 +37,7 @@ Q_OBJECT
Q_INTERFACES(GeneralFactory);
public:
const GeneralProperties properties() const;
- General *create(QObject *parent);
+ General *create(Control*, QObject *parent);
QDialog *createConfigDialog(QWidget *parent);
void showAbout(QWidget *parent);
QTranslator *createTranslator(QObject *parent);
diff --git a/src/plugins/General/scrobbler/scrobblerfactory.cpp b/src/plugins/General/scrobbler/scrobblerfactory.cpp
index 2bf7bfdfc..7a8c2f333 100644
--- a/src/plugins/General/scrobbler/scrobblerfactory.cpp
+++ b/src/plugins/General/scrobbler/scrobblerfactory.cpp
@@ -34,7 +34,7 @@ const GeneralProperties ScrobblerFactory::properties() const
return properties;
}
-General *ScrobblerFactory::create(QObject *parent)
+General *ScrobblerFactory::create(Control*, QObject *parent)
{
return new Scrobbler(parent);
}
@@ -51,7 +51,7 @@ void ScrobblerFactory::showAbout(QWidget *parent)
tr("Writen by: Ilya Kotov <forkotov02@hotmail.ru>"));
}
-QTranslator *ScrobblerFactory::createTranslator(QObject *parent)
+QTranslator *ScrobblerFactory::createTranslator(QObject*)
{
return 0;
}
diff --git a/src/plugins/General/scrobbler/scrobblerfactory.h b/src/plugins/General/scrobbler/scrobblerfactory.h
index a0bd0a626..d883da917 100644
--- a/src/plugins/General/scrobbler/scrobblerfactory.h
+++ b/src/plugins/General/scrobbler/scrobblerfactory.h
@@ -27,6 +27,7 @@
#include <QTranslator>
#include <qmmpui/general.h>
+#include <qmmpui/control.h>
#include <qmmpui/generalfactory.h>
class ScrobblerFactory : public QObject, public GeneralFactory
@@ -35,7 +36,7 @@ Q_OBJECT
Q_INTERFACES(GeneralFactory);
public:
const GeneralProperties properties() const;
- General *create(QObject *parent);
+ General *create(Control*, QObject *parent);
QDialog *createConfigDialog(QWidget *parent);
void showAbout(QWidget *parent);
QTranslator *createTranslator(QObject *parent);
diff --git a/src/plugins/General/statusicon/statusicon.cpp b/src/plugins/General/statusicon/statusicon.cpp
index 59225d028..119af0e78 100644
--- a/src/plugins/General/statusicon/statusicon.cpp
+++ b/src/plugins/General/statusicon/statusicon.cpp
@@ -23,24 +23,26 @@
#include <QDir>
#include <QTimer>
#include <QCoreApplication>
+#include <qmmpui/control.h>
#include "statusicon.h"
-StatusIcon::StatusIcon(QObject *parent)
+StatusIcon::StatusIcon(Control *control, QObject *parent)
: General(parent)
{
+ m_control = control;
m_tray = new QSystemTrayIcon(this);
connect(m_tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
m_tray->setIcon ( QIcon(":/tray_stop.png"));
m_tray->show();
QMenu *menu = new QMenu(qobject_cast<QWidget *>(parent));
- menu->addAction(tr("Play"), this, SLOT(play()));
- menu->addAction(tr("Pause"), this, SLOT(pause()));
- menu->addAction(tr("Stop"), this, SLOT(stop()));
- menu->addAction(tr("Next"), this, SLOT(next()));
- menu->addAction(tr("Previous"), this, SLOT(previous()));
+ menu->addAction(tr("Play"), control, SLOT(play()));
+ menu->addAction(tr("Pause"), control, SLOT(pause()));
+ menu->addAction(tr("Stop"), control, SLOT(stop()));
+ menu->addAction(tr("Next"), control, SLOT(next()));
+ menu->addAction(tr("Previous"), control, SLOT(previous()));
menu->addSeparator();
- menu->addAction(tr("Exit"), this, SLOT(exit()));
+ menu->addAction(tr("Exit"), control, SLOT(exit()));
m_tray->setContextMenu(menu);
QSettings settings(QDir::homePath()+"/.qmmp/qmmprc", QSettings::IniFormat);
@@ -100,7 +102,7 @@ void StatusIcon::setSongInfo(const SongInfo &song)
void StatusIcon::trayActivated(QSystemTrayIcon::ActivationReason reason)
{
if (reason == QSystemTrayIcon::Trigger)
- toggleVisibility();
+ m_control->toggleVisibility();
}
void StatusIcon::enable()
diff --git a/src/plugins/General/statusicon/statusicon.h b/src/plugins/General/statusicon/statusicon.h
index fae20422d..549cf5f18 100644
--- a/src/plugins/General/statusicon/statusicon.h
+++ b/src/plugins/General/statusicon/statusicon.h
@@ -24,7 +24,7 @@
#include <qmmpui/general.h>
-
+class Control;
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
@@ -34,7 +34,7 @@ class StatusIcon : public General
{
Q_OBJECT
public:
- StatusIcon(QObject *parent = 0);
+ StatusIcon(Control *control, QObject *parent = 0);
~StatusIcon();
@@ -52,6 +52,7 @@ private:
bool m_hideToTray;
bool m_enabled;
int m_messageDelay;
+ Control *m_control;
};
diff --git a/src/plugins/General/statusicon/statusiconfactory.cpp b/src/plugins/General/statusicon/statusiconfactory.cpp
index 5aedc6f7c..1bb21e9ea 100644
--- a/src/plugins/General/statusicon/statusiconfactory.cpp
+++ b/src/plugins/General/statusicon/statusiconfactory.cpp
@@ -34,9 +34,9 @@ const GeneralProperties StatusIconFactory::properties() const
return properties;
}
-General *StatusIconFactory::create(QObject *parent)
+General *StatusIconFactory::create(Control *control, QObject *parent)
{
- return new StatusIcon(parent);
+ return new StatusIcon(control, parent);
}
QDialog *StatusIconFactory::createConfigDialog(QWidget *parent)
diff --git a/src/plugins/General/statusicon/statusiconfactory.h b/src/plugins/General/statusicon/statusiconfactory.h
index c2dc76bc5..bb75f8843 100644
--- a/src/plugins/General/statusicon/statusiconfactory.h
+++ b/src/plugins/General/statusicon/statusiconfactory.h
@@ -28,6 +28,7 @@
#include <QDialog>
#include <qmmpui/general.h>
+#include <qmmpui/control.h>
#include <qmmpui/generalfactory.h>
class StatusIconFactory : public QObject, public GeneralFactory
@@ -36,7 +37,7 @@ Q_OBJECT
Q_INTERFACES(GeneralFactory);
public:
const GeneralProperties properties() const;
- General *create(QObject *parent);
+ General *create(Control *control, QObject *parent);
QDialog *createConfigDialog(QWidget *parent);
void showAbout(QWidget *parent);
QTranslator *createTranslator(QObject *parent);
diff --git a/src/qmmpui/CMakeLists.txt b/src/qmmpui/CMakeLists.txt
index 87654ddfc..adf003264 100644
--- a/src/qmmpui/CMakeLists.txt
+++ b/src/qmmpui/CMakeLists.txt
@@ -19,6 +19,7 @@ SET(libqmmpui_SRCS
general.cpp
generalhandler.cpp
songinfo.cpp
+ control.cpp
)
SET(libqmmpui_MOC_HDRS
@@ -26,6 +27,7 @@ SET(libqmmpui_MOC_HDRS
general.h
generalhandler.h
songinfo.h
+ control.h
)
QT4_WRAP_CPP(libqmmpui_MOC_SRCS ${libqmmpui_MOC_HDRS})
diff --git a/src/qmmpui/control.cpp b/src/qmmpui/control.cpp
new file mode 100644
index 000000000..4b734f824
--- /dev/null
+++ b/src/qmmpui/control.cpp
@@ -0,0 +1,71 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Control Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU Control Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Control Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "control.h"
+
+Control::Control(QObject *parent)
+ : QObject(parent)
+{
+}
+
+
+Control::~Control()
+{
+}
+
+void Control::play()
+{
+ emit commandCalled(Play);
+}
+
+void Control::pause()
+{
+ emit commandCalled(Pause);
+}
+
+void Control::stop()
+{
+ emit commandCalled(Stop);
+}
+
+void Control::next()
+{
+ emit commandCalled(Next);
+}
+
+void Control::previous()
+{
+ emit commandCalled(Previous);
+}
+
+void Control::exit()
+{
+ emit commandCalled(Exit);
+}
+
+void Control::toggleVisibility()
+{
+ emit commandCalled(ToggleVisibility);
+}
+
+void Control::setVolume(int left, int right)
+{
+ emit volumeChanged(left, right);
+}
+
diff --git a/src/qmmpui/control.h b/src/qmmpui/control.h
new file mode 100644
index 000000000..3ac856327
--- /dev/null
+++ b/src/qmmpui/control.h
@@ -0,0 +1,63 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef CONTROL_H
+#define CONTROL_H
+
+#include <QObject>
+
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
+class Control : public QObject
+{
+Q_OBJECT
+public:
+ Control(QObject *parent = 0);
+
+ ~Control();
+
+ enum Command
+ {
+ Play = 0,
+ Stop,
+ Pause,
+ Previous,
+ Next,
+ Exit,
+ ToggleVisibility
+ };
+
+signals:
+ void commandCalled(uint command);
+ void volumeChanged(int left, int right);
+
+public slots:
+ void play();
+ void pause();
+ void stop();
+ void next();
+ void previous();
+ void exit();
+ void toggleVisibility();
+ void setVolume(int left, int right);
+
+};
+
+#endif
diff --git a/src/qmmpui/general.cpp b/src/qmmpui/general.cpp
index 81edc9460..a9791731b 100644
--- a/src/qmmpui/general.cpp
+++ b/src/qmmpui/general.cpp
@@ -63,7 +63,9 @@ static void checkFactories()
General::General(QObject *parent)
: QObject(parent)
-{}
+{
+ Q_UNUSED(parent);
+}
General::~General()
@@ -82,7 +84,7 @@ QList<GeneralFactory*> *General::generalFactories()
return factories;
}
-void General::updateVolume(int left, int right)
+void General::setVolume(int left, int right)
{}
QStringList General::generalFiles()
@@ -122,43 +124,3 @@ bool General::isEnabled(GeneralFactory* factory)
return genList.contains(name);
}
-void General::play()
-{
- emit commandCalled(Play);
-}
-
-void General::pause()
-{
- emit commandCalled(Pause);
-}
-
-void General::stop()
-{
- emit commandCalled(Stop);
-}
-
-void General::next()
-{
- emit commandCalled(Next);
-}
-
-void General::previous()
-{
- emit commandCalled(Previous);
-}
-
-void General::exit()
-{
- emit commandCalled(Exit);
-}
-
-void General::toggleVisibility()
-{
- emit commandCalled(ToggleVisibility);
-}
-
-void General::setVolume(int left, int right)
-{
- emit volumeChanged(left, right);
-}
-
diff --git a/src/qmmpui/general.h b/src/qmmpui/general.h
index 7f4993211..8c26866ec 100644
--- a/src/qmmpui/general.h
+++ b/src/qmmpui/general.h
@@ -27,6 +27,8 @@
#include "songinfo.h"
#include "generalfactory.h"
+class Control;
+
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
*/
@@ -45,20 +47,9 @@ public:
Stopped
};
- enum Command
- {
- Play = 0,
- Stop,
- Pause,
- Previous,
- Next,
- Exit,
- ToggleVisibility
- };
-
virtual void setState(const uint &state);
virtual void setSongInfo(const SongInfo &song);
- virtual void updateVolume(int left, int right);
+ virtual void setVolume(int left, int right);
//static methods
static QList<GeneralFactory*> *generalFactories();
@@ -66,20 +57,6 @@ public:
static void setEnabled(GeneralFactory* factory, bool enable = TRUE);
static bool isEnabled(GeneralFactory* factory);
-signals:
- void commandCalled(uint command);
- void volumeChanged(int left, int right);
-
-public slots:
- void play();
- void pause();
- void stop();
- void next();
- void previous();
- void exit();
- void toggleVisibility();
- void setVolume(int left, int right);
-
private:
QMap <uint, QString> m_strValues;
QMap <uint, uint> m_numValues;
diff --git a/src/qmmpui/generalfactory.h b/src/qmmpui/generalfactory.h
index 619632f4d..7bcb31520 100644
--- a/src/qmmpui/generalfactory.h
+++ b/src/qmmpui/generalfactory.h
@@ -26,6 +26,7 @@
class QObject;
class QTranslator;
class QDialog;
+class Control;
class General;
@@ -42,7 +43,7 @@ class GeneralFactory
public:
virtual ~GeneralFactory() {}
virtual const GeneralProperties properties() const = 0;
- virtual General *create(QObject *parent) = 0;
+ virtual General *create(Control *control, QObject *parent) = 0;
virtual QDialog *createConfigDialog(QWidget *parent) = 0;
virtual void showAbout(QWidget *parent) = 0;
virtual QTranslator *createTranslator(QObject *parent) = 0;
diff --git a/src/qmmpui/generalhandler.cpp b/src/qmmpui/generalhandler.cpp
index 94536fc4c..a70068a02 100644
--- a/src/qmmpui/generalhandler.cpp
+++ b/src/qmmpui/generalhandler.cpp
@@ -21,6 +21,7 @@
#include <QDialog>
#include "general.h"
#include "generalfactory.h"
+#include "control.h"
#include "generalhandler.h"
@@ -34,13 +35,14 @@ GeneralHandler::GeneralHandler(QObject *parent)
m_right = 0;
m_state = General::Stopped;
GeneralFactory* factory;
+ m_control = new Control(this);
+ connect(m_control, SIGNAL(commandCalled(uint)), SLOT(processCommand(uint)));
+ connect(m_control, SIGNAL(volumeChanged(int, int)), SIGNAL(volumeChanged(int, int)));
foreach(factory, *General::generalFactories())
{
if (General::isEnabled(factory))
{
- General *general = factory->create(parent);
- connect(general, SIGNAL(commandCalled(uint)), SLOT(processCommand(uint)));
- connect(general, SIGNAL(volumeChanged(int, int)), SIGNAL(volumeChanged(int, int)));
+ General *general = factory->create(m_control, parent);
m_generals.insert(factory, general);
}
}
@@ -79,14 +81,14 @@ void GeneralHandler::setSongInfo(const SongInfo &info)
}
}
-void GeneralHandler::updateVolume(int left, int right)
+void GeneralHandler::setVolume(int left, int right)
{
m_left = left;
m_right = right;
General *general;
foreach(general, m_generals.values())
{
- general->updateVolume(left, right);
+ general->setVolume(left, right);
}
}
@@ -96,11 +98,9 @@ void GeneralHandler::setEnabled(GeneralFactory* factory, bool enable)
return;
if (enable)
{
- General *general = factory->create(parent());
- connect(general, SIGNAL(commandCalled(uint)), SLOT(processCommand(uint)));
- connect(general, SIGNAL(volumeChanged(int, int)), SIGNAL(volumeChanged(int, int)));
+ General *general = factory->create(m_control, parent());
m_generals.insert(factory, general);
- general->updateVolume(m_left, m_right);
+ general->setVolume(m_left, m_right);
if (m_state != General::Stopped)
{
general->setState(m_state);
@@ -124,11 +124,9 @@ void GeneralHandler::showSettings(GeneralFactory* factory, QWidget* parentWidget
if (dialog->exec() == QDialog::Accepted && m_generals.keys().contains(factory))
{
delete m_generals.value(factory);
- General *general = factory->create(parent());
- connect(general, SIGNAL(commandCalled(uint)), SLOT(processCommand(uint)));
- connect(general, SIGNAL(volumeChanged(int, int)), SIGNAL(volumeChanged(int, int)));
+ General *general = factory->create(m_control, parent());
m_generals[factory] = general;
- general->updateVolume(m_left, m_right);
+ general->setVolume(m_left, m_right);
if (m_state != General::Stopped)
{
general->setState(m_state);
@@ -158,37 +156,37 @@ void GeneralHandler::processCommand(uint command)
{
switch ((uint) command)
{
- case General::Play:
+ case Control::Play:
{
emit playCalled();
break;
}
- case General::Stop:
+ case Control::Stop:
{
emit stopCalled();
break;
}
- case General::Pause:
+ case Control::Pause:
{
emit pauseCalled();
break;
}
- case General::Previous:
+ case Control::Previous:
{
emit previousCalled();
break;
}
- case General::Next:
+ case Control::Next:
{
emit nextCalled();
break;
}
- case General::Exit:
+ case Control::Exit:
{
emit exitCalled();
break;
}
- case General::ToggleVisibility:
+ case Control::ToggleVisibility:
{
emit toggleVisibilityCalled();
break;
diff --git a/src/qmmpui/generalhandler.h b/src/qmmpui/generalhandler.h
index 23232ae86..7af0f8171 100644
--- a/src/qmmpui/generalhandler.h
+++ b/src/qmmpui/generalhandler.h
@@ -25,6 +25,7 @@
#include "songinfo.h"
class General;
+class Control;
class GeneralFactory;
/**
@@ -39,7 +40,7 @@ public:
~GeneralHandler();
void setSongInfo(const SongInfo &info);
- void updateVolume(int left, int right);
+ void setVolume(int left, int right);
void setEnabled(GeneralFactory* factory, bool enable);
void showSettings(GeneralFactory* factory, QWidget* parentWidget);
bool visibilityControl();
@@ -65,6 +66,7 @@ private:
void connectSignals(General*);
QMap <GeneralFactory*, General*> m_generals;
SongInfo m_songInfo;
+ Control* m_control;
uint m_state;
int m_left, m_right;
static GeneralHandler* m_instance;
diff --git a/src/qmmpui/qmmpui.pro b/src/qmmpui/qmmpui.pro
index 88c60a0da..79f1d285b 100644
--- a/src/qmmpui/qmmpui.pro
+++ b/src/qmmpui/qmmpui.pro
@@ -31,8 +31,10 @@ INSTALLS += target
HEADERS += general.h \
generalfactory.h \
generalhandler.h \
- songinfo.h
+ songinfo.h \
+ control.h
SOURCES += general.cpp \
generalhandler.cpp \
- songinfo.cpp
+ songinfo.cpp \
+ control.cpp
diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp
index 59294d31a..46bf23c65 100644
--- a/src/ui/mainwindow.cpp
+++ b/src/ui/mainwindow.cpp
@@ -364,7 +364,7 @@ void MainWindow::showOutputState(const OutputState &st)
}
case OutputState::Volume:
{
- m_generalHandler->updateVolume(st.leftVolume(), st.rightVolume());
+ m_generalHandler->setVolume(st.leftVolume(), st.rightVolume());
}
}