Skip to content

Commit

Permalink
Merge pull request #38 from wojtryb/development
Browse files Browse the repository at this point in the history
Deploy v1.2.0
  • Loading branch information
wojtryb authored Apr 11, 2023
2 parents d505547 + 7cc4e6a commit f87c3b5
Show file tree
Hide file tree
Showing 130 changed files with 3,722 additions and 2,030 deletions.
33 changes: 0 additions & 33 deletions CHANGELOG.md

This file was deleted.

251 changes: 184 additions & 67 deletions README.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions shortcut_composer/INFO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later

__version__ = "1.2.0"
__author__ = "Wojciech Trybus"
__license__ = "GPL-3.0-or-later"
4 changes: 3 additions & 1 deletion shortcut_composer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2022 Wojciech Trybus <[email protected]>
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later

"""
Expand All @@ -16,6 +16,8 @@

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

sys.path.remove(directory)
4 changes: 0 additions & 4 deletions shortcut_composer/actions.action
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@
<Action name="Configure Shortcut Composer">
<activationFlags>0</activationFlags>
</Action>

<Action name="Reload Shortcut Composer">
<activationFlags>0</activationFlags>
</Action>

<Action name="Transform tool: free">
<activationFlags>1</activationFlags>
Expand Down
65 changes: 48 additions & 17 deletions shortcut_composer/actions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2022 Wojciech Trybus <[email protected]>
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later

"""
Expand All @@ -14,23 +14,19 @@

from PyQt5.QtGui import QColor

from api_krita.enums import BlendingMode, Tool, Toggle, TransformMode
from api_krita.enums import Tool, Toggle, BlendingMode, TransformMode
from core_components import instructions, controllers
from composer_utils import Config
from input_adapter import ComplexAction
from data_components import (
CurrentLayerStack,
PickStrategy,
EnumConfigValues,
TagConfigValues,
Slider,
Range,
Tag,
)
infinity = float("inf")


def create_actions() -> List[ComplexAction]: 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 @@ -95,7 +91,11 @@ def create_actions() -> List[ComplexAction]: return [
name="Cycle selection tools",
controller=controllers.ToolController(),
default_value=Tool.FREEHAND_BRUSH,
values=EnumConfigValues(Config.SELECTION_TOOLS_VALUES, Tool),
values=[
Tool.FREEHAND_SELECTION,
Tool.RECTANGULAR_SELECTION,
Tool.CONTIGUOUS_SELECTION,
],
),

