Improve UI of db query widget
* Move query options into menu so it is possible to add more without being limited by available space * Trigger the last query action when hitting the enter key * Change order of elements; I guess it looks better with buttons and fields to be used at the top
This commit is contained in:
parent
d3f84c4c39
commit
a94f2e3675
|
@ -75,22 +75,30 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent)
|
||||||
m_ui->overrideCheckBox->setChecked(values().dbQuery.override);
|
m_ui->overrideCheckBox->setChecked(values().dbQuery.override);
|
||||||
|
|
||||||
// setup menu
|
// setup menu
|
||||||
m_insertPresentDataAction = m_menu->addAction(tr("Insert present data"));
|
const auto searchIcon = QIcon::fromTheme(QStringLiteral("search"));
|
||||||
|
m_searchMusicBrainzAction = m_lastSearchAction = m_menu->addAction(tr("Query MusicBrainz"));
|
||||||
|
m_searchMusicBrainzAction->setIcon(searchIcon);
|
||||||
|
m_searchMusicBrainzAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
|
||||||
|
connect(m_searchMusicBrainzAction, &QAction::triggered, this, &DbQueryWidget::searchMusicBrainz);
|
||||||
|
m_searchLyricsWikiaAction = m_menu->addAction(tr("Query LyricsWikia"));
|
||||||
|
m_searchLyricsWikiaAction->setIcon(searchIcon);
|
||||||
|
m_searchLyricsWikiaAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
|
||||||
|
connect(m_searchLyricsWikiaAction, &QAction::triggered, this, &DbQueryWidget::searchLyricsWikia);
|
||||||
|
m_menu->addSeparator();
|
||||||
|
m_insertPresentDataAction = m_menu->addAction(tr("Use present data as search criteria"));
|
||||||
m_insertPresentDataAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
|
m_insertPresentDataAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
|
||||||
m_insertPresentDataAction->setEnabled(m_tagEditorWidget->activeTagEdit());
|
m_insertPresentDataAction->setEnabled(m_tagEditorWidget->activeTagEdit());
|
||||||
connect(m_insertPresentDataAction, &QAction::triggered, this, &DbQueryWidget::insertSearchTermsFromActiveTagEdit);
|
connect(m_insertPresentDataAction, &QAction::triggered, this, &DbQueryWidget::insertSearchTermsFromActiveTagEdit);
|
||||||
QAction *clearSearchCriteria = m_menu->addAction(tr("Clear search criteria"));
|
auto *const clearSearchCriteria = m_menu->addAction(tr("Clear search criteria"));
|
||||||
clearSearchCriteria->setIcon(QIcon::fromTheme(QStringLiteral("edit-clear")));
|
clearSearchCriteria->setIcon(QIcon::fromTheme(QStringLiteral("edit-clear")));
|
||||||
connect(clearSearchCriteria, &QAction::triggered, this, &DbQueryWidget::clearSearchCriteria);
|
connect(clearSearchCriteria, &QAction::triggered, this, &DbQueryWidget::clearSearchCriteria);
|
||||||
m_ui->menuPushButton->setMenu(m_menu);
|
m_ui->searchPushButton->setMenu(m_menu);
|
||||||
|
|
||||||
// ensure fieldsGroupBox takes only minimal space (initially)
|
// ensure fieldsGroupBox takes only minimal space (initially)
|
||||||
m_ui->splitter->setSizes({ 1000, 1 });
|
m_ui->splitter->setSizes({ 1, 1000 });
|
||||||
|
|
||||||
// connect signals and slots
|
// connect signals and slots
|
||||||
connect(m_ui->abortPushButton, &QPushButton::clicked, this, &DbQueryWidget::abortSearch);
|
connect(m_ui->abortPushButton, &QPushButton::clicked, this, &DbQueryWidget::abortSearch);
|
||||||
connect(m_ui->searchMusicBrainzPushButton, &QPushButton::clicked, this, &DbQueryWidget::searchMusicBrainz);
|
|
||||||
connect(m_ui->searchLyricsWikiaPushButton, &QPushButton::clicked, this, &DbQueryWidget::searchLyricsWikia);
|
|
||||||
connect(m_ui->resultsTreeView, &QTreeView::doubleClicked, this, &DbQueryWidget::applySpecifiedResults);
|
connect(m_ui->resultsTreeView, &QTreeView::doubleClicked, this, &DbQueryWidget::applySpecifiedResults);
|
||||||
connect(m_ui->applyPushButton, &QPushButton::clicked, this, &DbQueryWidget::applySelectedResults);
|
connect(m_ui->applyPushButton, &QPushButton::clicked, this, &DbQueryWidget::applySelectedResults);
|
||||||
connect(m_tagEditorWidget, &TagEditorWidget::fileStatusChanged, this, &DbQueryWidget::fileStatusChanged);
|
connect(m_tagEditorWidget, &TagEditorWidget::fileStatusChanged, this, &DbQueryWidget::fileStatusChanged);
|
||||||
|
@ -133,6 +141,8 @@ SongDescription DbQueryWidget::currentSongDescription() const
|
||||||
|
|
||||||
void DbQueryWidget::searchMusicBrainz()
|
void DbQueryWidget::searchMusicBrainz()
|
||||||
{
|
{
|
||||||
|
m_lastSearchAction = m_searchMusicBrainzAction;
|
||||||
|
|
||||||
// check whether enough search terms are supplied
|
// check whether enough search terms are supplied
|
||||||
if (m_ui->titleLineEdit->text().isEmpty() && m_ui->albumLineEdit->text().isEmpty() && m_ui->artistLineEdit->text().isEmpty()) {
|
if (m_ui->titleLineEdit->text().isEmpty() && m_ui->albumLineEdit->text().isEmpty() && m_ui->artistLineEdit->text().isEmpty()) {
|
||||||
m_ui->notificationLabel->setNotificationType(NotificationType::Critical);
|
m_ui->notificationLabel->setNotificationType(NotificationType::Critical);
|
||||||
|
@ -155,6 +165,8 @@ void DbQueryWidget::searchMusicBrainz()
|
||||||
|
|
||||||
void DbQueryWidget::searchLyricsWikia()
|
void DbQueryWidget::searchLyricsWikia()
|
||||||
{
|
{
|
||||||
|
m_lastSearchAction = m_searchLyricsWikiaAction;
|
||||||
|
|
||||||
// check whether enough search terms are supplied
|
// check whether enough search terms are supplied
|
||||||
if (m_ui->artistLineEdit->text().isEmpty()) {
|
if (m_ui->artistLineEdit->text().isEmpty()) {
|
||||||
m_ui->notificationLabel->setNotificationType(NotificationType::Critical);
|
m_ui->notificationLabel->setNotificationType(NotificationType::Critical);
|
||||||
|
@ -252,8 +264,8 @@ void DbQueryWidget::showResults()
|
||||||
void DbQueryWidget::setStatus(bool aborted)
|
void DbQueryWidget::setStatus(bool aborted)
|
||||||
{
|
{
|
||||||
m_ui->abortPushButton->setVisible(!aborted);
|
m_ui->abortPushButton->setVisible(!aborted);
|
||||||
m_ui->searchMusicBrainzPushButton->setVisible(aborted);
|
m_searchMusicBrainzAction->setEnabled(aborted);
|
||||||
m_ui->searchLyricsWikiaPushButton->setVisible(aborted);
|
m_searchLyricsWikiaAction->setEnabled(aborted);
|
||||||
m_ui->applyPushButton->setVisible(aborted);
|
m_ui->applyPushButton->setVisible(aborted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,7 +670,7 @@ bool DbQueryWidget::eventFilter(QObject *obj, QEvent *event)
|
||||||
case QEvent::KeyRelease:
|
case QEvent::KeyRelease:
|
||||||
switch (static_cast<QKeyEvent *>(event)->key()) {
|
switch (static_cast<QKeyEvent *>(event)->key()) {
|
||||||
case Qt::Key_Return:
|
case Qt::Key_Return:
|
||||||
searchMusicBrainz();
|
m_lastSearchAction->trigger();
|
||||||
break;
|
break;
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,9 @@ private:
|
||||||
int m_coverIndex, m_lyricsIndex;
|
int m_coverIndex, m_lyricsIndex;
|
||||||
QMenu *m_menu;
|
QMenu *m_menu;
|
||||||
QAction *m_insertPresentDataAction;
|
QAction *m_insertPresentDataAction;
|
||||||
|
QAction *m_searchMusicBrainzAction;
|
||||||
|
QAction *m_searchLyricsWikiaAction;
|
||||||
|
QAction *m_lastSearchAction;
|
||||||
QPoint m_contextMenuPos;
|
QPoint m_contextMenuPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,92 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="topWidget" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="bottomLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="NotificationLabel" name="notificationLabel" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="abortPushButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Aborts the current query</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Abort</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="searchPushButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Searches for meta data matching the specified "Search criteria"</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Search</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="edit-find">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="applyPushButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Inserts values of "Fields to be used" from the selected result into the current tag but does not save anything</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Use row</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="searchGroupBox">
|
<widget class="QGroupBox" name="searchGroupBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -151,25 +237,11 @@
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QTreeView" name="resultsTreeView">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="contextMenuPolicy">
|
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeAdjustPolicy">
|
|
||||||
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QGroupBox" name="fieldsGroupBox">
|
<widget class="QGroupBox" name="fieldsGroupBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>1</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -271,137 +343,20 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
<widget class="QTreeView" name="resultsTreeView">
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="bottomWidget" native="true">
|
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>1</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="bottomLayout">
|
<property name="contextMenuPolicy">
|
||||||
<property name="spacing">
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
<number>1</number>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="sizeAdjustPolicy">
|
||||||
<number>1</number>
|
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="NotificationLabel" name="notificationLabel" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="menuPushButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>23</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="flat">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="abortPushButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Aborts the current query</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Abort</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="searchMusicBrainzPushButton">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Searches MusicBrainz for meta data matching the specified "Search criteria"</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Search
|
|
||||||
MusicBrainz</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="edit-find">
|
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="searchLyricsWikiaPushButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Searches LyricWikia for meta data matching the specified "Search criteria"</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Search
|
|
||||||
LyricWikia</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="edit-find">
|
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="applyPushButton">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Inserts values of "Fields to be used" from the selected result into the current tag but does not save anything</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Use selected
|
|
||||||
row</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
Loading…
Reference in New Issue