KDE 4 Drop Icon
← KDE4 Integration | ● | KDE4 Examples →
Dragging files onto a widget is platform independent.
Dragging a file onto a desktop icon is platform dependent. We exercise it for KDE4.
First we place the DropPNG application into a panel, since only panel apps can be dropped onto.
When dropping a file from the File Manager view onto a panel icon, the dropped files are passed to the opening program as standard command line arguments. So they end up to be parameters to int main(int argc, char *argv[]).
For that to work the Exec line of the .desktop file needs to contain
- %f as a place holder for an file name
- %F for a list of file names
- %u as a place holder for an url
- %U for a list of urls
To process one argument in the background thread, we add a process method
{
if (file.startsWith("file://"))
file = file.remove("file://");
MyConverterJob *job = new MyConverterJob(file.toStdString());
thread->run_job(job);
}
and pass all arguments from the command line to it:
for (int i=1; i<args.size(); i++)
converter.process(args[i]);
← KDE4 Integration | ● | KDE4 Examples →