diff --git a/gui/dbquerywidget.cpp b/gui/dbquerywidget.cpp index 3a7f6af..a0fe873 100644 --- a/gui/dbquerywidget.cpp +++ b/gui/dbquerywidget.cpp @@ -35,7 +35,8 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent) m_ui(new Ui::DbQueryWidget), m_tagEditorWidget(tagEditorWidget), m_model(nullptr), - m_coverIndex(-1) + m_coverIndex(-1), + m_menu(new QMenu(parent)) { m_ui->setupUi(this); #ifdef Q_OS_WIN32 @@ -61,6 +62,16 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent) // restore settings m_ui->overrideCheckBox->setChecked(Settings::dbQueryOverride()); + // setup menu + m_insertPresentDataAction = m_menu->addAction(tr("Insert present data")); + m_insertPresentDataAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"))); + m_insertPresentDataAction->setEnabled(m_tagEditorWidget->activeTagEdit()); + connect(m_insertPresentDataAction, &QAction::triggered, this, &DbQueryWidget::insertSearchTermsFromActiveTagEdit); + QAction *clearSearchCriteria = m_menu->addAction(tr("Clear search criteria")); + clearSearchCriteria->setIcon(QIcon::fromTheme(QStringLiteral("edit-clear"))); + connect(clearSearchCriteria, &QAction::triggered, this, &DbQueryWidget::clearSearchCriteria); + m_ui->menuPushButton->setMenu(m_menu); + // connect signals and slots connect(m_ui->abortPushButton, &QPushButton::clicked, this, &DbQueryWidget::abortSearch); connect(m_ui->startPushButton, &QPushButton::clicked, this, &DbQueryWidget::startSearch); @@ -194,7 +205,8 @@ void DbQueryWidget::setStatus(bool aborted) void DbQueryWidget::fileStatusChanged(bool, bool hasTags) { m_ui->applyPushButton->setEnabled(hasTags && m_ui->resultsTreeView->selectionModel() && m_ui->resultsTreeView->selectionModel()->hasSelection()); - insertSearchTermsFromTagEdit(m_tagEditorWidget->activeTagEdit()); + insertSearchTermsFromActiveTagEdit(); + m_insertPresentDataAction->setEnabled(hasTags); } void DbQueryWidget::applyResults() @@ -248,6 +260,11 @@ void DbQueryWidget::applyResults() } } +void DbQueryWidget::insertSearchTermsFromActiveTagEdit() +{ + insertSearchTermsFromTagEdit(m_tagEditorWidget->activeTagEdit()); +} + void DbQueryWidget::showResultsContextMenu() { if(const QItemSelectionModel *selectionModel = m_ui->resultsTreeView->selectionModel()) { @@ -322,6 +339,14 @@ void DbQueryWidget::showCoverFromIndex(const QModelIndex &index) } } +void DbQueryWidget::clearSearchCriteria() +{ + m_ui->titleLineEdit->clear(); + m_ui->albumLineEdit->clear(); + m_ui->artistLineEdit->clear(); + m_ui->trackSpinBox->setValue(0); +} + bool DbQueryWidget::eventFilter(QObject *obj, QEvent *event) { if(obj == m_ui->searchGroupBox) { diff --git a/gui/dbquerywidget.h b/gui/dbquerywidget.h index 0c36b81..1897c9a 100644 --- a/gui/dbquerywidget.h +++ b/gui/dbquerywidget.h @@ -6,6 +6,8 @@ #include QT_FORWARD_DECLARE_CLASS(QItemSelection) +QT_FORWARD_DECLARE_CLASS(QMenu) +QT_FORWARD_DECLARE_CLASS(QAction) namespace Settings { class KnownFieldModel; @@ -34,12 +36,14 @@ public: public slots: void startSearch(); void abortSearch(); + void applyResults(); + void insertSearchTermsFromActiveTagEdit(); + void clearSearchCriteria(); private slots: void showResults(); void setStatus(bool aborted); void fileStatusChanged(bool opened, bool hasTags); - void applyResults(); void showResultsContextMenu(); void fetchAndShowCoverForSelection(); void showCover(const QByteArray &data); @@ -53,6 +57,8 @@ private: TagEditorWidget *m_tagEditorWidget; QueryResultsModel *m_model; int m_coverIndex; + QMenu *m_menu; + QAction *m_insertPresentDataAction; }; } diff --git a/gui/dbquerywidget.ui b/gui/dbquerywidget.ui index 34fc42a..e8ebc3e 100644 --- a/gui/dbquerywidget.ui +++ b/gui/dbquerywidget.ui @@ -50,7 +50,7 @@ - Search criteria + Search &criteria @@ -71,14 +71,14 @@ 2 - + Song - + 2 @@ -105,28 +105,28 @@ - + Album - + ? - + Artist - + ? @@ -258,6 +258,22 @@ + + + + + 23 + 16777215 + + + + + + + true + + + @@ -281,6 +297,9 @@ false + + Inserts the selected result into the current tag (doesn't save anything) + Apply results diff --git a/translations/tageditor_de_DE.ts b/translations/tageditor_de_DE.ts index 65944b2..d8e516a 100644 --- a/translations/tageditor_de_DE.ts +++ b/translations/tageditor_de_DE.ts @@ -646,7 +646,7 @@ - Search criteria + Search &criteria @@ -683,47 +683,62 @@ - + Abort - + Search - + + Inserts the selected result into the current tag (doesn't save anything) + + + + Apply results - + Search hasn't been started. - + + Insert present data + + + + + Clear search criteria + + + + Insufficient search criteria supplied - + Retrieving meta data ... - + Aborted - + No results available - + %1 result(s) available @@ -731,22 +746,22 @@ - + Retrieving cover art to be applied ... - + Show cover - + Retrieving cover art ... - + Cover - %1 diff --git a/translations/tageditor_en_US.ts b/translations/tageditor_en_US.ts index c6a9458..5cdd60c 100644 --- a/translations/tageditor_en_US.ts +++ b/translations/tageditor_en_US.ts @@ -646,7 +646,7 @@ - Search criteria + Search &criteria @@ -683,47 +683,62 @@ - + Abort - + Search - + + Inserts the selected result into the current tag (doesn't save anything) + + + + Apply results - + Search hasn't been started. - + + Insert present data + + + + + Clear search criteria + + + + Insufficient search criteria supplied - + Retrieving meta data ... - + Aborted - + No results available - + %1 result(s) available @@ -731,22 +746,22 @@ - + Retrieving cover art to be applied ... - + Show cover - + Retrieving cover art ... - + Cover - %1