-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from wojtryb/development
Deploy v1.2.0
- Loading branch information
Showing
130 changed files
with
3,722 additions
and
2,030 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
""" | ||
|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
""" | ||
|
@@ -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", | ||
|
@@ -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 | ||
|
@@ -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 | ||
), | ||
|
||
|
@@ -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. | ||
|
@@ -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), | ||
), | ||
|
@@ -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), | ||
), | ||
|
@@ -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), | ||
), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -14,6 +14,7 @@ | |
|
||
from ..enums import Tool, TransformMode | ||
from ..core_api import KritaInstance | ||
|
||
Krita = KritaInstance() | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
@@ -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( | ||
|
@@ -78,7 +97,7 @@ def create_action( | |
name: str, | ||
group: str = "", | ||
callback: Callable[[], None] = lambda: None | ||
): | ||
) -> QWidgetAction: | ||
""" | ||
Create a new action in krita. | ||
|
@@ -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): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.""" | ||
|
Oops, something went wrong.