Skip to content

Commit

Permalink
Merge pull request #77 from wojtryb/development
Browse files Browse the repository at this point in the history
Deploy 1.5.0
  • Loading branch information
wojtryb authored Feb 24, 2024
2 parents 7bee5b7 + b1e1a59 commit 20a1d82
Show file tree
Hide file tree
Showing 164 changed files with 2,792 additions and 1,313 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Bug report
about: Create a report so that the bug can be fixed in future relase.
about: Create a report so that the bug can be fixed in future release.
title: ''
labels: bug
assignees: wojtryb
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Shortcut composer **v1.4.2**
# Shortcut composer **v1.5.0**

[![python](https://img.shields.io/badge/Python-3.8-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
[![python](https://img.shields.io/badge/Python-3.10-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
[![Code style: black](https://img.shields.io/badge/code%20style-autopep8-333333.svg)](https://pypi.org/project/autopep8/)
[![License: GPLv3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![wojtryb website](https://img.shields.io/badge/YouTube-wojtryb-ee0000.svg?style=flat&logo=youtube)](https://youtube.com/wojtryb)
Expand All @@ -17,6 +17,7 @@ The plugin adds new shortcuts of the following types:
- [**`Canvas preview`**](https://github.com/wojtryb/Shortcut-Composer/wiki/Plugin-actions#canvas-previews) - Temporarily changes canvas elements while the key is pressed.
- [**`Multiple assignment`**](https://github.com/wojtryb/Shortcut-Composer/wiki/Plugin-actions#multiple-assignments) - repeatedly pressing a key, cycles between multiple values of krita property.
- [**`Temporary key`**](https://github.com/wojtryb/Shortcut-Composer/wiki/Plugin-actions#temporary-keys) - temporarily activates a krita property with long press or toggles it on/off with short press.
- [**`Rotation selector`**](https://github.com/wojtryb/Shortcut-Composer/wiki/Plugin-actions#rotation-selectors) - while key is pressed, displays a widget, which allows to set an angle-based property.

## Important links
> Download the [**`latest version`**](https://github.com/wojtryb/Shortcut-Composer/archive/refs/heads/main.zip) of the plugin, or visit its [**`github page`**](https://github.com/wojtryb/Shortcut-Composer).
Expand All @@ -39,8 +40,8 @@ The plugin adds new shortcuts of the following types:
[![PIE MENUS - release video](https://github-production-user-asset-6210df.s3.amazonaws.com/51094047/238179887-87c00d86-0e65-46c2-94c4-52bb02c99501.png)](https://youtu.be/hrjBycVYFZM "PIE MENUS - introducing Shortcut Composer")

## Requirements
- Version of krita on plugin release: **5.2.0**
- Required version of krita: **5.1.0** or later
- Version of krita on plugin release: **5.2.2**
- Required version of krita: **5.2.2** or later

OS support state:
- [x] Windows (10, 11)
Expand Down
16 changes: 14 additions & 2 deletions shortcut_composer/INFO.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-FileCopyrightText: © 2022-2024 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-License-Identifier: GPL-3.0-or-later

__version__ = "1.4.2"
"""Importable information about the plugin."""

from api_krita.wrappers import Version

__version__ = Version(1, 5, 0)
"""Version of the Shortcut Composer plugin."""

__required_krita_version__ = Version(5, 2, 2)
"""Version of krita required by the plugin to work."""

__author__ = "Wojciech Trybus"
"""Maintainer of the plugin."""

__license__ = "GPL-3.0-or-later"
"""Plugin license."""
31 changes: 26 additions & 5 deletions shortcut_composer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-FileCopyrightText: © 2022-2024 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-License-Identifier: GPL-3.0-or-later

"""
Expand All @@ -14,8 +14,29 @@

sys.path.append(directory := os.path.dirname(__file__))

from .shortcut_composer import ShortcutComposer # noqa
from .api_krita import Krita # noqa
Krita.add_extension(ShortcutComposer)

sys.path.remove(directory)
def main() -> None:
from PyQt5.QtWidgets import QMessageBox
from .INFO import __version__, __required_krita_version__
from .api_krita import Krita # noqa

if Krita.version < __required_krita_version__:
warning_box = QMessageBox()
warning_box.setIcon(QMessageBox.Warning)
warning_box.setWindowTitle("Shortcut composer version mismatch")
warning_box.setText(
"Shortcut Composer will not load.\n\n"
f"The plugin in version {__version__} requires higher "
"Krita version:\n\n"
f"Krita version: {Krita.version}\n"
f"Required Krita version: {__required_krita_version__}\n\n"
"Upgrade your Krita, or downgrade the plugin.")
warning_box.setStandardButtons(QMessageBox.Ok)
warning_box.exec_()
return

from .shortcut_composer import ShortcutComposer # noqa
Krita.add_extension(ShortcutComposer)


main()
14 changes: 14 additions & 0 deletions shortcut_composer/actions.action
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@
<icon>addlayer</icon>
</Action>

</Actions>
<Actions category="Scripts">
<text>Shortcut Composer: Rotation Selectors</text>

<Action name="Rotate canvas">
<activationFlags>1</activationFlags>
<icon>transform_icons_rotate_cw</icon>
</Action>

<Action name="Rotate brush">
<activationFlags>1</activationFlags>
<icon>transform_icons_rotate_ccw</icon>
</Action>

</Actions>
<Actions category="Scripts">
<text>Shortcut Composer: Utilities</text>
Expand Down
62 changes: 42 additions & 20 deletions shortcut_composer/actions.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-FileCopyrightText: © 2022-2024 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-License-Identifier: GPL-3.0-or-later

"""
Implementation of complex actions.
Make sure that every complex action implemented here has a definition in
`shortcut_composer.action` file. Otherwise the action will not be
visible in `keyboard shortcuts` menu in krita settings.
NOTE: Make sure that every complex action implemented here has a
definition in `shortcut_composer.action` file. Otherwise the action
will not be visible in `keyboard shortcuts` menu in krita settings.
"""

import templates
from typing import List

from PyQt5.QtGui import QColor

from api_krita.enums import Action, Tool, Toggle, BlendingMode, TransformMode
from core_components import instructions, controllers
from data_components import (
RotationDeadzoneStrategy,
PieDeadzoneStrategy,
CurrentLayerStack,
DeadzoneStrategy,
PickStrategy,
Slider,
Range,
Tag,
)
infinity = float("inf")
Tag)

INFINITY = float("inf")

def create_actions() -> List[templates.RawInstructions]: return [

def create_actions() -> list[templates.RawInstructions]: return [
# Switch between FREEHAND BRUSH and the MOVE tool
templates.TemporaryKey(
name="Temporary move tool",
Expand Down Expand Up @@ -107,7 +107,7 @@ def create_actions() -> List[templates.RawInstructions]: return [
instructions=[instructions.UndoOnPress()],
horizontal_slider=Slider(
controller=controllers.UndoController(),
values=Range(-infinity, infinity),
values=Range(-INFINITY, INFINITY),
deadzone=100,
),
),
Expand All @@ -132,7 +132,7 @@ def create_actions() -> List[templates.RawInstructions]: return [
instructions=[instructions.TemporaryOn(Toggle.ISOLATE_LAYER)],
horizontal_slider=Slider(
controller=controllers.TimeController(),
values=Range(0, infinity),
values=Range(0, INFINITY),
),
vertical_slider=Slider(
controller=controllers.ActiveLayerController(),
Expand Down Expand Up @@ -170,12 +170,12 @@ def create_actions() -> List[templates.RawInstructions]: return [
name="Scroll canvas zoom or rotation",
horizontal_slider=Slider(
controller=controllers.CanvasRotationController(),
values=Range(-infinity, infinity),
values=Range(-INFINITY, INFINITY),
sensitivity_scale=10,
),
vertical_slider=Slider(
controller=controllers.CanvasZoomController(),
values=Range(0, infinity),
values=Range(0, INFINITY),
sensitivity_scale=10,
),
),
Expand Down Expand Up @@ -246,7 +246,7 @@ def create_actions() -> List[templates.RawInstructions]: return [
name="Pick painting blending modes",
controller=controllers.BlendingModeController(),
instructions=[instructions.SetBrushOnNonPaintable()],
deadzone_strategy=DeadzoneStrategy.PICK_TOP,
deadzone_strategy=PieDeadzoneStrategy.PICK_TOP,
values=[
BlendingMode.NORMAL,
BlendingMode.OVERLAY,
Expand Down Expand Up @@ -280,7 +280,7 @@ def create_actions() -> List[templates.RawInstructions]: return [
templates.PieMenu(
name="Pick transform tool modes",
controller=controllers.TransformModeController(),
deadzone_strategy=DeadzoneStrategy.PICK_TOP,
deadzone_strategy=PieDeadzoneStrategy.PICK_TOP,
values=[
TransformMode.FREE,
TransformMode.PERSPECTIVE,
Expand All @@ -297,7 +297,7 @@ def create_actions() -> List[templates.RawInstructions]: return [
name="Pick brush presets (red)",
controller=controllers.PresetController(),
instructions=[instructions.SetBrushOnNonPaintable()],
deadzone_strategy=DeadzoneStrategy.PICK_PREVIOUS,
deadzone_strategy=PieDeadzoneStrategy.PICK_PREVIOUS,
values=Tag("★ My Favorites"),
background_color=QColor(95, 65, 65, 190),
active_color=QColor(200, 70, 70),
Expand All @@ -309,7 +309,7 @@ def create_actions() -> List[templates.RawInstructions]: return [
name="Pick brush presets (green)",
controller=controllers.PresetController(),
instructions=[instructions.SetBrushOnNonPaintable()],
deadzone_strategy=DeadzoneStrategy.PICK_PREVIOUS,
deadzone_strategy=PieDeadzoneStrategy.PICK_PREVIOUS,
values=Tag("RGBA"),
background_color=QColor(65, 95, 65, 190),
active_color=QColor(70, 200, 70),
Expand All @@ -321,7 +321,7 @@ def create_actions() -> List[templates.RawInstructions]: return [
name="Pick brush presets (blue)",
controller=controllers.PresetController(),
instructions=[instructions.SetBrushOnNonPaintable()],
deadzone_strategy=DeadzoneStrategy.PICK_PREVIOUS,
deadzone_strategy=PieDeadzoneStrategy.PICK_PREVIOUS,
values=Tag("Erasers"),
background_color=QColor(70, 70, 105, 190),
active_color=QColor(110, 160, 235),
Expand All @@ -334,12 +334,34 @@ def create_actions() -> List[templates.RawInstructions]: return [
name="Pick local brush presets",
controller=controllers.PresetController(),
instructions=[instructions.SetBrushOnNonPaintable()],
deadzone_strategy=DeadzoneStrategy.PICK_PREVIOUS,
deadzone_strategy=PieDeadzoneStrategy.PICK_PREVIOUS,
values=[],
save_local=True,
active_color=QColor(234, 172, 0),
),

# Use rotation widget to rotate the canvas.
templates.RotationSelector(
name="Rotate canvas",
controller=controllers.CanvasRotationController(),
is_counterclockwise=False,
offset=0,
inverse_zones=False,
divisions=24,
deadzone_strategy=RotationDeadzoneStrategy.KEEP_CHANGE,
),

# Use rotation widget to rotate current brush preset.
templates.RotationSelector(
name="Rotate brush",
controller=controllers.BrushRotationController(),
is_counterclockwise=True,
offset=90,
inverse_zones=False,
divisions=24,
deadzone_strategy=RotationDeadzoneStrategy.KEEP_CHANGE,
),

# .......................................
# Insert your actions implementation here
# .......................................
Expand Down
2 changes: 1 addition & 1 deletion shortcut_composer/api_krita/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-FileCopyrightText: © 2022-2024 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-License-Identifier: GPL-3.0-or-later

"""
Expand Down
4 changes: 3 additions & 1 deletion shortcut_composer/api_krita/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-FileCopyrightText: © 2022-2024 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-License-Identifier: GPL-3.0-or-later

"""Contains utility actions to register in krita."""

from .transform_actions import TransformModeActions, TransformModeFinder

__all__ = ["TransformModeActions", "TransformModeFinder"]
12 changes: 5 additions & 7 deletions shortcut_composer/api_krita/actions/transform_actions.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-FileCopyrightText: © 2022-2024 Wojciech Trybus <wojtryb@gmail.com>
# SPDX-License-Identifier: GPL-3.0-or-later

from typing import Dict, Optional
from functools import partial, partialmethod

from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import (
QWidgetAction,
QToolButton,
QPushButton,
QWidget,
)
QWidget)

from ..enums import Tool, TransformMode
from ..core_api import KritaInstance
Expand All @@ -27,7 +25,7 @@ class TransformModeActions:

def __init__(self, window) -> None:
self._finder = TransformModeFinder()
self._actions: Dict[TransformMode, QWidgetAction] = {}
self._actions: dict[TransformMode, QWidgetAction] = {}
self._create_actions(window)

def _create_actions(self, window) -> None:
Expand Down Expand Up @@ -84,7 +82,7 @@ class TransformModeFinder:
"""

def __init__(self) -> None:
self._mode_buttons: Dict[TransformMode, QToolButton] = {}
self._mode_buttons: dict[TransformMode, QToolButton] = {}
self._transform_options: QWidget
self._apply_button: QPushButton

Expand All @@ -111,7 +109,7 @@ def activate_mode(self, mode: TransformMode, apply: bool) -> None:
self._apply_button.click()
self._mode_buttons[mode].click()

def get_active_mode(self) -> Optional[TransformMode]:
def get_active_mode(self) -> TransformMode | None:
for mode, button in self._mode_buttons.items():
if button.isChecked():
return mode
Expand Down
Loading

0 comments on commit 20a1d82

Please sign in to comment.