From ed3baff01369c04a67aacb865e1f4e350f8e288b Mon Sep 17 00:00:00 2001 From: tarek_saidi Date: Tue, 11 Mar 2008 13:56:07 +0000 Subject: [PATCH] reactivated KDE4 plugin git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@178 b624d157-de02-0410-bad0-e51aec6abb33 --- src/keepassx.h | 3 ++ src/lib/tools.cpp | 5 +- src/main.cpp | 93 +++++++++++++++++--------------- src/main.h | 3 +- src/plugins/kde/keepassx-kde.cpp | 4 +- 5 files changed, 59 insertions(+), 49 deletions(-) diff --git a/src/keepassx.h b/src/keepassx.h index 92151e3..0326f9c 100644 --- a/src/keepassx.h +++ b/src/keepassx.h @@ -91,7 +91,10 @@ #include "Database.h" #include "KpxConfig.h" +#include "plugins/interfaces/IIconTheme.h" + extern QString PluginLoadError; +extern IIconTheme* IconLoader; extern KpxConfig *config; extern QString AppDir; extern QString HomeDir; diff --git a/src/lib/tools.cpp b/src/lib/tools.cpp index 3be420b..5a3bc31 100644 --- a/src/lib/tools.cpp +++ b/src/lib/tools.cpp @@ -144,8 +144,7 @@ const QIcon& getIcon(const QString& name){ if(CachedIcon) return *CachedIcon; QIcon* NewIcon=NULL; - //TODO plugins - /*if(IconLoader){ + if(IconLoader){ NewIcon=new QIcon(IconLoader->getIcon(name)); if(NewIcon->isNull()){ delete NewIcon; @@ -153,7 +152,7 @@ const QIcon& getIcon(const QString& name){ } else IconCache.insert(name,NewIcon); - }*/ + } if(!NewIcon) { NewIcon=new QIcon(getImageFile(name+".png")); diff --git a/src/main.cpp b/src/main.cpp index 4e98141..c269253 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,16 +19,15 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -/* #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 #include +#include #include "mainwindow.h" #include "main.h" #include "crypto/yarrow.h" @@ -48,29 +47,26 @@ QString DetailViewTemplate; bool EventOccurred; QPixmap* EntryIcons; -//IIconTheme* IconLoader=NULL; //TODO plugins +IIconTheme* IconLoader=NULL; int main(int argc, char **argv) { - QApplication* app; -#if defined(Q_WS_X11) && defined(GLOBAL_AUTOTYPE) - app = new KeepassApplication(argc,argv); -#else - app = new QApplication(argc,argv); -#endif + QApplication* app=NULL; initAppPaths(argc,argv); CmdLineArgs args; - args.parse(QApplication::arguments()); - qDebug(CSTR(AppDir)); - qDebug(CSTR(DataDir)); + if(!args.preparse(argc,argv)){ // searches only for the -cfg parameter + qCritical(CSTR(args.error())); + return 1; + } + //Load Config QString IniFilename; if(args.configLocation().isEmpty()){ if(!QDir(HomeDir).exists()){ QDir conf(QDir::homePath()); if(!QDir().mkpath(HomeDir)) - qDebug("Warning: Could not create directory '%s'", CSTR(HomeDir)); + qWarning("Warning: Could not create directory '%s'", CSTR(HomeDir)); } IniFilename=HomeDir+"/config"; } @@ -79,9 +75,10 @@ int main(int argc, char **argv) config = new KpxConfig(IniFilename); fileDlgHistory.load(); + + // PlugIns - // TODO Plugins - /*if(config->integrPlugin()!=KpxConfig::NoIntegr){ + if(config->integrPlugin()!=KpxConfig::NoIntegr){ QString LibName="libkeepassx-"; if(config->integrPlugin()==KpxConfig::KDE) LibName+="kde.so"; @@ -122,7 +119,16 @@ int main(int argc, char **argv) qWarning(CSTR(QString("Could not load desktop integration plugin: File '%1' not found.").arg(LibName))); PluginLoadError=QObject::tr("Could not locate library file."); } - }*/ + } + if(!app){ + #if defined(Q_WS_X11) && defined(GLOBAL_AUTOTYPE) + app = new KeepassApplication(argc,argv); + #else + app = new QApplication(argc,argv); + #endif + } + args.parse(QApplication::arguments()); + //Internationalization QLocale loc; @@ -225,20 +231,6 @@ bool CmdLineArgs::parse(const QStringList& argv){ Help=true; break; // break, because other arguments will be ignored anyway } - if(argv[i]=="-cfg"){ - if(argv.size()==i+1){ - Error="Missing argument for '-cfg'."; - return false; - } - if(argv[i+1].left(1)=="-"){ - Error=QString("Expected a path as argument for '-cfg' but got '%1.'").arg(argv[i+1]); - return false; - } - QFileInfo file(argv[i+1]); - ConfigLocation=file.absoluteFilePath(); - i++; - continue; - } if(argv[i]=="-lang"){ if(argv.size()==i+1){ Error="Missing argument for '-lang'."; @@ -252,6 +244,11 @@ bool CmdLineArgs::parse(const QStringList& argv){ i++; continue; } + if(argv[i]=="-cfg"){ + //already done in preparse() -> skip + i++; + continue; + } if(argv[i]=="-min"){ StartMinimized=true; continue; @@ -270,6 +267,26 @@ bool CmdLineArgs::parse(const QStringList& argv){ return true; } +bool CmdLineArgs::preparse(int argc,char** argv){ + for(int i=1;i( new KpKApplication() ); #else return dynamic_cast( new KApplication() ); -#emdif +#endif } QIcon KdePlugin::getIcon(const QString& name){ KIconLoader loader; - QPixmap pxm=loader.loadIcon(IconMap.value(name),K3Icon::Desktop,0,K3Icon::DefaultState,QStringList(),NULL,true); + QPixmap pxm=loader.loadIcon(IconMap.value(name),KIconLoader::Desktop,0,KIconLoader::DefaultState,QStringList(),NULL,true); if(pxm.isNull())return QIcon(); QIcon icon(pxm); return icon;