From 93fa37a5f769b17d1a3996bf444480961f196103 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Sun, 25 Oct 2020 09:57:18 +0100 Subject: [PATCH 1/7] WSearchRelatedTracksMenu: Elide action text --- src/widget/wsearchrelatedtracksmenu.cpp | 172 +++++++++++++++--------- src/widget/wsearchrelatedtracksmenu.h | 8 +- 2 files changed, 115 insertions(+), 65 deletions(-) diff --git a/src/widget/wsearchrelatedtracksmenu.cpp b/src/widget/wsearchrelatedtracksmenu.cpp index 51d3603b574..61be541f315 100644 --- a/src/widget/wsearchrelatedtracksmenu.cpp +++ b/src/widget/wsearchrelatedtracksmenu.cpp @@ -1,10 +1,18 @@ #include "widget/wsearchrelatedtracksmenu.h" +#include + #include "track/track.h" +#include "util/math.h" #include "util/qt.h" +#include "util/widgethelper.h" namespace { +constexpr double kMaxMenuToAvailableScreenWidthRatio = 0.2; // 20% + +constexpr int kMinMenuWidthInPixels = 100; + constexpr double kRelativeBpmRange = 0.06; // +/-6 % inline int bpmLowerBound(double bpm) { @@ -15,6 +23,10 @@ inline int bpmUpperBound(double bpm) { return static_cast(std::ceil((1 + kRelativeBpmRange) * bpm)); } +inline QString quoteText(const QString& text) { + return QChar('"') + text + QChar('"'); +} + QString extractCalendarYearNumberFromReleaseDate( const QString& releaseDate) { // TODO: Improve this poor calendar year number parser @@ -49,21 +61,60 @@ WSearchRelatedTracksMenu::WSearchRelatedTracksMenu( void WSearchRelatedTracksMenu::addTriggerSearchAction( bool* /*in/out*/ pAddSeparatorBeforeNextAction, - const QString& actionText, - QString /*!by-value-because-captured-by-lambda!*/ searchQuery) { + QString /*!by-value-because-captured-by-lambda!*/ searchQuery, + const QString& actionTextPrefix, + const QString& elidableTextSuffix) { DEBUG_ASSERT(pAddSeparatorBeforeNextAction); if (*pAddSeparatorBeforeNextAction) { addSeparator(); } // Reset the flag before adding the next action *pAddSeparatorBeforeNextAction = false; + const auto elidedActionText = + elideActionText( + actionTextPrefix, + elidableTextSuffix); addAction( - mixxx::escapeTextPropertyWithoutShortcuts(actionText), + mixxx::escapeTextPropertyWithoutShortcuts(elidedActionText), [this, searchQuery]() { emit triggerSearch(searchQuery); }); } +QString WSearchRelatedTracksMenu::elideActionText( + const QString& actionTextPrefix, + const QString& elidableTextSuffix) const { + if (elidableTextSuffix.isEmpty()) { + return actionTextPrefix; + } + const auto prefixWidthInPixels = + fontMetrics().boundingRect(actionTextPrefix).width(); + const auto minWidthInPixels = + math_max( + prefixWidthInPixels, + kMinMenuWidthInPixels); + const auto* const pScreen = + mixxx::widgethelper::getScreen(*this); + VERIFY_OR_DEBUG_ASSERT(pScreen) { + // This should never fail + return actionTextPrefix; + } + const auto maxWidthInPixels = + math_max( + static_cast( + pScreen->availableSize().width() * + kMaxMenuToAvailableScreenWidthRatio), + minWidthInPixels); + const auto elidedTextSuffix = + fontMetrics().elidedText( + elidableTextSuffix, + // Most suffix text is quoted and should always + // be elided in the middle + Qt::ElideMiddle, + maxWidthInPixels - prefixWidthInPixels); + return actionTextPrefix + elidedTextSuffix; +} + void WSearchRelatedTracksMenu::addActionsForTrack( const Track& track) { // NOTE: We have to explicitly use `QString` instead of `auto` @@ -75,16 +126,16 @@ void WSearchRelatedTracksMenu::addActionsForTrack( { const auto keyText = track.getKeyText(); if (!keyText.isEmpty()) { - const auto actionText = - tr("Key: Harmonic with \"%1\"").arg(keyText); const QString searchQuery = QStringLiteral("~key:\"") + keyText + QChar('"'); + const auto actionText = + tr("Key: Harmonic with \"%1\"").arg(keyText); addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + actionText); } } { @@ -92,17 +143,17 @@ void WSearchRelatedTracksMenu::addActionsForTrack( if (bpm > 0) { const auto minBpmNumber = QString::number(bpmLowerBound(bpm)); const auto maxBpmNumber = QString::number(bpmUpperBound(bpm)); - const auto actionText = - tr("BPM: Between %1 and %2").arg(minBpmNumber, maxBpmNumber); const QString searchQuery = QStringLiteral("bpm:>=") + minBpmNumber + QStringLiteral(" bpm:<=") + maxBpmNumber; + const auto actionText = + tr("BPM: Between %1 and %2").arg(minBpmNumber, maxBpmNumber); addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + actionText); } } @@ -129,69 +180,69 @@ void WSearchRelatedTracksMenu::addActionsForTrack( DEBUG_ASSERT(!primaryArtist.isEmpty() || secondaryArtist.isEmpty()); if (!primaryArtist.isEmpty()) { // Search tracks with similar artist(s) + const auto artistTextPrefix = tr("Artist: "); + const auto artistQueryPrefix = QStringLiteral("artist:\""); + const auto querySuffix = QChar('"'); { - const auto actionText = - tr("Artist: \"%1\"").arg(primaryArtist); const QString searchQuery = - QStringLiteral("artist:\"") + + artistQueryPrefix + primaryArtist + - QChar('"'); + querySuffix; addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + artistTextPrefix, + quoteText(primaryArtist)); } if (!secondaryArtist.isEmpty()) { - const auto actionText = - tr("Artist: \"%1\"").arg(secondaryArtist); const QString searchQuery = - QStringLiteral("artist:\"") + + artistQueryPrefix + secondaryArtist + - QChar('"'); + querySuffix; addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + artistTextPrefix, + quoteText(secondaryArtist)); } + const auto albumArtistTextPrefix = tr("Album Artist: "); + const auto albumArtistQueryPrefix = QStringLiteral("album_artist:\""); { - const auto actionText = - tr("Album Artist: \"%1\"").arg(primaryArtist); const QString searchQuery = - QStringLiteral("album_artist:\"") + + albumArtistQueryPrefix + primaryArtist + - QChar('"'); + querySuffix; addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + albumArtistTextPrefix, + quoteText(primaryArtist)); } if (!secondaryArtist.isEmpty()) { - const auto actionText = - tr("Album Artist: \"%1\"").arg(secondaryArtist); const QString searchQuery = - QStringLiteral("album_artist:\"") + + albumArtistQueryPrefix + secondaryArtist + - QChar('"'); + querySuffix; addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + albumArtistTextPrefix, + quoteText(secondaryArtist)); } } } { const auto composer = track.getComposer(); if (!composer.isEmpty()) { - const auto actionText = - tr("Composer: \"%1\"").arg(composer); const QString searchQuery = QStringLiteral("composer:\"") + composer + QChar('"'); addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + tr("Composer: "), + quoteText(composer)); } } @@ -200,46 +251,43 @@ void WSearchRelatedTracksMenu::addActionsForTrack( { const auto title = track.getTitle(); if (!title.isEmpty()) { - const auto actionText = - tr("Title: \"%1\"").arg(title); const QString searchQuery = QStringLiteral("title:\"") + title + QChar('"'); addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + tr("Title: "), + quoteText(title)); } } { const auto album = track.getAlbum(); if (!album.isEmpty()) { - const auto actionText = - tr("Album: \"%1\"").arg(album); const QString searchQuery = QStringLiteral("album:\"") + album + QChar('"'); addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + tr("Album: "), + quoteText(album)); } } { const auto grouping = track.getGrouping(); if (!grouping.isEmpty()) { - const auto actionText = - tr("Grouping: \"%1\"").arg(grouping); const QString searchQuery = QStringLiteral("grouping:\"") + grouping + QChar('"'); addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + tr("Grouping: "), + quoteText(grouping)); } } @@ -249,45 +297,43 @@ void WSearchRelatedTracksMenu::addActionsForTrack( const auto releaseYearNumber = extractCalendarYearNumberFromReleaseDate(track.getYear()); if (!releaseYearNumber.isEmpty()) { - const auto actionText = - tr("Year: %1").arg(releaseYearNumber); const QString searchQuery = QStringLiteral("year:") + releaseYearNumber; + const auto actionText = + tr("Year: %1").arg(releaseYearNumber); addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + actionText); } } { const auto genre = track.getGenre(); if (!genre.isEmpty()) { - const auto actionText = - tr("Genre: \"%1\"").arg(genre); const QString searchQuery = QStringLiteral("genre:\"") + genre + QChar('"'); addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + tr("Genre: "), + quoteText(genre)); } } { const auto locationPath = track.getFileInfo().directory(); if (!locationPath.isEmpty()) { - const auto actionText = - tr("Folder: \"%1\"").arg(locationPath); const QString searchQuery = QStringLiteral("location:\"") + locationPath + QChar('"'); addTriggerSearchAction( &addSeparatorBeforeNextAction, - actionText, - searchQuery); + searchQuery, + tr("Folder: "), + quoteText(locationPath)); } } } diff --git a/src/widget/wsearchrelatedtracksmenu.h b/src/widget/wsearchrelatedtracksmenu.h index dcd8fb17866..20612354710 100644 --- a/src/widget/wsearchrelatedtracksmenu.h +++ b/src/widget/wsearchrelatedtracksmenu.h @@ -21,6 +21,10 @@ class WSearchRelatedTracksMenu : public QMenu { private: void addTriggerSearchAction( bool* /*in/out*/ pAddSeparatorBeforeNextAction, - const QString& actionText, - QString searchQuery); + QString searchQuery, + const QString& actionTextPrefix, + const QString& elidableTextSuffix = QString()); + QString elideActionText( + const QString& actionTextPrefix, + const QString& elidableTextSuffix) const; }; From c92c3c6d34c8f9615c873953be4a230113596c59 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Sun, 25 Oct 2020 19:23:07 +0100 Subject: [PATCH 2/7] WSearchRelatedTracksMenu: Add a comment about the constant value --- src/widget/wsearchrelatedtracksmenu.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widget/wsearchrelatedtracksmenu.cpp b/src/widget/wsearchrelatedtracksmenu.cpp index 61be541f315..4c00dbf3d56 100644 --- a/src/widget/wsearchrelatedtracksmenu.cpp +++ b/src/widget/wsearchrelatedtracksmenu.cpp @@ -9,7 +9,9 @@ namespace { -constexpr double kMaxMenuToAvailableScreenWidthRatio = 0.2; // 20% +// Occupying up to 20% of the screen's width has been considered +// a viable upper bound for the context menu. +constexpr double kMaxMenuToAvailableScreenWidthRatio = 0.2; constexpr int kMinMenuWidthInPixels = 100; From 2601ffaa2d61c5c3d98f5d00c93ce7630d753eed Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Sun, 25 Oct 2020 19:24:17 +0100 Subject: [PATCH 3/7] Delete arbitrary minimum width value that is not needed --- src/widget/wsearchrelatedtracksmenu.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/widget/wsearchrelatedtracksmenu.cpp b/src/widget/wsearchrelatedtracksmenu.cpp index 4c00dbf3d56..48e3e48bb43 100644 --- a/src/widget/wsearchrelatedtracksmenu.cpp +++ b/src/widget/wsearchrelatedtracksmenu.cpp @@ -13,8 +13,6 @@ namespace { // a viable upper bound for the context menu. constexpr double kMaxMenuToAvailableScreenWidthRatio = 0.2; -constexpr int kMinMenuWidthInPixels = 100; - constexpr double kRelativeBpmRange = 0.06; // +/-6 % inline int bpmLowerBound(double bpm) { @@ -89,24 +87,20 @@ QString WSearchRelatedTracksMenu::elideActionText( if (elidableTextSuffix.isEmpty()) { return actionTextPrefix; } - const auto prefixWidthInPixels = - fontMetrics().boundingRect(actionTextPrefix).width(); - const auto minWidthInPixels = - math_max( - prefixWidthInPixels, - kMinMenuWidthInPixels); const auto* const pScreen = mixxx::widgethelper::getScreen(*this); VERIFY_OR_DEBUG_ASSERT(pScreen) { // This should never fail return actionTextPrefix; } + const auto prefixWidthInPixels = + fontMetrics().boundingRect(actionTextPrefix).width(); const auto maxWidthInPixels = math_max( - static_cast( + static_cast(std::ceil( pScreen->availableSize().width() * - kMaxMenuToAvailableScreenWidthRatio), - minWidthInPixels); + kMaxMenuToAvailableScreenWidthRatio)), + prefixWidthInPixels); const auto elidedTextSuffix = fontMetrics().elidedText( elidableTextSuffix, From dc88fbdd37ac22047b9ea111415ba6a69e1f0b76 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Sun, 25 Oct 2020 20:46:18 +0100 Subject: [PATCH 4/7] WSearchRelatedTracksMenu: Restrict folder search --- src/widget/wsearchrelatedtracksmenu.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/widget/wsearchrelatedtracksmenu.cpp b/src/widget/wsearchrelatedtracksmenu.cpp index 48e3e48bb43..49254143ce8 100644 --- a/src/widget/wsearchrelatedtracksmenu.cpp +++ b/src/widget/wsearchrelatedtracksmenu.cpp @@ -321,15 +321,21 @@ void WSearchRelatedTracksMenu::addActionsForTrack( { const auto locationPath = track.getFileInfo().directory(); if (!locationPath.isEmpty()) { + // Search folder and all subfolders, i.e. for "path/to/folder" + // also find files in "path/to/folder/subfolder" but not in + // "path/to/folder copy". + DEBUG_ASSERT(!locationPath.endsWith(QChar('/'))); + const auto locationPathWithTerminator = + locationPath + QChar('/'); const QString searchQuery = QStringLiteral("location:\"") + - locationPath + + locationPathWithTerminator + QChar('"'); addTriggerSearchAction( &addSeparatorBeforeNextAction, searchQuery, tr("Folder: "), - quoteText(locationPath)); + quoteText(locationPathWithTerminator)); } } } From 81aa1137f590b20fba68c5128822c2ffe0033df9 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Thu, 29 Oct 2020 10:38:34 +0100 Subject: [PATCH 5/7] WSearchRelatedTracksMenu: Declutter action text --- src/widget/wsearchrelatedtracksmenu.cpp | 176 +++++++++++------------- 1 file changed, 84 insertions(+), 92 deletions(-) diff --git a/src/widget/wsearchrelatedtracksmenu.cpp b/src/widget/wsearchrelatedtracksmenu.cpp index 49254143ce8..9ddef7fe455 100644 --- a/src/widget/wsearchrelatedtracksmenu.cpp +++ b/src/widget/wsearchrelatedtracksmenu.cpp @@ -15,6 +15,8 @@ constexpr double kMaxMenuToAvailableScreenWidthRatio = 0.2; constexpr double kRelativeBpmRange = 0.06; // +/-6 % +const QString kActionTextPrefixSuffixSeparator = QString::fromUtf8(" ▶ "); + inline int bpmLowerBound(double bpm) { return static_cast(std::floor((1 - kRelativeBpmRange) * bpm)); } @@ -23,7 +25,7 @@ inline int bpmUpperBound(double bpm) { return static_cast(std::ceil((1 + kRelativeBpmRange) * bpm)); } -inline QString quoteText(const QString& text) { +inline QString quoteSearchQueryText(const QString& text) { return QChar('"') + text + QChar('"'); } @@ -93,8 +95,10 @@ QString WSearchRelatedTracksMenu::elideActionText( // This should never fail return actionTextPrefix; } + const auto actionTextPrefixWithSeparator = + actionTextPrefix + kActionTextPrefixSuffixSeparator; const auto prefixWidthInPixels = - fontMetrics().boundingRect(actionTextPrefix).width(); + fontMetrics().boundingRect(actionTextPrefixWithSeparator).width(); const auto maxWidthInPixels = math_max( static_cast(std::ceil( @@ -104,11 +108,10 @@ QString WSearchRelatedTracksMenu::elideActionText( const auto elidedTextSuffix = fontMetrics().elidedText( elidableTextSuffix, - // Most suffix text is quoted and should always - // be elided in the middle + // TODO: Customize the suffix elision? Qt::ElideMiddle, maxWidthInPixels - prefixWidthInPixels); - return actionTextPrefix + elidedTextSuffix; + return actionTextPrefixWithSeparator + elidedTextSuffix; } void WSearchRelatedTracksMenu::addActionsForTrack( @@ -123,15 +126,13 @@ void WSearchRelatedTracksMenu::addActionsForTrack( const auto keyText = track.getKeyText(); if (!keyText.isEmpty()) { const QString searchQuery = - QStringLiteral("~key:\"") + - keyText + - QChar('"'); - const auto actionText = - tr("Key: Harmonic with \"%1\"").arg(keyText); + QStringLiteral("~key:") + + quoteSearchQueryText(keyText); addTriggerSearchAction( &addSeparatorBeforeNextAction, searchQuery, - actionText); + tr("Key"), + tr("harmonic with %1").arg(keyText)); } } { @@ -144,12 +145,11 @@ void WSearchRelatedTracksMenu::addActionsForTrack( minBpmNumber + QStringLiteral(" bpm:<=") + maxBpmNumber; - const auto actionText = - tr("BPM: Between %1 and %2").arg(minBpmNumber, maxBpmNumber); addTriggerSearchAction( &addSeparatorBeforeNextAction, searchQuery, - actionText); + tr("BPM"), + tr("between %1 and %2").arg(minBpmNumber, maxBpmNumber)); } } @@ -176,54 +176,53 @@ void WSearchRelatedTracksMenu::addActionsForTrack( DEBUG_ASSERT(!primaryArtist.isEmpty() || secondaryArtist.isEmpty()); if (!primaryArtist.isEmpty()) { // Search tracks with similar artist(s) - const auto artistTextPrefix = tr("Artist: "); - const auto artistQueryPrefix = QStringLiteral("artist:\""); - const auto querySuffix = QChar('"'); { - const QString searchQuery = - artistQueryPrefix + - primaryArtist + - querySuffix; - addTriggerSearchAction( - &addSeparatorBeforeNextAction, - searchQuery, - artistTextPrefix, - quoteText(primaryArtist)); - } - if (!secondaryArtist.isEmpty()) { - const QString searchQuery = - artistQueryPrefix + - secondaryArtist + - querySuffix; - addTriggerSearchAction( - &addSeparatorBeforeNextAction, - searchQuery, - artistTextPrefix, - quoteText(secondaryArtist)); + const auto actionTextPrefix = tr("Artist"); + const auto searchQueryPrefix = QStringLiteral("artist:\""); + { + const QString searchQuery = + searchQueryPrefix + + quoteSearchQueryText(primaryArtist); + addTriggerSearchAction( + &addSeparatorBeforeNextAction, + searchQuery, + actionTextPrefix, + primaryArtist); + } + if (!secondaryArtist.isEmpty()) { + const QString searchQuery = + searchQueryPrefix + + quoteSearchQueryText(secondaryArtist); + addTriggerSearchAction( + &addSeparatorBeforeNextAction, + searchQuery, + actionTextPrefix, + secondaryArtist); + } } - const auto albumArtistTextPrefix = tr("Album Artist: "); - const auto albumArtistQueryPrefix = QStringLiteral("album_artist:\""); { - const QString searchQuery = - albumArtistQueryPrefix + - primaryArtist + - querySuffix; - addTriggerSearchAction( - &addSeparatorBeforeNextAction, - searchQuery, - albumArtistTextPrefix, - quoteText(primaryArtist)); - } - if (!secondaryArtist.isEmpty()) { - const QString searchQuery = - albumArtistQueryPrefix + - secondaryArtist + - querySuffix; - addTriggerSearchAction( - &addSeparatorBeforeNextAction, - searchQuery, - albumArtistTextPrefix, - quoteText(secondaryArtist)); + const auto actionTextPrefix = tr("Album Artist"); + const auto searchQueryPrefix = QStringLiteral("album_artist:\""); + { + const QString searchQuery = + searchQueryPrefix + + quoteSearchQueryText(primaryArtist); + addTriggerSearchAction( + &addSeparatorBeforeNextAction, + searchQuery, + actionTextPrefix, + primaryArtist); + } + if (!secondaryArtist.isEmpty()) { + const QString searchQuery = + searchQueryPrefix + + quoteSearchQueryText(secondaryArtist); + addTriggerSearchAction( + &addSeparatorBeforeNextAction, + searchQuery, + actionTextPrefix, + secondaryArtist); + } } } } @@ -231,14 +230,13 @@ void WSearchRelatedTracksMenu::addActionsForTrack( const auto composer = track.getComposer(); if (!composer.isEmpty()) { const QString searchQuery = - QStringLiteral("composer:\"") + - composer + - QChar('"'); + QStringLiteral("composer:") + + quoteSearchQueryText(composer); addTriggerSearchAction( &addSeparatorBeforeNextAction, searchQuery, - tr("Composer: "), - quoteText(composer)); + tr("Composer"), + composer); } } @@ -248,42 +246,39 @@ void WSearchRelatedTracksMenu::addActionsForTrack( const auto title = track.getTitle(); if (!title.isEmpty()) { const QString searchQuery = - QStringLiteral("title:\"") + - title + - QChar('"'); + QStringLiteral("title:") + + quoteSearchQueryText(title); addTriggerSearchAction( &addSeparatorBeforeNextAction, searchQuery, - tr("Title: "), - quoteText(title)); + tr("Title"), + title); } } { const auto album = track.getAlbum(); if (!album.isEmpty()) { const QString searchQuery = - QStringLiteral("album:\"") + - album + - QChar('"'); + QStringLiteral("album:") + + quoteSearchQueryText(album); addTriggerSearchAction( &addSeparatorBeforeNextAction, searchQuery, - tr("Album: "), - quoteText(album)); + tr("Album"), + album); } } { const auto grouping = track.getGrouping(); if (!grouping.isEmpty()) { const QString searchQuery = - QStringLiteral("grouping:\"") + - grouping + - QChar('"'); + QStringLiteral("grouping:") + + quoteSearchQueryText(grouping); addTriggerSearchAction( &addSeparatorBeforeNextAction, searchQuery, - tr("Grouping: "), - quoteText(grouping)); + tr("Grouping"), + grouping); } } @@ -296,26 +291,24 @@ void WSearchRelatedTracksMenu::addActionsForTrack( const QString searchQuery = QStringLiteral("year:") + releaseYearNumber; - const auto actionText = - tr("Year: %1").arg(releaseYearNumber); addTriggerSearchAction( &addSeparatorBeforeNextAction, searchQuery, - actionText); + tr("Year"), + releaseYearNumber); } } { const auto genre = track.getGenre(); if (!genre.isEmpty()) { const QString searchQuery = - QStringLiteral("genre:\"") + - genre + - QChar('"'); + QStringLiteral("genre:") + + quoteSearchQueryText(genre); addTriggerSearchAction( &addSeparatorBeforeNextAction, searchQuery, - tr("Genre: "), - quoteText(genre)); + tr("Genre"), + genre); } } { @@ -328,14 +321,13 @@ void WSearchRelatedTracksMenu::addActionsForTrack( const auto locationPathWithTerminator = locationPath + QChar('/'); const QString searchQuery = - QStringLiteral("location:\"") + - locationPathWithTerminator + - QChar('"'); + QStringLiteral("location:") + + quoteSearchQueryText(locationPathWithTerminator); addTriggerSearchAction( &addSeparatorBeforeNextAction, searchQuery, - tr("Folder: "), - quoteText(locationPathWithTerminator)); + tr("Folder"), + locationPathWithTerminator); } } } From 3b3ef6c948688faf48c00c02a06231bf710b31c8 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Thu, 29 Oct 2020 17:07:37 +0100 Subject: [PATCH 6/7] WSearchRelatedTracksMenu: Remove stray double quotes from query --- src/widget/wsearchrelatedtracksmenu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widget/wsearchrelatedtracksmenu.cpp b/src/widget/wsearchrelatedtracksmenu.cpp index 9ddef7fe455..b0940cda372 100644 --- a/src/widget/wsearchrelatedtracksmenu.cpp +++ b/src/widget/wsearchrelatedtracksmenu.cpp @@ -178,7 +178,7 @@ void WSearchRelatedTracksMenu::addActionsForTrack( // Search tracks with similar artist(s) { const auto actionTextPrefix = tr("Artist"); - const auto searchQueryPrefix = QStringLiteral("artist:\""); + const auto searchQueryPrefix = QStringLiteral("artist:"); { const QString searchQuery = searchQueryPrefix + @@ -202,7 +202,7 @@ void WSearchRelatedTracksMenu::addActionsForTrack( } { const auto actionTextPrefix = tr("Album Artist"); - const auto searchQueryPrefix = QStringLiteral("album_artist:\""); + const auto searchQueryPrefix = QStringLiteral("album_artist:"); { const QString searchQuery = searchQueryPrefix + From c24b21ae84e1423a60eb5d24a6b65ba3337a9adb Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Mon, 2 Nov 2020 23:57:51 +0100 Subject: [PATCH 7/7] WSearchRelatedTracksMenu: Separate action text by pipe symbol --- src/widget/wsearchrelatedtracksmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget/wsearchrelatedtracksmenu.cpp b/src/widget/wsearchrelatedtracksmenu.cpp index b0940cda372..9b4b6c37c06 100644 --- a/src/widget/wsearchrelatedtracksmenu.cpp +++ b/src/widget/wsearchrelatedtracksmenu.cpp @@ -15,7 +15,7 @@ constexpr double kMaxMenuToAvailableScreenWidthRatio = 0.2; constexpr double kRelativeBpmRange = 0.06; // +/-6 % -const QString kActionTextPrefixSuffixSeparator = QString::fromUtf8(" ▶ "); +const QString kActionTextPrefixSuffixSeparator = QStringLiteral(" | "); inline int bpmLowerBound(double bpm) { return static_cast(std::floor((1 - kRelativeBpmRange) * bpm));