added plugin for gnome/gtk integration
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@111 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
parent
b9feb0b74d
commit
2b088a31e6
14
src/main.cpp
14
src/main.cpp
|
@ -30,6 +30,9 @@
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
|
#include <QPluginLoader>
|
||||||
|
|
||||||
|
#include "plugins/interfaces/IFileDialog.h"
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "PwmConfig.h"
|
#include "PwmConfig.h"
|
||||||
|
@ -87,6 +90,17 @@ 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();
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
QPluginLoader gtkplugin("/home/tarek/Documents/KeePassX/src/plugins/gnome/libkeepassx-gnome.so");
|
||||||
|
if(!gtkplugin.load())
|
||||||
|
qDebug(gtkplugin.errorString().toUtf8().data());
|
||||||
|
IFileDialog* filedlg=qobject_cast<IFileDialog*>(gtkplugin.instance());
|
||||||
|
showErrMsg(filedlg->openExistingFileDialog(NULL,"Hallo","/home",QStringList()<<"Images (*.jpg *.bmp *.jpeg *.png)"<<"Text Files (*.txt *.rtf)"<<"All files (*)"));
|
||||||
|
return 0;
|
||||||
|
*/
|
||||||
|
|
||||||
//Load Config
|
//Load Config
|
||||||
if(ArgCfg==QString()){
|
if(ArgCfg==QString()){
|
||||||
if(!QDir(QDir::homePath()+"/.keepass").exists()){
|
if(!QDir(QDir::homePath()+"/.keepass").exists()){
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 <gtk/gtk.h>
|
||||||
|
#include "keepassx-gnome.h"
|
||||||
|
#define CSTRING(x)(x.toUtf8().data())
|
||||||
|
|
||||||
|
Q_EXPORT_PLUGIN2(keepassx_gnome, GnomePlugin)
|
||||||
|
|
||||||
|
QString GnomePlugin::openExistingFileDialog(QWidget* parent,QString title,QString dir,
|
||||||
|
QStringList Filters){
|
||||||
|
|
||||||
|
GtkWidget *FileDlg;
|
||||||
|
QString filename;
|
||||||
|
gtk_init(0,0);
|
||||||
|
FileDlg=gtk_file_chooser_dialog_new(title.toUtf8().data(),NULL,
|
||||||
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||||
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
|
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
|
||||||
|
NULL);
|
||||||
|
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(FileDlg),dir.toUtf8().data());
|
||||||
|
GtkFileFilter** filters=parseFilterStrings(Filters);
|
||||||
|
|
||||||
|
for(int i=0;i<Filters.size();i++){
|
||||||
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(FileDlg),filters[i]);
|
||||||
|
}
|
||||||
|
if (gtk_dialog_run(GTK_DIALOG(FileDlg)) == GTK_RESPONSE_ACCEPT){
|
||||||
|
char* filename_cstring=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(FileDlg));
|
||||||
|
filename = QString::fromUtf8(filename_cstring);
|
||||||
|
g_free(filename_cstring);
|
||||||
|
}
|
||||||
|
gtk_widget_destroy (FileDlg);
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkFileFilter** GnomePlugin::parseFilterStrings(const QStringList& filters){
|
||||||
|
if(!filters.size())return NULL;
|
||||||
|
GtkFileFilter **f=new GtkFileFilter*[filters.size()];
|
||||||
|
for(int i=0;i<filters.size();i++){
|
||||||
|
f[i]=gtk_file_filter_new();
|
||||||
|
QString name;
|
||||||
|
int p=0;
|
||||||
|
for(p;p<filters[i].size();p++){
|
||||||
|
if(filters[i][p]!='(')
|
||||||
|
name += filters[i][p];
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
gtk_file_filter_set_name(f[i],CSTRING(name));
|
||||||
|
p++;
|
||||||
|
QString pattern;
|
||||||
|
for(p;p<filters[i].size()-1;p++){
|
||||||
|
if(filters[i][p]==' '){
|
||||||
|
gtk_file_filter_add_pattern(f[i],CSTRING(pattern));
|
||||||
|
pattern=QString();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pattern += filters[i][p];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GnomePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters){return QString();}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 <gtk/gtk.h>
|
||||||
|
#include <QtPlugin>
|
||||||
|
#include <QObject>
|
||||||
|
#include "../interfaces/IFileDialog.h"
|
||||||
|
|
||||||
|
|
||||||
|
class GnomePlugin:public QObject,public IFileDialog{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(IFileDialog)
|
||||||
|
public:
|
||||||
|
virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
|
||||||
|
QStringList Filters);
|
||||||
|
virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
|
||||||
|
QStringList Filters);
|
||||||
|
private:
|
||||||
|
GtkFileFilter** parseFilterStrings(const QStringList &Filters);
|
||||||
|
};
|
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
INCLUDEPATH += /opt/gnome/include/gtk-2.0 \
|
||||||
|
/opt/gnome/include/glib-2.0 \
|
||||||
|
/opt/gnome/include/pango-1.0 \
|
||||||
|
/opt/gnome/include/atk-1.0 \
|
||||||
|
/opt/gnome/include/orbit-2.0 \
|
||||||
|
/usr/include/cairo \
|
||||||
|
/opt/gnome/lib/glib-2.0/include \
|
||||||
|
/opt/gnome/lib/gtk-2.0/include
|
||||||
|
TEMPLATE = lib
|
||||||
|
CONFIG += plugin release
|
||||||
|
HEADERS += keepassx-gnome.h
|
||||||
|
SOURCES += keepassx-gnome.cpp
|
||||||
|
MOC_DIR = build/moc
|
||||||
|
OBJECTS_DIR = build/
|
||||||
|
LIBS+=-lgtk-x11-2.0
|
|
@ -0,0 +1,31 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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>
|
||||||
|
|
||||||
|
class IFileDialog{
|
||||||
|
public:
|
||||||
|
virtual ~IFileDialog(){}
|
||||||
|
virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
|
||||||
|
QStringList Filters)=0;
|
||||||
|
virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
|
||||||
|
QStringList Filters)=0;
|
||||||
|
};
|
||||||
|
Q_DECLARE_INTERFACE(IFileDialog,"org.KeePassX.FileDialogInterface/1.0")
|
|
@ -88,7 +88,8 @@ HEADERS += lib/IniReader.h \
|
||||||
crypto/aescpp.h \
|
crypto/aescpp.h \
|
||||||
crypto/sha256.h \
|
crypto/sha256.h \
|
||||||
crypto/yarrow.h \
|
crypto/yarrow.h \
|
||||||
lib/WaitAnimationWidget.h
|
lib/WaitAnimationWidget.h \
|
||||||
|
plugins/interfaces/IFileDialog.h
|
||||||
SOURCES += lib/IniReader.cpp \
|
SOURCES += lib/IniReader.cpp \
|
||||||
lib/UrlLabel.cpp \
|
lib/UrlLabel.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
|
|
Loading…
Reference in New Issue