-KDE-Plugin: Updated API, plugin works fine again

-KDE-Plugin: added KDE icon loader to load KDE's currunt icon theme (incomplete)
-reverted change in the group combobox in the editentrydialog


git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@141 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 18 years ago
parent 57416c61d2
commit 05ec5eb40c
  1. 2
      src/dialogs/EditEntryDlg.cpp
  2. 21
      src/main.cpp
  3. 33
      src/plugins/interfaces/IIconTheme.h
  4. 55
      src/plugins/kde/keepassx-kde.cpp
  5. 13
      src/plugins/kde/keepassx-kde.h
  6. 10
      src/plugins/kde/keepassx-kde.pro
  7. 1
      src/src.pro

@ -192,7 +192,7 @@ void CEditEntryDlg::InitGroupComboBox(){
QString Space;
groups=db->sortedGroups();
for(int i=0;i<groups.size();i++){
Space.fill(' ', 2 * (groups[i]->level() - 1));
Space.fill(' ', 2 * (groups[i]->level()));
Combo_Group->insertItem(i,db->icon(groups[i]->image()),Space+groups[i]->title());
if(groups[i]==entry->group()){
Combo_Group->setCurrentIndex(i);

@ -37,6 +37,7 @@
#include "plugins/interfaces/IFileDialog.h"
#include "plugins/interfaces/IKdeInit.h"
#include "plugins/interfaces/IGnomeInit.h"
#include "plugins/interfaces/IIconTheme.h"
#include "lib/FileDialogs.h"
#include "main.h"
@ -68,6 +69,7 @@ bool TrActive;
QString DetailViewTemplate;
QPixmap* EntryIcons;
IIconTheme* IconLoader=NULL;
inline void loadImages();
inline void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg,QString& ArgLang);
@ -135,7 +137,12 @@ int main(int argc, char **argv)
qWarning(CSTR(PluginLoadError));
}
else{
IFileDialog* fdlg=qobject_cast<IFileDialog*>(plugin.instance());
QObject *plugininstance=plugin.instance();
IFileDialog* fdlg=qobject_cast<IFileDialog*>(plugininstance);
IconLoader=qobject_cast<IIconTheme*>(plugininstance);
if(IconLoader==NULL){
qWarning("Error: Integration Plugin: Could not initialize IconTheme interface.");
}
KpxFileDialogs::setPlugin(fdlg);
if(config->integrPlugin()==KpxConfig::KDE){
IKdeInit* kdeinit=qobject_cast<IKdeInit*>(plugin.instance());
@ -350,13 +357,19 @@ const QIcon& getIcon(const QString& name){
QIcon* CachedIcon=IconCache.value(name);
if(CachedIcon)
return *CachedIcon;
QIcon* NewIcon=NULL;
if(IconLoader==NULL){
QFileInfo IconFile(AppDir+"/../share/keepass/icons/"+name+".png");
if(!IconFile.isFile() || !IconFile.exists() || !IconFile.isReadable()){
///TODO 0.2.3 error handling
qWarning("%s",CSTR(name));
}
QIcon* NewIcon=new QIcon(AppDir+"/../share/keepass/icons/"+name+".png");
NewIcon=new QIcon(AppDir+"/../share/keepass/icons/"+name+".png");
IconCache.insert(name,NewIcon);
} else {
NewIcon=new QIcon(IconLoader->getIcon(name));
IconCache.insert(name,NewIcon);
}
return *NewIcon;
}
@ -436,9 +449,9 @@ QMessageBox::critical(parent,QObject::tr("Error"),msg,QObject::tr("OK"));
QString findPlugin(const QString& filename){
QFileInfo info;
info.setFile(AppDir+"/../lib/keepassx/"+filename);
info.setFile(AppDir+"/../lib/"+filename);
if(info.exists() && info.isFile())
return AppDir+"/../lib/keepassx/"+filename;
return AppDir+"/../lib/"+filename;
return QString();
}

@ -0,0 +1,33 @@
/***************************************************************************
* Copyright (C) 2007 by Tarek Saidi *
* tarek.saidi@arcor.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; Version 2 of the license only. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QString>
#include <QStringList>
#include <QIcon>
#ifndef _I_ICON_THEME_H_
#define _I_ICON_THEME_H_
class IIconTheme{
public:
virtual ~IIconTheme(){}
virtual QIcon getIcon(const QString& name)=0;
};
Q_DECLARE_INTERFACE(IIconTheme,"org.KeePassX.IconThemeInterface/0.2.3")
#endif

@ -17,27 +17,74 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <kapplication.h>
#include <kfiledialog.h>
#include <kcmdlineargs.h>
#include <kiconloader.h>
#include <QPixmap>
#include <QHash>
#include "keepassx-kde.h"
QHash<QString,QString>IconMap;
Q_EXPORT_PLUGIN2(keepassx_kde, KdePlugin)
QString KdePlugin::openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters){
return KFileDialog::getOpenFileName();
void createIconMap(){
IconMap["alarmclock"]="alarmclock";
IconMap["appsettings"]="configure";
IconMap["autotype"]="input-keyboard";
IconMap["clock"]="chronometer";
IconMap["clonenetry"]="edit-copy";
IconMap["copypwd"]="kgpg-export-kgpg";
IconMap["copyusername"]="user";
IconMap["dbsearch"]="edit-find";
IconMap["dbsettings"]="configure";
IconMap["delete"]="edit-delete";
IconMap["delete-entry"]="edit-delete";
IconMap["delete-group"]="edit-delete";
IconMap["editentry"]="edit";
IconMap["editgroup"]="edit";
IconMap["exit"]="application-exit";
IconMap["expired"]="flag-red";
IconMap["fileclose"]="dialog-close";
IconMap["filedelete"]="edit-delete";
IconMap["filenew"]="document-new";
IconMap["fileopen"]="document-open";
IconMap["filesave"]="document-save";
IconMap["filesaveas"]="document-save-as";
IconMap["filesaveasdisabled"]="document-save-as"; ///FIXME
IconMap["generator"]="roll";
IconMap["groupsearch"]="file-find";
IconMap["help"]="help-contents";
IconMap["key"]="password";
IconMap["manual"]="help-contents";
}
QString KdePlugin::openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter){
return KFileDialog::getOpenFileName();
}
QStringList KdePlugin::openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters){
QStringList KdePlugin::openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter){
return QStringList();
}
QString KdePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool OverWriteWarn){return QString();}
QString KdePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter,bool OverWriteWarn){return QString();}
QApplication* KdePlugin::getMainAppObject(int argc, char** argv){
KCmdLineArgs::init(argc,argv,"keepassx","KeePassX","Cross Platform Password Manager","0.2.3");
createIconMap();
return dynamic_cast<QApplication*>( new KApplication() );
}
QIcon KdePlugin::getIcon(const QString& name){
KIconLoader loader;
QPixmap pxm=loader.loadIcon(IconMap.value(name),K3Icon::Desktop);
QIcon icon(pxm);
return icon;
}

@ -20,21 +20,26 @@
#include <QtPlugin>
#include <QObject>
#include <QIcon>
#include "../interfaces/IFileDialog.h"
#include "../interfaces/IKdeInit.h"
#include "../interfaces/IIconTheme.h"
class KdePlugin:public QObject,public IFileDialog,public IKdeInit{
class KdePlugin:public QObject,public IFileDialog,public IKdeInit,public IIconTheme{
Q_OBJECT
Q_INTERFACES(IFileDialog)
Q_INTERFACES(IKdeInit)
Q_INTERFACES(IIconTheme)
public:
virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
QStringList Filters);
QStringList Filters, int SelectedFilter);
virtual QStringList openExistingFilesDialog(QWidget* parent,QString title,QString dir,
QStringList Filters);
QStringList Filters, int SelectedFilter);
virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
QStringList Filters,bool ShowOverwriteWarning=true);
QStringList Filters, int SelectedFilter, bool ShowOverwriteWarning=true);
virtual int getLastFilter(){return 0;}
virtual QApplication* getMainAppObject(int argc, char** argv);
virtual QIcon getIcon(const QString& name);
};

@ -1,9 +1,9 @@
INCLUDEPATH += /opt/kde4/include
INCLUDEPATH += /usr/lib/kde4/include
TEMPLATE = lib
CONFIG += plugin release
HEADERS += keepassx-kde.h
SOURCES += keepassx-kde.cpp
MOC_DIR = build/moc
OBJECTS_DIR = build/
LIBS+=-L/opt/kde4/lib -lkio -lkdecore
MOC_DIR = ../../../build/moc
OBJECTS_DIR = ../../../build
TARGET = ../../../lib/keepassx-kde
LIBS+=-L/usr/lib/kde4/lib -lkio -lkdecore

@ -114,6 +114,7 @@ HEADERS += lib/IniReader.h \
plugins/interfaces/IFileDialog.h \
plugins/interfaces/IKdeInit.h \
plugins/interfaces/IGnomeInit.h \
plugins/interfaces/IIconTheme.h \
KpxConfig.h \
KpxFirefox.h
SOURCES += lib/UrlLabel.cpp \