aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/General/dbuscontrol/dbusadaptor.cpp5
-rw-r--r--src/plugins/General/dbuscontrol/dbusadaptor.h1
-rw-r--r--src/qmmp/soundcore.h63
-rw-r--r--src/qmmpui/general.cpp23
-rw-r--r--src/qmmpui/general.h3
-rw-r--r--src/qmmpui/generalhandler.cpp26
-rw-r--r--src/qmmpui/generalhandler.h3
-rw-r--r--src/ui/mainwindow.cpp7
-rw-r--r--src/ui/mainwindow.h1
9 files changed, 89 insertions, 43 deletions
diff --git a/src/plugins/General/dbuscontrol/dbusadaptor.cpp b/src/plugins/General/dbuscontrol/dbusadaptor.cpp
index 77ace9208..23646b5bb 100644
--- a/src/plugins/General/dbuscontrol/dbusadaptor.cpp
+++ b/src/plugins/General/dbuscontrol/dbusadaptor.cpp
@@ -59,4 +59,7 @@ void DBUSAdaptor::exit()
QMetaObject::invokeMethod(parent(), "exit");
}
-
+void DBUSAdaptor::setVolume(int left, int right)
+{
+ QMetaObject::invokeMethod(parent(), "setVolume", Q_ARG(int, left), Q_ARG(int, right));
+}
diff --git a/src/plugins/General/dbuscontrol/dbusadaptor.h b/src/plugins/General/dbuscontrol/dbusadaptor.h
index 43294e753..b1b5fa50d 100644
--- a/src/plugins/General/dbuscontrol/dbusadaptor.h
+++ b/src/plugins/General/dbuscontrol/dbusadaptor.h
@@ -41,6 +41,7 @@ public slots:
void previous();
void pause();
void exit();
+ void setVolume(int, int);
};
diff --git a/src/qmmp/soundcore.h b/src/qmmp/soundcore.h
index 3fa785a2a..5bc0c8deb 100644
--- a/src/qmmp/soundcore.h
+++ b/src/qmmp/soundcore.h
@@ -51,13 +51,7 @@ public:
~SoundCore();
-
- //control
-
- /*!
- * This function plays file with given path, returns \b TRUE if all is OK, otherwise \b FALSE
- */
- bool play(const QString &source);
+ // properties
/*!
* Returns the playback error status.
@@ -67,23 +61,6 @@ public:
uint error();
/*!
- * Stops playing
- */
- void stop();
-
- /*!
- * Pauses/resumes playing
- */
- void pause();
-
- /*!
- *This function sets the current play position to \b pos
- */
- void seek(int pos);
-
- // properties
-
- /*!
* Returns length in seconds
*/
int length();
@@ -119,12 +96,6 @@ public:
//volume
- /*!
- * Sets volume. \b L - volume of left channel. \b R - volume of right channel.
- * \b L and \b R should be 0..100
- */
- void setVolume(int L, int R);
-
void volume(int*, int*);
//config
@@ -162,6 +133,38 @@ public:
static SoundCore* instance();
+public slots:
+
+ /*!
+ * Sets volume. \b L - volume of left channel. \b R - volume of right channel.
+ * \b L and \b R should be 0..100
+ */
+ void setVolume(int L, int R);
+
+ //control
+
+ /*!
+ * This function plays file with given path, returns \b TRUE if all is OK, otherwise \b FALSE
+ */
+ bool play(const QString &source);
+
+
+ /*!
+ * Stops playing
+ */
+ void stop();
+
+ /*!
+ * Pauses/resumes playing
+ */
+ void pause();
+
+ /*!
+ *This function sets the current play position to \b pos
+ */
+ void seek(int pos);
+
+
signals:
/*!
diff --git a/src/qmmpui/general.cpp b/src/qmmpui/general.cpp
index aebd06647..81edc9460 100644
--- a/src/qmmpui/general.cpp
+++ b/src/qmmpui/general.cpp
@@ -62,14 +62,12 @@ static void checkFactories()
}
General::General(QObject *parent)
- : QObject(parent)
-{
-}
+ : QObject(parent)
+{}
General::~General()
-{
-}
+{}
void General::setState(const uint&)
{}
@@ -84,6 +82,9 @@ QList<GeneralFactory*> *General::generalFactories()
return factories;
}
+void General::updateVolume(int left, int right)
+{}
+
QStringList General::generalFiles()
{
checkFactories();
@@ -93,14 +94,14 @@ QStringList General::generalFiles()
void General::setEnabled(GeneralFactory* factory, bool enable)
{
checkFactories();
- if(!factories->contains(factory))
+ if (!factories->contains(factory))
return;
QString name = files.at(factories->indexOf(factory)).section('/',-1);
QSettings settings ( QDir::homePath() +"/.qmmp/qmmprc", QSettings::IniFormat );
QStringList genList = settings.value("General/plugin_files").toStringList();
- if(enable)
+ if (enable)
{
if (!genList.contains(name))
genList << name;
@@ -113,7 +114,7 @@ void General::setEnabled(GeneralFactory* factory, bool enable)
bool General::isEnabled(GeneralFactory* factory)
{
checkFactories();
- if(!factories->contains(factory))
+ if (!factories->contains(factory))
return FALSE;
QString name = files.at(factories->indexOf(factory)).section('/',-1);
QSettings settings ( QDir::homePath() +"/.qmmp/qmmprc", QSettings::IniFormat );
@@ -155,3 +156,9 @@ 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 a7cc0e142..7f4993211 100644
--- a/src/qmmpui/general.h
+++ b/src/qmmpui/general.h
@@ -58,6 +58,7 @@ public:
virtual void setState(const uint &state);
virtual void setSongInfo(const SongInfo &song);
+ virtual void updateVolume(int left, int right);
//static methods
static QList<GeneralFactory*> *generalFactories();
@@ -67,6 +68,7 @@ public:
signals:
void commandCalled(uint command);
+ void volumeChanged(int left, int right);
public slots:
void play();
@@ -76,6 +78,7 @@ public slots:
void previous();
void exit();
void toggleVisibility();
+ void setVolume(int left, int right);
private:
QMap <uint, QString> m_strValues;
diff --git a/src/qmmpui/generalhandler.cpp b/src/qmmpui/generalhandler.cpp
index c4dd86934..99df0e320 100644
--- a/src/qmmpui/generalhandler.cpp
+++ b/src/qmmpui/generalhandler.cpp
@@ -30,6 +30,8 @@ GeneralHandler::GeneralHandler(QObject *parent)
: QObject(parent)
{
m_instance = this;
+ m_left = 0;
+ m_right = 0;
m_state = General::Stopped;
GeneralFactory* factory;
foreach(factory, *General::generalFactories())
@@ -38,6 +40,7 @@ GeneralHandler::GeneralHandler(QObject *parent)
{
General *general = factory->create(parent);
connect(general, SIGNAL(commandCalled(uint)), SLOT(processCommand(uint)));
+ connect(general, SIGNAL(volumeChanged(int, int)), SIGNAL(volumeChanged(int, int)));
m_generals.insert(factory, general);
}
}
@@ -76,15 +79,28 @@ void GeneralHandler::setSongInfo(const SongInfo &info)
}
}
+void GeneralHandler::updateVolume(int left, int right)
+{
+ m_left = left;
+ m_right = right;
+ General *general;
+ foreach(general, m_generals.values())
+ {
+ general->updateVolume(left, right);
+ }
+}
+
void GeneralHandler::setEnabled(GeneralFactory* factory, bool enable)
{
- if(enable == m_generals.keys().contains(factory))
+ if (enable == m_generals.keys().contains(factory))
return;
- if(enable)
+ 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)));
m_generals.insert(factory, general);
+ general->updateVolume(m_left, m_right);
if (m_state != General::Stopped)
{
general->setState(m_state);
@@ -102,15 +118,17 @@ void GeneralHandler::setEnabled(GeneralFactory* factory, bool enable)
void GeneralHandler::showSettings(GeneralFactory* factory, QWidget* parentWidget)
{
QDialog *dialog = factory->createConfigDialog(parentWidget);
- if(!dialog)
+ if (!dialog)
return;
- if(dialog->exec() == QDialog::Accepted && m_generals.keys().contains(factory))
+ 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)));
m_generals[factory] = general;
+ general->updateVolume(m_left, m_right);
if (m_state != General::Stopped)
{
general->setState(m_state);
diff --git a/src/qmmpui/generalhandler.h b/src/qmmpui/generalhandler.h
index 657eb2e82..26129f4bc 100644
--- a/src/qmmpui/generalhandler.h
+++ b/src/qmmpui/generalhandler.h
@@ -39,6 +39,7 @@ public:
~GeneralHandler();
void setSongInfo(const SongInfo &info);
+ void updateVolume(int left, int right);
void setEnabled(GeneralFactory* factory, bool enable);
void showSettings(GeneralFactory* factory, QWidget* parentWidget);
static GeneralHandler* instance();
@@ -51,6 +52,7 @@ signals:
void previousCalled();
void exitCalled();
void toggleVisibilityCalled();
+ void volumeChanged(int left, int right);
public slots:
void setState(uint state);
@@ -63,6 +65,7 @@ private:
QMap <GeneralFactory*, General*> m_generals;
SongInfo m_songInfo;
uint m_state;
+ int m_left, m_right;
static GeneralHandler* m_instance;
};
diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp
index e8ce0b3bd..b2cff377d 100644
--- a/src/ui/mainwindow.cpp
+++ b/src/ui/mainwindow.cpp
@@ -148,6 +148,8 @@ MainWindow::MainWindow(const QStringList& args,CommandLineOptionManager* option_
connect(m_generalHandler, SIGNAL(pauseCalled()), SLOT(pause()));
connect(m_generalHandler, SIGNAL(toggleVisibilityCalled()), SLOT(toggleVisibility()));
connect(m_generalHandler, SIGNAL(exitCalled()), SLOT(close()));
+ connect(m_generalHandler, SIGNAL(volumeChanged(int, int)),
+ m_core, SLOT(setVolume(int, int)));
m_playListModel->readSettings();
char buf[PATH_MAX + 1];
@@ -356,6 +358,11 @@ void MainWindow::showOutputState(const OutputState &st)
case OutputState::Info:
{
m_elapsed = st.elapsedSeconds();
+ break;
+ }
+ case OutputState::Volume:
+ {
+ m_generalHandler->updateVolume(st.leftVolume(), st.rightVolume());
}
}
diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h
index 0a1b6b60d..0ad44cec4 100644
--- a/src/ui/mainwindow.h
+++ b/src/ui/mainwindow.h
@@ -65,6 +65,7 @@ public:
SoundCore* soundCore()const;
MainDisplay* mainDisplay()const;
bool processCommandArgs(const QStringList &list,const QString& cwd);
+
public slots:
void previous();
void play();