diff --git a/plugins/python/tenbrushes/tenbrushes.py b/plugins/python/tenbrushes/tenbrushes.py --- a/plugins/python/tenbrushes/tenbrushes.py +++ b/plugins/python/tenbrushes/tenbrushes.py @@ -21,6 +21,9 @@ self.actions = [] self.buttons = [] self.selectedPresets = [] + # Indicates whether we want to activate the previous-selected brush + # on the second press of the shortcut + self.activatePrev = True self.oldPreset = None def setup(self): @@ -38,14 +41,19 @@ def readSettings(self): self.selectedPresets = Application.readSetting("", "tenbrushes", "").split(',') + setting = Application.readSetting("", "tenbrushesActivatePrev2ndPress", "True") + # we should not get anything other than 'True' and 'False' + self.activatePrev = setting == 'True' def writeSettings(self): presets = [] for index, button in enumerate(self.buttons): self.actions[index].preset = button.preset presets.append(button.preset) Application.writeSetting("", "tenbrushes", ','.join(map(str, presets))) + Application.writeSetting("", "tenbrushesActivatePrev2ndPress", + str(self.activatePrev)) def loadActions(self, window): allPresets = Application.resources("preset") @@ -65,7 +73,7 @@ allPresets = Application.resources("preset") if Application.activeWindow() and len(Application.activeWindow().views()) > 0 and self.sender().preset in allPresets: currentPreset = Application.activeWindow().views()[0].currentBrushPreset() - if self.sender().preset == currentPreset.name(): + if self.activatePrev and self.sender().preset == currentPreset.name(): Application.activeWindow().views()[0].activateResource(self.oldPreset) else: self.oldPreset = Application.activeWindow().views()[0].currentBrushPreset() diff --git a/plugins/python/tenbrushes/uitenbrushes.py b/plugins/python/tenbrushes/uitenbrushes.py --- a/plugins/python/tenbrushes/uitenbrushes.py +++ b/plugins/python/tenbrushes/uitenbrushes.py @@ -11,7 +11,7 @@ ''' from PyQt5.QtCore import Qt, QSize from PyQt5.QtGui import QPixmap, QIcon -from PyQt5.QtWidgets import (QDialogButtonBox, QLabel, QVBoxLayout, QHBoxLayout) +from PyQt5.QtWidgets import (QDialogButtonBox, QLabel, QVBoxLayout, QHBoxLayout, QCheckBox) from . import tenbrushesdialog, dropbutton import krita @@ -25,6 +25,7 @@ self.buttonBox = QDialogButtonBox(self.mainDialog) self.vbox = QVBoxLayout(self.mainDialog) self.hbox = QHBoxLayout(self.mainDialog) + self.checkBox = QCheckBox(i18n("&Activate previous brush when pressing the shortcut for the second time"), self.mainDialog) self.buttonBox.accepted.connect(self.mainDialog.accept) self.buttonBox.rejected.connect(self.mainDialog.reject) @@ -42,12 +43,20 @@ self.vbox.addLayout(self.hbox) self.vbox.addWidget(QLabel(i18n("Select the brush preset, then click on the button you want to use to select the preset"))) self.vbox.addWidget(self.presetChooser) + + self.checkBox.setChecked(self.tenbrushes.activatePrev) + self.checkBox.toggled.connect(self.setActivatePrev) + self.vbox.addWidget(self.checkBox) + self.vbox.addWidget(self.buttonBox) self.mainDialog.show() self.mainDialog.activateWindow() self.mainDialog.exec_() + def setActivatePrev(self, checked): + self.tenbrushes.activatePrev = checked + def loadButtons(self): self.tenbrushes.buttons = []