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