aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2019-11-04 13:25:05 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2019-11-04 13:25:05 +0000
commit74ec7eeee3de7e5b1a7f07206da65b604356f9be (patch)
tree13a529acdc009d84bf8edb9621f574f6553b5365
parenta52f165675d244a4e01c583ec44fd40a1cc127d1 (diff)
downloadqmmp-74ec7eeee3de7e5b1a7f07206da65b604356f9be.tar.gz
qmmp-74ec7eeee3de7e5b1a7f07206da65b604356f9be.tar.bz2
qmmp-74ec7eeee3de7e5b1a7f07206da65b604356f9be.zip
lyrics: added settings dialog, fixed remaining issues
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9093 90c681e8-e032-0410-971d-27865f9a5e38
-rw-r--r--src/plugins/General/lyrics/lyrics.pro9
-rw-r--r--src/plugins/General/lyrics/lyricsfactory.cpp9
-rw-r--r--src/plugins/General/lyrics/lyricsprovider.cpp9
-rw-r--r--src/plugins/General/lyrics/lyricsprovider.h3
-rw-r--r--src/plugins/General/lyrics/lyricswindow.cpp87
-rw-r--r--src/plugins/General/lyrics/lyricswindow.h5
-rw-r--r--src/plugins/General/lyrics/lyricswindow.ui200
-rw-r--r--src/plugins/General/lyrics/settingsdialog.cpp61
-rw-r--r--src/plugins/General/lyrics/settingsdialog.h45
-rw-r--r--src/plugins/General/lyrics/settingsdialog.ui83
-rw-r--r--src/plugins/General/lyrics/ultimatelyricsparser.cpp12
-rw-r--r--src/plugins/General/lyrics/ultimatelyricsparser.h1
12 files changed, 462 insertions, 62 deletions
diff --git a/src/plugins/General/lyrics/lyrics.pro b/src/plugins/General/lyrics/lyrics.pro
index fc3a717a7..46d0b5292 100644
--- a/src/plugins/General/lyrics/lyrics.pro
+++ b/src/plugins/General/lyrics/lyrics.pro
@@ -8,15 +8,18 @@ HEADERS += lyricsfactory.h \
lyrics.h \
lyricswindow.h \
lyricsprovider.h \
- ultimatelyricsparser.h
+ ultimatelyricsparser.h \
+ settingsdialog.h
SOURCES += lyricsfactory.cpp \
lyrics.cpp \
lyricswindow.cpp \
lyricsprovider.cpp \
- ultimatelyricsparser.cpp
+ ultimatelyricsparser.cpp \
+ settingsdialog.cpp
-FORMS += lyricswindow.ui
+FORMS += lyricswindow.ui \
+ settingsdialog.ui
RESOURCES = translations/translations.qrc \
providers/providers.qrc
diff --git a/src/plugins/General/lyrics/lyricsfactory.cpp b/src/plugins/General/lyrics/lyricsfactory.cpp
index aef4322f9..be8b2fee5 100644
--- a/src/plugins/General/lyrics/lyricsfactory.cpp
+++ b/src/plugins/General/lyrics/lyricsfactory.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009 by Ilya Kotov *
+ * Copyright (C) 2009-2019 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -18,8 +18,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-
#include <QMessageBox>
+#include "settingsdialog.h"
#include "lyrics.h"
#include "lyricsfactory.h"
@@ -29,7 +29,7 @@ GeneralProperties LyricsFactory::properties() const
properties.name = tr("Lyrics Plugin");
properties.shortName = "lyrics";
properties.hasAbout = true;
- properties.hasSettings = false;
+ properties.hasSettings = true;
properties.visibilityControl = false;
return properties;
}
@@ -41,8 +41,7 @@ QObject *LyricsFactory::create(QObject *parent)
QDialog *LyricsFactory::createConfigDialog(QWidget *parent)
{
- Q_UNUSED(parent);
- return nullptr;
+ return new SettingsDialog(parent);
}
void LyricsFactory::showAbout(QWidget *parent)
diff --git a/src/plugins/General/lyrics/lyricsprovider.cpp b/src/plugins/General/lyrics/lyricsprovider.cpp
index 4dae451dd..755e1ba06 100644
--- a/src/plugins/General/lyrics/lyricsprovider.cpp
+++ b/src/plugins/General/lyrics/lyricsprovider.cpp
@@ -101,6 +101,9 @@ QString LyricsProvider::format(const QByteArray &data, const TrackInfo &track) c
return QString();
}
+ if(m_skipRules)
+ return content;
+
const QMap<QString, QString> replaceMap = generateReplaceMap(track);
for(const Rule &rule : qAsConst(m_extractRules))
@@ -157,6 +160,11 @@ const QString &LyricsProvider::name() const
return m_name;
}
+void LyricsProvider::skipRules(bool skip)
+{
+ m_skipRules = skip;
+}
+
QString LyricsProvider::fixCase(const QString &title) const
{
QString out;
@@ -201,7 +209,6 @@ QString LyricsProvider::extract(const QString &content, const Rule &rule) const
for(const Item &item : qAsConst(rule))
{
-
if(!item.url.isEmpty())
{
QString url = item.url;
diff --git a/src/plugins/General/lyrics/lyricsprovider.h b/src/plugins/General/lyrics/lyricsprovider.h
index 3e9e7bf81..734f0749c 100644
--- a/src/plugins/General/lyrics/lyricsprovider.h
+++ b/src/plugins/General/lyrics/lyricsprovider.h
@@ -23,6 +23,7 @@ public:
QString getUrl(const TrackInfo &track) const;
QString format(const QByteArray &data, const TrackInfo &track) const;
const QString &name() const;
+ void skipRules(bool skip);
private:
@@ -50,7 +51,7 @@ private:
QList<Rule> m_extractRules;
QList<Rule> m_excludeRules;
QStringList m_invalidIndicators;
-
+ bool m_skipRules = false;
};
#endif // LYRICSPROVIDER_H
diff --git a/src/plugins/General/lyrics/lyricswindow.cpp b/src/plugins/General/lyrics/lyricswindow.cpp
index 5036bc4c8..39dee905a 100644
--- a/src/plugins/General/lyrics/lyricswindow.cpp
+++ b/src/plugins/General/lyrics/lyricswindow.cpp
@@ -23,9 +23,9 @@
#include <QNetworkReply>
#include <QNetworkProxy>
#include <QUrl>
-#include <QRegExp>
#include <QFile>
#include <QDir>
+#include <QSettings>
#include <QCryptographicHash>
#include <qmmp/qmmpsettings.h>
#include <qmmp/qmmp.h>
@@ -38,10 +38,14 @@ LyricsWindow::LyricsWindow(const TrackInfo *info, QWidget *parent)
setWindowFlags(Qt::Dialog);
setAttribute(Qt::WA_DeleteOnClose);
setAttribute(Qt::WA_QuitOnClose, false);
- m_info = *info;
m_cachePath = Qmmp::configDir() + "/lyrics/";
- //m_ui.artistLineEdit->setText(info);
- //m_ui.titleLineEdit->setText(title);
+ m_ui.editWidget->setVisible(false);
+ m_ui.titleLineEdit->setText(info->value(Qmmp::TITLE));
+ m_ui.artistLineEdit->setText(info->value(Qmmp::ARTIST));
+ m_ui.albumLineEdit->setText(info->value(Qmmp::ALBUM));
+ m_ui.trackSpinBox->setValue(info->value(Qmmp::TRACK).toInt());
+ m_ui.yearSpinBox->setValue(info->value(Qmmp::YEAR).toInt());
+
m_http = new QNetworkAccessManager(this);
//load global proxy settings
QmmpSettings *gs = QmmpSettings::instance();
@@ -62,6 +66,9 @@ LyricsWindow::LyricsWindow(const TrackInfo *info, QWidget *parent)
if(!m_parser.load(":/ultimate_providers.xml"))
qWarning("LyricsWindow: unable to load ultimate_providers.xml");
+ QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
+ m_enabledProviders = settings.value("Lyrics/enabled_providers", m_parser.defaultProviders()).toStringList();
+
QDir cacheDir(m_cachePath);
if(!cacheDir.exists())
{
@@ -69,10 +76,9 @@ LyricsWindow::LyricsWindow(const TrackInfo *info, QWidget *parent)
qWarning("LyricsWindow: unable to create cache directory");
}
if(!loadFromCache())
- on_searchPushButton_clicked();
+ on_refreshButton_clicked();
}
-
LyricsWindow::~LyricsWindow()
{
}
@@ -81,20 +87,34 @@ void LyricsWindow::onRequestFinished(QNetworkReply *reply)
{
QString name = m_tasks.take(reply);
QVariant redirectTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ int code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- if(reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 200)
+ if(reply->error() == QNetworkReply::NoError && code == 200)
{
QByteArray data = reply->readAll();
LyricsProvider *provider = m_parser.provider(name);
if(provider)
{
QString content = provider->format(data, m_info);
- qDebug() << content;
- if(!content.isEmpty())
+
+ if(content.startsWith("http") || content.startsWith("https"))
{
- m_ui.textBrowser->append(QString("<b>%1</b>").arg(provider->name()));
- m_ui.textBrowser->append(content);
- m_ui.textBrowser->append("<br>-------------------------------------<br>");
+ QNetworkRequest request;
+ request.setUrl(content);
+ request.setRawHeader("User-Agent", QString("qmmp/%1").arg(Qmmp::strVersion()).toLatin1());
+ m_tasks.insert(m_http->get(request), provider->name());
+ provider->skipRules(true);
+ }
+ else if(!content.isEmpty())
+ {
+ content.prepend(tr("<h2>%1 - %2</h2>").arg(m_info.value(Qmmp::ARTIST)).arg(m_info.value(Qmmp::TITLE)));
+ m_ui.providerComboBox->addItem(name, content);
+ if(m_ui.providerComboBox->count() == 1)
+ {
+ m_ui.providerComboBox->setCurrentIndex(0);
+ m_ui.textBrowser->setHtml(content);
+ saveToCache(content);
+ }
}
}
}
@@ -102,6 +122,11 @@ void LyricsWindow::onRequestFinished(QNetworkReply *reply)
{
m_tasks.insert(m_http->get(QNetworkRequest(redirectTarget.toUrl())), name);
}
+ else if(m_tasks.isEmpty() && m_ui.providerComboBox->count() == 0)
+ {
+ m_ui.textBrowser->setText(tr("Error: %1 - %2").arg(code).arg(reply->errorString()));
+ qWarning() << "error:" << reply->errorString();
+ }
else
{
qWarning() << "error:" << reply->errorString();
@@ -110,24 +135,42 @@ void LyricsWindow::onRequestFinished(QNetworkReply *reply)
reply->deleteLater();
}
-void LyricsWindow::on_searchPushButton_clicked()
+void LyricsWindow::on_refreshButton_clicked()
{
- m_ui.stateLabel->setText(tr("Receiving"));
+ m_ui.textBrowser->setHtml(QString("<b>%1</b>").arg(tr("Receiving")));
+ m_ui.providerComboBox->clear();
+
+ m_info.clear();
+ m_info.setValue(Qmmp::TITLE, m_ui.titleLineEdit->text());
+ m_info.setValue(Qmmp::ARTIST, m_ui.artistLineEdit->text());
+ m_info.setValue(Qmmp::ALBUM, m_ui.albumLineEdit->text());
+ m_info.setValue(Qmmp::TRACK, m_ui.trackSpinBox->value());
+ m_info.setValue(Qmmp::YEAR, m_ui.yearSpinBox->value());
for(LyricsProvider *provider : m_parser.providers())
{
- //if(provider->name() == "lyrics.wikia.com")
+ if(m_enabledProviders.contains(provider->name()))
{
- QString url = provider->getUrl(m_info);
- qDebug() << provider->name() << url;
- QNetworkRequest request;
- request.setUrl(url);
- request.setRawHeader("User-Agent", QString("qmmp/%1").arg(Qmmp::strVersion()).toLatin1());
- m_tasks.insert(m_http->get(request), provider->name());
+ QString url = provider->getUrl(m_info);
+ QNetworkRequest request;
+ request.setUrl(url);
+ request.setRawHeader("User-Agent", QString("qmmp/%1").arg(Qmmp::strVersion()).toLatin1());
+ m_tasks.insert(m_http->get(request), provider->name());
+ provider->skipRules(false);
}
}
}
+void LyricsWindow::on_editButton_clicked(bool checked)
+{
+ m_ui.editWidget->setVisible(checked);
+}
+
+void LyricsWindow::on_providerComboBox_activated(int index)
+{
+ m_ui.textBrowser->setHtml(m_ui.providerComboBox->itemData(index).toString());
+}
+
QString LyricsWindow::cacheFilePath() const
{
QString name = m_ui.artistLineEdit->text() + "_" + m_ui.titleLineEdit->text();
@@ -149,7 +192,7 @@ bool LyricsWindow::loadFromCache()
}
m_ui.textBrowser->setHtml(QString::fromUtf8(file.readAll()));
- m_ui.stateLabel->setText(tr("Done"));
+ m_ui.providerComboBox->addItem(tr("cache"));
return true;
}
diff --git a/src/plugins/General/lyrics/lyricswindow.h b/src/plugins/General/lyrics/lyricswindow.h
index 87f3d578c..6d4bfaa77 100644
--- a/src/plugins/General/lyrics/lyricswindow.h
+++ b/src/plugins/General/lyrics/lyricswindow.h
@@ -43,7 +43,9 @@ public:
private slots:
void onRequestFinished(QNetworkReply *reply);
- void on_searchPushButton_clicked();
+ void on_refreshButton_clicked();
+ void on_editButton_clicked(bool checked);
+ void on_providerComboBox_activated(int index);
QString cacheFilePath() const;
bool loadFromCache();
void saveToCache(const QString &text);
@@ -55,6 +57,7 @@ private:
UltimateLyricsParser m_parser;
TrackInfo m_info;
QHash<QNetworkReply *, QString> m_tasks;
+ QStringList m_enabledProviders;
};
#endif
diff --git a/src/plugins/General/lyrics/lyricswindow.ui b/src/plugins/General/lyrics/lyricswindow.ui
index 235bafdb6..28e901ef1 100644
--- a/src/plugins/General/lyrics/lyricswindow.ui
+++ b/src/plugins/General/lyrics/lyricswindow.ui
@@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
- <width>513</width>
- <height>420</height>
+ <width>656</width>
+ <height>542</height>
</rect>
</property>
<property name="windowTitle">
<string>Lyrics Plugin</string>
</property>
- <layout class="QGridLayout" name="gridLayout">
+ <layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>6</number>
</property>
@@ -23,52 +23,194 @@
<property name="bottomMargin">
<number>6</number>
</property>
- <item row="1" column="0" colspan="2">
- <widget class="QTextBrowser" name="textBrowser">
- <property name="openExternalLinks">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="stateLabel">
- <property name="text">
- <string>No connection</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="2">
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="label_6">
<property name="text">
- <string>Artist:</string>
+ <string>Provider:</string>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="artistLineEdit"/>
+ <widget class="QComboBox" name="providerComboBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="sizeAdjustPolicy">
+ <enum>QComboBox::AdjustToContents</enum>
+ </property>
+ </widget>
</item>
<item>
- <widget class="QLabel" name="label_2">
+ <widget class="QToolButton" name="refreshButton">
<property name="text">
- <string>Title:</string>
+ <string notr="true">...</string>
+ </property>
+ <property name="icon">
+ <iconset theme="view-refresh">
+ <normaloff>.</normaloff>.</iconset>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="titleLineEdit"/>
- </item>
- <item>
- <widget class="QPushButton" name="searchPushButton">
+ <widget class="QToolButton" name="editButton">
<property name="text">
- <string>Search</string>
+ <string notr="true">...</string>
+ </property>
+ <property name="icon">
+ <iconset theme="accessories-text-editor">
+ <normaloff>.</normaloff>.</iconset>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
</property>
</widget>
</item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</item>
- <item row="2" column="1">
+ <item>
+ <widget class="QWidget" name="editWidget" native="true">
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Title:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Album:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="titleLineEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Track:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Artist:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="albumLineEdit"/>
+ </item>
+ <item row="1" column="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QSpinBox" name="trackSpinBox"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Year:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="yearSpinBox">
+ <property name="minimumSize">
+ <size>
+ <width>73</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>2050</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLineEdit" name="artistLineEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextBrowser" name="textBrowser">
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
diff --git a/src/plugins/General/lyrics/settingsdialog.cpp b/src/plugins/General/lyrics/settingsdialog.cpp
new file mode 100644
index 000000000..59a900d23
--- /dev/null
+++ b/src/plugins/General/lyrics/settingsdialog.cpp
@@ -0,0 +1,61 @@
+/***************************************************************************
+ * 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 <QSettings>
+#include <qmmp/qmmp.h>
+#include "settingsdialog.h"
+#include "ultimatelyricsparser.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);
+ UltimateLyricsParser parser;
+ parser.load(":/ultimate_providers.xml");
+ QStringList enabledProviders = settings.value("Lyrics/enabled_providers", parser.defaultProviders()).toStringList();
+
+ for(const LyricsProvider *provider : parser.providers())
+ {
+ QListWidgetItem *item = new QListWidgetItem(provider->name());
+ item->setCheckState(enabledProviders.contains(provider->name()) ? Qt::Checked : Qt::Unchecked);
+ m_ui->providersListWidget->addItem(item);
+ }
+}
+
+SettingsDialog::~SettingsDialog()
+{
+ delete m_ui;
+}
+
+void SettingsDialog::accept()
+{
+ QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
+ QStringList enabledProviders;
+ for(int i = 0; i < m_ui->providersListWidget->count(); ++i)
+ {
+ if(m_ui->providersListWidget->item(i)->checkState() == Qt::Checked)
+ enabledProviders << m_ui->providersListWidget->item(i)->text();
+ }
+ settings.setValue("Lyrics/enabled_providers", enabledProviders);
+ QDialog::accept();
+}
diff --git a/src/plugins/General/lyrics/settingsdialog.h b/src/plugins/General/lyrics/settingsdialog.h
new file mode 100644
index 000000000..b266d1028
--- /dev/null
+++ b/src/plugins/General/lyrics/settingsdialog.h
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * 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 SETTINGSDIALOG_H
+#define SETTINGSDIALOG_H
+
+#include <QDialog>
+
+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/lyrics/settingsdialog.ui b/src/plugins/General/lyrics/settingsdialog.ui
new file mode 100644
index 000000000..b71eed632
--- /dev/null
+++ b/src/plugins/General/lyrics/settingsdialog.ui
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SettingsDialog</class>
+ <widget class="QDialog" name="SettingsDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>431</width>
+ <height>371</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Lyrics Plugin Settings</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <property name="bottomMargin">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Lyrics providers:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="providersListWidget"/>
+ </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>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>SettingsDialog</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>SettingsDialog</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>
diff --git a/src/plugins/General/lyrics/ultimatelyricsparser.cpp b/src/plugins/General/lyrics/ultimatelyricsparser.cpp
index fb5281bdb..07a89684b 100644
--- a/src/plugins/General/lyrics/ultimatelyricsparser.cpp
+++ b/src/plugins/General/lyrics/ultimatelyricsparser.cpp
@@ -118,3 +118,15 @@ LyricsProvider *UltimateLyricsParser::provider(const QString &name) const
}
return nullptr;
}
+
+QStringList UltimateLyricsParser::defaultProviders()
+{
+ QStringList out = {
+ "lyrics.wikia.com",
+ "Encyclopaedia Metallum",
+ "letras.mus.br",
+ "darklyrics.com"
+ };
+
+ return out;
+}
diff --git a/src/plugins/General/lyrics/ultimatelyricsparser.h b/src/plugins/General/lyrics/ultimatelyricsparser.h
index 4f2967597..a74c57ddb 100644
--- a/src/plugins/General/lyrics/ultimatelyricsparser.h
+++ b/src/plugins/General/lyrics/ultimatelyricsparser.h
@@ -17,6 +17,7 @@ public:
const QString &errorString() const;
const QList<LyricsProvider *> &providers();
LyricsProvider *provider(const QString &name) const;
+ static QStringList defaultProviders();
private:
QString m_errorString;