Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions picard/ui/caa_types_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@
)

from picard.ui import PicardDialog
from picard.ui.util import (
StandardButton,
qlistwidget_items,
)
from picard.ui.util import qlistwidget_items


class ArrowButton(QtWidgets.QPushButton):
Expand Down Expand Up @@ -267,11 +264,9 @@ def __init__(

self.buttonbox = QtWidgets.QDialogButtonBox(self)
self.buttonbox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonbox.addButton(StandardButton(StandardButton.OK), QtWidgets.QDialogButtonBox.ButtonRole.AcceptRole)
self.buttonbox.addButton(
StandardButton(StandardButton.CANCEL), QtWidgets.QDialogButtonBox.ButtonRole.RejectRole
)
self.buttonbox.addButton(StandardButton(StandardButton.HELP), QtWidgets.QDialogButtonBox.ButtonRole.HelpRole)
self.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Cancel)
self.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Help)

extrabuttons = [
(N_("I&nclude all"), self.move_all_to_include_list),
Expand Down
7 changes: 2 additions & 5 deletions picard/ui/coverartbox/imageurldialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from picard.i18n import gettext as _

from picard.ui import PicardDialog
from picard.ui.util import StandardButton


class ImageURLDialog(PicardDialog):
Expand All @@ -55,10 +54,8 @@ def __init__(self, parent=None):
self.label = QtWidgets.QLabel(_("Cover art URL:"))
self.url = QtWidgets.QLineEdit(self)
self.buttonbox = QtWidgets.QDialogButtonBox(self)
accept_role = QtWidgets.QDialogButtonBox.ButtonRole.AcceptRole
self.buttonbox.addButton(StandardButton(StandardButton.OK), accept_role)
reject_role = QtWidgets.QDialogButtonBox.ButtonRole.RejectRole
self.buttonbox.addButton(StandardButton(StandardButton.CANCEL), reject_role)
self.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Cancel)
self.buttonbox.accepted.connect(self.accept)
self.buttonbox.rejected.connect(self.reject)
self.layout.addWidget(self.label)
Expand Down
5 changes: 1 addition & 4 deletions picard/ui/infodialog/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
from picard.ui import PicardDialog
from picard.ui.colors import interface_colors
from picard.ui.forms.ui_infodialog import Ui_InfoDialog
from picard.ui.util import StandardButton


class ArtworkRow:
Expand Down Expand Up @@ -103,9 +102,7 @@ def __init__(self, obj, parent=None):
artworktable_class = ArtworkTableExisting

self.ui.setupUi(self)
self.ui.buttonBox.addButton(
StandardButton(StandardButton.CLOSE), QtWidgets.QDialogButtonBox.ButtonRole.AcceptRole
)
self.ui.buttonBox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Close)
self.ui.buttonBox.accepted.connect(self.accept)

# Add the ArtworkTable to the ui
Expand Down
14 changes: 4 additions & 10 deletions picard/ui/options/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
tags_compatibility_id3,
tags_compatibility_wave,
)
from picard.ui.util import StandardButton


class ErrorOptionsPage(OptionsPage):
Expand Down Expand Up @@ -194,13 +193,10 @@ def __init__(self, default_page=None, parent=None):
self.ui.reset_button = QtWidgets.QPushButton(_("Restore &Defaults"))
self.ui.reset_button.setToolTip(_("Reset all settings for current option page"))

ok = StandardButton(StandardButton.OK)
ok.setText(_("Make It So!"))
ok = QtWidgets.QPushButton(_("Make It So!"))
self.ui.buttonbox.addButton(ok, QtWidgets.QDialogButtonBox.ButtonRole.AcceptRole)
self.ui.buttonbox.addButton(
StandardButton(StandardButton.CANCEL), QtWidgets.QDialogButtonBox.ButtonRole.RejectRole
)
self.ui.buttonbox.addButton(StandardButton(StandardButton.HELP), QtWidgets.QDialogButtonBox.ButtonRole.HelpRole)
self.ui.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Cancel)
self.ui.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Help)
self.ui.buttonbox.addButton(self.ui.reset_all_button, QtWidgets.QDialogButtonBox.ButtonRole.ActionRole)
self.ui.buttonbox.addButton(self.ui.reset_button, QtWidgets.QDialogButtonBox.ButtonRole.ActionRole)

Expand Down Expand Up @@ -574,9 +570,7 @@ def __init__(self, option_group, parent=None, override_profiles=None, override_s
self.option_group = option_group
self.ui = Ui_AttachedProfilesDialog()
self.ui.setupUi(self)
self.ui.buttonBox.addButton(
StandardButton(StandardButton.CLOSE), QtWidgets.QDialogButtonBox.ButtonRole.RejectRole
)
self.ui.buttonBox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Close)
self.ui.buttonBox.rejected.connect(self.close_window)

