some work on the gtk plug-in, added integration tab in the settings dlg

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@112 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 18 years ago
parent 2b088a31e6
commit db8ba66067
  1. 14
      src/dialogs/SettingsDlg.cpp
  2. 44
      src/dialogs/SettingsDlg.h
  3. 1103
      src/forms/SettingsDlg.ui
  4. 11
      src/main.cpp
  5. 10
      src/mainwindow.cpp
  6. 60
      src/plugins/gnome/keepassx-gnome.cpp
  7. 4
      src/plugins/gnome/keepassx-gnome.h
  8. 12
      src/plugins/interfaces/IFileDialog.h
  9. 2
      src/src.pro

@ -27,6 +27,7 @@
#include <qlineedit.h>
#include <QFileDialog>
#include <QDir>
#include <QPainter>
#include "SettingsDlg.h"
@ -34,14 +35,14 @@ CSettingsDlg::CSettingsDlg(QWidget* parent)
: QDialog(parent,Qt::Dialog)
{
setupUi(this);
connect(ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
connect(ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
connect(DialogButtons, SIGNAL( accepted() ), this, SLOT( OnOK() ) );
connect(DialogButtons, SIGNAL( rejected() ), this, SLOT( OnCancel() ) );
connect(ButtonColor1, SIGNAL( clicked() ), this, SLOT( OnColor1() ) );
connect(ButtonColor2, SIGNAL( clicked() ), this, SLOT( OnColor2() ) );
connect(ButtonTextColor, SIGNAL( clicked() ), this, SLOT( OnTextColor() ) );
connect(CheckBox_OpenLast,SIGNAL(stateChanged(int)),this,SLOT(OnCeckBoxOpenLastChanged(int)));
connect(Button_MountDirBrowse,SIGNAL(clicked()),this,SLOT(OnMountDirBrowse()));
createBanner(Banner,Icon_Settings32x32,tr("Settings"));
createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width());
CheckBox_OpenLast->setChecked(config.OpenLast);
SpinBox_ClipboardTime->setValue(config.ClipboardTimeOut);
@ -75,6 +76,13 @@ CSettingsDlg::~CSettingsDlg()
{
}
void CSettingsDlg::paintEvent(QPaintEvent *event){
QDialog::paintEvent(event);
QPainter painter(this);
painter.setClipRegion(event->region());
painter.drawPixmap(QPoint(0,0),BannerPixmap);
}
void CSettingsDlg::OnOK()
{
config.OpenLast=CheckBox_OpenLast->isChecked();

@ -17,31 +17,37 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "main.h"
#ifndef SETTINGSDLG_H
#define SETTINGSDLG_H
#include <QColor>
#include <QPixmap>
#include <QPaintEvent>
#include "ui_SettingsDlg.h"
#include <qcolor.h>
#include "main.h"
class CSettingsDlg : public QDialog, public Ui_SettingsDialog
{
Q_OBJECT
public:
CSettingsDlg(QWidget* parent /*, Qt::WFlags fl*/);
~CSettingsDlg();
public slots:
virtual void OnCancel();
virtual void OnOK();
virtual void OnTextColor();
virtual void OnColor2();
virtual void OnColor1();
void OnCeckBoxOpenLastChanged(int state);
void OnMountDirBrowse();
private:
QColor color1,color2,textcolor;
Q_OBJECT
public:
CSettingsDlg(QWidget* parent);
~CSettingsDlg();
public slots:
virtual void OnCancel();
virtual void OnOK();
virtual void OnTextColor();
virtual void OnColor2();
virtual void OnColor1();
void OnCeckBoxOpenLastChanged(int state);
void OnMountDirBrowse();
private:
virtual void paintEvent(QPaintEvent*);
QColor color1,color2,textcolor;
QPixmap BannerPixmap;
};
#endif

File diff suppressed because it is too large Load Diff

@ -33,6 +33,7 @@
#include <QPluginLoader>
#include "plugins/interfaces/IFileDialog.h"
#include "lib/FileDialogs.h"
#include "main.h"
#include "PwmConfig.h"
@ -91,15 +92,11 @@ 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");
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;
*/
KpxFileDialogs::setPlugin(qobject_cast<IFileDialog*>(gtkplugin.instance()));
//Load Config
if(ArgCfg==QString()){

@ -41,6 +41,7 @@
#include "lib/random.h"
#include "lib/IniReader.h"
#include "lib/AutoType.h"
#include "lib/FileDialogs.h"
#include "import/Import_PwManager.h"
#include "import/Import_KWalletXml.h"
#include "export/Export_Txt.h"
@ -440,15 +441,18 @@ void KeepassMainWindow::OnFileNewKxdb(){
void KeepassMainWindow::OnFileOpen(){
QFileDialog FileDlg(this,tr("Open Database..."),QDir::homePath());
/*QFileDialog FileDlg(this,tr("Open Database..."),QDir::homePath());
FileDlg.setFilters(QStringList()<< tr("KeePass Databases (*.kdb)")<< tr("All Files (*)"));
FileDlg.setFileMode(QFileDialog::ExistingFile);
FileDlg.setAcceptMode(QFileDialog::AcceptOpen);
if(!FileDlg.exec())return;
if(!FileDlg.selectedFiles().size())return;
if(!FileDlg.selectedFiles().size())return;*/
QString filename=KpxFileDialogs::openExistingFile(this,"MainWindow_FileOpen",
tr("Open Database..."),QStringList()<<tr("KeePass Databases (*.kdb)")<< tr("All Files (*)"));
if(filename==QString())return;
if(FileOpen)
if(!closeDatabase())return;
openDatabase(FileDlg.selectedFiles()[0]);
openDatabase(filename);
}
void KeepassMainWindow::OnFileClose(){

@ -20,39 +20,38 @@
#include <gtk/gtk.h>
#include "keepassx-gnome.h"
#define CSTRING(x)(x.toUtf8().data())
#define CSTR(x)(x.toUtf8().data())
Q_EXPORT_PLUGIN2(keepassx_gnome, GnomePlugin)
QString GnomePlugin::openExistingFileDialog(QWidget* parent,QString title,QString dir,
QStringList Filters){
QString GnomePlugin::openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters){
unsigned int NumFilters=Filters.size();
GtkWidget *FileDlg;
QString filename;
gtk_init(0,0);
FileDlg=gtk_file_chooser_dialog_new(title.toUtf8().data(),NULL,
FileDlg=gtk_file_chooser_dialog_new(CSTR(title),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());
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(FileDlg),CSTR(dir));
GtkFileFilter** filters=parseFilterStrings(Filters);
for(int i=0;i<Filters.size();i++){
for(int i=0;i<NumFilters;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);
}
gtk_widget_destroy(FileDlg);
return filename;
}
GtkFileFilter** GnomePlugin::parseFilterStrings(const QStringList& filters){
if(!filters.size())return NULL;
GtkFileFilter **f=new GtkFileFilter*[filters.size()];
GtkFileFilter **f=g_new(GtkFileFilter*,filters.size());
for(int i=0;i<filters.size();i++){
f[i]=gtk_file_filter_new();
QString name;
@ -63,12 +62,13 @@ GtkFileFilter** GnomePlugin::parseFilterStrings(const QStringList& filters){
else
break;
}
gtk_file_filter_set_name(f[i],CSTRING(name));
gtk_file_filter_set_name(f[i],CSTR(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));
for(p;p<filters[i].size();p++){
if(filters[i][p]==' ' || filters[i][p]==')'){
gtk_file_filter_add_pattern(f[i],CSTR(pattern));
qDebug(CSTR(pattern));
pattern=QString();
}
else{
@ -80,4 +80,34 @@ GtkFileFilter** GnomePlugin::parseFilterStrings(const QStringList& filters){
return f;
}
QString GnomePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters){return QString();}
QStringList GnomePlugin::openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters){
unsigned int NumFilters=Filters.size();
GtkWidget *FileDlg;
QStringList filenames;
gtk_init(0,0);
FileDlg=gtk_file_chooser_dialog_new(CSTR(title),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),CSTR(dir));
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(FileDlg),true);
GtkFileFilter** filters=parseFilterStrings(Filters);
for(int i=0;i<NumFilters;i++){
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(FileDlg),filters[i]);
}
if (gtk_dialog_run(GTK_DIALOG(FileDlg)) == GTK_RESPONSE_ACCEPT){
GSList* FilenameList=gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(FileDlg));
GSList* front=FilenameList;
while(FilenameList!=0){
filenames << QString::fromUtf8((char*)FilenameList->data);
FilenameList=FilenameList->next;
}
g_slist_free(front);
}
gtk_widget_destroy(FileDlg);
return filenames;
}
QString GnomePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool OverWriteWarn){return QString();}

@ -31,8 +31,10 @@ class GnomePlugin:public QObject,public 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);
QStringList Filters,bool ShowOverwriteWarning=true);
private:
GtkFileFilter** parseFilterStrings(const QStringList &Filters);
};

@ -20,12 +20,20 @@
#include <QString>
#include <QStringList>
#ifndef _I_FILE_DIALOG_H_
#define _I_FILE_DIALOG_H_
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,
virtual QStringList openExistingFilesDialog(QWidget* parent,QString title,QString dir,
QStringList Filters)=0;
virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
QStringList Filters,bool ShowOverwriteWarning=true)=0;
};
Q_DECLARE_INTERFACE(IFileDialog,"org.KeePassX.FileDialogInterface/1.0")
Q_DECLARE_INTERFACE(IFileDialog,"org.KeePassX.FileDialogInterface/1.0")
#endif

@ -74,6 +74,7 @@ HEADERS += lib/IniReader.h \
Database.h \
lib/KdePlugin.h \
lib/AutoType.h \
lib/FileDialogs.h \
global.h \
main.h \
lib/GroupView.h \
@ -118,6 +119,7 @@ SOURCES += lib/IniReader.cpp \
lib/KdePlugin.cpp \
lib/GroupView.cpp \
lib/EntryView.cpp \
lib/FileDialogs.cpp \
crypto/arcfour.cpp \
lib/KpFileIconProvider.cpp \
crypto/aescrypt.c \