Open in KolourPaint or another associated application #50
Manually merged
deloptes
merged 1 commits from feat/open_in_kolourpaint
into master
1 year ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'feat/open_in_kolourpaint'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Signed-off-by: Emanoil Kotsev deloptes@gmail.com
Open in KolourPaintto WIP: Open in KolourPaint 1 year agoThis is a handy function if one wants to highlight or edit a screenshot before doing something else with it.
However, I need a bit of help to finalize this PR.
How can I pass the content of the buffer from ksnapshot to kolourpaint automatically?
ATM, I can CTRL+V after kolourpaint opens.
Also an idea around 383 - check or not check if kolourpaint is running
You could use a KTempFile to store buffer data and pass that to KolourPaint.
It would be nice to offer other options along Kolourpaint, such as GIMP. Also, hardcoding paths is bad. Better use something like TDETrader
Thank you for the ideas.
I remember a saying - you give it the finger, it bites the hand.
What is TDETrader?
TDETrader is part of TDEIO. In short, it allows you to dynamically query which applications support a given file type. If you want I can help you implement it. I'll test the PR shortly.
PS: Another reason we need TDETrader or something similar is so as to not hardcode paths. A user might have kolourpaint installed in a different prefix, such as
/opt/tde
,/usr
or whatever (I know for sure Ray-V's SlackBuild scripts offer these prefixes as options for installing TDE).Could you please explain why we need this? Launching a new instance would be better in any case IMO since this is what the user expects.
I just pushed a commit that solves this problem by using a temporary file. When KolourPaint opens, it has loaded this file (seamlessly to the user) and allows editing. When the user saves the changes and closes the editor, the snapshot within KSnapshot gets updated, allowing the user to save/copy/print/drag the screenshot as usual.
84fffa2d70
to3fc5fd6d26
1 year agoImplemented KService/TDETrader functionality. Now we can be sure that KolourPaint is installed and provide options to open the snapshot in other applications associated with the according mimetype.
@deloptes I'm waiting for your feedback. I hope that my work was helpful.
yes I also think so
Thank you, it looks very good.
Now the "Open in KolourPaint" button is obsolete.
PS: I am sorry for answering that late - perhaps you had other expectations, but it is Sunday - a family day (and if it is not Sunday - it is work day).
I intentionally left the KolourPaint button as a quick shortcut when you need simple editing. IMO it is nice to have. And late reply is totally OK. Actually I was originally going to apologize for just giving bare pointers and not some working code.
}
void KSnapshot::slotOpenWithKP() {
KService::Ptr kpaint = KService::serviceByDesktopName("kolourpaint");
Isn't it better to use #define KOLOURPAINT "kolourpaint"?
Someone was teaching me it is the preferred way.
I think it would make sense in case we had a long string literal reused many times in the codebase and wanted a shorthand form for it, or if we defined it via CMake just before build time. I think that in this case it would be redundant, but I'm no C(++) guru.
Instead, we could use a #define for storing the default image output format (PNG) so that we could make it easier to change in case a change was .
I assume that if we were changing from
kolourpaint
to some other program, there would be other changes in the code – for example, the name of thekpaint
variable. So it doesn't look too useful to use#define
for this case.But there is definitely an interesting note about the use of
#define
for the default image format. However, this is probably suitable for a separate change, not as part of this PR.Hi Philippe,
thank you for the great work!
I am not the finest developer and there is too much about TDE I do not know.
My original use case was to be able to highlight some part of screenshot like this
And with your help it looks perfect. See my comment.
Also it is great that it cleans up the tmp file after closing.
So I would say, I remove the WIP and it can go.
WIP: Open in KolourPaintto Open in KolourPaint 1 year agoI just answered your comment. Once we resolve that little question you can freely merge this (of course, you might want to squash the commits into one first). Thank you for the initial work. It will be a great addition to KSnapshot!
Thank you Philippe,
I am satisfied with the result and the comment by Slavek is also fine.
I will squash and push and leave it for merging.
BR
3fc5fd6d26
to418437b36d
1 year agoIt looks good. One small note: the git log message of your opening commit could also contain the prefix
KSnaphot:
.418437b36d
todb379a2f50
1 year agoGit log message updated, removed
#include <tqbuffer.h>
that is no longer needed. So we are ready to merge.All looks good.
db379a2f50
into master manually 1 year agoNeeds some fixes for potential SEGV. I will post steps to reproduce it in the Conversation section soon after.
}
}
static KTempFile *tmpFile = nullptr;
The user may capture multiple screenshots and open them in separate applications. Having a single tmpFile will lead to either SEGV (with the current code) or memory leak (if we protect against dereferencing nullptr).
We need a solution that keeps track of how many applications have been opened and which one is being closed. I will prepare a commit later or tomorrow, I have already an idea in mind.
}
void KSnapshot::slotExternalAppClosed() {
snapshot.load(tmpFile->name());
We should test for tmpFile being not a nullptr or it will lead to a SEGV. See comments that I will post soon on the Conversation page.
First of all, well done everyone for this. It is a very good improvement and something that was indeed missing by today's standard.
The current code can easily lead to SEGV. Steps to reproduce it:
I will create a fix and upload (either tonight or tomorrow)
Open in KolourPaintto Open in KolourPaint or another associated application 1 year agoThere is also another issue. Take a snapshot, open the file in KolourPaint and close KSnapshot. The temporary file is not getting deleted.
Please test PR #52, which proposes a solution for the issues raised above.
Reviewers
db379a2f50
.