reactivated KDE4 plugin
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@178 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
		
							parent
							
								
									317397e063
								
							
						
					
					
						commit
						ed3baff013
					
				|  | @ -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; | ||||
|  |  | |||
|  | @ -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")); | ||||
|  |  | |||
							
								
								
									
										89
									
								
								src/main.cpp
								
								
								
								
							
							
						
						
									
										89
									
								
								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 <QTranslator> | ||||
| #include <QLibraryInfo> | ||||
| #include <QPluginLoader> | ||||
| #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"; | ||||
| 	} | ||||
|  | @ -80,8 +76,9 @@ int main(int argc, char **argv) | |||
| 	config = new KpxConfig(IniFilename); | ||||
| 	fileDlgHistory.load(); | ||||
| 	 | ||||
| 	// TODO Plugins
 | ||||
| 	/*if(config->integrPlugin()!=KpxConfig::NoIntegr){
 | ||||
| 	// PlugIns
 | ||||
| 
 | ||||
| 	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<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(){ | ||||
| 	cout << "KeePassX" << APP_VERSION << endl; | ||||
| 	cout << "Usage: keepassx  [Filename] [Options]" << endl; | ||||
|  | @ -285,23 +302,13 @@ void CmdLineArgs::printHelp(){ | |||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| //TODO Plugins
 | ||||
| /*
 | ||||
| QString findPlugin(const QString& filename){ | ||||
| 	QFileInfo info;	 | ||||
| 
 | ||||
| 	info.setFile(AppDir+"/../lib/"+filename); | ||||
| 	if(info.exists() && info.isFile()) | ||||
| 		return AppDir+"/../lib/"+filename;	 | ||||
| 
 | ||||
| 	return QString(); | ||||
| } | ||||
| */ | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -20,7 +20,7 @@ | |||
| #ifndef _MAIN_H_ | ||||
| #define _MAIN_H_ | ||||
| 
 | ||||
| //QString findPlugin(const QString& filename); //TODO Plugins
 | ||||
| QString findPlugin(const QString& filename); | ||||
| void loadImages(); | ||||
| bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& LocaleCode,const QStringList& SearchPaths); | ||||
| void initAppPaths(int argc, char **argv); | ||||
|  | @ -29,6 +29,7 @@ class CmdLineArgs { | |||
| public: | ||||
| 	CmdLineArgs(); | ||||
| 	bool parse(const QStringList& argv); | ||||
| 	bool preparse(int argc,char** argv); | ||||
| 	static void printHelp(); | ||||
| 	QString error() {return Error;} | ||||
| 	QString file() {return File;} | ||||
|  |  | |||
|  | @ -157,13 +157,13 @@ QApplication* KdePlugin::getMainAppObject(int argc, char** argv){ | |||
| 	return dynamic_cast<QApplication*>( new KpKApplication() ); | ||||
| #else | ||||
| 	return dynamic_cast<QApplication*>( 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; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 tarek_saidi
						tarek_saidi