From a8d60588cc3896836561c902d5a85f5e3d35f5ee Mon Sep 17 00:00:00 2001 From: tarek_saidi Date: Sat, 4 Nov 2006 20:28:34 +0000 Subject: [PATCH] KdeInitInterface git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@115 b624d157-de02-0410-bad0-e51aec6abb33 --- src/main.cpp | 19 ++++++++++------- src/plugins/interfaces/IKdeInit.h | 34 +++++++++++++++++++++++++++++++ src/plugins/kde/keepassx-kde.cpp | 9 ++++++-- src/plugins/kde/keepassx-kde.h | 5 ++++- 4 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 src/plugins/interfaces/IKdeInit.h diff --git a/src/main.cpp b/src/main.cpp index 1970450..b24d7d3 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,6 +33,7 @@ #include #include "plugins/interfaces/IFileDialog.h" +#include "plugins/interfaces/IKdeInit.h" #include "lib/FileDialogs.h" #include "main.h" @@ -87,11 +88,8 @@ bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& Locale int main(int argc, char **argv) { - QApplication* app=new QApplication(argc,argv); QString ArgFile,ArgCfg,ArgLang,IniFilename; - parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang); - AppDir=app->applicationDirPath(); - + QApplication* app=NULL; //Load Config if(ArgCfg==QString()){ @@ -117,14 +115,21 @@ int main(int argc, char **argv) LibName+="gnome.so"; QPluginLoader plugin("/home/tarek/Documents/KeePassX/src/plugins/gnome/"+LibName); if(!plugin.load()){ - qDebug(plugin.errorString().toUtf8().data()); - exit(1); + qWarning("Could not load destop integration plugin:"); + qWarning(plugin.errorString().toUtf8().data()); } else{ IFileDialog* fdlg=qobject_cast(plugin.instance()); - KpxFileDialogs::setPlugin(fdlg); + KpxFileDialogs::setPlugin(fdlg); + if(config.IntegrPlugin==CConfig::KDE){ + IKdeInit* kdeinit=qobject_cast(plugin.instance()); + app=kdeinit->getMainAppObject(argc,argv); + } } } + if(!app) QApplication* app=new QApplication(argc,argv); + parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang); + AppDir=app->applicationDirPath(); diff --git a/src/plugins/interfaces/IKdeInit.h b/src/plugins/interfaces/IKdeInit.h new file mode 100644 index 0000000..b829f7a --- /dev/null +++ b/src/plugins/interfaces/IKdeInit.h @@ -0,0 +1,34 @@ +/*************************************************************************** + * Copyright (C) 2005-2006 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; either version 2 of the License, or * + * (at your option) any later version. * + * * + * 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 +#include +#include + +#ifndef _I_KDE_INIT_H_ +#define _I_KDE_INIT_H_ + +class IKdeInit{ + public: + virtual ~IKdeInit(){} + virtual QApplication* getMainAppObject(int argc, char** argv)=0; +}; +Q_DECLARE_INTERFACE(IKdeInit,"org.KeePassX.KdeInitInterface/1.0") + +#endif diff --git a/src/plugins/kde/keepassx-kde.cpp b/src/plugins/kde/keepassx-kde.cpp index f9adc87..c26f18c 100644 --- a/src/plugins/kde/keepassx-kde.cpp +++ b/src/plugins/kde/keepassx-kde.cpp @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - +#include #include #include "keepassx-kde.h" @@ -34,4 +34,9 @@ QStringList KdePlugin::openExistingFilesDialog(QWidget* parent,QString title,QSt return QStringList(); } -QString KdePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool OverWriteWarn){return QString();} \ No newline at end of file +QString KdePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool OverWriteWarn){return QString();} + +QApplication* KdePlugin::getMainAppObject(int argc, char** argv){ + + +} \ No newline at end of file diff --git a/src/plugins/kde/keepassx-kde.h b/src/plugins/kde/keepassx-kde.h index 9077f72..830c757 100644 --- a/src/plugins/kde/keepassx-kde.h +++ b/src/plugins/kde/keepassx-kde.h @@ -21,11 +21,13 @@ #include #include #include "../interfaces/IFileDialog.h" +#include "../interfaces/IKdeInit.h" -class KdePlugin:public QObject,public IFileDialog{ +class KdePlugin:public QObject,public IFileDialog,public IKdeInit{ Q_OBJECT Q_INTERFACES(IFileDialog) + Q_INTERFACES(IKdeInit) public: virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir, QStringList Filters); @@ -33,5 +35,6 @@ class KdePlugin:public QObject,public IFileDialog{ QStringList Filters); virtual QString saveFileDialog(QWidget* parent,QString title,QString dir, QStringList Filters,bool ShowOverwriteWarning=true); + virtual QApplication* getMainAppObject(int argc, char** argv); };