Beispiel #1
0
def registerDocker():
    docker = DockWidgetFactory("pykrita_gdquest_art_tools",
                               DockWidgetFactoryBase.DockRight, GameArtTools)
    KI.addDockWidgetFactory(docker)
Beispiel #2
0
    def removeForegroundAndBackground(self):
        self.foregroundImage = QImage()
        self.backgroundImage = QImage()
        self.refresh()

        writeTag("custom-preview-fg", "")
        writeTag("custom-preview-bg", "")

        print("Custom Preview: Foreground and background reset")


def writeTag(key, value):
    docInfo = KI.activeDocument().documentInfo()

    if key in docInfo:
        newDocInfo = re.sub(r"(?<=" + key + r"=)[^,]*", value, docInfo)
    else:
        pattern = "<abstract><![CDATA["
        index = docInfo.find(pattern) + len(pattern)
        newDocInfo = docInfo[:index] + key + "=" + value + "," + docInfo[index:]

    KI.activeDocument().setDocumentInfo(newDocInfo)

    print("Custom Preview: Modified '" + key + "'tag. New documentInfo:")
    print(KI.activeDocument().documentInfo())


KI.addDockWidgetFactory(
    DockWidgetFactory("customPreview", DockWidgetFactoryBase.DockRight,
                      CustomPreview))
Beispiel #3
0
from krita import DockWidgetFactory, DockWidgetFactoryBase
from .quick_settings_docker import QuickSettingsDocker


Application.addDockWidgetFactory(
    DockWidgetFactory("quick_settings_docker",
                      DockWidgetFactoryBase.DockRight,
                      QuickSettingsDocker))
Beispiel #4
0
    def clearOutput(self):
        self.outputlines = []
        self.outputlinescnt = []
        self.lbl.setText("")

    def output(self, text):
        if len(self.outputlines) > 0 and self.outputlines[0] == text:
            self.outputlinescnt[0] += 1
        else:
            self.outputlines.insert(0, text)
            self.outputlinescnt.insert(0, 1)

        lt = ""
        idx = 0
        for l in self.outputlines:
            if self.outputlinescnt[idx] > 1:
                lt += l + ' (' + str(self.outputlinescnt[idx]) + ')\n'
            else:
                lt += l + '\n'
            idx += 1
        self.lbl.setText(lt)

    def canvasChanged(self, canvas):
        pass


Application.addDockWidgetFactory(
    DockWidgetFactory("animlayers", DockWidgetFactoryBase.DockRight,
                      AnimLayersDocker))
Beispiel #5
0
        editingText = ""
        outChars = list(beforeText)
        y = 0
        x = (width - 1) * 1.2
        for part in outChars:
            if part == "\n":
                y = 0
                x -= 1.2
            else:
                editedTextX = DefineLocate.getEditedX(
                    part, self.fontSizeCombo.currentText())
                editedTextY = DefineLocate.getEditedY(
                    part, self.fontSizeCombo.currentText())
                resultX = x + editedTextX
                resultY = y + editedTextY
                editingText = editingText + "  <tspan x=\"" + \
                    str(resultX) + "em\" y=\"" + str(resultY) + "em\">" + \
                    html.escape(part) + "</tspan>\n"
                y += 1.2
        outText = "<text style=\"font-family:" + \
            self.fontSelector.currentText() + \
            ";font-size:"+self.fontSizeCombo.currentText() + \
            ";fill:" + self.fontColorCombo.currentText() + "\">\n" + \
            editingText + "</text>"
        return outText


Krita.instance().addDockWidgetFactory(
    DockWidgetFactory("Text to SVG", DockWidgetFactoryBase.DockRight,
                      WritingModeRLDocker))
Beispiel #6
0
class HelloDocker(DockWidget):
    """
    The HelloDocker is an example of a simple Python-based docker.
    """
    def __init__(self):
        """
        Constructs an instance of HelloDocker and the widget it contains
        """
        super(HelloDocker, self).__init__()

        # The window title is also used in the Docker menu,
        # so it should be set to something sensible!
        self.setWindowTitle("HelloDocker")
        label = QLabel("Hello", self)
        self.setWidget(label)
        self._label = label

    def canvasChanged(self, canvas):
        """
        Override canvasChanged from :class:`DockWidget`.
        This gets called when the canvas changes.
        You can also access the active canvas via :func:`DockWidget.canvas`
        Parameter `canvas` can be null if the last document is closed
        """
        self._label.setText("HelloDocker: canvas changed")


# Register the docker so Krita can use it!
Application.addDockWidgetFactory(
    DockWidgetFactory("hello", DockWidgetFactoryBase.DockRight, HelloDocker))
Beispiel #7
0
class HelloDocker(DockWidget):
    """
    The HelloDocker is an example of a simple Python-based docker.
    """

    def __init__(self):
        """
        Constructs an instance of HelloDocker and the widget it contains
        """
        super().__init__()

        # The window title is also used in the Docker menu,
        # so it should be set to something sensible!
        self.setWindowTitle("HelloDocker")
        label = QLabel("Hello", self)
        self.setWidget(label)
        self._label = label

    def canvasChanged(self, canvas):
        """
        Override canvasChanged from :class:`DockWidget`.
        This gets called when the canvas changes.
        You can also access the active canvas via :func:`DockWidget.canvas`
        Parameter `canvas` can be null if the last document is closed
        """
        self._label.setText("HelloDocker: canvas changed")


