Added KDE4 Plugin
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@113 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
		
							parent
							
								
									db8ba66067
								
							
						
					
					
						commit
						b39ca12cd5
					
				| 
						 | 
					@ -34,6 +34,8 @@ using namespace std;
 | 
				
			||||||
	#define DEFAULT_MOUNT_DIR "/"
 | 
						#define DEFAULT_MOUNT_DIR "/"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define CSTR(x)((const char*)x.toUtf8())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool CConfig::loadFromIni(QString filename){
 | 
					bool CConfig::loadFromIni(QString filename){
 | 
				
			||||||
QString defaultSearchOptions = "001101111";
 | 
					QString defaultSearchOptions = "001101111";
 | 
				
			||||||
| 
						 | 
					@ -59,7 +61,6 @@ ParseBoolString(ini.GetValue("Options","PwGenOptions",(const char*)defaultPwGenO
 | 
				
			||||||
PwGenLength=ini.GetValueI("Options","PwGenLength",25);
 | 
					PwGenLength=ini.GetValueI("Options","PwGenLength",25);
 | 
				
			||||||
PwGenCharList=ini.GetValue("Options","PwGenCharList","").c_str();
 | 
					PwGenCharList=ini.GetValue("Options","PwGenCharList","").c_str();
 | 
				
			||||||
ExpandGroupTree=ini.GetValueB("Options","ExpandGroupTree",true);
 | 
					ExpandGroupTree=ini.GetValueB("Options","ExpandGroupTree",true);
 | 
				
			||||||
EnableKdePlugin=ini.GetValueB("KDE Plugin","Enabled",false);
 | 
					 | 
				
			||||||
MainWinHeight=ini.GetValueI("UI","MainWinHeight",550);
 | 
					MainWinHeight=ini.GetValueI("UI","MainWinHeight",550);
 | 
				
			||||||
MainWinWidth=ini.GetValueI("UI","MainWinWidth",900);
 | 
					MainWinWidth=ini.GetValueI("UI","MainWinWidth",900);
 | 
				
			||||||
MainWinSplit1=ini.GetValueI("UI","MainWinSplit1",100);
 | 
					MainWinSplit1=ini.GetValueI("UI","MainWinSplit1",100);
 | 
				
			||||||
| 
						 | 
					@ -73,6 +74,17 @@ LastKeyLocation=ini.GetValue("Options","LastKeyLocation","").c_str();
 | 
				
			||||||
LastKeyType=(tKeyType)ini.GetValueI("Options","LastKeyType",(int)PASSWORD);
 | 
					LastKeyType=(tKeyType)ini.GetValueI("Options","LastKeyType",(int)PASSWORD);
 | 
				
			||||||
if(!OpenLast)RememberLastKey=false;
 | 
					if(!OpenLast)RememberLastKey=false;
 | 
				
			||||||
ToolbarIconSize=ini.GetValueI("UI","ToolbarIconSize",16);
 | 
					ToolbarIconSize=ini.GetValueI("UI","ToolbarIconSize",16);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString IntegrPluginVal=ini.GetValue("Options","IntegrPlugin","None").c_str();
 | 
				
			||||||
 | 
					if(IntegrPluginVal=="None")	
 | 
				
			||||||
 | 
						IntegrPlugin=NONE;
 | 
				
			||||||
 | 
					else if(IntegrPluginVal=="Gnome")
 | 
				
			||||||
 | 
						IntegrPlugin=GNOME;
 | 
				
			||||||
 | 
					else if(IntegrPluginVal=="KDE")
 | 
				
			||||||
 | 
						IntegrPlugin=KDE;
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
						IntegrPlugin=NONE;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
return true;
 | 
					return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -97,7 +109,6 @@ ini.SetValue("Options","PwGenOptions",(const char*)CreateBoolString(PwGenOptions
 | 
				
			||||||
ini.SetValueI("Options","PwGenLength",PwGenLength,true);
 | 
					ini.SetValueI("Options","PwGenLength",PwGenLength,true);
 | 
				
			||||||
ini.SetValue("Options","PwGenCharList",(const char*)PwGenCharList.toUtf8(),true);
 | 
					ini.SetValue("Options","PwGenCharList",(const char*)PwGenCharList.toUtf8(),true);
 | 
				
			||||||
ini.SetValueB("Options","ExpandGroupTree",ExpandGroupTree,true);
 | 
					ini.SetValueB("Options","ExpandGroupTree",ExpandGroupTree,true);
 | 
				
			||||||
ini.SetValueB("KDE Plugin","Enabled",EnableKdePlugin,true);
 | 
					 | 
				
			||||||
ini.SetValueI("UI","MainWinHeight",MainWinHeight);
 | 
					ini.SetValueI("UI","MainWinHeight",MainWinHeight);
 | 
				
			||||||
ini.SetValueI("UI","MainWinWidth",MainWinWidth);
 | 
					ini.SetValueI("UI","MainWinWidth",MainWinWidth);
 | 
				
			||||||
ini.SetValueI("UI","MainWinSplit1",MainWinSplit1);
 | 
					ini.SetValueI("UI","MainWinSplit1",MainWinSplit1);
 | 
				
			||||||
| 
						 | 
					@ -114,6 +125,14 @@ else{
 | 
				
			||||||
	ini.SetValue("Options","LastKeyLocation","");
 | 
						ini.SetValue("Options","LastKeyLocation","");
 | 
				
			||||||
	ini.SetValueI("Options","LastKeyType",0);}
 | 
						ini.SetValueI("Options","LastKeyType",0);}
 | 
				
			||||||
ini.SetValueI("UI","ToolbarIconSize",ToolbarIconSize,true);
 | 
					ini.SetValueI("UI","ToolbarIconSize",ToolbarIconSize,true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if(IntegrPlugin==NONE)
 | 
				
			||||||
 | 
						ini.SetValue("Options","IntegrPlugin","None");
 | 
				
			||||||
 | 
					if(IntegrPlugin==GNOME)
 | 
				
			||||||
 | 
						ini.SetValue("Options","IntegrPlugin","Gnome");
 | 
				
			||||||
 | 
					if(IntegrPlugin==KDE)
 | 
				
			||||||
 | 
						ini.SetValue("Options","IntegrPlugin","KDE");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(!ini.WriteFile())return false;
 | 
					if(!ini.WriteFile())return false;
 | 
				
			||||||
else return true;
 | 
					else return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,8 +24,10 @@
 | 
				
			||||||
#include "lib/IniReader.h"
 | 
					#include "lib/IniReader.h"
 | 
				
			||||||
#include <qcolor.h>
 | 
					#include <qcolor.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							
 | 
				
			||||||
class CConfig{
 | 
					class CConfig{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					enum IntegrPluginType{NONE,KDE,GNOME};
 | 
				
			||||||
 int TimeFormat;
 | 
					 int TimeFormat;
 | 
				
			||||||
 int ClipboardTimeOut;
 | 
					 int ClipboardTimeOut;
 | 
				
			||||||
 bool Toolbar;
 | 
					 bool Toolbar;
 | 
				
			||||||
| 
						 | 
					@ -59,7 +61,7 @@ public:
 | 
				
			||||||
 tKeyType LastKeyType;
 | 
					 tKeyType LastKeyType;
 | 
				
			||||||
 QString LastKeyLocation;
 | 
					 QString LastKeyLocation;
 | 
				
			||||||
 int ToolbarIconSize;
 | 
					 int ToolbarIconSize;
 | 
				
			||||||
 | 
					 IntegrPluginType IntegrPlugin;
 | 
				
			||||||
 bool loadFromIni(QString filename);
 | 
					 bool loadFromIni(QString filename);
 | 
				
			||||||
 bool saveToIni(QString filename);
 | 
					 bool saveToIni(QString filename);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										26
									
								
								src/main.cpp
								
								
								
								
							
							
						
						
									
										26
									
								
								src/main.cpp
								
								
								
								
							| 
						 | 
					@ -93,11 +93,6 @@ parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang);
 | 
				
			||||||
	AppDir=app->applicationDirPath();
 | 
						AppDir=app->applicationDirPath();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
					 | 
				
			||||||
QPluginLoader gtkplugin("/home/tarek/Documents/KeePassX/src/plugins/gnome/libkeepassx-gnome.so");
 | 
					 | 
				
			||||||
KpxFileDialogs::setPlugin(qobject_cast<IFileDialog*>(gtkplugin.instance()));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	//Load Config
 | 
						//Load Config
 | 
				
			||||||
	if(ArgCfg==QString()){
 | 
						if(ArgCfg==QString()){
 | 
				
			||||||
	if(!QDir(QDir::homePath()+"/.keepass").exists()){
 | 
						if(!QDir(QDir::homePath()+"/.keepass").exists()){
 | 
				
			||||||
| 
						 | 
					@ -112,6 +107,27 @@ else{
 | 
				
			||||||
	IniFilename=ArgCfg;
 | 
						IniFilename=ArgCfg;
 | 
				
			||||||
	config.loadFromIni(IniFilename);}
 | 
						config.loadFromIni(IniFilename);}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						//Plugins
 | 
				
			||||||
 | 
						if(config.IntegrPlugin!=CConfig::NONE){
 | 
				
			||||||
 | 
							QString LibName="libkeepassx-";
 | 
				
			||||||
 | 
							if(config.IntegrPlugin==CConfig::KDE)
 | 
				
			||||||
 | 
								LibName+="kde.so";
 | 
				
			||||||
 | 
							else if(config.IntegrPlugin==CConfig::GNOME)
 | 
				
			||||||
 | 
								LibName+="gnome.so";
 | 
				
			||||||
 | 
							QPluginLoader plugin("/home/tarek/Documents/KeePassX/src/plugins/gnome/"+LibName);
 | 
				
			||||||
 | 
							if(!plugin.load()){
 | 
				
			||||||
 | 
								qDebug(plugin.errorString().toUtf8().data());
 | 
				
			||||||
 | 
								exit(1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else{
 | 
				
			||||||
 | 
								IFileDialog* fdlg=qobject_cast<IFileDialog*>(plugin.instance());
 | 
				
			||||||
 | 
								KpxFileDialogs::setPlugin(fdlg);		
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	//Internationalization
 | 
						//Internationalization
 | 
				
			||||||
	QLocale loc;
 | 
						QLocale loc;
 | 
				
			||||||
	if(!ArgLang.size())
 | 
						if(!ArgLang.size())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,37 @@
 | 
				
			||||||
 | 
					/***************************************************************************
 | 
				
			||||||
 | 
					 *   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 <kfiledialog.h>
 | 
				
			||||||
 | 
					#include "keepassx-kde.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Q_EXPORT_PLUGIN2(keepassx_kde, KdePlugin)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString KdePlugin::openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters){	
 | 
				
			||||||
 | 
						return KFileDialog::getOpenFileName();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QStringList KdePlugin::openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters){
 | 
				
			||||||
 | 
						return QStringList();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString KdePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool OverWriteWarn){return QString();}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,37 @@
 | 
				
			||||||
 | 
					/***************************************************************************
 | 
				
			||||||
 | 
					 *   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 <QtPlugin>
 | 
				
			||||||
 | 
					#include <QObject>
 | 
				
			||||||
 | 
					#include "../interfaces/IFileDialog.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class KdePlugin:public QObject,public IFileDialog{
 | 
				
			||||||
 | 
						Q_OBJECT
 | 
				
			||||||
 | 
						Q_INTERFACES(IFileDialog)
 | 
				
			||||||
 | 
						public:
 | 
				
			||||||
 | 
							virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
 | 
				
			||||||
 | 
												QStringList Filters);
 | 
				
			||||||
 | 
							virtual QStringList openExistingFilesDialog(QWidget* parent,QString title,QString dir,
 | 
				
			||||||
 | 
												QStringList Filters);		
 | 
				
			||||||
 | 
							virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
 | 
				
			||||||
 | 
												QStringList Filters,bool ShowOverwriteWarning=true);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,9 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					INCLUDEPATH +=	/opt/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/ -lkdeui
 | 
				
			||||||
		Loading…
	
		Reference in New Issue