Reply to topic

konqueror: get selected/opened file in plugin

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
18657
Karma
83
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.


System Settings and Device Actions KCM maintainer
Image
smartyM
Registered Member
Posts
2
Karma
0
Ok, thanks for your time and advice. I will look further at the mailing list.

 
Reply to topic

Bookmarks



Who is online

Registered users: adabrowski, Alexa [Bot], Baidu [Spider], Bing [Bot], bjoernbalazs, CyberAngel, edmael, Exabot [Bot], Felix VI, firewalker, Google [Bot], gp[], jensreuterberg, lazyit, maggy, MSNbot Media, nezumi, orbmiser, pbCyanide, salvochea, sebas, stavallo, TheraHedwig, Uri_Herrera, Yahoo [Bot]