def update_toolbar_style(self): if config.setting["toolbar_show_labels"]: self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) else: self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) self.cd_lookup_action.setEnabled( len(get_cdrom_drives()) > 0 and discid is not None)
def create_toolbar(self): self.toolbar = toolbar = self.addToolBar(_(u"Actions")) self.toolbar_toggle_action = self.toolbar.toggleViewAction() self.update_toolbar_style() toolbar.setObjectName("main_toolbar") def add_toolbar_action(action): toolbar.addAction(action) widget = toolbar.widgetForAction(action) widget.setFocusPolicy(QtCore.Qt.TabFocus) widget.setAttribute(QtCore.Qt.WA_MacShowFocusRect) add_toolbar_action(self.add_directory_action) add_toolbar_action(self.add_files_action) toolbar.addSeparator() add_toolbar_action(self.play_file_action) toolbar.addSeparator() add_toolbar_action(self.save_action) add_toolbar_action(self.submit_action) toolbar.addSeparator() add_toolbar_action(self.cd_lookup_action) drives = get_cdrom_drives() if len(drives) > 1: self.cd_lookup_menu = QtGui.QMenu() for drive in drives: self.cd_lookup_menu.addAction(drive) self.cd_lookup_menu.triggered.connect(self.tagger.lookup_cd) button = toolbar.widgetForAction(self.cd_lookup_action) button.setPopupMode(QtGui.QToolButton.MenuButtonPopup) button.setMenu(self.cd_lookup_menu) add_toolbar_action(self.cluster_action) add_toolbar_action(self.autotag_action) add_toolbar_action(self.analyze_action) add_toolbar_action(self.view_info_action) add_toolbar_action(self.remove_action) add_toolbar_action(self.browser_lookup_action) self.search_toolbar = toolbar = self.addToolBar(_(u"Search")) self.search_toolbar_toggle_action = self.search_toolbar.toggleViewAction( ) toolbar.setObjectName("search_toolbar") search_panel = QtGui.QWidget(toolbar) hbox = QtGui.QHBoxLayout(search_panel) self.search_combo = QtGui.QComboBox(search_panel) self.search_combo.addItem(_(u"Album"), "album") self.search_combo.addItem(_(u"Artist"), "artist") self.search_combo.addItem(_(u"Track"), "track") hbox.addWidget(self.search_combo, 0) self.search_edit = ButtonLineEdit(search_panel) self.search_edit.returnPressed.connect(self.search) hbox.addWidget(self.search_edit, 0) self.search_button = QtGui.QToolButton(search_panel) self.search_button.setAutoRaise(True) self.search_button.setDefaultAction(self.search_action) self.search_button.setIconSize(QtCore.QSize(22, 22)) self.search_button.setAttribute(QtCore.Qt.WA_MacShowFocusRect) hbox.addWidget(self.search_button) toolbar.addWidget(search_panel)
def __init__(self, parent=None): super(CDLookupOptionsPage, self).__init__(parent) self.ui = Ui_CDLookupOptionsPage() self.ui.setupUi(self) if AUTO_DETECT_DRIVES: self.drives = get_cdrom_drives() self.ui.cd_lookup_device.addItems(self.drives)
def update_toolbar_style(self): if config.setting["toolbar_show_labels"]: self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) else: self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) self.cd_lookup_action.setEnabled(len(get_cdrom_drives()) > 0 and discid is not None)
def create_toolbar(self): self.toolbar = toolbar = self.addToolBar(_(u"Actions")) self.toolbar_toggle_action = self.toolbar.toggleViewAction() self.update_toolbar_style() toolbar.setObjectName("main_toolbar") def add_toolbar_action(action): toolbar.addAction(action) widget = toolbar.widgetForAction(action) widget.setFocusPolicy(QtCore.Qt.TabFocus) widget.setAttribute(QtCore.Qt.WA_MacShowFocusRect) add_toolbar_action(self.add_directory_action) add_toolbar_action(self.add_files_action) toolbar.addSeparator() add_toolbar_action(self.play_file_action) toolbar.addSeparator() add_toolbar_action(self.save_action) add_toolbar_action(self.submit_action) toolbar.addSeparator() add_toolbar_action(self.cd_lookup_action) drives = get_cdrom_drives() if len(drives) > 1: self.cd_lookup_menu = QtGui.QMenu() for drive in drives: self.cd_lookup_menu.addAction(drive) self.cd_lookup_menu.triggered.connect(self.tagger.lookup_cd) button = toolbar.widgetForAction(self.cd_lookup_action) button.setPopupMode(QtGui.QToolButton.MenuButtonPopup) button.setMenu(self.cd_lookup_menu) add_toolbar_action(self.cluster_action) add_toolbar_action(self.autotag_action) add_toolbar_action(self.analyze_action) add_toolbar_action(self.view_info_action) add_toolbar_action(self.remove_action) add_toolbar_action(self.browser_lookup_action) self.search_toolbar = toolbar = self.addToolBar(_(u"Search")) self.search_toolbar_toggle_action = self.search_toolbar.toggleViewAction() toolbar.setObjectName("search_toolbar") search_panel = QtGui.QWidget(toolbar) hbox = QtGui.QHBoxLayout(search_panel) self.search_combo = QtGui.QComboBox(search_panel) self.search_combo.addItem(_(u"Album"), "album") self.search_combo.addItem(_(u"Artist"), "artist") self.search_combo.addItem(_(u"Track"), "track") hbox.addWidget(self.search_combo, 0) self.search_edit = ButtonLineEdit(search_panel) self.search_edit.returnPressed.connect(self.trigger_search_action) self.search_edit.textChanged.connect(self.enable_search) hbox.addWidget(self.search_edit, 0) self.search_button = QtGui.QToolButton(search_panel) self.search_button.setAutoRaise(True) self.search_button.setDefaultAction(self.search_action) self.search_button.setIconSize(QtCore.QSize(22, 22)) self.search_button.setAttribute(QtCore.Qt.WA_MacShowFocusRect) hbox.addWidget(self.search_button) toolbar.addWidget(search_panel)
def create_action_toolbar(self): if getattr(self, 'toolbar', None): self.toolbar.clear() self.removeToolBar(self.toolbar) self.toolbar = toolbar = QtWidgets.QToolBar(_(u"Actions")) self.insertToolBar(self.search_toolbar, self.toolbar) self.update_toolbar_style() toolbar.setObjectName("main_toolbar") def add_toolbar_action(action): toolbar.addAction(action) widget = toolbar.widgetForAction(action) widget.setFocusPolicy(QtCore.Qt.TabFocus) widget.setAttribute(QtCore.Qt.WA_MacShowFocusRect) for action in config.setting['toolbar_layout']: if action not in ('cd_lookup_action', 'separator'): try: add_toolbar_action(getattr(self, action)) except AttributeError: log.warning('Warning: Unknown action name "%r" found in config. Ignored.', action) elif action == 'cd_lookup_action': add_toolbar_action(self.cd_lookup_action) drives = get_cdrom_drives() if len(drives) > 1: self.cd_lookup_menu = QtWidgets.QMenu() for drive in drives: self.cd_lookup_menu.addAction(drive) self.cd_lookup_menu.triggered.connect(self.tagger.lookup_cd) button = toolbar.widgetForAction(self.cd_lookup_action) button.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup) button.setMenu(self.cd_lookup_menu) elif action == 'separator': toolbar.addSeparator() self.show_toolbar()
def test_get_cdrom_drives(self): self.set_config_values({"cd_lookup_device": "/dev/cdrom"}) # Independent of the implementation get_cdrom_drives must not rais # and return an Iterable. drives = cdrom.get_cdrom_drives() self.assertIsInstance(drives, Iterable) self.assertTrue(set(cdrom.DEFAULT_DRIVES).issubset(drives))
def create_action_toolbar(self): if getattr(self, 'toolbar', None): self.toolbar.clear() self.removeToolBar(self.toolbar) self.toolbar = toolbar = QtWidgets.QToolBar(_("Actions")) self.insertToolBar(self.search_toolbar, self.toolbar) self.update_toolbar_style() toolbar.setObjectName("main_toolbar") def add_toolbar_action(action): toolbar.addAction(action) widget = toolbar.widgetForAction(action) widget.setFocusPolicy(QtCore.Qt.TabFocus) widget.setAttribute(QtCore.Qt.WA_MacShowFocusRect) for action in config.setting['toolbar_layout']: if action not in ('cd_lookup_action', 'separator'): try: add_toolbar_action(getattr(self, action)) except AttributeError: log.warning('Warning: Unknown action name "%r" found in config. Ignored.', action) elif action == 'cd_lookup_action': add_toolbar_action(self.cd_lookup_action) drives = get_cdrom_drives() if len(drives) > 1: self.cd_lookup_menu = QtWidgets.QMenu() for drive in drives: self.cd_lookup_menu.addAction(drive) self.cd_lookup_menu.triggered.connect(self.tagger.lookup_cd) button = toolbar.widgetForAction(self.cd_lookup_action) button.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup) button.setMenu(self.cd_lookup_menu) elif action == 'separator': toolbar.addSeparator() self.show_toolbar()
def create_toolbar(self): self.toolbar = toolbar = self.addToolBar(_(u"&Toolbar")) self.update_toolbar_style() toolbar.setObjectName("main_toolbar") toolbar.addAction(self.add_files_action) toolbar.addAction(self.add_directory_action) toolbar.addSeparator() toolbar.addAction(self.save_action) toolbar.addAction(self.submit_action) toolbar.addSeparator() toolbar.addAction(self.cd_lookup_action) drives = get_cdrom_drives() if len(drives) > 1: self.cd_lookup_menu = QtGui.QMenu() for drive in drives: self.cd_lookup_menu.addAction(drive) self.cd_lookup_menu.triggered.connect(self.tagger.lookup_cd) button = toolbar.widgetForAction(self.cd_lookup_action) button.setPopupMode(QtGui.QToolButton.MenuButtonPopup) button.setMenu(self.cd_lookup_menu) toolbar.addAction(self.cluster_action) toolbar.addAction(self.autotag_action) toolbar.addAction(self.analyze_action) toolbar.addAction(self.view_info_action) toolbar.addAction(self.remove_action) toolbar.addAction(self.browser_lookup_action) self.search_toolbar = toolbar = self.addToolBar(_(u"&Search Bar")) toolbar.setObjectName("search_toolbar") search_panel = QtGui.QWidget(toolbar) hbox = QtGui.QHBoxLayout(search_panel) self.search_combo = QtGui.QComboBox(search_panel) self.search_combo.addItem(_(u"Album"), QtCore.QVariant("album")) self.search_combo.addItem(_(u"Artist"), QtCore.QVariant("artist")) self.search_combo.addItem(_(u"Track"), QtCore.QVariant("track")) hbox.addWidget(self.search_combo, 0) self.search_edit = QtGui.QLineEdit(search_panel) self.search_edit.returnPressed.connect(self.search) hbox.addWidget(self.search_edit, 0) self.search_button = QtGui.QToolButton(search_panel) self.search_button.setAutoRaise(True) self.search_button.setDefaultAction(self.search_action) self.search_button.setIconSize(QtCore.QSize(22, 22)) hbox.addWidget(self.search_button) toolbar.addWidget(search_panel)
def create_toolbar(self): self.toolbar = toolbar = self.addToolBar(_(u"&Toolbar")) self.update_toolbar_style() toolbar.setObjectName("main_toolbar") toolbar.addAction(self.add_files_action) toolbar.addAction(self.add_directory_action) toolbar.addSeparator() toolbar.addAction(self.save_action) toolbar.addAction(self.submit_action) toolbar.addSeparator() toolbar.addAction(self.cd_lookup_action) drives = get_cdrom_drives() if len(drives) > 1: self.cd_lookup_menu = QtGui.QMenu() for drive in drives: self.cd_lookup_menu.addAction(drive) self.connect(self.cd_lookup_menu, QtCore.SIGNAL("triggered(QAction*)"), self.tagger.lookup_cd) button = toolbar.widgetForAction(self.cd_lookup_action) button.setPopupMode(QtGui.QToolButton.MenuButtonPopup) button.setMenu(self.cd_lookup_menu) toolbar.addAction(self.cluster_action) toolbar.addAction(self.autotag_action) toolbar.addAction(self.analyze_action) toolbar.addAction(self.view_info_action) toolbar.addAction(self.remove_action) toolbar.addAction(self.browser_lookup_action) self.search_toolbar = toolbar = self.addToolBar(_(u"&Search Bar")) toolbar.setObjectName("search_toolbar") search_panel = QtGui.QWidget(toolbar) hbox = QtGui.QHBoxLayout(search_panel) self.search_combo = QtGui.QComboBox(search_panel) self.search_combo.addItem(_(u"Album"), QtCore.QVariant("album")) self.search_combo.addItem(_(u"Artist"), QtCore.QVariant("artist")) self.search_combo.addItem(_(u"Track"), QtCore.QVariant("track")) hbox.addWidget(self.search_combo, 0) self.search_edit = QtGui.QLineEdit(search_panel) self.connect(self.search_edit, QtCore.SIGNAL("returnPressed()"), self.search) hbox.addWidget(self.search_edit, 0) self.search_button = QtGui.QToolButton(search_panel) self.search_button.setAutoRaise(True) self.search_button.setDefaultAction(self.search_action) self.search_button.setIconSize(QtCore.QSize(22, 22)) hbox.addWidget(self.search_button) toolbar.addWidget(search_panel)
def create_actions(self): self.options_action = QtWidgets.QAction( icontheme.lookup('preferences-desktop'), _("&Options..."), self) self.options_action.setMenuRole(QtWidgets.QAction.PreferencesRole) self.options_action.triggered.connect(self.show_options) self.cut_action = QtWidgets.QAction( icontheme.lookup('edit-cut', icontheme.ICON_SIZE_MENU), _("&Cut"), self) self.cut_action.setShortcut(QtGui.QKeySequence.Cut) self.cut_action.setEnabled(False) self.cut_action.triggered.connect(self.cut) self.paste_action = QtWidgets.QAction( icontheme.lookup('edit-paste', icontheme.ICON_SIZE_MENU), _("&Paste"), self) self.paste_action.setShortcut(QtGui.QKeySequence.Paste) self.paste_action.setEnabled(False) self.paste_action.triggered.connect(self.paste) self.help_action = QtWidgets.QAction(_("&Help..."), self) self.help_action.setShortcut(QtGui.QKeySequence.HelpContents) self.help_action.triggered.connect(self.show_help) self.about_action = QtWidgets.QAction(_("&About..."), self) self.about_action.setMenuRole(QtWidgets.QAction.AboutRole) self.about_action.triggered.connect(self.show_about) self.donate_action = QtWidgets.QAction(_("&Donate..."), self) self.donate_action.triggered.connect(self.open_donation_page) self.report_bug_action = QtWidgets.QAction(_("&Report a Bug..."), self) self.report_bug_action.triggered.connect(self.open_bug_report) self.support_forum_action = QtWidgets.QAction(_("&Support Forum..."), self) self.support_forum_action.triggered.connect(self.open_support_forum) self.add_files_action = QtWidgets.QAction( icontheme.lookup('document-open'), _("&Add Files..."), self) self.add_files_action.setStatusTip(_("Add files to the tagger")) # TR: Keyboard shortcut for "Add Files..." self.add_files_action.setShortcut(QtGui.QKeySequence.Open) self.add_files_action.triggered.connect(self.add_files) self.add_directory_action = QtWidgets.QAction( icontheme.lookup('folder'), _("A&dd Folder..."), self) self.add_directory_action.setStatusTip(_("Add a folder to the tagger")) # TR: Keyboard shortcut for "Add Directory..." self.add_directory_action.setShortcut(QtGui.QKeySequence(_("Ctrl+D"))) self.add_directory_action.triggered.connect(self.add_directory) self.save_action = QtWidgets.QAction(icontheme.lookup('document-save'), _("&Save"), self) self.save_action.setStatusTip(_("Save selected files")) # TR: Keyboard shortcut for "Save" self.save_action.setShortcut(QtGui.QKeySequence.Save) self.save_action.setEnabled(False) self.save_action.triggered.connect(self.save) self.submit_acoustid_action = QtWidgets.QAction( icontheme.lookup('acoustid-fingerprinter'), _("S&ubmit AcoustIDs"), self) self.submit_acoustid_action.setStatusTip( _("Submit acoustic fingerprints")) self.submit_acoustid_action.setEnabled(False) self.submit_acoustid_action.triggered.connect(self._on_submit_acoustid) self.exit_action = QtWidgets.QAction(_("E&xit"), self) self.exit_action.setMenuRole(QtWidgets.QAction.QuitRole) # TR: Keyboard shortcut for "Exit" self.exit_action.setShortcut(QtGui.QKeySequence(_("Ctrl+Q"))) self.exit_action.triggered.connect(self.close) self.remove_action = QtWidgets.QAction(icontheme.lookup('list-remove'), _("&Remove"), self) self.remove_action.setStatusTip(_("Remove selected files/albums")) self.remove_action.setEnabled(False) self.remove_action.triggered.connect(self.remove) self.browser_lookup_action = QtWidgets.QAction( icontheme.lookup('lookup-musicbrainz'), _("Lookup in &Browser"), self) self.browser_lookup_action.setStatusTip( _("Lookup selected item on MusicBrainz website")) self.browser_lookup_action.setEnabled(False) # TR: Keyboard shortcut for "Lookup in Browser" self.browser_lookup_action.setShortcut( QtGui.QKeySequence(_("Ctrl+Shift+L"))) self.browser_lookup_action.triggered.connect(self.browser_lookup) self.album_search_action = QtWidgets.QAction( icontheme.lookup('system-search'), _("Search for similar albums..."), self) self.album_search_action.setStatusTip( _("View similar releases and optionally choose a different release" )) self.album_search_action.triggered.connect(self.show_more_albums) self.track_search_action = QtWidgets.QAction( icontheme.lookup('system-search'), _("Search for similar tracks..."), self) self.track_search_action.setStatusTip( _("View similar tracks and optionally choose a different release")) self.track_search_action.triggered.connect(self.show_more_tracks) self.show_file_browser_action = QtWidgets.QAction( _("File &Browser"), self) self.show_file_browser_action.setCheckable(True) if config.persist["view_file_browser"]: self.show_file_browser_action.setChecked(True) self.show_file_browser_action.setShortcut( QtGui.QKeySequence(_("Ctrl+B"))) self.show_file_browser_action.triggered.connect(self.show_file_browser) self.show_cover_art_action = QtWidgets.QAction(_("&Cover Art"), self) self.show_cover_art_action.setCheckable(True) if config.persist["view_cover_art"]: self.show_cover_art_action.setChecked(True) self.show_cover_art_action.triggered.connect(self.show_cover_art) self.show_toolbar_action = QtWidgets.QAction(_("&Actions"), self) self.show_toolbar_action.setCheckable(True) if config.persist["view_toolbar"]: self.show_toolbar_action.setChecked(True) self.show_toolbar_action.triggered.connect(self.show_toolbar) self.search_action = QtWidgets.QAction( icontheme.lookup('system-search'), _("Search"), self) self.search_action.setEnabled(False) self.search_action.triggered.connect(self.search) self.cd_lookup_action = QtWidgets.QAction( icontheme.lookup('media-optical'), _("Lookup &CD..."), self) self.cd_lookup_action.setStatusTip( _("Lookup the details of the CD in your drive")) # TR: Keyboard shortcut for "Lookup CD" self.cd_lookup_action.setShortcut(QtGui.QKeySequence(_("Ctrl+K"))) self.cd_lookup_action.triggered.connect(self.tagger.lookup_cd) self.cd_lookup_menu = QtWidgets.QMenu(_("Lookup &CD...")) self.cd_lookup_menu.triggered.connect(self.tagger.lookup_cd) self.cd_lookup_action.setEnabled(False) if discid is None: log.warning( "CDROM: discid library not found - Lookup CD functionality disabled" ) else: drives = get_cdrom_drives() if not drives: log.warning( "CDROM: No CD-ROM drives found - Lookup CD functionality disabled" ) else: shortcut_drive = config.setting["cd_lookup_device"].split( ",")[0] if len(drives) > 1 else "" self.cd_lookup_action.setEnabled(True) for drive in drives: action = self.cd_lookup_menu.addAction(drive) if drive == shortcut_drive: # Clear existing shortcode on main action and assign it to sub-action self.cd_lookup_action.setShortcut(QtGui.QKeySequence()) action.setShortcut(QtGui.QKeySequence(_("Ctrl+K"))) self.analyze_action = QtWidgets.QAction( icontheme.lookup('picard-analyze'), _("&Scan"), self) self.analyze_action.setStatusTip( _("Use AcoustID audio fingerprint to identify the files by the actual music, even if they have no metadata" )) self.analyze_action.setEnabled(False) self.analyze_action.setToolTip( _('Identify the file using its AcoustID audio fingerprint')) # TR: Keyboard shortcut for "Analyze" self.analyze_action.setShortcut(QtGui.QKeySequence(_("Ctrl+Y"))) self.analyze_action.triggered.connect(self.analyze) self.cluster_action = QtWidgets.QAction( icontheme.lookup('picard-cluster'), _("Cl&uster"), self) self.cluster_action.setStatusTip( _("Cluster files into album clusters")) self.cluster_action.setEnabled(False) # TR: Keyboard shortcut for "Cluster" self.cluster_action.setShortcut(QtGui.QKeySequence(_("Ctrl+U"))) self.cluster_action.triggered.connect(self.cluster) self.autotag_action = QtWidgets.QAction( icontheme.lookup('picard-auto-tag'), _("&Lookup"), self) tip = _("Lookup selected items in MusicBrainz") self.autotag_action.setToolTip(tip) self.autotag_action.setStatusTip(tip) self.autotag_action.setEnabled(False) # TR: Keyboard shortcut for "Lookup" self.autotag_action.setShortcut(QtGui.QKeySequence(_("Ctrl+L"))) self.autotag_action.triggered.connect(self.autotag) self.view_info_action = QtWidgets.QAction( icontheme.lookup('picard-edit-tags'), _("&Info..."), self) self.view_info_action.setEnabled(False) # TR: Keyboard shortcut for "Info" self.view_info_action.setShortcut(QtGui.QKeySequence(_("Ctrl+I"))) self.view_info_action.triggered.connect(self.view_info) self.refresh_action = QtWidgets.QAction( icontheme.lookup('view-refresh', icontheme.ICON_SIZE_MENU), _("&Refresh"), self) self.refresh_action.setShortcut(QtGui.QKeySequence(_("Ctrl+R"))) self.refresh_action.triggered.connect(self.refresh) self.enable_renaming_action = QtWidgets.QAction( _("&Rename Files"), self) self.enable_renaming_action.setCheckable(True) self.enable_renaming_action.setChecked(config.setting["rename_files"]) self.enable_renaming_action.triggered.connect(self.toggle_rename_files) self.enable_moving_action = QtWidgets.QAction(_("&Move Files"), self) self.enable_moving_action.setCheckable(True) self.enable_moving_action.setChecked(config.setting["move_files"]) self.enable_moving_action.triggered.connect(self.toggle_move_files) self.enable_tag_saving_action = QtWidgets.QAction( _("Save &Tags"), self) self.enable_tag_saving_action.setCheckable(True) self.enable_tag_saving_action.setChecked( not config.setting["dont_write_tags"]) self.enable_tag_saving_action.triggered.connect(self.toggle_tag_saving) self.tags_from_filenames_action = QtWidgets.QAction( _("Tags From &File Names..."), self) self.tags_from_filenames_action.triggered.connect( self.open_tags_from_filenames) self.tags_from_filenames_action.setEnabled(False) self.open_collection_in_browser_action = QtWidgets.QAction( _("&Open My Collections in Browser"), self) self.open_collection_in_browser_action.triggered.connect( self.open_collection_in_browser) self.open_collection_in_browser_action.setEnabled( config.setting["username"] != '') self.view_log_action = QtWidgets.QAction(_("View Error/Debug &Log"), self) self.view_log_action.triggered.connect(self.show_log) self.view_history_action = QtWidgets.QAction( _("View Activity &History"), self) self.view_history_action.triggered.connect(self.show_history) xmlws_manager = self.tagger.xmlws.manager xmlws_manager.authenticationRequired.connect(self.show_password_dialog) xmlws_manager.proxyAuthenticationRequired.connect( self.show_proxy_dialog) self.play_file_action = QtWidgets.QAction( icontheme.lookup('play-music'), _("Open in &Player"), self) self.play_file_action.setStatusTip( _("Play the file in your default media player")) self.play_file_action.setEnabled(False) self.play_file_action.triggered.connect(self.play_file) self.open_folder_action = QtWidgets.QAction( icontheme.lookup('folder', icontheme.ICON_SIZE_MENU), _("Open Containing &Folder"), self) self.open_folder_action.setStatusTip( _("Open the containing folder in your file explorer")) self.open_folder_action.setEnabled(False) self.open_folder_action.triggered.connect(self.open_folder)
def create_actions(self): self.options_action = QtWidgets.QAction(icontheme.lookup('preferences-desktop'), _("&Options..."), self) self.options_action.setMenuRole(QtWidgets.QAction.PreferencesRole) self.options_action.triggered.connect(self.show_options) self.cut_action = QtWidgets.QAction(icontheme.lookup('edit-cut', icontheme.ICON_SIZE_MENU), _("&Cut"), self) self.cut_action.setShortcut(QtGui.QKeySequence.Cut) self.cut_action.setEnabled(False) self.cut_action.triggered.connect(self.cut) self.paste_action = QtWidgets.QAction(icontheme.lookup('edit-paste', icontheme.ICON_SIZE_MENU), _("&Paste"), self) self.paste_action.setShortcut(QtGui.QKeySequence.Paste) self.paste_action.setEnabled(False) self.paste_action.triggered.connect(self.paste) self.help_action = QtWidgets.QAction(_("&Help..."), self) self.help_action.setShortcut(QtGui.QKeySequence.HelpContents) self.help_action.triggered.connect(self.show_help) self.about_action = QtWidgets.QAction(_("&About..."), self) self.about_action.setMenuRole(QtWidgets.QAction.AboutRole) self.about_action.triggered.connect(self.show_about) self.donate_action = QtWidgets.QAction(_("&Donate..."), self) self.donate_action.triggered.connect(self.open_donation_page) self.report_bug_action = QtWidgets.QAction(_("&Report a Bug..."), self) self.report_bug_action.triggered.connect(self.open_bug_report) self.support_forum_action = QtWidgets.QAction(_("&Support Forum..."), self) self.support_forum_action.triggered.connect(self.open_support_forum) self.add_files_action = QtWidgets.QAction(icontheme.lookup('document-open'), _("&Add Files..."), self) self.add_files_action.setStatusTip(_("Add files to the tagger")) # TR: Keyboard shortcut for "Add Files..." self.add_files_action.setShortcut(QtGui.QKeySequence.Open) self.add_files_action.triggered.connect(self.add_files) self.add_directory_action = QtWidgets.QAction(icontheme.lookup('folder'), _("A&dd Folder..."), self) self.add_directory_action.setStatusTip(_("Add a folder to the tagger")) # TR: Keyboard shortcut for "Add Directory..." self.add_directory_action.setShortcut(QtGui.QKeySequence(_("Ctrl+D"))) self.add_directory_action.triggered.connect(self.add_directory) if self.show_close_window: self.close_window_action = QtWidgets.QAction(_("Close Window"), self) self.close_window_action.setShortcut(QtGui.QKeySequence(_("Ctrl+W"))) self.close_window_action.triggered.connect(self.close_active_window) self.save_action = QtWidgets.QAction(icontheme.lookup('document-save'), _("&Save"), self) self.save_action.setStatusTip(_("Save selected files")) # TR: Keyboard shortcut for "Save" self.save_action.setShortcut(QtGui.QKeySequence.Save) self.save_action.setEnabled(False) self.save_action.triggered.connect(self.save) self.submit_acoustid_action = QtWidgets.QAction(icontheme.lookup('acoustid-fingerprinter'), _("S&ubmit AcoustIDs"), self) self.submit_acoustid_action.setStatusTip(_("Submit acoustic fingerprints")) self.submit_acoustid_action.setEnabled(False) self.submit_acoustid_action.triggered.connect(self._on_submit_acoustid) self.exit_action = QtWidgets.QAction(_("E&xit"), self) self.exit_action.setMenuRole(QtWidgets.QAction.QuitRole) # TR: Keyboard shortcut for "Exit" self.exit_action.setShortcut(QtGui.QKeySequence(_("Ctrl+Q"))) self.exit_action.triggered.connect(self.close) self.remove_action = QtWidgets.QAction(icontheme.lookup('list-remove'), _("&Remove"), self) self.remove_action.setStatusTip(_("Remove selected files/albums")) self.remove_action.setEnabled(False) self.remove_action.triggered.connect(self.remove) self.browser_lookup_action = QtWidgets.QAction(icontheme.lookup('lookup-musicbrainz'), _("Lookup in &Browser"), self) self.browser_lookup_action.setStatusTip(_("Lookup selected item on MusicBrainz website")) self.browser_lookup_action.setEnabled(False) # TR: Keyboard shortcut for "Lookup in Browser" self.browser_lookup_action.setShortcut(QtGui.QKeySequence(_("Ctrl+Shift+L"))) self.browser_lookup_action.triggered.connect(self.browser_lookup) self.album_search_action = QtWidgets.QAction(icontheme.lookup('system-search'), _("Search for similar albums..."), self) self.album_search_action.setStatusTip(_("View similar releases and optionally choose a different release")) self.album_search_action.triggered.connect(self.show_more_albums) self.track_search_action = QtWidgets.QAction(icontheme.lookup('system-search'), _("Search for similar tracks..."), self) self.track_search_action.setStatusTip(_("View similar tracks and optionally choose a different release")) self.track_search_action.triggered.connect(self.show_more_tracks) self.show_file_browser_action = QtWidgets.QAction(_("File &Browser"), self) self.show_file_browser_action.setCheckable(True) if config.persist["view_file_browser"]: self.show_file_browser_action.setChecked(True) self.show_file_browser_action.setShortcut(QtGui.QKeySequence(_("Ctrl+B"))) self.show_file_browser_action.triggered.connect(self.show_file_browser) self.show_cover_art_action = QtWidgets.QAction(_("&Cover Art"), self) self.show_cover_art_action.setCheckable(True) if config.persist["view_cover_art"]: self.show_cover_art_action.setChecked(True) self.show_cover_art_action.triggered.connect(self.show_cover_art) self.show_toolbar_action = QtWidgets.QAction(_("&Actions"), self) self.show_toolbar_action.setCheckable(True) if config.persist["view_toolbar"]: self.show_toolbar_action.setChecked(True) self.show_toolbar_action.triggered.connect(self.show_toolbar) self.search_action = QtWidgets.QAction(icontheme.lookup('system-search'), _("Search"), self) self.search_action.setEnabled(False) self.search_action.triggered.connect(self.search) self.cd_lookup_action = QtWidgets.QAction(icontheme.lookup('media-optical'), _("Lookup &CD..."), self) self.cd_lookup_action.setStatusTip(_("Lookup the details of the CD in your drive")) # TR: Keyboard shortcut for "Lookup CD" self.cd_lookup_action.setShortcut(QtGui.QKeySequence(_("Ctrl+K"))) self.cd_lookup_action.triggered.connect(self.tagger.lookup_cd) self.cd_lookup_menu = QtWidgets.QMenu(_("Lookup &CD...")) self.cd_lookup_menu.triggered.connect(self.tagger.lookup_cd) self.cd_lookup_action.setEnabled(False) if discid is None: log.warning("CDROM: discid library not found - Lookup CD functionality disabled") else: drives = get_cdrom_drives() if not drives: log.warning("CDROM: No CD-ROM drives found - Lookup CD functionality disabled") else: shortcut_drive = config.setting["cd_lookup_device"].split(",")[0] if len(drives) > 1 else "" self.cd_lookup_action.setEnabled(True) for drive in drives: action = self.cd_lookup_menu.addAction(drive) action.setData(drive) if drive == shortcut_drive: # Clear existing shortcode on main action and assign it to sub-action self.cd_lookup_action.setShortcut(QtGui.QKeySequence()) action.setShortcut(QtGui.QKeySequence(_("Ctrl+K"))) self.analyze_action = QtWidgets.QAction(icontheme.lookup('picard-analyze'), _("&Scan"), self) self.analyze_action.setStatusTip(_("Use AcoustID audio fingerprint to identify the files by the actual music, even if they have no metadata")) self.analyze_action.setEnabled(False) self.analyze_action.setToolTip(_('Identify the file using its AcoustID audio fingerprint')) # TR: Keyboard shortcut for "Analyze" self.analyze_action.setShortcut(QtGui.QKeySequence(_("Ctrl+Y"))) self.analyze_action.triggered.connect(self.analyze) self.cluster_action = QtWidgets.QAction(icontheme.lookup('picard-cluster'), _("Cl&uster"), self) self.cluster_action.setStatusTip(_("Cluster files into album clusters")) self.cluster_action.setEnabled(False) # TR: Keyboard shortcut for "Cluster" self.cluster_action.setShortcut(QtGui.QKeySequence(_("Ctrl+U"))) self.cluster_action.triggered.connect(self.cluster) self.autotag_action = QtWidgets.QAction(icontheme.lookup('picard-auto-tag'), _("&Lookup"), self) tip = _("Lookup selected items in MusicBrainz") self.autotag_action.setToolTip(tip) self.autotag_action.setStatusTip(tip) self.autotag_action.setEnabled(False) # TR: Keyboard shortcut for "Lookup" self.autotag_action.setShortcut(QtGui.QKeySequence(_("Ctrl+L"))) self.autotag_action.triggered.connect(self.autotag) self.view_info_action = QtWidgets.QAction(icontheme.lookup('picard-edit-tags'), _("&Info..."), self) self.view_info_action.setEnabled(False) # TR: Keyboard shortcut for "Info" self.view_info_action.setShortcut(QtGui.QKeySequence(_("Ctrl+I"))) self.view_info_action.triggered.connect(self.view_info) self.refresh_action = QtWidgets.QAction(icontheme.lookup('view-refresh', icontheme.ICON_SIZE_MENU), _("&Refresh"), self) self.refresh_action.setShortcut(QtGui.QKeySequence(_("Ctrl+R"))) self.refresh_action.triggered.connect(self.refresh) self.enable_renaming_action = QtWidgets.QAction(_("&Rename Files"), self) self.enable_renaming_action.setCheckable(True) self.enable_renaming_action.setChecked(config.setting["rename_files"]) self.enable_renaming_action.triggered.connect(self.toggle_rename_files) self.enable_moving_action = QtWidgets.QAction(_("&Move Files"), self) self.enable_moving_action.setCheckable(True) self.enable_moving_action.setChecked(config.setting["move_files"]) self.enable_moving_action.triggered.connect(self.toggle_move_files) self.enable_tag_saving_action = QtWidgets.QAction(_("Save &Tags"), self) self.enable_tag_saving_action.setCheckable(True) self.enable_tag_saving_action.setChecked(not config.setting["dont_write_tags"]) self.enable_tag_saving_action.triggered.connect(self.toggle_tag_saving) self.tags_from_filenames_action = QtWidgets.QAction(_("Tags From &File Names..."), self) self.tags_from_filenames_action.triggered.connect(self.open_tags_from_filenames) self.tags_from_filenames_action.setEnabled(False) self.open_collection_in_browser_action = QtWidgets.QAction(_("&Open My Collections in Browser"), self) self.open_collection_in_browser_action.triggered.connect(self.open_collection_in_browser) self.open_collection_in_browser_action.setEnabled(config.setting["username"] != '') self.view_log_action = QtWidgets.QAction(_("View &Error/Debug Log"), self) self.view_log_action.triggered.connect(self.show_log) # TR: Keyboard shortcut for "View Error/Debug Log" self.view_log_action.setShortcut(QtGui.QKeySequence(_("Ctrl+E"))) self.view_history_action = QtWidgets.QAction(_("View Activity &History"), self) self.view_history_action.triggered.connect(self.show_history) # TR: Keyboard shortcut for "View Activity History" self.view_history_action.setShortcut(QtGui.QKeySequence(_("Ctrl+H"))) webservice_manager = self.tagger.webservice.manager webservice_manager.authenticationRequired.connect(self.show_password_dialog) webservice_manager.proxyAuthenticationRequired.connect(self.show_proxy_dialog) self.play_file_action = QtWidgets.QAction(icontheme.lookup('play-music'), _("Open in &Player"), self) self.play_file_action.setStatusTip(_("Play the file in your default media player")) self.play_file_action.setEnabled(False) self.play_file_action.triggered.connect(self.play_file) self.open_folder_action = QtWidgets.QAction(icontheme.lookup('folder', icontheme.ICON_SIZE_MENU), _("Open Containing &Folder"), self) self.open_folder_action.setStatusTip(_("Open the containing folder in your file explorer")) self.open_folder_action.setEnabled(False) self.open_folder_action.triggered.connect(self.open_folder) if self.tagger.autoupdate_enabled: self.check_update_action = QtWidgets.QAction(_("&Check for Update…"), self) self.check_update_action.setMenuRole(QtWidgets.QAction.ApplicationSpecificRole) self.check_update_action.triggered.connect(self.do_update_check)