FMTX support
[someplayer] / src / mainwindow.cpp
index 2654394..2785cc7 100644 (file)
@@ -41,6 +41,7 @@
 
 using namespace SomePlayer::DataObjects;
 using namespace SomePlayer::Storage;
+using namespace SomePlayer::Playback;
 
 MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
@@ -98,6 +99,8 @@ MainWindow::MainWindow(QWidget *parent) :
        connect(_settings_form, SIGNAL(trackColorChanged()), _player_form, SLOT(updateTrackColor()));
        connect(_settings_form, SIGNAL(hwZoomPolicyChanged()), this, SLOT(_hw_zoom_policy_changed()));
        connect(&_dbus_client, SIGNAL(displayStateChanged(bool)), this, SLOT(_set_display_state(bool)));
+       connect(_settings_form, SIGNAL(fmtxSettingsChanged()), this, SLOT(_fmtx_settings_changed()));
+       connect(_player_form, SIGNAL(trackChanged()), this, SLOT(_update_fmtx_text()));
        _player_form->reload(true);
        QString mode = config.getValue("ui/orientation").toString();
        if (mode == "landscape") {
@@ -384,3 +387,24 @@ void MainWindow::_zoom_key_pressed(quint32 code) {
                }
        }
 }
+
+void MainWindow::_fmtx_settings_changed() {
+       Config config;
+       if (config.getValue("fmtx/enabled").toString() == "yes") {
+               QString station_name = config.getValue("fmtx/station_name").toString();
+               int frequency = config.getValue("fmtx/frequency").toInt();
+               system(QString("fmtx_client -p1 -f%1 -s\"%2\" -t\"%3\" 2>&1 >/dev/null")
+                      .arg(frequency)
+                      .arg(station_name)
+                      .arg(_player_form->playerCaption()).toAscii());
+       } else {
+               system("fmtx_client -p 0 2>&1 >/dev/null");
+       }
+}
+
+void MainWindow::_update_fmtx_text() {
+       Config config;
+       if (config.getValue("fmtx/enabled").toString() == "yes") {
+               system(QString("fmtx_client -t \"%1\" 2>&1 >/dev/null").arg(_player_form->playerCaption()).toAscii());
+       }
+}