# Control undo and redo actions by sliding the cursor horizontally
Expand Down Expand Up @@ -183,7 +183,13 @@ def create_actions() -> List[ComplexAction]: return [
templates.PieMenu(
name="Pick misc tools",
controller=controllers.ToolController(),
values=EnumConfigValues(Config.MISC_TOOLS_VALUES, Tool),
values=[
Tool.CROP,
Tool.REFERENCE,
Tool.GRADIENT,
Tool.MULTI_BRUSH,
Tool.ASSISTANTS,
],
pie_radius_scale=0.9
),

Expand All @@ -193,22 +199,47 @@ def create_actions() -> List[ComplexAction]: return [
name="Pick painting blending modes",
controller=controllers.BlendingModeController(),
instructions=[instructions.SetBrushOnNonPaintable()],
values=EnumConfigValues(Config.BLENDING_MODES_VALUES, BlendingMode),
values=[
BlendingMode.NORMAL,
BlendingMode.OVERLAY,
BlendingMode.COLOR,
BlendingMode.MULTIPLY,
BlendingMode.ADD,
BlendingMode.SCREEN,
BlendingMode.DARKEN,
BlendingMode.LIGHTEN,
]
),

# Use pie menu to create painting layer with selected blending mode.
templates.PieMenu(
name="Create painting layer with blending mode",
controller=controllers.CreateLayerWithBlendingController(),
values=EnumConfigValues(
Config.CREATE_BLENDING_LAYER_VALUES, BlendingMode),
values=[
BlendingMode.NORMAL,
BlendingMode.ERASE,
BlendingMode.OVERLAY,
BlendingMode.COLOR,
BlendingMode.MULTIPLY,
BlendingMode.ADD,
BlendingMode.SCREEN,
BlendingMode.DARKEN,
BlendingMode.LIGHTEN,
],
),

# Pick one of the transform tool modes.
templates.PieMenu(
name="Pick transform tool modes",
controller=controllers.TransformModeController(),
values=EnumConfigValues(Config.TRANSFORM_MODES_VALUES, TransformMode),
values=[
TransformMode.FREE,
TransformMode.PERSPECTIVE,
TransformMode.WARP,
TransformMode.CAGE,
TransformMode.LIQUIFY,
TransformMode.MESH,
]
),

# Use pie menu to pick one of presets from tag specified in settings.
Expand All @@ -217,7 +248,7 @@ def create_actions() -> List[ComplexAction]: return [
name="Pick brush presets (red)",
controller=controllers.PresetController(),
instructions=[instructions.SetBrushOnNonPaintable()],
values=TagConfigValues(Config.TAG_RED, Config.TAG_RED_VALUES),
values=Tag("★ My Favorites"),
background_color=QColor(95, 65, 65, 190),
active_color=QColor(200, 70, 70),
),
Expand All @@ -228,7 +259,7 @@ def create_actions() -> List[ComplexAction]: return [
name="Pick brush presets (green)",
controller=controllers.PresetController(),
instructions=[instructions.SetBrushOnNonPaintable()],
values=TagConfigValues(Config.TAG_GREEN, Config.TAG_GREEN_VALUES),
values=Tag("RGBA"),
background_color=QColor(65, 95, 65, 190),
active_color=QColor(70, 200, 70),
),
Expand All @@ -239,7 +270,7 @@ def create_actions() -> List[ComplexAction]: return [
name="Pick brush presets (blue)",
controller=controllers.PresetController(),
instructions=[instructions.SetBrushOnNonPaintable()],
values=TagConfigValues(Config.TAG_BLUE, Config.TAG_BLUE_VALUES),
values=Tag("Erasers"),
background_color=QColor(70, 70, 105, 190),
active_color=QColor(110, 160, 235),
),
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 Wojciech Trybus <[email protected]>
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later

"""
Expand Down
2 changes: 1 addition & 1 deletion shortcut_composer/api_krita/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2022 Wojciech Trybus <[email protected]>
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later

from .transform_actions import TransformModeActions, TransformModeFinder
Expand Down
3 changes: 2 additions & 1 deletion shortcut_composer/api_krita/actions/transform_actions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2022 Wojciech Trybus <[email protected]>
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later

from typing import Dict, Optional
Expand All @@ -14,6 +14,7 @@

from ..enums import Tool, TransformMode
from ..core_api import KritaInstance

Krita = KritaInstance()


Expand Down
38 changes: 28 additions & 10 deletions shortcut_composer/api_krita/core_api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# SPDX-FileCopyrightText: © 2022 Wojciech Trybus <[email protected]>
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later

from krita import Krita as Api, Extension, qApp
from typing import Callable, Protocol, Any
from typing import Callable, Protocol, Any, Optional

from PyQt5.QtWidgets import QMainWindow, QDesktopWidget, QWidgetAction
from PyQt5.QtWidgets import (
QMainWindow,
QDesktopWidget,
QWidgetAction,
QMdiArea)
from PyQt5.QtGui import QKeySequence, QColor, QIcon
from PyQt5.QtCore import QTimer

Expand Down Expand Up @@ -61,15 +65,30 @@ def get_active_qwindow(self) -> QMainWindow:
"""Return qt window of krita. Don't use on plugin init phase."""
return self.instance.activeWindow().qwindow()

def get_active_mdi_area(self) -> QMdiArea:
return self.get_active_qwindow().findChild(QMdiArea) # type: ignore

def get_icon(self, icon_name: str) -> QIcon:
return self.instance.icon(icon_name)

def read_setting(self, group: str, name: str, default: str) -> str:
"""Read setting from .kritarc file as string."""
return self.instance.readSetting(group, name, default)
def read_setting(
self,
group: str,
name: str,
default: str = "Not stored"
) -> Optional[str]:
"""
Read a setting from kritarc file.
- Return string red from file if present
- Return default if it was given
- Return None if default was not given
"""
red_value = self.instance.readSetting(group, name, default)
return None if red_value == "Not stored" else red_value

def write_setting(self, group: str, name: str, value: Any) -> None:
"""Write setting to .kritarc file. Value type will be lost."""
"""Write setting to kritarc file. Value type will be lost."""
self.instance.writeSetting(group, name, str(value))

def create_action(
Expand All @@ -78,7 +97,7 @@ def create_action(
name: str,
group: str = "",
callback: Callable[[], None] = lambda: None
):
) -> QWidgetAction:
"""
Create a new action in krita.
Expand Down Expand Up @@ -111,8 +130,7 @@ def connect_callback():
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()
average = (main_color.red()+main_color.green()+main_color.blue()) // 3
return average > 128
return main_color.value() > 128


class KritaWindow(Protocol):
Expand Down
2 changes: 1 addition & 1 deletion shortcut_composer/api_krita/enums/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2022 Wojciech Trybus <[email protected]>
# SPDX-FileCopyrightText: © 2022-2023 Wojciech Trybus <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later

"""Enumerated values used in krita api wrappers."""
Expand Down
Loading

0 comments on commit f87c3b5

Please sign in to comment.