aboutsummaryrefslogtreecommitdiff
path: root/src/qmmpui
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmmpui')
-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
9 files changed, 170 insertions, 92 deletions
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