Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
workflow_buttons, add highlight on selected button in settings
Timothée Giet0cb91e07e3ec
diff --git a/plugins/python/workflow_buttons/Manual.html b/plugins/python/workflow_buttons/Manual.htmlindex 1b945ccce1..ec7c26621b 100644--- a/plugins/python/workflow_buttons/Manual.html+++ b/plugins/python/workflow_buttons/Manual.html@@ -16,9 +16,9 @@<li>select a background color</li><li>launch an extra script</li></ul>-<p>The first time you open the docker, it contains only one button to open its settings dialog.</p>+<p>The first time you open the docker, it contains only the settings button to open its settings dialog.</p><p>In the settings dialog, start by clicking the "+" button to add an empty button. It is selected by default. After creating several buttons, click on one to select it. You can move it to the left or to the right of the list with the arrow buttons. You can also delete selected button with the trash can button.</p>-<p>You can see which button is selected in the list as it is "checked" (its background color is darker). If you add an icon which covers all of the button's background, you can still see which button is selected from the "Selected button" label which indicates the number of the selected button in the list.</p>+<p>You can see which button is selected in the list as it is highlighted. Also the number of the selected button is displayed next to the "Selected button" label.</p><p>After creating and selecting a button, you can now:</p><ul><li>Select the icon mode for the button: custom icon, tool icon, or brush preset icon.</li>diff --git a/plugins/python/workflow_buttons/buttons_settings_dialog.py b/plugins/python/workflow_buttons/buttons_settings_dialog.pyindex 0d99383217..2a4fc34dd9 100644--- a/plugins/python/workflow_buttons/buttons_settings_dialog.py+++ b/plugins/python/workflow_buttons/buttons_settings_dialog.py@@ -373,9 +373,9 @@ class ButtonsSettingsDialog(QDialog):for widget in self.buttonsWidget.children():if isinstance(widget, CustomButtonForSettings):if widget.buttonID == self.selectedButtonID:- widget.setChecked(True)+ widget.selectButton()else:- widget.setChecked(False)+ widget.deselectButton()self.updateDialogFields()def addButton(self):@@ -598,7 +598,32 @@ class CustomButtonForSettings(QToolButton):def __init__(self, parent=None, buttonID=-1):super().__init__(parent)self.buttonID = buttonID- self.setCheckable(True)+ self.highlightSquare = selectedButtonHighlight(self, self.height())++ def resizeEvent(self, event):+ self.highlightSquare.setMinimumSize(QSize(self.height(), self.height()))++ def selectButton(self):+ self.highlightSquare.setVisible(True)++ def deselectButton(self):+ self.highlightSquare.setVisible(False)+++class selectedButtonHighlight(QWidget):+ # Class to define the highlight for selected button+ def __init__(self, parent=None, size=32):+ super().__init__(parent)+ self.color = self.palette().highlight().color()+ self.color.setAlpha(64)+ self.setMinimumSize(QSize(size,size))++ def paintEvent(self, event):+ painter = QPainter(self)+ painter.setPen(QPen(self.color, 1, 1)) # last 1 is for Qt.SolidLine+ painter.setBrush(QBrush(self.color, 1)) # last 1 is for Qt.SolidPattern+ painter.drawRect(1,1,self.minimumSize().width(),self.minimumSize().height())+class SelectedColorPreview(QWidget):# Class to define the widget used to visualize selected FG and BG colors