Skip to content

Commit

Permalink
Merge pull request #60 from wojtryb/development
Browse files Browse the repository at this point in the history
Deploy 1.4.0
  • Loading branch information
wojtryb authored Aug 6, 2023
2 parents 1649f05 + 0c047d7 commit 9695bed
Show file tree
Hide file tree
Showing 88 changed files with 2,536 additions and 975 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Shortcut composer **v1.3.2**
# Shortcut composer **v1.4.0**

[![python](https://img.shields.io/badge/Python-3.8-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/)
Expand Down Expand Up @@ -28,16 +28,19 @@ The plugin adds new shortcuts of the following types:
- [Join community discussion 👥](https://krita-artists.org/t/shortcut-composer-v1-2-2-plugin-for-pie-menus-multiple-key-assignment-mouse-trackers-and-more/55314)
- [Report a bug 🦗](https://github.com/wojtryb/Shortcut-Composer/issues)
- [Request a new feature 💡](https://github.com/wojtryb/Shortcut-Composer/discussions)
- [What's new in latest version? ⭐](https://github.com/wojtryb/Shortcut-Composer/releases)

## What's new in the latest release?

Watch the video below, or read the [changelog](https://github.com/wojtryb/Shortcut-Composer/releases).
## Changelog videos

[![PIE MENUS - introducing Shortcut Composer](https://user-images.githubusercontent.com/51094047/244950488-83bd44ff-87f6-4b95-82c7-0f5031bb1b8e.png)](https://www.youtube.com/watch?v=eHK5LBMNiU0 "Managing BRUSHES with Shortcut Composer 1.3")

[![PIE MENUS - introducing Shortcut Composer](https://github-production-user-asset-6210df.s3.amazonaws.com/51094047/238015603-3143fc2d-0fa7-4da1-868d-2ec054ccaeb3.png)](https://www.youtube.com/watch?v=Tkf2-U0OyG4 "PIE MENUS - introducing Shortcut Composer")

[![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.1.5**
- Required version of krita: **5.1.0**
- Required version of krita: **5.1.0** or later

OS support state:
- [x] Windows (10, 11)
Expand Down
2 changes: 1 addition & 1 deletion shortcut_composer/INFO.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later

__version__ = "1.3.2"
__version__ = "1.4.0"
__author__ = "Wojciech Trybus"
__license__ = "GPL-3.0-or-later"
6 changes: 2 additions & 4 deletions shortcut_composer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

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

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

sys.path.remove(directory)
15 changes: 15 additions & 0 deletions shortcut_composer/actions.action
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@
<icon>krita_tool_grid</icon>
</Action>

<Action name="Activate krita action (red)">
<activationFlags>1</activationFlags>
<icon>palette-edit</icon>
</Action>

<Action name="Activate krita action (green)">
<activationFlags>1</activationFlags>
<icon>palette-edit</icon>
</Action>

<Action name="Activate krita action (blue)">
<activationFlags>1</activationFlags>
<icon>palette-edit</icon>
</Action>

<Action name="Pick painting blending modes">
<activationFlags>1</activationFlags>
<icon>format-text-bold</icon>
Expand Down
74 changes: 65 additions & 9 deletions shortcut_composer/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

from PyQt5.QtGui import QColor

from api_krita.enums import Tool, Toggle, BlendingMode, TransformMode
from api_krita.enums import Action, Tool, Toggle, BlendingMode, TransformMode
from core_components import instructions, controllers
from data_components import (
CurrentLayerStack,
DeadzoneStrategy,
PickStrategy,
Slider,
Range,
Expand Down Expand Up @@ -124,7 +125,7 @@ def create_actions() -> List[templates.RawInstructions]: return [

# Scroll timeline by sliding the cursor horizontally or
# animated layers by sliding it vertically

#
# Use TemporaryOn instruction to temporarily isolate active layer
templates.CursorTracker(
name="Scroll timeline or animated layers",
Expand All @@ -141,7 +142,7 @@ def create_actions() -> List[templates.RawInstructions]: return [

# Scroll brush sizes by sliding the cursor horizontally or
# brush opacity layers by sliding it vertically

#
# Opacity is contiguous from 10% to 100%, sizes come from a list
# Switch 1% of opacity every 5 px (instead of default 50 px)
templates.CursorTracker(
Expand Down Expand Up @@ -179,7 +180,7 @@ def create_actions() -> List[templates.RawInstructions]: return [
),
),

# Use pie menu to pick one of the sporadically used tools.
# Use pie menu to pick one of the tools.
templates.PieMenu(
name="Pick misc tools",
controller=controllers.ToolController(),
Expand All @@ -190,7 +191,53 @@ def create_actions() -> List[templates.RawInstructions]: return [
Tool.MULTI_BRUSH,
Tool.ASSISTANTS,
],
pie_radius_scale=0.9
pie_radius_scale=0.9,
),


# Use pie menu to pick one of the actions
templates.PieMenu(
name="Activate krita action (red)",
controller=controllers.ActionController(),
values=[
Action.HORIZONTAL_MIRROR_TOOL,
Action.WRAP_AROUND_MODE,
Action.ERASER,
Action.PRESERVE_ALPHA,
Action.MIRROR_CANVAS,
],
background_color=QColor(95, 65, 65, 190),
active_color=QColor(200, 70, 70),
),

# Use pie menu to pick one of the actions
templates.PieMenu(
name="Activate krita action (green)",
controller=controllers.ActionController(),
values=[
Action.CREATE_BLANK_FRAME,
Action.CREATE_DUPLICATE_FRAME,
Action.REMOVE_KEYFRAME,
Action.VIEW_ONION_SKIN,
Action.RECORD_TIMELAPSE,
],
background_color=QColor(65, 95, 65, 190),
active_color=QColor(70, 200, 70),
),

# Use pie menu to pick one of the actions
templates.PieMenu(
name="Activate krita action (blue)",
controller=controllers.ActionController(),
values=[
Action.ADD_PAINT_LAYER,
Action.TOGGLE_LAYER_VISIBILITY,
Action.TOGGLE_LAYER_ALPHA_INHERITANCE,
Action.TOGGLE_LAYER_ALPHA,
Action.TOGGLE_LAYER_LOCK,
],
background_color=QColor(70, 70, 105, 190),
active_color=QColor(110, 160, 235),
),

# Use pie menu to pick one of the brush blending modes.
Expand All @@ -199,6 +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,
values=[
BlendingMode.NORMAL,
BlendingMode.OVERLAY,
Expand All @@ -208,7 +256,7 @@ def create_actions() -> List[templates.RawInstructions]: return [
BlendingMode.SCREEN,
BlendingMode.DARKEN,
BlendingMode.LIGHTEN,
]
],
),

# Use pie menu to create painting layer with selected blending mode.
Expand All @@ -232,6 +280,7 @@ def create_actions() -> List[templates.RawInstructions]: return [
templates.PieMenu(
name="Pick transform tool modes",
controller=controllers.TransformModeController(),
deadzone_strategy=DeadzoneStrategy.PICK_TOP,
values=[
TransformMode.FREE,
TransformMode.PERSPECTIVE,
Expand All @@ -242,43 +291,50 @@ def create_actions() -> List[templates.RawInstructions]: return [
]
),

# Use pie menu to pick one of presets from tag specified in settings.
# Use pie menu to pick one of stored presets.
# Set tool to FREEHAND BRUSH if current tool does not allow to paint
templates.PieMenu(
name="Pick brush presets (red)",
controller=controllers.PresetController(),
instructions=[instructions.SetBrushOnNonPaintable()],
deadzone_strategy=DeadzoneStrategy.PICK_PREVIOUS,
values=Tag("★ My Favorites"),
background_color=QColor(95, 65, 65, 190),
active_color=QColor(200, 70, 70),
),

# Use pie menu to pick one of presets from tag specified in settings.
# Use pie menu to pick one of stored presets.
# Set tool to FREEHAND BRUSH if current tool does not allow to paint
templates.PieMenu(
name="Pick brush presets (green)",
controller=controllers.PresetController(),
instructions=[instructions.SetBrushOnNonPaintable()],
deadzone_strategy=DeadzoneStrategy.PICK_PREVIOUS,
values=Tag("RGBA"),
background_color=QColor(65, 95, 65, 190),
active_color=QColor(70, 200, 70),
),

# Use pie menu to pick one of presets from tag specified in settings.
# Use pie menu to pick one of stored presets.
# Set tool to FREEHAND BRUSH if current tool does not allow to paint
templates.PieMenu(
name="Pick brush presets (blue)",
controller=controllers.PresetController(),
instructions=[instructions.SetBrushOnNonPaintable()],
deadzone_strategy=DeadzoneStrategy.PICK_PREVIOUS,
values=Tag("Erasers"),
background_color=QColor(70, 70, 105, 190),
active_color=QColor(110, 160, 235),
),

# Use pie menu to pick one of stored presets.
# By default, preset names are stored in .kra document.
# Set tool to FREEHAND BRUSH if current tool does not allow to paint
templates.PieMenu(
name="Pick local brush presets",
controller=controllers.PresetController(),
instructions=[instructions.SetBrushOnNonPaintable()],
deadzone_strategy=DeadzoneStrategy.PICK_PREVIOUS,
values=[],
save_local=True,
active_color=QColor(234, 172, 0),
Expand Down
7 changes: 3 additions & 4 deletions shortcut_composer/api_krita/actions/transform_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ def _create_actions(self, window) -> None:
TransformMode.WARP: self.set_warp,
TransformMode.CAGE: self.set_cage,
TransformMode.LIQUIFY: self.set_liquify,
TransformMode.MESH: self.set_mesh,
}
TransformMode.MESH: self.set_mesh}

for action, implementation in _ACTION_MAP.items():
self._actions[action] = Krita.create_action(
window=window,
name=action.value,
callback=implementation
)
callback=implementation)

def _set_mode(self, mode: TransformMode) -> None:
"""Set a passed mode. Implementation of the new krita tool."""
Expand All @@ -59,6 +57,7 @@ def _set_mode(self, mode: TransformMode) -> None:
self._delayed_click(mode)

def _delayed_click(self, mode: TransformMode) -> None:
"""Trigger an mode after short period of time to workaround a bug."""
method = partial(self._finder.activate_mode, mode=mode, apply=False)
QTimer.singleShot(40, method)

Expand Down
12 changes: 10 additions & 2 deletions shortcut_composer/api_krita/core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
QDesktopWidget,
QWidgetAction,
QMdiArea)
from PyQt5.QtGui import QKeySequence, QColor, QIcon
from PyQt5.QtGui import QKeySequence, QColor, QIcon, QPalette
from PyQt5.QtCore import QTimer

from .wrappers import (
Expand Down Expand Up @@ -129,10 +129,18 @@ def connect_callback():
self.main_window.themeChanged.connect(callback)
QTimer.singleShot(1000, connect_callback)

def get_main_color_from_theme(self) -> QColor:
"""Return main color of the current theme."""
return qApp.palette().color(QPalette.Window)

def get_active_color_from_theme(self) -> QColor:
"""Return active color of the current theme."""
return qApp.palette().color(QPalette.Highlight)

@property
def is_light_theme_active(self) -> bool:
"""Return if currently set theme is light using it's main color."""
main_color: QColor = qApp.palette().window().color()
main_color = self.get_main_color_from_theme()
return main_color.value() > 128


Expand Down
10 changes: 9 additions & 1 deletion shortcut_composer/api_krita/enums/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
from .transform_mode import TransformMode
from .blending_mode import BlendingMode
from .node_types import NodeType
from .action import Action
from .toggle import Toggle
from .tool import Tool

__all__ = ["TransformMode", "BlendingMode", "NodeType", "Toggle", "Tool"]
__all__ = [
"TransformMode",
"BlendingMode",
"NodeType",
"Action",
"Toggle",
"Tool"
]
Loading

0 comments on commit 9695bed

Please sign in to comment.