From ae9b41a535a0d86968d8ec68ba1be4bf203a2176 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Mon, 1 Jul 2019 21:25:36 +0000 Subject: prepare for ListenBrainz plugin implementation git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8980 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/General.pro | 3 +- .../General/listenbrainz/listenbrainzfactory.cpp | 59 +++++++++++++ .../General/listenbrainz/listenbrainzfactory.h | 44 ++++++++++ .../General/listenbrainz/settingsdialog.cpp | 24 ++++++ src/plugins/General/listenbrainz/settingsdialog.h | 24 ++++++ src/plugins/General/listenbrainz/settingsdialog.ui | 96 ++++++++++++++++++++++ 6 files changed, 249 insertions(+), 1 deletion(-) create mode 100644 src/plugins/General/listenbrainz/listenbrainzfactory.cpp create mode 100644 src/plugins/General/listenbrainz/listenbrainzfactory.h create mode 100644 src/plugins/General/listenbrainz/settingsdialog.cpp create mode 100644 src/plugins/General/listenbrainz/settingsdialog.h create mode 100644 src/plugins/General/listenbrainz/settingsdialog.ui (limited to 'src/plugins') diff --git a/src/plugins/General/General.pro b/src/plugins/General/General.pro index cd07a3c37..630434dff 100644 --- a/src/plugins/General/General.pro +++ b/src/plugins/General/General.pro @@ -10,7 +10,8 @@ SUBDIRS += statusicon \ trackchange \ copypaste \ rgscan \ - hotkey + hotkey \ + listenbrainz unix:SUBDIRS += mpris \ kdenotify \ diff --git a/src/plugins/General/listenbrainz/listenbrainzfactory.cpp b/src/plugins/General/listenbrainz/listenbrainzfactory.cpp new file mode 100644 index 000000000..70d4884e6 --- /dev/null +++ b/src/plugins/General/listenbrainz/listenbrainzfactory.cpp @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2019 by Ilya Kotov * + * forkotov02@ya.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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include +#include +//#include "scrobblerhandler.h" +#include "settingsdialog.h" +#include "listenbrainzfactory.h" + +GeneralProperties ListenBrainzFactory::properties() const +{ + GeneralProperties properties; + properties.name = tr("ListenBrainz Plugin"); + properties.shortName = "listenbrainz"; + properties.hasAbout = true; + properties.hasSettings = true; + properties.visibilityControl = false; + return properties; +} + +QObject *ListenBrainzFactory::create(QObject *parent) +{ + //return new ScrobblerHandler(parent); + return nullptr; +} + +QDialog *ListenBrainzFactory::createConfigDialog(QWidget *parent) +{ + return new SettingsDialog(parent); +} + +void ListenBrainzFactory::showAbout(QWidget *parent) +{ + QMessageBox::about (parent, tr("About ListenBrainz Plugin"), + tr("Qmmp ListenBrainz Plugin")+"\n"+ + tr("Written by: Ilya Kotov ")); +} + +QString ListenBrainzFactory::translation() const +{ + return QLatin1String(":/listenbrainz_plugin_"); +} diff --git a/src/plugins/General/listenbrainz/listenbrainzfactory.h b/src/plugins/General/listenbrainz/listenbrainzfactory.h new file mode 100644 index 000000000..c7b77d608 --- /dev/null +++ b/src/plugins/General/listenbrainz/listenbrainzfactory.h @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (C) 2019 by Ilya Kotov * + * forkotov02@ya.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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef LISTENBRAINZFACTORY_H +#define LISTENBRAINZFACTORY_H + +/** + @author Ilya Kotov +*/ +#include + +#include +#include + +class ListenBrainzFactory : public QObject, public GeneralFactory +{ +Q_OBJECT +Q_PLUGIN_METADATA(IID "org.qmmp.qmmpui.GeneralFactoryInterface.1.0") +Q_INTERFACES(GeneralFactory) +public: + GeneralProperties properties() const override; + QObject *create(QObject *parent) override; + QDialog *createConfigDialog(QWidget *parent) override; + void showAbout(QWidget *parent) override; + QString translation() const override; +}; + +#endif diff --git a/src/plugins/General/listenbrainz/settingsdialog.cpp b/src/plugins/General/listenbrainz/settingsdialog.cpp new file mode 100644 index 000000000..fe6bbf964 --- /dev/null +++ b/src/plugins/General/listenbrainz/settingsdialog.cpp @@ -0,0 +1,24 @@ +#include +#include +#include "settingsdialog.h" +#include "ui_settingsdialog.h" + +SettingsDialog::SettingsDialog(QWidget *parent) : + QDialog(parent), m_ui(new Ui::SettingsDialog) +{ + m_ui->setupUi(this); + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + m_ui->userTokenLineEdit->setText(settings.value("ListenBrainz/user_token").toString()); +} + +SettingsDialog::~SettingsDialog() +{ + delete m_ui; +} + +void SettingsDialog::accept() +{ + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + settings.setValue("ListenBrainz/user_token", m_ui->userTokenLineEdit->text()); + QDialog::accept(); +} diff --git a/src/plugins/General/listenbrainz/settingsdialog.h b/src/plugins/General/listenbrainz/settingsdialog.h new file mode 100644 index 000000000..3ee8b0ac0 --- /dev/null +++ b/src/plugins/General/listenbrainz/settingsdialog.h @@ -0,0 +1,24 @@ +#ifndef SETTINGSDIALOG_H +#define SETTINGSDIALOG_H + +#include + +namespace Ui { +class SettingsDialog; +} + +class SettingsDialog : public QDialog +{ + Q_OBJECT +public: + explicit SettingsDialog(QWidget *parent = 0); + ~SettingsDialog(); + +public slots: + void accept() override; + +private: + Ui::SettingsDialog *m_ui; +}; + +#endif // SETTINGSDIALOG_H diff --git a/src/plugins/General/listenbrainz/settingsdialog.ui b/src/plugins/General/listenbrainz/settingsdialog.ui new file mode 100644 index 000000000..3197fec04 --- /dev/null +++ b/src/plugins/General/listenbrainz/settingsdialog.ui @@ -0,0 +1,96 @@ + + + SettingsDialog + + + + 0 + 0 + 400 + 107 + + + + Dialog + + + + 6 + + + 6 + + + 6 + + + + + ListenBrainz user token: + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + SettingsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + SettingsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + -- cgit v1.2.3-13-gbd6f