config = get_config()
Expand Down
7 changes: 3 additions & 4 deletions picard/ui/scripteditor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,13 @@ def __init__(self, parent=None, examples=None):
self.installEventFilter(self)

# Dialog buttons
self.reset_button = QtWidgets.QPushButton(_("Reset"))
self.reset_button = self.ui.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Reset)
self.reset_button.setToolTip(self.reset_action.toolTip())
self.reset_button.clicked.connect(self.reload_from_config)
# Adding the button with an ActionRole places it with the Cancel and Ok buttons
self.ui.buttonbox.addButton(self.reset_button, QtWidgets.QDialogButtonBox.ButtonRole.ActionRole)

self.save_button = self.ui.buttonbox.addButton(
_("Make It So!"), QtWidgets.QDialogButtonBox.ButtonRole.AcceptRole
)
self.save_button = self.ui.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.save_button.setToolTip(self.save_action.toolTip())
self.ui.buttonbox.accepted.connect(self.make_it_so)

Expand Down
5 changes: 1 addition & 4 deletions picard/ui/searchdialog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
)

from picard.ui.tablebaseddialog import TableBasedDialog
from picard.ui.util import StandardButton


class SearchQLineEdit(QtWidgets.QLineEdit):
Expand Down Expand Up @@ -196,9 +195,7 @@ def setupUi(self):
self.accept_button = QtWidgets.QPushButton(_(self.accept_button_title), self.buttonBox)
self.accept_button.setEnabled(False)
self.buttonBox.addButton(self.accept_button, QtWidgets.QDialogButtonBox.ButtonRole.AcceptRole)
self.buttonBox.addButton(
StandardButton(StandardButton.CANCEL), QtWidgets.QDialogButtonBox.ButtonRole.RejectRole
)
self.buttonBox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Cancel)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
self.verticalLayout.addWidget(self.buttonBox)
Expand Down
9 changes: 3 additions & 6 deletions picard/ui/tagsfromfilenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

from picard.ui import PicardDialog
from picard.ui.forms.ui_tagsfromfilenames import Ui_TagsFromFileNamesDialog
from picard.ui.util import StandardButton


class TagMatchExpression:
Expand Down Expand Up @@ -120,11 +119,9 @@ def __init__(self, files, parent=None):
selected_index = items.index(tff_format)
self.ui.format.addItems(items)
self.ui.format.setCurrentIndex(selected_index)
self.ui.buttonbox.addButton(StandardButton(StandardButton.HELP), QtWidgets.QDialogButtonBox.ButtonRole.HelpRole)
self.ui.buttonbox.addButton(StandardButton(StandardButton.OK), QtWidgets.QDialogButtonBox.ButtonRole.AcceptRole)
self.ui.buttonbox.addButton(
StandardButton(StandardButton.CANCEL), QtWidgets.QDialogButtonBox.ButtonRole.RejectRole
)
self.ui.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Help)
self.ui.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.ui.buttonbox.addButton(QtWidgets.QDialogButtonBox.StandardButton.Cancel)
self.ui.buttonbox.accepted.connect(self.accept)
self.ui.buttonbox.rejected.connect(self.reject)
self.ui.buttonbox.helpRequested.connect(self.show_help)
Expand Down
35 changes: 2 additions & 33 deletions picard/ui/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,44 +35,13 @@

from picard import PICARD_DISPLAY_NAME
from picard.config import get_config
from picard.const.sys import (
IS_LINUX,
IS_MACOS,
IS_WIN,
)
from picard.i18n import (
N_,
gettext as _,
)
from picard.const.sys import IS_LINUX
from picard.i18n import gettext as _
from picard.util import find_existing_path

from picard.ui.enums import MainAction


class StandardButton(QtWidgets.QPushButton):
OK = 0
CANCEL = 1
HELP = 2
CLOSE = 4

__types = {
OK: (N_("&Ok"), 'SP_DialogOkButton'),
CANCEL: (N_("&Cancel"), 'SP_DialogCancelButton'),
HELP: (N_("&Help"), 'SP_DialogHelpButton'),
CLOSE: (N_("Clos&e"), 'SP_DialogCloseButton'),
}

def __init__(self, btntype):
label = _(self.__types[btntype][0])
args = [label]
if not IS_WIN and not IS_MACOS:
iconname = self.__types[btntype][1]
if hasattr(QtWidgets.QStyle, iconname):
icon = QtCore.QCoreApplication.instance().style().standardIcon(getattr(QtWidgets.QStyle, iconname))
args = [icon, label]
super().__init__(*args)


def find_starting_directory():
config = get_config()
if config.setting['starting_directory']:
Expand Down
Loading