KdeInitInterface
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@115 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
		
							parent
							
								
									1f31bf95c1
								
							
						
					
					
						commit
						a8d60588cc
					
				
							
								
								
									
										17
									
								
								src/main.cpp
								
								
								
								
							
							
						
						
									
										17
									
								
								src/main.cpp
								
								
								
								
							| 
						 | 
					@ -33,6 +33,7 @@
 | 
				
			||||||
#include <QPluginLoader>
 | 
					#include <QPluginLoader>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "plugins/interfaces/IFileDialog.h"
 | 
					#include "plugins/interfaces/IFileDialog.h"
 | 
				
			||||||
 | 
					#include "plugins/interfaces/IKdeInit.h"
 | 
				
			||||||
#include "lib/FileDialogs.h"
 | 
					#include "lib/FileDialogs.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "main.h"
 | 
					#include "main.h"
 | 
				
			||||||
| 
						 | 
					@ -87,11 +88,8 @@ bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& Locale
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char **argv)
 | 
					int main(int argc, char **argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QApplication* app=new QApplication(argc,argv);
 | 
					 | 
				
			||||||
	QString ArgFile,ArgCfg,ArgLang,IniFilename;
 | 
						QString ArgFile,ArgCfg,ArgLang,IniFilename;
 | 
				
			||||||
	parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang);
 | 
						QApplication* app=NULL;
 | 
				
			||||||
	AppDir=app->applicationDirPath();
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	//Load Config
 | 
						//Load Config
 | 
				
			||||||
	if(ArgCfg==QString()){
 | 
						if(ArgCfg==QString()){
 | 
				
			||||||
| 
						 | 
					@ -117,14 +115,21 @@ int main(int argc, char **argv)
 | 
				
			||||||
			LibName+="gnome.so";
 | 
								LibName+="gnome.so";
 | 
				
			||||||
		QPluginLoader plugin("/home/tarek/Documents/KeePassX/src/plugins/gnome/"+LibName);
 | 
							QPluginLoader plugin("/home/tarek/Documents/KeePassX/src/plugins/gnome/"+LibName);
 | 
				
			||||||
		if(!plugin.load()){
 | 
							if(!plugin.load()){
 | 
				
			||||||
			qDebug(plugin.errorString().toUtf8().data());
 | 
								qWarning("Could not load destop integration plugin:");
 | 
				
			||||||
			exit(1);
 | 
								qWarning(plugin.errorString().toUtf8().data());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else{
 | 
							else{
 | 
				
			||||||
			IFileDialog* fdlg=qobject_cast<IFileDialog*>(plugin.instance());
 | 
								IFileDialog* fdlg=qobject_cast<IFileDialog*>(plugin.instance());
 | 
				
			||||||
			KpxFileDialogs::setPlugin(fdlg);
 | 
								KpxFileDialogs::setPlugin(fdlg);
 | 
				
			||||||
 | 
								if(config.IntegrPlugin==CConfig::KDE){
 | 
				
			||||||
 | 
									IKdeInit* kdeinit=qobject_cast<IKdeInit*>(plugin.instance());
 | 
				
			||||||
 | 
									app=kdeinit->getMainAppObject(argc,argv);
 | 
				
			||||||
 | 
								}			
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if(!app) QApplication* app=new QApplication(argc,argv);
 | 
				
			||||||
 | 
						parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang);
 | 
				
			||||||
 | 
						AppDir=app->applicationDirPath();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 <QString>
 | 
				
			||||||
 | 
					#include <QStringList>
 | 
				
			||||||
 | 
					#include <QApplication>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#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 
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@
 | 
				
			||||||
 *   Free Software Foundation, Inc.,                                       *
 | 
					 *   Free Software Foundation, Inc.,                                       *
 | 
				
			||||||
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 | 
					 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 | 
				
			||||||
 ***************************************************************************/
 | 
					 ***************************************************************************/
 | 
				
			||||||
 
 | 
					#include <kapplication.h>
 | 
				
			||||||
#include <kfiledialog.h>
 | 
					#include <kfiledialog.h>
 | 
				
			||||||
#include "keepassx-kde.h"
 | 
					#include "keepassx-kde.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,3 +35,8 @@ QStringList KdePlugin::openExistingFilesDialog(QWidget* parent,QString title,QSt
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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,bool OverWriteWarn){return QString();}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QApplication* KdePlugin::getMainAppObject(int argc, char** argv){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -21,11 +21,13 @@
 | 
				
			||||||
#include <QtPlugin>
 | 
					#include <QtPlugin>
 | 
				
			||||||
#include <QObject>
 | 
					#include <QObject>
 | 
				
			||||||
#include "../interfaces/IFileDialog.h"
 | 
					#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_OBJECT
 | 
				
			||||||
	Q_INTERFACES(IFileDialog)
 | 
						Q_INTERFACES(IFileDialog)
 | 
				
			||||||
 | 
						Q_INTERFACES(IKdeInit)
 | 
				
			||||||
	public:
 | 
						public:
 | 
				
			||||||
		virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
 | 
							virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
 | 
				
			||||||
							QStringList Filters);
 | 
												QStringList Filters);
 | 
				
			||||||
| 
						 | 
					@ -33,5 +35,6 @@ class KdePlugin:public QObject,public IFileDialog{
 | 
				
			||||||
							QStringList Filters);		
 | 
												QStringList Filters);		
 | 
				
			||||||
		virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
 | 
							virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
 | 
				
			||||||
							QStringList Filters,bool ShowOverwriteWarning=true);
 | 
												QStringList Filters,bool ShowOverwriteWarning=true);
 | 
				
			||||||
 | 
							virtual QApplication* getMainAppObject(int argc, char** argv);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue