Last.fm config
This commit is contained in:
parent
4aa1cdfa52
commit
8dd3242cd6
|
@ -1,13 +1,15 @@
|
||||||
#include "lastfmconfig.h"
|
#include "lastfmconfig.h"
|
||||||
#include "lastfmservice.h"
|
#include "lastfmservice.h"
|
||||||
|
#include "radiomodel.h"
|
||||||
|
|
||||||
#include <lastfm/ws.h>
|
#include <lastfm/ws.h>
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
LastFMConfig::LastFMConfig(LastFMService* service, QWidget *parent)
|
LastFMConfig::LastFMConfig(QWidget *parent)
|
||||||
: QDialog(parent),
|
: QWidget(parent),
|
||||||
service_(service)
|
service_(static_cast<LastFMService*>(RadioModel::ServiceByName("Last.fm")))
|
||||||
{
|
{
|
||||||
ui_.setupUi(this);
|
ui_.setupUi(this);
|
||||||
ui_.busy->hide();
|
ui_.busy->hide();
|
||||||
|
@ -15,29 +17,42 @@ LastFMConfig::LastFMConfig(LastFMService* service, QWidget *parent)
|
||||||
connect(service_, SIGNAL(AuthenticationComplete(bool)), SLOT(AuthenticationComplete(bool)));
|
connect(service_, SIGNAL(AuthenticationComplete(bool)), SLOT(AuthenticationComplete(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LastFMConfig::accept() {
|
bool LastFMConfig::NeedsValidation() const {
|
||||||
if (ui_.username->text().isEmpty() || ui_.password->text().isEmpty()) {
|
return !ui_.username->text().isEmpty() && !ui_.password->text().isEmpty();
|
||||||
QDialog::accept();
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void LastFMConfig::Validate() {
|
||||||
ui_.busy->show();
|
ui_.busy->show();
|
||||||
ui_.button_box->setEnabled(false);
|
|
||||||
|
|
||||||
service_->Authenticate(ui_.username->text(), ui_.password->text());
|
service_->Authenticate(ui_.username->text(), ui_.password->text());
|
||||||
|
|
||||||
emit ScrobblingEnabledChanged(ui_.scrobble->isChecked());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LastFMConfig::AuthenticationComplete(bool success) {
|
void LastFMConfig::AuthenticationComplete(bool success) {
|
||||||
|
if (!ui_.busy->isVisible())
|
||||||
|
return; // Wasn't us that was waiting for auth
|
||||||
|
|
||||||
ui_.busy->hide();
|
ui_.busy->hide();
|
||||||
ui_.button_box->setEnabled(true);
|
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
ui_.username->setText(lastfm::ws::Username);
|
ui_.username->setText(lastfm::ws::Username);
|
||||||
ui_.password->clear();
|
ui_.password->clear();
|
||||||
QDialog::accept();
|
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(this, "Authentication failed", "Your Last.fm credentials were incorrect");
|
QMessageBox::warning(this, "Authentication failed", "Your Last.fm credentials were incorrect");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit ValidationComplete(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LastFMConfig::Load() {
|
||||||
|
ui_.username->setText(lastfm::ws::Username);
|
||||||
|
ui_.scrobble->setChecked(service_->IsScrobblingEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
void LastFMConfig::Save() {
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(LastFMService::kSettingsGroup);
|
||||||
|
s.setValue("ScrobblingEnabled", ui_.scrobble->isChecked());
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
service_->ReloadSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,34 @@
|
||||||
#ifndef LASTFMCONFIG_H
|
#ifndef LASTFMCONFIG_H
|
||||||
#define LASTFMCONFIG_H
|
#define LASTFMCONFIG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "ui_lastfmconfig.h"
|
#include "ui_lastfmconfig.h"
|
||||||
|
|
||||||
class LastFMService;
|
class LastFMService;
|
||||||
|
|
||||||
class LastFMConfig : public QDialog {
|
class LastFMConfig : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LastFMConfig(LastFMService* service, QWidget* parent = 0);
|
LastFMConfig(QWidget* parent = 0);
|
||||||
|
|
||||||
void accept();
|
bool NeedsValidation() const;
|
||||||
|
|
||||||
Ui::LastFMConfig ui_;
|
public slots:
|
||||||
|
void Validate();
|
||||||
|
void Load();
|
||||||
|
void Save();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ScrobblingEnabledChanged(bool value);
|
void ValidationComplete(bool success);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void AuthenticationComplete(bool success);
|
void AuthenticationComplete(bool success);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LastFMService* service_;
|
LastFMService* service_;
|
||||||
|
Ui::LastFMConfig ui_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LASTFMCONFIG_H
|
#endif // LASTFMCONFIG_H
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>LastFMConfig</class>
|
<class>LastFMConfig</class>
|
||||||
<widget class="QDialog" name="LastFMConfig">
|
<widget class="QWidget" name="LastFMConfig">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>385</width>
|
<width>385</width>
|
||||||
<height>245</height>
|
<height>213</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Last.fm</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -115,16 +115,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="button_box">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
@ -135,38 +125,5 @@
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>button_box</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>LastFMConfig</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>button_box</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>LastFMConfig</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
#include "lastfmconfigdialog.h"
|
||||||
|
#include "ui_lastfmconfigdialog.h"
|
||||||
|
|
||||||
|
LastFMConfigDialog::LastFMConfigDialog(QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
ui_.setupUi(this);
|
||||||
|
|
||||||
|
connect(ui_.lastfm, SIGNAL(ValidationComplete(bool)), SLOT(ValidationComplete(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LastFMConfigDialog::showEvent(QShowEvent *) {
|
||||||
|
ui_.lastfm->Load();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LastFMConfigDialog::accept() {
|
||||||
|
if (ui_.lastfm->NeedsValidation()) {
|
||||||
|
ui_.lastfm->Validate();
|
||||||
|
ui_.buttonBox->setEnabled(false);
|
||||||
|
} else {
|
||||||
|
ui_.lastfm->Save();
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LastFMConfigDialog::ValidationComplete(bool success) {
|
||||||
|
ui_.buttonBox->setEnabled(true);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef LASTFMCONFIGDIALOG_H
|
||||||
|
#define LASTFMCONFIGDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include "ui_lastfmconfigdialog.h"
|
||||||
|
|
||||||
|
class LastFMConfigDialog : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
LastFMConfigDialog(QWidget* parent = 0);
|
||||||
|
|
||||||
|
void accept();
|
||||||
|
void showEvent(QShowEvent *);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ValidationComplete(bool success);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::LastFMConfigDialog ui_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LASTFMCONFIGDIALOG_H
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>LastFMConfigDialog</class>
|
||||||
|
<widget class="QDialog" name="LastFMConfigDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Last,fm</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>:/last.fm/as.png</normaloff>:/last.fm/as.png</iconset>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="LastFMConfig" name="lastfm" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>LastFMConfig</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>lastfmconfig.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>LastFMConfigDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>LastFMConfigDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -1,8 +1,8 @@
|
||||||
#include "lastfmservice.h"
|
#include "lastfmservice.h"
|
||||||
#include "lastfmconfig.h"
|
|
||||||
#include "radioitem.h"
|
#include "radioitem.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "lastfmstationdialog.h"
|
#include "lastfmstationdialog.h"
|
||||||
|
#include "lastfmconfigdialog.h"
|
||||||
|
|
||||||
#include <lastfm/ws.h>
|
#include <lastfm/ws.h>
|
||||||
#include <lastfm/misc.h>
|
#include <lastfm/misc.h>
|
||||||
|
@ -23,6 +23,7 @@ LastFMService::LastFMService(QObject* parent)
|
||||||
: RadioService(kServiceName, parent),
|
: RadioService(kServiceName, parent),
|
||||||
tuner_(NULL),
|
tuner_(NULL),
|
||||||
scrobbler_(NULL),
|
scrobbler_(NULL),
|
||||||
|
config_(NULL),
|
||||||
station_dialog_(new LastFMStationDialog),
|
station_dialog_(new LastFMStationDialog),
|
||||||
context_menu_(new QMenu),
|
context_menu_(new QMenu),
|
||||||
initial_tune_(false),
|
initial_tune_(false),
|
||||||
|
@ -35,17 +36,7 @@ LastFMService::LastFMService(QObject* parent)
|
||||||
lastfm::ws::ApiKey = kApiKey;
|
lastfm::ws::ApiKey = kApiKey;
|
||||||
lastfm::ws::SharedSecret = kSecret;
|
lastfm::ws::SharedSecret = kSecret;
|
||||||
|
|
||||||
QSettings settings;
|
ReloadSettings();
|
||||||
settings.beginGroup(kSettingsGroup);
|
|
||||||
lastfm::ws::Username = settings.value("username").toString();
|
|
||||||
lastfm::ws::SessionKey = settings.value("session").toString();
|
|
||||||
scrobbling_enabled_ = settings.value("scrobbling_enabled", true).toBool();
|
|
||||||
|
|
||||||
config_ = new LastFMConfig(this);
|
|
||||||
connect(config_, SIGNAL(ScrobblingEnabledChanged(bool)), SLOT(ScrobblingEnabledChangedSlot(bool)));
|
|
||||||
|
|
||||||
config_->ui_.username->setText(lastfm::ws::Username);
|
|
||||||
config_->ui_.scrobble->setEnabled(scrobbling_enabled_);
|
|
||||||
|
|
||||||
play_action_ = context_menu_->addAction(QIcon(":media-playback-start.png"), "Add to playlist", this, SLOT(AddToPlaylist()));
|
play_action_ = context_menu_->addAction(QIcon(":media-playback-start.png"), "Add to playlist", this, SLOT(AddToPlaylist()));
|
||||||
remove_action_ = context_menu_->addAction(QIcon(":list-remove.png"), "Remove", this, SLOT(Remove()));
|
remove_action_ = context_menu_->addAction(QIcon(":list-remove.png"), "Remove", this, SLOT(Remove()));
|
||||||
|
@ -53,7 +44,7 @@ LastFMService::LastFMService(QObject* parent)
|
||||||
add_artist_action_ = context_menu_->addAction(QIcon(":last.fm/icon_radio.png"), "Play artist radio...", this, SLOT(AddArtistRadio()));
|
add_artist_action_ = context_menu_->addAction(QIcon(":last.fm/icon_radio.png"), "Play artist radio...", this, SLOT(AddArtistRadio()));
|
||||||
add_tag_action_ = context_menu_->addAction(QIcon(":last.fm/icon_tag.png"), "Play tag radio...", this, SLOT(AddTagRadio()));
|
add_tag_action_ = context_menu_->addAction(QIcon(":last.fm/icon_tag.png"), "Play tag radio...", this, SLOT(AddTagRadio()));
|
||||||
context_menu_->addAction(QIcon(":configure.png"), "Configure Last.fm...",
|
context_menu_->addAction(QIcon(":configure.png"), "Configure Last.fm...",
|
||||||
config_, SLOT(show()));
|
this, SLOT(ShowConfig()));
|
||||||
|
|
||||||
remove_action_->setEnabled(false);
|
remove_action_->setEnabled(false);
|
||||||
add_artist_action_->setEnabled(false);
|
add_artist_action_->setEnabled(false);
|
||||||
|
@ -66,18 +57,26 @@ LastFMService::~LastFMService() {
|
||||||
delete context_menu_;
|
delete context_menu_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LastFMService::IsAuthenticated() const {
|
void LastFMService::ReloadSettings() {
|
||||||
return !lastfm::ws::SessionKey.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LastFMService::ScrobblingEnabledChangedSlot(bool value) {
|
|
||||||
scrobbling_enabled_ = value;
|
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.beginGroup(kSettingsGroup);
|
settings.beginGroup(kSettingsGroup);
|
||||||
settings.setValue("scrobbling_enabled", scrobbling_enabled_);
|
lastfm::ws::Username = settings.value("Username").toString();
|
||||||
|
lastfm::ws::SessionKey = settings.value("Session").toString();
|
||||||
|
scrobbling_enabled_ = settings.value("ScrobblingEnabled", true).toBool();
|
||||||
|
|
||||||
emit ScrobblingEnabledChanged(value);
|
emit ScrobblingEnabledChanged(scrobbling_enabled_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LastFMService::ShowConfig() {
|
||||||
|
if (!config_) {
|
||||||
|
config_ = new LastFMConfigDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
config_->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LastFMService::IsAuthenticated() const {
|
||||||
|
return !lastfm::ws::SessionKey.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioItem* LastFMService::CreateRootItem(RadioItem* parent) {
|
RadioItem* LastFMService::CreateRootItem(RadioItem* parent) {
|
||||||
|
@ -114,7 +113,7 @@ void LastFMService::LazyPopulate(RadioItem *item) {
|
||||||
neighbours_list_->icon = QIcon(":last.fm/my_neighbours.png");
|
neighbours_list_->icon = QIcon(":last.fm/my_neighbours.png");
|
||||||
|
|
||||||
if (!IsAuthenticated())
|
if (!IsAuthenticated())
|
||||||
config_->show();
|
ShowConfig();
|
||||||
|
|
||||||
add_artist_action_->setEnabled(true);
|
add_artist_action_->setEnabled(true);
|
||||||
add_tag_action_->setEnabled(true);
|
add_tag_action_->setEnabled(true);
|
||||||
|
@ -186,8 +185,8 @@ void LastFMService::AuthenticateReplyFinished() {
|
||||||
// Save the session key
|
// Save the session key
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.beginGroup(kSettingsGroup);
|
settings.beginGroup(kSettingsGroup);
|
||||||
settings.setValue("username", lastfm::ws::Username);
|
settings.setValue("Username", lastfm::ws::Username);
|
||||||
settings.setValue("session", lastfm::ws::SessionKey);
|
settings.setValue("Session", lastfm::ws::SessionKey);
|
||||||
|
|
||||||
// Invalidate the scrobbler - it will get recreated later
|
// Invalidate the scrobbler - it will get recreated later
|
||||||
delete scrobbler_;
|
delete scrobbler_;
|
||||||
|
@ -377,7 +376,7 @@ void LastFMService::Scrobble() {
|
||||||
|
|
||||||
void LastFMService::Love() {
|
void LastFMService::Love() {
|
||||||
if (!IsAuthenticated())
|
if (!IsAuthenticated())
|
||||||
config_->show();
|
ShowConfig();
|
||||||
|
|
||||||
lastfm::MutableTrack mtrack(last_track_);
|
lastfm::MutableTrack mtrack(last_track_);
|
||||||
mtrack.love();
|
mtrack.love();
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QAction;
|
class QAction;
|
||||||
|
|
||||||
class LastFMConfig;
|
class LastFMConfigDialog;
|
||||||
|
|
||||||
class LastFMService : public RadioService {
|
class LastFMService : public RadioService {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -58,6 +58,8 @@ class LastFMService : public RadioService {
|
||||||
bool IsPauseAllowed() const { return false; }
|
bool IsPauseAllowed() const { return false; }
|
||||||
bool ShowLastFmControls() const { return true; }
|
bool ShowLastFmControls() const { return true; }
|
||||||
|
|
||||||
|
void ReloadSettings();
|
||||||
|
|
||||||
// Last.fm specific stuff
|
// Last.fm specific stuff
|
||||||
bool IsAuthenticated() const;
|
bool IsAuthenticated() const;
|
||||||
bool IsScrobblingEnabled() const { return scrobbling_enabled_; }
|
bool IsScrobblingEnabled() const { return scrobbling_enabled_; }
|
||||||
|
@ -76,9 +78,9 @@ class LastFMService : public RadioService {
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void AuthenticateReplyFinished();
|
void AuthenticateReplyFinished();
|
||||||
void ScrobblingEnabledChangedSlot(bool value);
|
|
||||||
void RefreshFriendsFinished();
|
void RefreshFriendsFinished();
|
||||||
void RefreshNeighboursFinished();
|
void RefreshNeighboursFinished();
|
||||||
|
void ShowConfig();
|
||||||
|
|
||||||
void TunerTrackAvailable();
|
void TunerTrackAvailable();
|
||||||
void TunerError(lastfm::ws::Error error);
|
void TunerError(lastfm::ws::Error error);
|
||||||
|
@ -108,7 +110,7 @@ class LastFMService : public RadioService {
|
||||||
lastfm::Audioscrobbler* scrobbler_;
|
lastfm::Audioscrobbler* scrobbler_;
|
||||||
lastfm::Track last_track_;
|
lastfm::Track last_track_;
|
||||||
|
|
||||||
LastFMConfig* config_;
|
LastFMConfigDialog* config_;
|
||||||
LastFMStationDialog* station_dialog_;
|
LastFMStationDialog* station_dialog_;
|
||||||
|
|
||||||
QMenu* context_menu_;
|
QMenu* context_menu_;
|
||||||
|
|
|
@ -40,12 +40,12 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
track_slider_(new TrackSlider(this)),
|
track_slider_(new TrackSlider(this)),
|
||||||
edit_tag_dialog_(new EditTagDialog(this)),
|
edit_tag_dialog_(new EditTagDialog(this)),
|
||||||
multi_loading_indicator_(new MultiLoadingIndicator(this)),
|
multi_loading_indicator_(new MultiLoadingIndicator(this)),
|
||||||
settings_dialog_(new SettingsDialog(this)),
|
|
||||||
library_config_dialog_(new LibraryConfigDialog(this)),
|
library_config_dialog_(new LibraryConfigDialog(this)),
|
||||||
radio_model_(new RadioModel(this)),
|
radio_model_(new RadioModel(this)),
|
||||||
playlist_(new Playlist(this)),
|
playlist_(new Playlist(this)),
|
||||||
player_(new Player(playlist_, radio_model_->GetLastFMService(), this)),
|
player_(new Player(playlist_, radio_model_->GetLastFMService(), this)),
|
||||||
library_(new Library(player_->GetEngine(), this)),
|
library_(new Library(player_->GetEngine(), this)),
|
||||||
|
settings_dialog_(new SettingsDialog(this)),
|
||||||
playlist_menu_(new QMenu(this)),
|
playlist_menu_(new QMenu(this)),
|
||||||
library_sort_model_(new QSortFilterProxyModel(this)),
|
library_sort_model_(new QSortFilterProxyModel(this)),
|
||||||
track_position_timer_(new QTimer(this))
|
track_position_timer_(new QTimer(this))
|
||||||
|
|
|
@ -81,7 +81,6 @@ class MainWindow : public QMainWindow {
|
||||||
TrackSlider* track_slider_;
|
TrackSlider* track_slider_;
|
||||||
EditTagDialog* edit_tag_dialog_;
|
EditTagDialog* edit_tag_dialog_;
|
||||||
MultiLoadingIndicator* multi_loading_indicator_;
|
MultiLoadingIndicator* multi_loading_indicator_;
|
||||||
SettingsDialog* settings_dialog_;
|
|
||||||
LibraryConfigDialog* library_config_dialog_;
|
LibraryConfigDialog* library_config_dialog_;
|
||||||
|
|
||||||
RadioModel* radio_model_;
|
RadioModel* radio_model_;
|
||||||
|
@ -89,6 +88,8 @@ class MainWindow : public QMainWindow {
|
||||||
Player* player_;
|
Player* player_;
|
||||||
Library* library_;
|
Library* library_;
|
||||||
|
|
||||||
|
SettingsDialog* settings_dialog_;
|
||||||
|
|
||||||
QMenu* playlist_menu_;
|
QMenu* playlist_menu_;
|
||||||
QAction* playlist_play_pause_;
|
QAction* playlist_play_pause_;
|
||||||
QAction* playlist_stop_after_;
|
QAction* playlist_stop_after_;
|
||||||
|
|
|
@ -119,3 +119,9 @@ void RadioModel::ShowContextMenu(RadioItem* item, const QPoint& global_pos) {
|
||||||
if (item->service)
|
if (item->service)
|
||||||
item->service->ShowContextMenu(item, global_pos);
|
item->service->ShowContextMenu(item, global_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RadioModel::ReloadSettings() {
|
||||||
|
foreach (RadioService* service, sServices.values()) {
|
||||||
|
service->ReloadSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ class RadioModel : public SimpleTreeModel<RadioItem> {
|
||||||
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
||||||
|
|
||||||
void ShowContextMenu(RadioItem* item, const QPoint& global_pos);
|
void ShowContextMenu(RadioItem* item, const QPoint& global_pos);
|
||||||
|
void ReloadSettings();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void TaskStarted(const QString&);
|
void TaskStarted(const QString&);
|
||||||
|
|
|
@ -34,6 +34,8 @@ class RadioService : public QObject {
|
||||||
virtual bool IsPauseAllowed() const { return true; }
|
virtual bool IsPauseAllowed() const { return true; }
|
||||||
virtual bool ShowLastFmControls() const { return false; }
|
virtual bool ShowLastFmControls() const { return false; }
|
||||||
|
|
||||||
|
virtual void ReloadSettings() {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void TaskStarted(const QString& name);
|
void TaskStarted(const QString& name);
|
||||||
void TaskFinished(const QString& name);
|
void TaskFinished(const QString& name);
|
||||||
|
|
|
@ -9,6 +9,9 @@ SettingsDialog::SettingsDialog(QWidget* parent)
|
||||||
{
|
{
|
||||||
ui_.setupUi(this);
|
ui_.setupUi(this);
|
||||||
|
|
||||||
|
// Last.fm
|
||||||
|
connect(ui_.lastfm, SIGNAL(ValidationComplete(bool)), SLOT(LastFMValidationComplete(bool)));
|
||||||
|
|
||||||
// List box
|
// List box
|
||||||
connect(ui_.list, SIGNAL(currentTextChanged(QString)), SLOT(CurrentTextChanged(QString)));
|
connect(ui_.list, SIGNAL(currentTextChanged(QString)), SLOT(CurrentTextChanged(QString)));
|
||||||
ui_.list->setCurrentRow(0);
|
ui_.list->setCurrentRow(0);
|
||||||
|
@ -32,7 +35,22 @@ void SettingsDialog::SetLibraryDirectoryModel(LibraryDirectoryModel* model) {
|
||||||
ui_.library_config->SetModel(model);
|
ui_.library_config->SetModel(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::LastFMValidationComplete(bool success) {
|
||||||
|
ui_.buttonBox->setEnabled(true);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsDialog::accept() {
|
void SettingsDialog::accept() {
|
||||||
|
if (ui_.lastfm->NeedsValidation()) {
|
||||||
|
ui_.lastfm->Validate();
|
||||||
|
ui_.buttonBox->setEnabled(false);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
ui_.lastfm->Save();
|
||||||
|
}
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
|
||||||
// Playback
|
// Playback
|
||||||
|
@ -58,6 +76,9 @@ void SettingsDialog::accept() {
|
||||||
void SettingsDialog::showEvent(QShowEvent*) {
|
void SettingsDialog::showEvent(QShowEvent*) {
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
|
||||||
|
// Last.fm
|
||||||
|
ui_.lastfm->Load();
|
||||||
|
|
||||||
// Playback
|
// Playback
|
||||||
s.beginGroup(Engine::Base::kSettingsGroup);
|
s.beginGroup(Engine::Base::kSettingsGroup);
|
||||||
if (s.value("FadeoutEnabled", true).toBool())
|
if (s.value("FadeoutEnabled", true).toBool())
|
||||||
|
|
|
@ -24,6 +24,7 @@ class SettingsDialog : public QDialog {
|
||||||
private slots:
|
private slots:
|
||||||
void CurrentTextChanged(const QString& text);
|
void CurrentTextChanged(const QString& text);
|
||||||
void NotificationTypeChanged();
|
void NotificationTypeChanged();
|
||||||
|
void LastFMValidationComplete(bool success);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SettingsDialog ui_;
|
Ui::SettingsDialog ui_;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Settings</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
<string>Playback</string>
|
<string>Playback</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="../data/data.qrc">
|
||||||
<normaloff>:/media-playback-start-32.png</normaloff>:/media-playback-start-32.png</iconset>
|
<normaloff>:/media-playback-start-32.png</normaloff>:/media-playback-start-32.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
<string>Notifications</string>
|
<string>Notifications</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="../data/data.qrc">
|
||||||
<normaloff>:/lightbulb.png</normaloff>:/lightbulb.png</iconset>
|
<normaloff>:/lightbulb.png</normaloff>:/lightbulb.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
<string>Music Library</string>
|
<string>Music Library</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="../data/data.qrc">
|
||||||
<normaloff>:/library.png</normaloff>:/library.png</iconset>
|
<normaloff>:/library.png</normaloff>:/library.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
<string>Last.fm</string>
|
<string>Last.fm</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="../data/data.qrc">
|
||||||
<normaloff>:/last.fm/as.png</normaloff>:/last.fm/as.png</iconset>
|
<normaloff>:/last.fm/as.png</normaloff>:/last.fm/as.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
@ -99,9 +99,9 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="stackedWidget">
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="page">
|
<widget class="QWidget" name="playback_page">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -195,7 +195,7 @@
|
||||||
<zorder>groupBox</zorder>
|
<zorder>groupBox</zorder>
|
||||||
<zorder>verticalSpacer</zorder>
|
<zorder>verticalSpacer</zorder>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page_4">
|
<widget class="QWidget" name="notifications_page">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -288,7 +288,7 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page_2">
|
<widget class="QWidget" name="library_page">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -298,7 +298,16 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page_3"/>
|
<widget class="QWidget" name="lastfm_page">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="LastFMConfig" name="lastfm" native="true"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -326,6 +335,12 @@
|
||||||
<header>libraryconfig.h</header>
|
<header>libraryconfig.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>LastFMConfig</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>lastfmconfig.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>list</tabstop>
|
<tabstop>list</tabstop>
|
||||||
|
@ -334,7 +349,9 @@
|
||||||
<tabstop>fadeout_duration</tabstop>
|
<tabstop>fadeout_duration</tabstop>
|
||||||
<tabstop>buttonBox</tabstop>
|
<tabstop>buttonBox</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../data/data.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>list</sender>
|
<sender>list</sender>
|
||||||
|
|
|
@ -51,7 +51,8 @@ SOURCES += main.cpp \
|
||||||
somafmservice.cpp \
|
somafmservice.cpp \
|
||||||
settingsdialog.cpp \
|
settingsdialog.cpp \
|
||||||
librarydirectorymodel.cpp \
|
librarydirectorymodel.cpp \
|
||||||
libraryconfigdialog.cpp
|
libraryconfigdialog.cpp \
|
||||||
|
lastfmconfigdialog.cpp
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
player.h \
|
player.h \
|
||||||
library.h \
|
library.h \
|
||||||
|
@ -103,7 +104,8 @@ HEADERS += mainwindow.h \
|
||||||
somafmservice.h \
|
somafmservice.h \
|
||||||
settingsdialog.h \
|
settingsdialog.h \
|
||||||
librarydirectorymodel.h \
|
librarydirectorymodel.h \
|
||||||
libraryconfigdialog.h
|
libraryconfigdialog.h \
|
||||||
|
lastfmconfigdialog.h
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
libraryconfig.ui \
|
libraryconfig.ui \
|
||||||
fileview.ui \
|
fileview.ui \
|
||||||
|
@ -113,7 +115,8 @@ FORMS += mainwindow.ui \
|
||||||
edittagdialog.ui \
|
edittagdialog.ui \
|
||||||
multiloadingindicator.ui \
|
multiloadingindicator.ui \
|
||||||
settingsdialog.ui \
|
settingsdialog.ui \
|
||||||
libraryconfigdialog.ui
|
libraryconfigdialog.ui \
|
||||||
|
lastfmconfigdialog.ui
|
||||||
RESOURCES += ../data/data.qrc
|
RESOURCES += ../data/data.qrc
|
||||||
OTHER_FILES += ../data/schema.sql \
|
OTHER_FILES += ../data/schema.sql \
|
||||||
../data/mainwindow.css
|
../data/mainwindow.css
|
||||||
|
|
Loading…
Reference in New Issue