reactivated KDE4 plugin

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@178 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 17 years ago
parent 317397e063
commit ed3baff013
  1. 3
      src/keepassx.h
  2. 5
      src/lib/tools.cpp
  3. 93
      src/main.cpp
  4. 3
      src/main.h
  5. 4
      src/plugins/kde/keepassx-kde.cpp

@ -91,7 +91,10 @@
#include "Database.h" #include "Database.h"
#include "KpxConfig.h" #include "KpxConfig.h"
#include "plugins/interfaces/IIconTheme.h"
extern QString PluginLoadError; extern QString PluginLoadError;
extern IIconTheme* IconLoader;
extern KpxConfig *config; extern KpxConfig *config;
extern QString AppDir; extern QString AppDir;
extern QString HomeDir; extern QString HomeDir;

@ -144,8 +144,7 @@ const QIcon& getIcon(const QString& name){
if(CachedIcon) if(CachedIcon)
return *CachedIcon; return *CachedIcon;
QIcon* NewIcon=NULL; QIcon* NewIcon=NULL;
//TODO plugins if(IconLoader){
/*if(IconLoader){
NewIcon=new QIcon(IconLoader->getIcon(name)); NewIcon=new QIcon(IconLoader->getIcon(name));
if(NewIcon->isNull()){ if(NewIcon->isNull()){
delete NewIcon; delete NewIcon;
@ -153,7 +152,7 @@ const QIcon& getIcon(const QString& name){
} }
else else
IconCache.insert(name,NewIcon); IconCache.insert(name,NewIcon);
}*/ }
if(!NewIcon) if(!NewIcon)
{ {
NewIcon=new QIcon(getImageFile(name+".png")); NewIcon=new QIcon(getImageFile(name+".png"));

@ -19,16 +19,15 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
/*
#include "plugins/interfaces/IFileDialog.h" #include "plugins/interfaces/IFileDialog.h"
#include "plugins/interfaces/IKdeInit.h" #include "plugins/interfaces/IKdeInit.h"
#include "plugins/interfaces/IGnomeInit.h" #include "plugins/interfaces/IGnomeInit.h"
#include "plugins/interfaces/IIconTheme.h" #include "plugins/interfaces/IIconTheme.h"
#include "lib/FileDialogs.h"
*/
#include <QTranslator> #include <QTranslator>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QPluginLoader>
#include "mainwindow.h" #include "mainwindow.h"
#include "main.h" #include "main.h"
#include "crypto/yarrow.h" #include "crypto/yarrow.h"
@ -48,29 +47,26 @@ QString DetailViewTemplate;
bool EventOccurred; bool EventOccurred;
QPixmap* EntryIcons; QPixmap* EntryIcons;
//IIconTheme* IconLoader=NULL; //TODO plugins IIconTheme* IconLoader=NULL;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
QApplication* app; QApplication* app=NULL;
#if defined(Q_WS_X11) && defined(GLOBAL_AUTOTYPE)
app = new KeepassApplication(argc,argv);
#else
app = new QApplication(argc,argv);
#endif
initAppPaths(argc,argv); initAppPaths(argc,argv);
CmdLineArgs args; CmdLineArgs args;
args.parse(QApplication::arguments()); if(!args.preparse(argc,argv)){ // searches only for the -cfg parameter
qDebug(CSTR(AppDir)); qCritical(CSTR(args.error()));
qDebug(CSTR(DataDir)); return 1;
}
//Load Config //Load Config
QString IniFilename; QString IniFilename;
if(args.configLocation().isEmpty()){ if(args.configLocation().isEmpty()){
if(!QDir(HomeDir).exists()){ if(!QDir(HomeDir).exists()){
QDir conf(QDir::homePath()); QDir conf(QDir::homePath());
if(!QDir().mkpath(HomeDir)) 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"; IniFilename=HomeDir+"/config";
} }
@ -79,9 +75,10 @@ int main(int argc, char **argv)
config = new KpxConfig(IniFilename); config = new KpxConfig(IniFilename);
fileDlgHistory.load(); fileDlgHistory.load();
// PlugIns
// TODO Plugins if(config->integrPlugin()!=KpxConfig::NoIntegr){
/*if(config->integrPlugin()!=KpxConfig::NoIntegr){
QString LibName="libkeepassx-"; QString LibName="libkeepassx-";
if(config->integrPlugin()==KpxConfig::KDE) if(config->integrPlugin()==KpxConfig::KDE)
LibName+="kde.so"; 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))); qWarning(CSTR(QString("Could not load desktop integration plugin: File '%1' not found.").arg(LibName)));
PluginLoadError=QObject::tr("Could not locate library file."); 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 //Internationalization
QLocale loc; QLocale loc;
@ -225,20 +231,6 @@ bool CmdLineArgs::parse(const QStringList& argv){
Help=true; Help=true;
break; // break, because other arguments will be ignored anyway 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[i]=="-lang"){
if(argv.size()==i+1){ if(argv.size()==i+1){
Error="Missing argument for '-lang'."; Error="Missing argument for '-lang'.";
@ -252,6 +244,11 @@ bool CmdLineArgs::parse(const QStringList& argv){
i++; i++;
continue; continue;
} }
if(argv[i]=="-cfg"){
//already done in preparse() -> skip
i++;
continue;
}
if(argv[i]=="-min"){ if(argv[i]=="-min"){
StartMinimized=true; StartMinimized=true;
continue; continue;
@ -270,6 +267,26 @@ bool CmdLineArgs::parse(const QStringList& argv){
return true; return true;
} }
bool CmdLineArgs::preparse(int argc,char** argv){
for(int i=1;i<argc;i++){
if(QString(argv[i])=="-cfg"){
if(argc==i+1){
Error="Missing argument for '-cfg'.";
return false;
}
if(QString(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++;
return true;
}
}
return true;
}
void CmdLineArgs::printHelp(){ void CmdLineArgs::printHelp(){
cout << "KeePassX" << APP_VERSION << endl; cout << "KeePassX" << APP_VERSION << endl;
cout << "Usage: keepassx [Filename] [Options]" << endl; cout << "Usage: keepassx [Filename] [Options]" << endl;
@ -285,23 +302,13 @@ void CmdLineArgs::printHelp(){
} }
//TODO Plugins
/*
QString findPlugin(const QString& filename){ QString findPlugin(const QString& filename){
QFileInfo info; QFileInfo info;
info.setFile(AppDir+"/../lib/"+filename); info.setFile(AppDir+"/../lib/"+filename);
if(info.exists() && info.isFile()) if(info.exists() && info.isFile())
return AppDir+"/../lib/"+filename; return AppDir+"/../lib/"+filename;
return QString(); return QString();
} }
*/

@ -20,7 +20,7 @@
#ifndef _MAIN_H_ #ifndef _MAIN_H_
#define _MAIN_H_ #define _MAIN_H_
//QString findPlugin(const QString& filename); //TODO Plugins QString findPlugin(const QString& filename);
void loadImages(); void loadImages();
bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& LocaleCode,const QStringList& SearchPaths); bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& LocaleCode,const QStringList& SearchPaths);
void initAppPaths(int argc, char **argv); void initAppPaths(int argc, char **argv);
@ -29,6 +29,7 @@ class CmdLineArgs {
public: public:
CmdLineArgs(); CmdLineArgs();
bool parse(const QStringList& argv); bool parse(const QStringList& argv);
bool preparse(int argc,char** argv);
static void printHelp(); static void printHelp();
QString error() {return Error;} QString error() {return Error;}
QString file() {return File;} QString file() {return File;}

@ -157,13 +157,13 @@ QApplication* KdePlugin::getMainAppObject(int argc, char** argv){
return dynamic_cast<QApplication*>( new KpKApplication() ); return dynamic_cast<QApplication*>( new KpKApplication() );
#else #else
return dynamic_cast<QApplication*>( new KApplication() ); return dynamic_cast<QApplication*>( new KApplication() );
#emdif #endif
} }
QIcon KdePlugin::getIcon(const QString& name){ QIcon KdePlugin::getIcon(const QString& name){
KIconLoader loader; 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(); if(pxm.isNull())return QIcon();
QIcon icon(pxm); QIcon icon(pxm);
return icon; return icon;