From 813c63e76ba24b85259e00e313f21d5660111e50 Mon Sep 17 00:00:00 2001 From: Nikolay Tischenko Date: Sun, 12 Dec 2010 04:26:48 +0600 Subject: [PATCH] FMTX support --- someplayer.pro | 9 +- src/fmtxsettingsdialog.cpp | 60 ++++++ src/fmtxsettingsdialog.h | 43 +++++ src/mainwindow.cpp | 24 +++ src/mainwindow.h | 2 + src/playerform.cpp | 6 + src/playerform.h | 2 + src/settingsform.cpp | 23 +++ src/settingsform.h | 3 + src/ui/fmtxsettingsdialog.ui | 425 ++++++++++++++++++++++++++++++++++++++++++ src/ui/settingsform.ui | 46 ++++- 11 files changed, 636 insertions(+), 7 deletions(-) create mode 100644 src/fmtxsettingsdialog.cpp create mode 100644 src/fmtxsettingsdialog.h create mode 100644 src/ui/fmtxsettingsdialog.ui diff --git a/someplayer.pro b/someplayer.pro index c671223..c1333c5 100644 --- a/someplayer.pro +++ b/someplayer.pro @@ -127,7 +127,8 @@ SOURCES += src/main.cpp\ src/coverfinder.cpp \ src/clickablelabel.cpp \ src/settingsform.cpp \ - src/dbusclient.cpp + src/dbusclient.cpp \ + src/fmtxsettingsdialog.cpp HEADERS += src/mainwindow.h \ src/player/player.h \ @@ -233,7 +234,8 @@ HEADERS += src/mainwindow.h \ src/coverfinder.h \ src/clickablelabel.h \ src/settingsform.h \ - src/dbusclient.h + src/dbusclient.h \ + src/fmtxsettingsdialog.h FORMS += src/ui/mainwindow.ui \ src/ui/playerform.ui \ @@ -247,7 +249,8 @@ FORMS += src/ui/mainwindow.ui \ src/ui/toolswidget.ui \ src/ui/managelibraryform.ui \ src/ui/directoryview.ui \ - src/ui/settingsform.ui + src/ui/settingsform.ui \ + src/ui/fmtxsettingsdialog.ui CONFIG += mobility MOBILITY = diff --git a/src/fmtxsettingsdialog.cpp b/src/fmtxsettingsdialog.cpp new file mode 100644 index 0000000..2dd8b2b --- /dev/null +++ b/src/fmtxsettingsdialog.cpp @@ -0,0 +1,60 @@ +/* + * SomePlayer - An alternate music player for Maemo 5 + * Copyright (C) 2010 Nikolay (somebody) Tischenko + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "fmtxsettingsdialog.h" +#include "ui_fmtxsettingsdialog.h" +#include "someplayer.h" + +using namespace SomePlayer::Storage; + +FmtxSettingsDialog::FmtxSettingsDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::FmtxSettingsDialog) +{ + ui->setupUi(this); + Config config; + QString station_name = config.getValue("fmtx/station_name").toString(); + if (station_name.isEmpty()) { + station_name = "S.P."; + config.setValue("fmtx/station_name", station_name); + } + int freq = config.getValue("fmtx/frequency").toInt(); + ui->stationNameLineEdit->setText(station_name); + int freq_g = freq/1000; + int freq_s = (freq % 1000)/10; + freq_g = freq_g > 107 ? 107 : freq_g; + freq_g = freq_g < 88 ? 88 : freq_g; + ui->freqGWidget->scrollTo(ui->freqGWidget->model()->index(freq_g-88, 0)); + ui->freqGWidget->setCurrentRow(freq_g-88); + ui->freqSWidget->scrollTo(ui->freqSWidget->model()->index(freq_s/5, 0)); + ui->freqSWidget->setCurrentRow(freq_s/5); +} + +FmtxSettingsDialog::~FmtxSettingsDialog() +{ + delete ui; +} + +QString FmtxSettingsDialog::stationName() { + return ui->stationNameLineEdit->text(); +} + +int FmtxSettingsDialog::frequency() { + return (88+ui->freqGWidget->currentRow())*1000+10*(ui->freqSWidget->currentRow()*5); +} diff --git a/src/fmtxsettingsdialog.h b/src/fmtxsettingsdialog.h new file mode 100644 index 0000000..25e90a9 --- /dev/null +++ b/src/fmtxsettingsdialog.h @@ -0,0 +1,43 @@ +/* + * SomePlayer - An alternate music player for Maemo 5 + * Copyright (C) 2010 Nikolay (somebody) Tischenko + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef FMTXSETTINGSDIALOG_H +#define FMTXSETTINGSDIALOG_H + +#include + +namespace Ui { + class FmtxSettingsDialog; +} + +class FmtxSettingsDialog : public QDialog +{ + Q_OBJECT + +public: + explicit FmtxSettingsDialog(QWidget *parent = 0); + ~FmtxSettingsDialog(); + QString stationName(); + int frequency(); + +private: + Ui::FmtxSettingsDialog *ui; +}; + +#endif // FMTXSETTINGSDIALOG_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2654394..2785cc7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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()); + } +} diff --git a/src/mainwindow.h b/src/mainwindow.h index fecda17..2e3f180 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -77,6 +77,8 @@ private slots: void _hw_zoom_policy_changed(); void _set_display_state(bool); void _zoom_key_pressed(quint32); + void _fmtx_settings_changed(); + void _update_fmtx_text(); private: PlayerForm *_player_form; LibraryForm *_library_form; diff --git a/src/playerform.cpp b/src/playerform.cpp index ae91db2..d25c3f9 100644 --- a/src/playerform.cpp +++ b/src/playerform.cpp @@ -228,6 +228,7 @@ void PlayerForm::_track_changed(Track track) { ui->playlistView->show(); _display_track(track); _context_menu->actions().at(2)->setText(_lib->isFavorite(track) ? tr("Remove from favorites") : tr("Add to favorites")); + emit trackChanged(); } void PlayerForm::_display_track(Track track) { @@ -763,3 +764,8 @@ void PlayerForm::next() { void PlayerForm::prev() { _player->prev(); } + +QString PlayerForm::playerCaption() { + TrackMetadata meta = _player->current().metadata(); + return QString("%1 - %2").arg(meta.artist()).arg(meta.title()); +} diff --git a/src/playerform.h b/src/playerform.h index a081ace..fd02bc2 100644 --- a/src/playerform.h +++ b/src/playerform.h @@ -56,6 +56,7 @@ public: ~PlayerForm(); bool isEqualizerEnabled() { return _player->equalizerEnabled(); } bool isEqualizerAvailable() { return _player->equalizerAvailable(); } + QString playerCaption(); signals: void library(); @@ -63,6 +64,7 @@ signals: void clearPlaylist(); void refreshLibrary(); void dirView(); + void trackChanged(); public slots: void reload(bool); diff --git a/src/settingsform.cpp b/src/settingsform.cpp index 7baf60e..a922f32 100644 --- a/src/settingsform.cpp +++ b/src/settingsform.cpp @@ -23,6 +23,7 @@ #include #include #include "someplayer.h" +#include "fmtxsettingsdialog.h" using namespace SomePlayer::Storage; @@ -51,6 +52,7 @@ SettingsForm::SettingsForm(QWidget *parent) : ui->hwkeysLabel->setEnabled(false); ui->hwTControlButton->setEnabled(false); ui->hwVolumeButton->setEnabled(false); + ui->fmtxGroupBox->setChecked(false); if (albumSorting == "alphabet") { ui->albumsSortAButton->setChecked(true); } @@ -104,6 +106,10 @@ SettingsForm::SettingsForm(QWidget *parent) : ui->hwVolumeButton->setChecked(true); config.setValue("hw/zoom_action", "volume"); } + if (config.getValue("fmtx/enabled").toString() == "yes") { + ui->fmtxGroupBox->setChecked(true); + emit fmtxSettingsChanged(); + } if (!QFile::exists(QString(_APPLICATION_PATH_)+"/someplayer_ru.qm")) { ui->langBox->hide(); } // refactor this when more translations will be added @@ -136,6 +142,8 @@ SettingsForm::SettingsForm(QWidget *parent) : connect (ui->uiButton, SIGNAL(clicked()), this, SLOT(_toggle_view_ui())); connect (ui->hwButton, SIGNAL(clicked()), this, SLOT(_toggle_view_hw())); connect (ui->libraryButton, SIGNAL(clicked()), this, SLOT(_toggle_view_lib())); + connect (ui->fmtxSettingsButton, SIGNAL(clicked()), this, SLOT(_open_fmtx_settings())); + connect (ui->fmtxGroupBox, SIGNAL(toggled(bool)), this, SLOT(_toggle_fmtx_settings(bool))); _toggle_view_ui(); setAttribute(Qt::WA_Maemo5StackedWindow); setWindowFlags(Qt::Window | windowFlags()); @@ -402,3 +410,18 @@ void SettingsForm::portraitMode() { ui->orientationGridLayout->addWidget(ui->orientationAButton, 0, 1); ui->orientationGridLayout->addWidget(ui->orientationPButton, 1, 0, 1, 2); } + +void SettingsForm::_open_fmtx_settings() { + FmtxSettingsDialog dialog(this); + dialog.exec(); + Config config; + config.setValue("fmtx/station_name", dialog.stationName()); + config.setValue("fmtx/frequency", dialog.frequency()); + emit fmtxSettingsChanged(); +} + +void SettingsForm::_toggle_fmtx_settings(bool checked) { + Config config; + config.setValue("fmtx/enabled", checked ? "yes" : "no"); + emit fmtxSettingsChanged(); +} diff --git a/src/settingsform.h b/src/settingsform.h index bdd07d8..817d9f5 100644 --- a/src/settingsform.h +++ b/src/settingsform.h @@ -48,6 +48,7 @@ signals: void translationChanged(); void trackColorChanged(); void hwZoomPolicyChanged(); + void fmtxSettingsChanged(); private: Ui::SettingsForm *ui; @@ -82,6 +83,8 @@ private slots: void _toggle_view_ui(); void _toggle_view_lib(); void _toggle_view_hw(); + void _open_fmtx_settings(); + void _toggle_fmtx_settings(bool); }; #endif // SETTINGSFORM_H diff --git a/src/ui/fmtxsettingsdialog.ui b/src/ui/fmtxsettingsdialog.ui new file mode 100644 index 0000000..7145947 --- /dev/null +++ b/src/ui/fmtxsettingsdialog.ui @@ -0,0 +1,425 @@ + + + FmtxSettingsDialog + + + + 0 + 0 + 607 + 348 + + + + FMTX Settings + + + + + + + + + Frequency: + + + + + + + + + + 0 + 0 + + + + + 88 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 89 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 90 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 91 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 92 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 93 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 94 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 95 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 96 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 97 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 98 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 99 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 100 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 101 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 102 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 103 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 104 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 105 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 106 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 107 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + + + + + 0 + 0 + + + + + 00 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 05 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 10 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 15 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 20 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 25 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 30 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 35 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 40 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 45 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 50 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 55 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 60 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 65 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 70 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 75 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 80 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 85 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 90 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + 95 + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Station: + + + + + + + + + buttonBox + accepted() + FmtxSettingsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + FmtxSettingsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/ui/settingsform.ui b/src/ui/settingsform.ui index a1cf6e0..7d35f7f 100644 --- a/src/ui/settingsform.ui +++ b/src/ui/settingsform.ui @@ -51,7 +51,7 @@ - Hardware + System true @@ -68,7 +68,7 @@ 2 - + 0 @@ -414,7 +414,7 @@ - + 0 @@ -555,7 +555,7 @@ - + 0 @@ -673,6 +673,44 @@ + + + Use FMTX + + + true + + + + 6 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + Settings + + + + + + + Qt::Vertical -- 1.7.9.5