From 37e345ffe8d6e199fa542bbfe996d000516e74ec Mon Sep 17 00:00:00 2001 From: Simone Gaiarin Date: Fri, 6 Jan 2017 15:56:35 +0100 Subject: [PATCH] Replace _addButton method with HTML based one Support loading icon from anki qrc resource file or using the absolute path --- aqt/editor.py | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/aqt/editor.py b/aqt/editor.py index f3f26971b..ecb7e77bb 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -467,34 +467,13 @@ class Editor(object): # Top buttons ###################################################################### - def _addButton(self, name, func, key=None, tip=None, size=True, text="", - check=False, native=False, canDisable=True): - b = QPushButton(text) - if check: - b.clicked["bool"].connect(func) + def _addButton(self, icon, cmd, tip=""): + if os.path.isabs(icon): + iconstr = icon else: - b.clicked.connect(func) - if size: - b.setFixedHeight(20) - b.setFixedWidth(20) - if not native: - if self.plastiqueStyle: - b.setStyle(self.plastiqueStyle) - b.setFocusPolicy(Qt.NoFocus) - else: - b.setAutoDefault(False) - if not text: - b.setIcon(QIcon(":/icons/%s.png" % name)) - if key: - b.setShortcut(QKeySequence(key)) - if tip: - b.setToolTip(shortcut(tip)) - if check: - b.setCheckable(True) - self.iconsBox.addWidget(b) - if canDisable: - self._buttons[name] = b - return b + iconstr = "qrc:/icons/{}.png".format(icon) + return ''''''.format(icon=iconstr, cmd=cmd, tip=_(tip)) def setupShortcuts(self): cuts = [