Added KDE4 Plugin

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@113 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 18 years ago
parent db8ba66067
commit b39ca12cd5
  1. 23
      src/PwmConfig.cpp
  2. 4
      src/PwmConfig.h
  3. 176
      src/main.cpp
  4. 37
      src/plugins/kde/keepassx-kde.cpp
  5. 37
      src/plugins/kde/keepassx-kde.h
  6. 9
      src/plugins/kde/keepassx-kde.pro

@ -34,6 +34,8 @@ using namespace std;
#define DEFAULT_MOUNT_DIR "/"
#endif
#define CSTR(x)((const char*)x.toUtf8())
bool CConfig::loadFromIni(QString filename){
QString defaultSearchOptions = "001101111";
@ -59,7 +61,6 @@ ParseBoolString(ini.GetValue("Options","PwGenOptions",(const char*)defaultPwGenO
PwGenLength=ini.GetValueI("Options","PwGenLength",25);
PwGenCharList=ini.GetValue("Options","PwGenCharList","").c_str();
ExpandGroupTree=ini.GetValueB("Options","ExpandGroupTree",true);
EnableKdePlugin=ini.GetValueB("KDE Plugin","Enabled",false);
MainWinHeight=ini.GetValueI("UI","MainWinHeight",550);
MainWinWidth=ini.GetValueI("UI","MainWinWidth",900);
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);
if(!OpenLast)RememberLastKey=false;
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;
}
@ -97,7 +109,6 @@ ini.SetValue("Options","PwGenOptions",(const char*)CreateBoolString(PwGenOptions
ini.SetValueI("Options","PwGenLength",PwGenLength,true);
ini.SetValue("Options","PwGenCharList",(const char*)PwGenCharList.toUtf8(),true);
ini.SetValueB("Options","ExpandGroupTree",ExpandGroupTree,true);
ini.SetValueB("KDE Plugin","Enabled",EnableKdePlugin,true);
ini.SetValueI("UI","MainWinHeight",MainWinHeight);
ini.SetValueI("UI","MainWinWidth",MainWinWidth);
ini.SetValueI("UI","MainWinSplit1",MainWinSplit1);
@ -114,6 +125,14 @@ else{
ini.SetValue("Options","LastKeyLocation","");
ini.SetValueI("Options","LastKeyType",0);}
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;
else return true;
}

@ -24,8 +24,10 @@
#include "lib/IniReader.h"
#include <qcolor.h>
class CConfig{
public:
enum IntegrPluginType{NONE,KDE,GNOME};
int TimeFormat;
int ClipboardTimeOut;
bool Toolbar;
@ -59,7 +61,7 @@ public:
tKeyType LastKeyType;
QString LastKeyLocation;
int ToolbarIconSize;
IntegrPluginType IntegrPlugin;
bool loadFromIni(QString filename);
bool saveToIni(QString filename);

@ -87,87 +87,103 @@ 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();
QPluginLoader gtkplugin("/home/tarek/Documents/KeePassX/src/plugins/gnome/libkeepassx-gnome.so");
KpxFileDialogs::setPlugin(qobject_cast<IFileDialog*>(gtkplugin.instance()));
//Load Config
if(ArgCfg==QString()){
if(!QDir(QDir::homePath()+"/.keepass").exists()){
QDir conf(QDir::homePath());
if(!conf.mkdir(".keepass")){
cout << "Warning: Could not create directory '~/.keepass'." << endl;}
}
IniFilename=QDir::homePath()+"/.keepass/config";
config.loadFromIni(IniFilename);
}
else{
IniFilename=ArgCfg;
config.loadFromIni(IniFilename);}
//Internationalization
QLocale loc;
if(!ArgLang.size())
loc=QLocale::system();
else
loc=QLocale(ArgLang);
QTranslator* translator = NULL;
QTranslator* qtTranslator=NULL;
translator=new QTranslator;
qtTranslator=new QTranslator;
if(loadTranslation(translator,"keepass-",loc.name(),QStringList()
<< app->applicationDirPath()+"/../share/keepass/i18n/"
<< QDir::homePath()+"/.keepass/" ))
{app->installTranslator(translator);
TrActive=true;}
else{
if(loc.name()!="en_US")
qWarning(QString("Kpx: No Translation found for '%1 (%2)'using 'English (UnitedStates)'")
.arg(QLocale::languageToString(loc.language()))
.arg(QLocale::countryToString(loc.country())).toAscii());
delete translator;
TrActive=false;
}
if(loadTranslation(qtTranslator,"qt_",loc.name(),QStringList()
<< QLibraryInfo::location(QLibraryInfo::TranslationsPath)
<< app->applicationDirPath()+"/../share/keepass/i18n/"
<< QDir::homePath()+"/.keepass/" ))
app->installTranslator(qtTranslator);
else{
if(loc.name()!="en_US")
qWarning(QString("Qt: No Translation found for '%1 (%2)'using 'English (UnitedStates)'")
.arg(QLocale::languageToString(loc.language()))
.arg(QLocale::countryToString(loc.country())).toAscii());
delete qtTranslator;
}
loadImages();
initYarrow(); //init random number generator
SecString::generateSessionKey();
QApplication* app=new QApplication(argc,argv);
QString ArgFile,ArgCfg,ArgLang,IniFilename;
parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang);
AppDir=app->applicationDirPath();
//Load Config
if(ArgCfg==QString()){
if(!QDir(QDir::homePath()+"/.keepass").exists()){
QDir conf(QDir::homePath());
if(!conf.mkdir(".keepass")){
cout << "Warning: Could not create directory '~/.keepass'." << endl;}
}
IniFilename=QDir::homePath()+"/.keepass/config";
config.loadFromIni(IniFilename);
}
else{
IniFilename=ArgCfg;
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);
}
}
int r=0;
KeepassMainWindow *mainWin = new KeepassMainWindow(ArgFile);
if(mainWin->Start){
mainWin->show();
r=app->exec();
}
delete mainWin;
if(!config.saveToIni(IniFilename))
QMessageBox::warning(NULL,QObject::tr("Warning"),
QObject::tr("Could not save configuration file.\nMake sure you have write access to '~/.keepass'."),
QObject::tr("OK"),"","",0.0);
delete app;
return r;
//Internationalization
QLocale loc;
if(!ArgLang.size())
loc=QLocale::system();
else
loc=QLocale(ArgLang);
QTranslator* translator = NULL;
QTranslator* qtTranslator=NULL;
translator=new QTranslator;
qtTranslator=new QTranslator;
if(loadTranslation(translator,"keepass-",loc.name(),QStringList()
<< app->applicationDirPath()+"/../share/keepass/i18n/"
<< QDir::homePath()+"/.keepass/" ))
{app->installTranslator(translator);
TrActive=true;}
else{
if(loc.name()!="en_US")
qWarning(QString("Kpx: No Translation found for '%1 (%2)'using 'English (UnitedStates)'")
.arg(QLocale::languageToString(loc.language()))
.arg(QLocale::countryToString(loc.country())).toAscii());
delete translator;
TrActive=false;
}
if(loadTranslation(qtTranslator,"qt_",loc.name(),QStringList()
<< QLibraryInfo::location(QLibraryInfo::TranslationsPath)
<< app->applicationDirPath()+"/../share/keepass/i18n/"
<< QDir::homePath()+"/.keepass/" ))
app->installTranslator(qtTranslator);
else{
if(loc.name()!="en_US")
qWarning(QString("Qt: No Translation found for '%1 (%2)'using 'English (UnitedStates)'")
.arg(QLocale::languageToString(loc.language()))
.arg(QLocale::countryToString(loc.country())).toAscii());
delete qtTranslator;
}
loadImages();
initYarrow(); //init random number generator
SecString::generateSessionKey();
int r=0;
KeepassMainWindow *mainWin = new KeepassMainWindow(ArgFile);
if(mainWin->Start){
mainWin->show();
r=app->exec();
}
delete mainWin;
if(!config.saveToIni(IniFilename))
QMessageBox::warning(NULL,QObject::tr("Warning"),
QObject::tr("Could not save configuration file.\nMake sure you have write access to '~/.keepass'."),
QObject::tr("OK"),"","",0.0);
delete app;
return r;
}

@ -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