few more improvements for MusicBrainz search
This commit is contained in:
parent
e4a1dc055e
commit
7315302a88
|
@ -107,6 +107,7 @@ set(WIDGETS_UI_FILES
|
|||
gui/editorautocorrectionoptionpage.ui
|
||||
gui/picturepreviewselection.ui
|
||||
gui/editorfieldsoptionpage.ui
|
||||
gui/editordbqueryoptionpage.ui
|
||||
gui/infooptionpage.ui
|
||||
gui/entertargetdialog.ui
|
||||
gui/attachmentsedit.ui
|
||||
|
|
|
@ -240,6 +240,12 @@ KnownFieldModel &dbQueryFields()
|
|||
return v;
|
||||
}
|
||||
|
||||
QString &musicBrainzUrl()
|
||||
{
|
||||
static QString v;
|
||||
return v;
|
||||
}
|
||||
|
||||
// renaming files dialog
|
||||
int &scriptSource()
|
||||
{
|
||||
|
@ -388,6 +394,7 @@ void restore()
|
|||
dbQueryWidgetShown() = settings.value(QStringLiteral("visible"), false).toBool();
|
||||
dbQueryOverride() = settings.value(QStringLiteral("override"), true).toBool();
|
||||
dbQueryFields().restore(settings, QStringLiteral("fields"));
|
||||
musicBrainzUrl() = settings.value(QStringLiteral("musicbrainzurl")).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QStringLiteral("renamedlg"));
|
||||
|
@ -463,6 +470,7 @@ void save()
|
|||
settings.setValue(QStringLiteral("visible"), dbQueryWidgetShown());
|
||||
settings.setValue(QStringLiteral("override"), dbQueryOverride());
|
||||
dbQueryFields().save(settings, QStringLiteral("fields"));
|
||||
settings.setValue(QStringLiteral("musicbrainzurl"), musicBrainzUrl());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QStringLiteral("renamedlg"));
|
||||
|
|
|
@ -95,6 +95,7 @@ QString &mainWindowCurrentFileBrowserDirectory();
|
|||
bool &dbQueryWidgetShown();
|
||||
bool &dbQueryOverride();
|
||||
KnownFieldModel &dbQueryFields();
|
||||
QString &musicBrainzUrl();
|
||||
|
||||
// rename files dialog
|
||||
int &scriptSource();
|
||||
|
|
|
@ -18,6 +18,13 @@ Available at ```http://musicbrainz.org/ws/2```
|
|||
```
|
||||
/recording?query="$song_name" AND artist:"$artist_name" AND release:"$release_name"
|
||||
```
|
||||
* album by name
|
||||
```
|
||||
/release?query="$album_name"
|
||||
```
|
||||
* cover art: TODO
|
||||
* lyrics: TODO
|
||||
|
||||
|
||||
## Misc
|
||||
* enable JSON response: ```&fmt=json```
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../misc/utility.h"
|
||||
#include "../misc/networkaccessmanager.h"
|
||||
#include "../application/settings.h"
|
||||
|
||||
#include <tagparser/tagvalue.h>
|
||||
#include <tagparser/tag.h>
|
||||
|
@ -309,7 +310,7 @@ void MusicBrainzResultsModel::parseResults()
|
|||
|
||||
QueryResultsModel *queryMusicBrainz(const SongDescription &songDescription)
|
||||
{
|
||||
static QString musicBrainzUrl(QStringLiteral("https://musicbrainz.org/ws/2/recording"));
|
||||
static QString defaultMusicBrainzUrl(QStringLiteral("https://musicbrainz.org/ws/2/recording"));
|
||||
// TODO: make this configurable
|
||||
|
||||
// compose parts
|
||||
|
@ -324,9 +325,12 @@ QueryResultsModel *queryMusicBrainz(const SongDescription &songDescription)
|
|||
if(!songDescription.album.isEmpty()) {
|
||||
parts << QStringLiteral("release:\"") % songDescription.album % QChar('\"');
|
||||
}
|
||||
if(songDescription.track) {
|
||||
parts << QStringLiteral("number:") + QString::number(songDescription.track);
|
||||
}
|
||||
|
||||
// compose URL
|
||||
QUrl url(musicBrainzUrl);
|
||||
QUrl url(Settings::musicBrainzUrl().isEmpty() ? defaultMusicBrainzUrl : (Settings::musicBrainzUrl() + QStringLiteral("/recording")));
|
||||
QUrlQuery query;
|
||||
query.addQueryItem(QStringLiteral("query"), parts.join(QStringLiteral(" AND ")));
|
||||
url.setQuery(query);
|
||||
|
|
|
@ -35,6 +35,8 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent)
|
|||
m_ui->setupUi(this);
|
||||
#ifdef Q_OS_WIN32
|
||||
setStyleSheet(dialogStyle());
|
||||
#else
|
||||
setStyleSheet(QStringLiteral("QGroupBox { color: palette(text); background-color: palette(base); }"));
|
||||
#endif
|
||||
|
||||
m_ui->notificationLabel->setText(tr("Search hasn't been started."));
|
||||
|
@ -100,7 +102,8 @@ void DbQueryWidget::insertSearchTermsFromTagEdit(TagEdit *tagEdit)
|
|||
void DbQueryWidget::startSearch()
|
||||
{
|
||||
// check whether enought search terms are supplied
|
||||
if(m_ui->titleLineEdit->text().isEmpty() && (!m_ui->trackSpinBox->value() || m_ui->albumLineEdit->text().isEmpty() || m_ui->artistLineEdit->text().isEmpty())) {
|
||||
if((m_ui->titleLineEdit->text().isEmpty() && !m_ui->trackSpinBox->value() && (m_ui->albumLineEdit->text().isEmpty() || m_ui->artistLineEdit->text().isEmpty()))
|
||||
|| (m_ui->albumLineEdit->text().isEmpty() && m_ui->artistLineEdit->text().isEmpty() && m_ui->titleLineEdit->text().isEmpty())) {
|
||||
m_ui->notificationLabel->setNotificationType(NotificationType::Critical);
|
||||
m_ui->notificationLabel->setText(tr("Insufficient search criteria supplied"));
|
||||
return;
|
||||
|
@ -162,7 +165,7 @@ void DbQueryWidget::showResults()
|
|||
if(m_model->results().isEmpty()) {
|
||||
m_ui->applyPushButton->setEnabled(false);
|
||||
} else {
|
||||
m_ui->resultsTreeView->selectionModel()->setCurrentIndex(m_model->index(0, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Columns);
|
||||
m_ui->resultsTreeView->selectionModel()->setCurrentIndex(m_model->index(0, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
m_ui->applyPushButton->setEnabled(m_tagEditorWidget->activeTagEdit());
|
||||
}
|
||||
setStatus(true);
|
||||
|
|
|
@ -133,8 +133,33 @@
|
|||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QTreeView" name="resultsTreeView"/>
|
||||
<widget class="QTreeView" name="resultsTreeView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="fieldsGroupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>125</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Fields to be used</string>
|
||||
</property>
|
||||
|
@ -156,6 +181,12 @@
|
|||
</property>
|
||||
<item>
|
||||
<widget class="QListView" name="fieldsListView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="movement">
|
||||
<enum>QListView::Free</enum>
|
||||
</property>
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QtGui::EditorDbQueryOptionsPage</class>
|
||||
<widget class="QWidget" name="QtGui::EditorDbQueryOptionsPage">
|
||||
<property name="windowTitle">
|
||||
<string>General options page</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QGroupBox { font-weight: bold };</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="musicBrainzUrlLabel">
|
||||
<property name="text">
|
||||
<string>MusicBrainz URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Widgets::ClearLineEdit" name="musicBrainzUrlLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>https://musicbrainz.org/ws/2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Widgets::ClearLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">qtutilities/widgets/clearlineedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="usageButtonGroup"/>
|
||||
</buttongroups>
|
||||
</ui>
|
|
@ -247,6 +247,33 @@ QWidget *EditorAutoCorrectionOptionPage::setupWidget()
|
|||
return w;
|
||||
}
|
||||
|
||||
// EditorDbQueryOptionsPage
|
||||
EditorDbQueryOptionsPage::EditorDbQueryOptionsPage()
|
||||
{}
|
||||
|
||||
EditorDbQueryOptionsPage::~EditorDbQueryOptionsPage()
|
||||
{}
|
||||
|
||||
QString EditorDbQueryOptionsPage::displayName() const
|
||||
{
|
||||
return QApplication::translate("QtGui::EditorDbQueryOptionsPage", "Database queries");
|
||||
}
|
||||
|
||||
bool EditorDbQueryOptionsPage::apply()
|
||||
{
|
||||
if(hasBeenShown()) {
|
||||
Settings::musicBrainzUrl() = ui()->musicBrainzUrlLineEdit->text();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void EditorDbQueryOptionsPage::reset()
|
||||
{
|
||||
if(hasBeenShown()) {
|
||||
ui()->musicBrainzUrlLineEdit->setText(Settings::musicBrainzUrl());
|
||||
}
|
||||
}
|
||||
|
||||
// InfoOptionPage
|
||||
InfoOptionPage::InfoOptionPage()
|
||||
{}
|
||||
|
@ -568,7 +595,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
|||
category->setIcon(QIcon::fromTheme(QStringLiteral("document-edit"), QIcon(QStringLiteral(":/tageditor/icons/hicolor/32x32/settingscategories/key-enter.png"))));
|
||||
category->assignPages(QList<Dialogs::OptionPage *>()
|
||||
<< new EditorGeneralOptionPage << new EditorTempOptionPage(this) << new EditorFieldsOptionPage
|
||||
<< new InfoOptionPage << new EditorAutoCorrectionOptionPage);
|
||||
<< new InfoOptionPage << new EditorAutoCorrectionOptionPage << new EditorDbQueryOptionsPage);
|
||||
categories << category;
|
||||
|
||||
category = new Dialogs::OptionCategory(this);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "ui_editortempoptionpage.h"
|
||||
#include "ui_editorfieldsoptionpage.h"
|
||||
#include "ui_editorautocorrectionoptionpage.h"
|
||||
#include "ui_editordbqueryoptionpage.h"
|
||||
#include "ui_infooptionpage.h"
|
||||
#include "ui_tagprocessinggeneraloptionpage.h"
|
||||
#include "ui_id3v1optionpage.h"
|
||||
|
@ -115,6 +116,22 @@ private:
|
|||
Settings::KnownFieldModel *m_model;
|
||||
};
|
||||
|
||||
// EditorDbQueryOptionPage
|
||||
namespace Ui {
|
||||
class EditorDbQueryOptionsPage;
|
||||
}
|
||||
|
||||
class EditorDbQueryOptionsPage : public Dialogs::UiFileBasedOptionPage<Ui::EditorDbQueryOptionsPage>
|
||||
{
|
||||
public:
|
||||
explicit EditorDbQueryOptionsPage();
|
||||
~EditorDbQueryOptionsPage();
|
||||
|
||||
QString displayName() const;
|
||||
bool apply();
|
||||
void reset();
|
||||
};
|
||||
|
||||
// EditorInfoOptionPage
|
||||
namespace Ui {
|
||||
class InfoOptionPage;
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
<item>
|
||||
<widget class="QComboBox" name="tagSelectionComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -85,6 +85,12 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="keepPreviousValuesPushButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Let you choose whether the values of the
|
||||
previously opened file should be cleared when
|
||||
|
@ -100,7 +106,7 @@ tagging multiple files of the same album.</string>
|
|||
<item>
|
||||
<widget class="QPushButton" name="tagOptionsPushButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -119,6 +125,12 @@ You can also create or remove tags manually.</string>
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="restoreEntriesPushButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Restores the original values read from
|
||||
the file reverting all unsaved changings.</string>
|
||||
|
@ -140,6 +152,12 @@ the file reverting all unsaved changings.</string>
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearEntriesPushButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Clears all values.</string>
|
||||
</property>
|
||||
|
|
|
@ -522,6 +522,7 @@ ClearComboBox *TagFieldEdit::setupGenreComboBox()
|
|||
m_comboBox->setClearButtonEnabled(true);
|
||||
m_comboBox->insertCustomButton(0, setupRestoreButton());
|
||||
m_comboBox->installEventFilter(this);
|
||||
m_comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
connect(m_comboBox, &ClearComboBox::currentTextChanged, this, &TagFieldEdit::showRestoreButton);
|
||||
|
||||
m_layout->addWidget(m_comboBox);
|
||||
|
|
|
@ -109,6 +109,7 @@ FORMS += \
|
|||
gui/editorautocorrectionoptionpage.ui \
|
||||
gui/picturepreviewselection.ui \
|
||||
gui/editorfieldsoptionpage.ui \
|
||||
gui/editordbqueryoptionpage.ui \
|
||||
gui/infooptionpage.ui \
|
||||
gui/entertargetdialog.ui \
|
||||
gui/attachmentsedit.ui \
|
||||
|
|
Loading…
Reference in New Issue