This forum has been archived. All content is frozen. Please use KDE Discuss instead.

konqueror: get selected/opened file in plugin

Tags: None
(comma "," separated)
smartyM
Registered Member
Posts
2
Karma
0
I try to make a small plugin/extension for konqueror to organize some media files. The main purpose of it is to save some file specific information from file into a database.
My plugin already displays a toolbar in konqueror for the user to enter some properties/values. Now I want to link this information to the current selected or opened file.

I already found an example (kshellcmdplugin) to get the name and location of the currently selected file, but the problem is that this only seems to work when the plugin is installed as a dolphinpart plugin (under: ~/.kde4/shareapps/dolphinpart/kpartplugins/). I want this plugin to be also available when konqueror displays a picture (via some embedded viewer). To make my plugin also available in that last case, I need to install it as a konqueror plugin (under ~/.kde4/share/apps/konqueror/kpartplugins/), but then it does not seems to have any reference to the file list browser (the dolphinpart part).

So the main question is: How to get pathname the current selected or opened(/viewed) file by konqueror inside my plugin?


This code works to get all the selected files (when the .rc and .desktop files are installed in: ~/.kde4/shareapps/dolphinpart/kpartplugins/):
Code: Select all
QString path;
KParts::FileInfoExtension* ext = KParts::FileInfoExtension::childObject(qobject_cast<KParts::ReadOnlyPart *>(parent()));
if(ext && ext->hasSelection() && (ext->supportedQueryModes() & KParts::FileInfoExtension::SelectedItems))
{
   KFileItemList list = ext->queryFor(KParts::FileInfoExtension::SelectedItems);
   QStringList fileNames;
   Q_FOREACH(const KFileItem& item, list)
   {
      fileNames << item.url().url(); /* item.url() to get a KUrl; KUrl.url() returns the whole path */
   }
   path = KShell::joinArgs(fileNames);
}


thanks in advance
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
While I can't answer the Konqueror specific part of the question - you probably will require two plugins here, which work in unison together to provide the functionality you need. One part to write, another to display the information.

In regards to the Konqueror / KParts API, I would suggest asking on the kde-devel@kde.org mailing list.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
smartyM
Registered Member
Posts
2
Karma
0
Ok, thanks for your time and advice. I will look further at the mailing list.


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], Yahoo [Bot]