Skip to content

Commit

Permalink
PICARD-2629: Add a single "Search similar items" action to the menu
Browse files Browse the repository at this point in the history
This action triggers either "search similar tracks" or search similar albums" based on context. There is a single shortcut for both.
  • Loading branch information
phw committed Mar 3, 2023
1 parent 60eb83a commit 235b92e
Show file tree
Hide file tree
Showing 6 changed files with 18,736 additions and 18,553 deletions.
37,258 changes: 18,709 additions & 18,549 deletions picard/resources.py

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions picard/ui/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,16 @@ def _create_submit_file_as_release_action(self):
action = None
self.submit_file_as_release_action = action

@MainWindowActions.add()
def _create_similar_items_search_action(self):
action = QtWidgets.QAction(icontheme.lookup('system-search'), _("Search for similar items..."), self)
action.setIconText(_("Similar items"))
action.setStatusTip(_("View similar releases or recordings and optionally choose a different one"))
action.setEnabled(False)
action.setShortcut(QtGui.QKeySequence(_("Ctrl+T")))
action.triggered.connect(self.show_similar_items_search)
self.similar_items_search_action = action

@MainWindowActions.add()
def _create_album_search_action(self):
action = QtWidgets.QAction(icontheme.lookup('system-search'), _("Search for similar albums..."), self)
Expand Down Expand Up @@ -1040,8 +1050,7 @@ def create_menus(self):
menu.addAction(self.analyze_action)
menu.addAction(self.cluster_action)
menu.addAction(self.browser_lookup_action)
menu.addAction(self.track_search_action)
menu.addAction(self.album_search_action)
menu.addAction(self.similar_items_search_action)
menu.addAction(self.album_other_versions_action)
menu.addSeparator()
menu.addAction(self.generate_fingerprints_action)
Expand Down Expand Up @@ -1400,6 +1409,13 @@ def get_first_obj_with_type(self, type):
return obj
return None

def show_similar_items_search(self):
obj = self.get_first_obj_with_type(Cluster)
if obj:
self.show_more_albums()
else:
self.show_more_tracks()

def show_more_tracks(self):
if not self.selected_objects:
return
Expand Down Expand Up @@ -1525,7 +1541,7 @@ def update_actions(self):
can_browser_lookup = bool(single and single.can_browser_lookup())
is_file = bool(single and isinstance(single, (File, Track)))
is_album = bool(single and isinstance(single, Album))
is_cluster = bool(single and isinstance(single, Cluster))
is_cluster = bool(single and isinstance(single, Cluster) and not single.special)

if not self.selected_objects:
have_objects = have_files = False
Expand Down Expand Up @@ -1576,6 +1592,7 @@ def update_actions(self):
self.submit_file_as_release_action.setEnabled(have_files)
files = self.get_selected_or_unmatched_files()
self.tags_from_filenames_action.setEnabled(bool(files))
self.similar_items_search_action.setEnabled(is_file or is_cluster)
self.track_search_action.setEnabled(is_file)
self.album_search_action.setEnabled(is_cluster)
self.album_other_versions_action.setEnabled(is_album)
Expand Down
6 changes: 5 additions & 1 deletion picard/ui/options/interface_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Copyright (C) 2007-2008 Lukáš Lalinský
# Copyright (C) 2008 Will
# Copyright (C) 2009, 2019-2022 Philipp Wolfer
# Copyright (C) 2009, 2019-2023 Philipp Wolfer
# Copyright (C) 2011, 2013 Michael Wiencek
# Copyright (C) 2013, 2019 Wieland Hoffmann
# Copyright (C) 2013-2014, 2018, 2020-2021 Laurent Monin
Expand Down Expand Up @@ -119,6 +119,10 @@ class InterfaceToolbarOptionsPage(OptionsPage):
'label': N_('Parse File Names...'),
'icon': 'picard-tags-from-filename'
},
'similar_items_search_action': {
'label': N_('Similar items'),
'icon': 'system-search'
},
}
ACTION_NAMES = set(TOOLBAR_BUTTONS.keys())
options = [
Expand Down
Binary file added resources/images/16x16/system-search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/16x16/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions resources/picard.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
<file>images/16x16/[email protected]</file>
<file>images/16x16/speaker-100.png</file>
<file>images/16x16/[email protected]</file>
<file>images/16x16/system-search.png</file>
<file>images/16x16/[email protected]</file>
<file>images/16x16/view-refresh.png</file>
<file>images/16x16/[email protected]</file>
<file>images/22x22/acoustid-fingerprinter.png</file>
Expand Down

0 comments on commit 235b92e

Please sign in to comment.