[krita] [Bug 423341] Add menu manipulation to Python API

2020-07-17 Thread Scott Petrovic
https://bugs.kde.org/show_bug.cgi?id=423341

Scott Petrovic  changed:

   What|Removed |Added

 Resolution|WAITINGFORINFO  |NOT A BUG
 Status|NEEDSINFO   |RESOLVED

--- Comment #7 from Scott Petrovic  ---
Alright. I am going to mark this as closed since this ticket was about
manipulating the menu. Outside of this ticket I can look into the Extensions
API and what is going on with that. I don't know exactly how that setup() call
is working, so there might not be something wrong with it -- or it just isn't
clear what it is actually doing.

Adding a signal when the window is created might be a solution that is more
general. I can look into adding that.

-- 
You are receiving this mail because:
You are watching all bug changes.

[krita] [Bug 423341] Add menu manipulation to Python API

2020-07-17 Thread Adric Worley
https://bugs.kde.org/show_bug.cgi?id=423341

--- Comment #6 from Adric Worley  ---
I think it should get me far enough along to hack together what I need. I did
notice that there are no windows available when `setup` or `addActions` are
called in the Extension lifecycle, so I'll likely need to set up a timer to
re-check until a window is available before adding the menu(s).

-- 
You are receiving this mail because:
You are watching all bug changes.

[krita] [Bug 423341] Add menu manipulation to Python API

2020-07-15 Thread Scott Petrovic
https://bugs.kde.org/show_bug.cgi?id=423341

Scott Petrovic  changed:

   What|Removed |Added

 Status|REPORTED|NEEDSINFO
 Resolution|--- |WAITINGFORINFO

--- Comment #5 from Scott Petrovic  ---
Is this still an issue, or did that last code snippet help to do whatever you
were trying to do?

-- 
You are receiving this mail because:
You are watching all bug changes.

[krita] [Bug 423341] Add menu manipulation to Python API

2020-06-23 Thread Boudewijn Rempt
https://bugs.kde.org/show_bug.cgi?id=423341

--- Comment #4 from Boudewijn Rempt  ---
Weird... I tried something like that yesterday, and it didn't work for me.
Maybe because I first created the menu, then the action.

-- 
You are receiving this mail because:
You are watching all bug changes.

[krita] [Bug 423341] Add menu manipulation to Python API

2020-06-22 Thread Scott Petrovic
https://bugs.kde.org/show_bug.cgi?id=423341

Scott Petrovic  changed:

   What|Removed |Added

 CC||scottpetro...@gmail.com

--- Comment #3 from Scott Petrovic  ---
I am not sure if this helps, but adding actions to menus to do something. This
seems to work for something very simple.

from PyQt5.QtWidgets import (QWidget, QAction)
import krita

# connection methods
def close_application():
print("whoo so custom!!!")

#create an action that does stuff
extractAction = QAction(" TO THE CHOPPAH!!!")
extractAction.setShortcut("Ctrl+Q")
extractAction.setStatusTip('Leave The App')
extractAction.triggered.connect(close_application)


# Create menu off main menu and add a new action to it
main_menu = Krita.instance().activeWindow().qwindow().menuBar()
custom_menu = main_menu.addMenu("Special Actions Menu")
custom_menu.addAction(extractAction) # how to get items/actions in a menu


You are right thought that each new window in Krita is isolated...so the menu
isn't on new windows. If you look in the pykrita folder at some of the
pre-installed Python scripts, they have a "canvasChanged" method that signals
when the document changes. You might be able to do something with that. 

I made a little docker plugin that handles these document changed events if
that helps at all for reference...
https://invent.kde.org/scottpetrovic/krita-scratchpad-docker/-/blob/master/scratchpad/scratchpad.py#L201

-- 
You are receiving this mail because:
You are watching all bug changes.

[krita] [Bug 423341] Add menu manipulation to Python API

2020-06-22 Thread Adric Worley
https://bugs.kde.org/show_bug.cgi?id=423341

--- Comment #2 from Adric Worley  ---
Is there an example of how to do that? I found some xmlgui files in the source,
but it's not clear to me where/how they get loaded and used so I haven't been
able to test whether it works the way you described.

Overall, though, kxmlgui route doesn't sound promising, especially depending on
how much control Extensions have over load/init order. Our pipeline framework
dynamically populates its available actions based on contextual data baked into
the application environment on run, so our extension would need to (re)write
the xmlgui at load time before installing it, if that's even feasible.

-- 
You are receiving this mail because:
You are watching all bug changes.

[krita] [Bug 423341] Add menu manipulation to Python API

2020-06-22 Thread Boudewijn Rempt
https://bugs.kde.org/show_bug.cgi?id=423341

Boudewijn Rempt  changed:

   What|Removed |Added

   Severity|normal  |wishlist
 CC||b...@valdyas.org

--- Comment #1 from Boudewijn Rempt  ---
The way the menus are defined in Krita is pretty old (dating back to the late
nineties old): it uses .kxmlgui files to define the structure of menus and
toolbars. Theoretically, a plugin could install its own kxmlgui file and that
should get merged, but I'm not sure that still works...

-- 
You are receiving this mail because:
You are watching all bug changes.