Commit dfa7cb56 authored by Tusooa Zhu's avatar Tusooa Zhu 🔼 Committed by Dmitry Kazakov

Ten Brushes: Allow users to configure whether to enable the "Preset History" feature

Summary: Ten Brushes in Krita 4.0.4 offers the feature of "Preset History." If one press the shortcut for a preset for the second time, it switches to the previously selected preset. However, some users may be confused with this. This patch adds a check box in the Ten Brushes settings window, and allow users to enable or disable this feature. By default, Preset History will still be turned on.

Test Plan:
[0] Click on "Tools" menu -> "Scripting" -> "Ten Brushes"
Expected: the check box is checked by default.

[1] Open any document in Krita.

[2] Select any brush preset using a shortcut.
Expected: the brush is selected.

[3] Press that shortcut again.
Expected: the previous brush is selected.

[4] Click on "Tools" menu -> "Scripting" -> "Ten Brushes."

[5] Uncheck the check box, and press "OK."
Expected: No error happens, and the dialog closes.

[6] Selevct any other brush preset using a shortcut.
Expected: The brush is selected.

[7] Press that shortcut again.
Expected: The brush is still selected. It does not switch to the previous preset.

[8] Restart Krita, and click on "Tools" menu -> "Scripting" -> "Ten Brushes."
Expected: The settings remain.

[9] Repeat [6] and [7].
Expected: The same as in [6] and [7], respectively.

[10] The testing is done.

Reviewers: #krita, dkazakov

Reviewed By: #krita, dkazakov

Subscribers: dkazakov

Tags: #krita

Differential Revision:
parent 5f86c598
......@@ -21,6 +21,9 @@ class TenBrushesExtension(krita.Extension):
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,6 +41,9 @@ class TenBrushesExtension(krita.Extension):
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 = []
......@@ -46,6 +52,8 @@ class TenBrushesExtension(krita.Extension):
self.actions[index].preset = button.preset
Application.writeSetting("", "tenbrushes", ','.join(map(str, presets)))
Application.writeSetting("", "tenbrushesActivatePrev2ndPress",
def loadActions(self, window):
allPresets = Application.resources("preset")
......@@ -65,7 +73,7 @@ class TenBrushesExtension(krita.Extension):
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 ==
if self.activatePrev and self.sender().preset ==
self.oldPreset = Application.activeWindow().views()[0].currentBrushPreset()
......@@ -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 @@ class UITenBrushes(object):
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)
......@@ -42,12 +43,20 @@ class UITenBrushes(object):
self.vbox.addWidget(QLabel(i18n("Select the brush preset, then click on the button you want to use to select the preset")))
def setActivatePrev(self, checked):
self.tenbrushes.activatePrev = checked
def loadButtons(self):
self.tenbrushes.buttons = []
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment