feat: Add Krita config
This commit is contained in:
1 parent
e2e3af5fbb
commit
3193f3d028
237 files changed
+12544
No files matched your search
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--BBD's Krita Script Starter, Feb 2018 -->
|
||||
<head><title>Disable Quick Layer Search</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Disable Quick Layer Search</h3>
|
||||
Tell people about what your script does here.
|
||||
This is an html document so you can format it with html tags.
|
||||
<h3>Usage</h3>
|
||||
Tell people how to use your script here.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,7 @@
|
||||
from .disable_quick_layer_search import DisableQuickLayerSearch
|
||||
|
||||
# And add the extension to Krita's list of extensions:
|
||||
app = Krita.instance()
|
||||
# Instantiate your class:
|
||||
extension = DisableQuickLayerSearch(parent = app)
|
||||
app.addExtension(extension)
|
||||
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,71 @@
|
||||
# BBD's Krita Script Starter Feb 2018
|
||||
|
||||
from krita import Extension
|
||||
from krita import Krita
|
||||
from PyQt5.QtCore import Qt, QTimer
|
||||
from PyQt5.QtWidgets import QTreeView
|
||||
|
||||
EXTENSION_ID = 'pykrita_disable_quick_layer_search'
|
||||
MENU_ENTRY = 'Toggle Quick Layer Search'
|
||||
SETTING_NAMESPACE = 'DisableQuickLayerSearch'
|
||||
SETTING_KEY = 'focus_disabled'
|
||||
|
||||
|
||||
def get_layers_tree(app: Krita):
|
||||
kis_layer_box = next((d for d in app.dockers() if d.objectName() == 'KisLayerBox'), None)
|
||||
if not kis_layer_box: return None
|
||||
|
||||
layers_tree = kis_layer_box.findChild(QTreeView, 'listLayers')
|
||||
if not layers_tree: return None
|
||||
|
||||
return layers_tree
|
||||
|
||||
|
||||
class DisableQuickLayerSearch(Extension):
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent)
|
||||
|
||||
def createActions(self, window):
|
||||
action = window.createAction(EXTENSION_ID, MENU_ENTRY, "tools/scripts")
|
||||
action.triggered.connect(self.action_triggered)
|
||||
|
||||
def _show_floating_message(self, app: Krita, is_disabled: bool):
|
||||
view = app.activeWindow().activeView()
|
||||
status = "disabled" if is_disabled else "enabled"
|
||||
view.showFloatingMessage(
|
||||
f"Layer search by first letter {status}",
|
||||
app.icon("dialog-ok-apply"),
|
||||
2000,
|
||||
1
|
||||
)
|
||||
|
||||
def setup(self):
|
||||
QTimer.singleShot(500, self.apply_focus_policy)
|
||||
|
||||
def apply_focus_policy(self):
|
||||
app = Krita.instance()
|
||||
|
||||
layers_tree = get_layers_tree(app)
|
||||
if not layers_tree: return
|
||||
|
||||
saved_state = app.readSetting(SETTING_NAMESPACE, SETTING_KEY, "false")
|
||||
is_disabled = saved_state == 'true'
|
||||
|
||||
layers_tree.setFocusPolicy(Qt.NoFocus if is_disabled else Qt.StrongFocus)
|
||||
|
||||
self._show_floating_message(app, is_disabled)
|
||||
|
||||
def action_triggered(self):
|
||||
app = Krita.instance()
|
||||
|
||||
layers_tree = get_layers_tree(app)
|
||||
if not layers_tree: return
|
||||
|
||||
current_policy = layers_tree.focusPolicy()
|
||||
will_disable = current_policy != Qt.NoFocus
|
||||
|
||||
app.writeSetting(SETTING_NAMESPACE, SETTING_KEY, "true" if will_disable else "false")
|
||||
|
||||
layers_tree.setFocusPolicy(Qt.NoFocus if will_disable else Qt.StrongFocus)
|
||||
|
||||
self._show_floating_message(app, will_disable)
|
||||
Reference in new issue
Block a user