# Register the docker so Krita can use it!
Application.addDockWidgetFactory(DockWidgetFactory("hello", DockWidgetFactoryBase.DockRight, HelloDocker))
Beispiel #8
0
#
#  SPDX-License-Identifier: GPL-3.0-or-later
#

from krita import Krita, DockWidgetFactory
from .selectionsbagdocker import SelectionsBagDocker

Krita.instance().addDockWidgetFactory(
    DockWidgetFactory("SelectionsBagDocker", DockWidgetFactory.DockRight,
                      SelectionsBagDocker))
Beispiel #9
0
from krita import DockWidgetFactory, DockWidgetFactoryBase

from .docker_template1 import layerMeimei

DOCKER_ID = 'template_docker1'
instance = Krita.instance()
dock_widget_factory = DockWidgetFactory(DOCKER_ID,
                                        DockWidgetFactoryBase.DockRight,
                                        layerMeimei)

instance.addDockWidgetFactory(dock_widget_factory)
Beispiel #10
0
from krita import DockWidgetFactory, DockWidgetFactoryBase
from .palette_docker import PaletteDocker

Application.addDockWidgetFactory(
    DockWidgetFactory("palette_docker", DockWidgetFactoryBase.DockRight,
                      PaletteDocker))
Beispiel #11
0
            nodes = self.undo_tree[self.iteration]["nodes"]
            from_color = self.undo_tree[self.iteration]["from_color"]
            to_color = self.undo_tree[self.iteration]["to_color"]
            for node in nodes:
                replace_color_in_node(node, to_color, from_color)
            instance.activeDocument().refreshProjection()

    @pyqtSlot()
    def on_click(self):
        color = QColorDialog.getColor()
        if color.isValid():
            from_color = get_foreground_color()
            to_color = q_color_to_q_byte_array(color)
            active_view = instance.activeWindow().activeView()
            self.undo_tree[self.iteration] = {
                "from_color": from_color,
                "to_color": to_color,
                "nodes": get_nodes()
            }
            self.iteration = self.iteration + 1
            for node in get_nodes():
                replace_color_in_node(node, from_color, to_color)
            instance.activeDocument().refreshProjection()


dock_widget_factory = DockWidgetFactory(DOCKER_ID,
                                        DockWidgetFactoryBase.DockRight,
                                        Fill_discontiguous)

instance.addDockWidgetFactory(dock_widget_factory)
def registerDocker():
    docker = DockWidgetFactory(
        "pykrita_bulk_actions", DockWidgetFactoryBase.DockRight, BulkActionsDockWidget
    )
    KI.addDockWidgetFactory(docker)
Beispiel #13
0
from krita import DockWidgetFactory, DockWidgetFactoryBase
from .bulinotes import *

instance = Krita.instance()
bnDocker = DockWidgetFactory(f'{EXTENSION_ID}_current',
                             DockWidgetFactoryBase.DockRight, BuliNotesDocker)
instance.addDockWidgetFactory(bnDocker)
        ])

        main_program.writeSetting("", "MixerSliderColors", setting)

    def color_to_settings(self, managedcolor):
        return ','.join([
            managedcolor.colorModel(),
            managedcolor.colorDepth(),
            managedcolor.colorProfile()
        ] + [str(c) for c in managedcolor.components()])

    def parse_color(self, array):
        color = ManagedColor(array[0], array[1], array[2])
        color.setComponents([float(x) for x in array[3:]])
        return color

    def canvasChanged(self, canvas):
        pass

    def qcolor_to_managedcolor(self, qcolor):
        mc = ManagedColor.fromQColor(qcolor, self.canvas())
        return mc

    def managedcolor_to_qcolor(self, managedcolor):
        return managedcolor.colorForCanvas(self.canvas())


Application.addDockWidgetFactory(
    DockWidgetFactory("mixer_slider_docker", DockWidgetFactoryBase.DockRight,
                      MixerSliderDocker))
Beispiel #15
0
        mainWidget.layout().addWidget(resetCanvasContainer)


        resetZoomButton = self.create_button("100%", mainWidget, self.reset_zoom)
        resetCanvasContainer.layout().addWidget(resetZoomButton)
        resetCanvasRotationButton = self.create_button("Reset", mainWidget, self.reset_canvas_rotation)
        resetCanvasContainer.layout().addWidget(resetCanvasRotationButton)


        canvasContainer = QWidget(self)
        canvasContainer.setLayout(QHBoxLayout())
        mainWidget.layout().addWidget(canvasContainer)
        mirrorCanvasButton = self.create_button("Mirror", canvasContainer, self.mirror_canvas)
        canvasContainer.layout().addWidget(mirrorCanvasButton)
        onlyCanvasButton = self.create_button("Only", canvasContainer, self.only_canvas)
        canvasContainer.layout().addWidget(onlyCanvasButton)




    def canvasChanged(self, canvas):
        pass


instance = Krita.instance()
dock_widget_factory = DockWidgetFactory(DOCKER_ID,
                                                DockWidgetFactoryBase.DockLeft,
                                                HenriksOnscreenKritaShortcutButtons)

instance.addDockWidgetFactory(dock_widget_factory)
from krita import DockWidgetFactory, DockWidgetFactoryBase
from .rogudators_comic_panel_generator import RCPGWindow

DOCKER_ID = 'rogudators_comic_panel_generator'
instance = Krita.instance()
dock_widget_factory = DockWidgetFactory(DOCKER_ID,
                                        DockWidgetFactoryBase.DockRight,
                                        RCPGWindow)

instance.addDockWidgetFactory(dock_widget_factory)