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
This commit is contained in:
parent
2b088a31e6
commit
db8ba66067
|
@ -27,6 +27,7 @@
|
||||||
#include <qlineedit.h>
|
#include <qlineedit.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QPainter>
|
||||||
#include "SettingsDlg.h"
|
#include "SettingsDlg.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,14 +35,14 @@ CSettingsDlg::CSettingsDlg(QWidget* parent)
|
||||||
: QDialog(parent,Qt::Dialog)
|
: QDialog(parent,Qt::Dialog)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
connect(ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
|
connect(DialogButtons, SIGNAL( accepted() ), this, SLOT( OnOK() ) );
|
||||||
connect(ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
|
connect(DialogButtons, SIGNAL( rejected() ), this, SLOT( OnCancel() ) );
|
||||||
connect(ButtonColor1, SIGNAL( clicked() ), this, SLOT( OnColor1() ) );
|
connect(ButtonColor1, SIGNAL( clicked() ), this, SLOT( OnColor1() ) );
|
||||||
connect(ButtonColor2, SIGNAL( clicked() ), this, SLOT( OnColor2() ) );
|
connect(ButtonColor2, SIGNAL( clicked() ), this, SLOT( OnColor2() ) );
|
||||||
connect(ButtonTextColor, SIGNAL( clicked() ), this, SLOT( OnTextColor() ) );
|
connect(ButtonTextColor, SIGNAL( clicked() ), this, SLOT( OnTextColor() ) );
|
||||||
connect(CheckBox_OpenLast,SIGNAL(stateChanged(int)),this,SLOT(OnCeckBoxOpenLastChanged(int)));
|
connect(CheckBox_OpenLast,SIGNAL(stateChanged(int)),this,SLOT(OnCeckBoxOpenLastChanged(int)));
|
||||||
connect(Button_MountDirBrowse,SIGNAL(clicked()),this,SLOT(OnMountDirBrowse()));
|
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);
|
CheckBox_OpenLast->setChecked(config.OpenLast);
|
||||||
SpinBox_ClipboardTime->setValue(config.ClipboardTimeOut);
|
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()
|
void CSettingsDlg::OnOK()
|
||||||
{
|
{
|
||||||
config.OpenLast=CheckBox_OpenLast->isChecked();
|
config.OpenLast=CheckBox_OpenLast->isChecked();
|
||||||
|
|
|
@ -17,18 +17,22 @@
|
||||||
* Free Software Foundation, Inc., *
|
* Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "main.h"
|
|
||||||
#ifndef SETTINGSDLG_H
|
#ifndef SETTINGSDLG_H
|
||||||
#define SETTINGSDLG_H
|
#define SETTINGSDLG_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QPaintEvent>
|
||||||
#include "ui_SettingsDlg.h"
|
#include "ui_SettingsDlg.h"
|
||||||
#include <qcolor.h>
|
#include "main.h"
|
||||||
|
|
||||||
class CSettingsDlg : public QDialog, public Ui_SettingsDialog
|
class CSettingsDlg : public QDialog, public Ui_SettingsDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSettingsDlg(QWidget* parent /*, Qt::WFlags fl*/);
|
CSettingsDlg(QWidget* parent);
|
||||||
~CSettingsDlg();
|
~CSettingsDlg();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -41,7 +45,9 @@ public slots:
|
||||||
void OnMountDirBrowse();
|
void OnMountDirBrowse();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual void paintEvent(QPaintEvent*);
|
||||||
QColor color1,color2,textcolor;
|
QColor color1,color2,textcolor;
|
||||||
|
QPixmap BannerPixmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
<ui version="4.0" >
|
<ui version="4.0" >
|
||||||
<author></author>
|
|
||||||
<comment></comment>
|
|
||||||
<exportmacro></exportmacro>
|
|
||||||
<class>SettingsDialog</class>
|
<class>SettingsDialog</class>
|
||||||
<widget class="QDialog" name="SettingsDialog" >
|
<widget class="QDialog" name="SettingsDialog" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
|
@ -30,62 +27,33 @@
|
||||||
<property name="modal" >
|
<property name="modal" >
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QPushButton" name="ButtonCancel" >
|
<layout class="QVBoxLayout" >
|
||||||
<property name="geometry" >
|
<property name="margin" >
|
||||||
<rect>
|
<number>9</number>
|
||||||
<x>470</x>
|
|
||||||
<y>310</y>
|
|
||||||
<width>90</width>
|
|
||||||
<height>23</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
<property name="spacing" >
|
||||||
<string>&Cancel</string>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut" >
|
<item>
|
||||||
<string>Alt+C</string>
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="sizeType" >
|
||||||
<widget class="QLabel" name="Banner" >
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
<property name="geometry" >
|
</property>
|
||||||
<rect>
|
<property name="sizeHint" >
|
||||||
<x>0</x>
|
<size>
|
||||||
<y>0</y>
|
<width>20</width>
|
||||||
<width>570</width>
|
|
||||||
<height>50</height>
|
<height>50</height>
|
||||||
</rect>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="pixmap" >
|
</spacer>
|
||||||
<pixmap/>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
<property name="scaledContents" >
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton" name="ButtonOK" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>380</x>
|
|
||||||
<y>310</y>
|
|
||||||
<width>80</width>
|
|
||||||
<height>23</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>O&K</string>
|
|
||||||
</property>
|
|
||||||
<property name="shortcut" >
|
|
||||||
<string>Alt+K</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QTabWidget" name="tabWidget4" >
|
<widget class="QTabWidget" name="tabWidget4" >
|
||||||
<property name="geometry" >
|
<property name="currentIndex" >
|
||||||
<rect>
|
<number>3</number>
|
||||||
<x>10</x>
|
|
||||||
<y>60</y>
|
|
||||||
<width>550</width>
|
|
||||||
<height>241</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab" >
|
<widget class="QWidget" name="tab" >
|
||||||
<attribute name="title" >
|
<attribute name="title" >
|
||||||
|
@ -97,7 +65,7 @@
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>20</y>
|
<y>20</y>
|
||||||
<width>531</width>
|
<width>531</width>
|
||||||
<height>25</height>
|
<height>31</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
|
@ -483,6 +451,108 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2" >
|
||||||
|
<attribute name="title" >
|
||||||
|
<string>Intergration Plug-ins</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3" >
|
||||||
|
<property name="sizePolicy" >
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>4</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>< some text about plugin usage ></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox" >
|
||||||
|
<property name="sizePolicy" >
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>1</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title" >
|
||||||
|
<string>Plug-Ins</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="radioButton" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>None</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="radioButton_2" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Gnome Desktop Integration (Gtk 2.x)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="radioButton_3" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>KDE 4 Desktop Integration</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="Button_ConfigureDesktopPlugin" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Configure...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="tab" >
|
<widget class="QWidget" name="tab" >
|
||||||
<attribute name="title" >
|
<attribute name="title" >
|
||||||
<string>&Other</string>
|
<string>&Other</string>
|
||||||
|
@ -493,7 +563,7 @@
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>70</y>
|
<y>70</y>
|
||||||
<width>531</width>
|
<width>531</width>
|
||||||
<height>58</height>
|
<height>66</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" >
|
<layout class="QGridLayout" >
|
||||||
|
@ -575,9 +645,20 @@
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="DialogButtons" >
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons" >
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11" />
|
<layoutdefault spacing="6" margin="11" />
|
||||||
<pixmapfunction></pixmapfunction>
|
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>tabWidget4</tabstop>
|
<tabstop>tabWidget4</tabstop>
|
||||||
<tabstop>SpinBox_ClipboardTime</tabstop>
|
<tabstop>SpinBox_ClipboardTime</tabstop>
|
||||||
|
@ -586,8 +667,6 @@
|
||||||
<tabstop>ButtonTextColor</tabstop>
|
<tabstop>ButtonTextColor</tabstop>
|
||||||
<tabstop>ButtonColor2</tabstop>
|
<tabstop>ButtonColor2</tabstop>
|
||||||
<tabstop>CheckBox_OpenLast</tabstop>
|
<tabstop>CheckBox_OpenLast</tabstop>
|
||||||
<tabstop>ButtonOK</tabstop>
|
|
||||||
<tabstop>ButtonCancel</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -33,6 +33,7 @@
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
|
|
||||||
#include "plugins/interfaces/IFileDialog.h"
|
#include "plugins/interfaces/IFileDialog.h"
|
||||||
|
#include "lib/FileDialogs.h"
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "PwmConfig.h"
|
#include "PwmConfig.h"
|
||||||
|
@ -91,15 +92,11 @@ 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");
|
QPluginLoader gtkplugin("/home/tarek/Documents/KeePassX/src/plugins/gnome/libkeepassx-gnome.so");
|
||||||
if(!gtkplugin.load())
|
KpxFileDialogs::setPlugin(qobject_cast<IFileDialog*>(gtkplugin.instance()));
|
||||||
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()){
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "lib/random.h"
|
#include "lib/random.h"
|
||||||
#include "lib/IniReader.h"
|
#include "lib/IniReader.h"
|
||||||
#include "lib/AutoType.h"
|
#include "lib/AutoType.h"
|
||||||
|
#include "lib/FileDialogs.h"
|
||||||
#include "import/Import_PwManager.h"
|
#include "import/Import_PwManager.h"
|
||||||
#include "import/Import_KWalletXml.h"
|
#include "import/Import_KWalletXml.h"
|
||||||
#include "export/Export_Txt.h"
|
#include "export/Export_Txt.h"
|
||||||
|
@ -440,15 +441,18 @@ void KeepassMainWindow::OnFileNewKxdb(){
|
||||||
|
|
||||||
|
|
||||||
void KeepassMainWindow::OnFileOpen(){
|
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.setFilters(QStringList()<< tr("KeePass Databases (*.kdb)")<< tr("All Files (*)"));
|
||||||
FileDlg.setFileMode(QFileDialog::ExistingFile);
|
FileDlg.setFileMode(QFileDialog::ExistingFile);
|
||||||
FileDlg.setAcceptMode(QFileDialog::AcceptOpen);
|
FileDlg.setAcceptMode(QFileDialog::AcceptOpen);
|
||||||
if(!FileDlg.exec())return;
|
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(FileOpen)
|
||||||
if(!closeDatabase())return;
|
if(!closeDatabase())return;
|
||||||
openDatabase(FileDlg.selectedFiles()[0]);
|
openDatabase(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassMainWindow::OnFileClose(){
|
void KeepassMainWindow::OnFileClose(){
|
||||||
|
|
|
@ -20,25 +20,24 @@
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "keepassx-gnome.h"
|
#include "keepassx-gnome.h"
|
||||||
#define CSTRING(x)(x.toUtf8().data())
|
#define CSTR(x)(x.toUtf8().data())
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN2(keepassx_gnome, GnomePlugin)
|
Q_EXPORT_PLUGIN2(keepassx_gnome, GnomePlugin)
|
||||||
|
|
||||||
QString GnomePlugin::openExistingFileDialog(QWidget* parent,QString title,QString dir,
|
QString GnomePlugin::openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters){
|
||||||
QStringList Filters){
|
unsigned int NumFilters=Filters.size();
|
||||||
|
|
||||||
GtkWidget *FileDlg;
|
GtkWidget *FileDlg;
|
||||||
QString filename;
|
QString filename;
|
||||||
gtk_init(0,0);
|
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_FILE_CHOOSER_ACTION_OPEN,
|
||||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
|
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
|
||||||
NULL);
|
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);
|
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]);
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(FileDlg),filters[i]);
|
||||||
}
|
}
|
||||||
if (gtk_dialog_run(GTK_DIALOG(FileDlg)) == GTK_RESPONSE_ACCEPT){
|
if (gtk_dialog_run(GTK_DIALOG(FileDlg)) == GTK_RESPONSE_ACCEPT){
|
||||||
|
@ -52,7 +51,7 @@ QString GnomePlugin::openExistingFileDialog(QWidget* parent,QString title,QStrin
|
||||||
|
|
||||||
GtkFileFilter** GnomePlugin::parseFilterStrings(const QStringList& filters){
|
GtkFileFilter** GnomePlugin::parseFilterStrings(const QStringList& filters){
|
||||||
if(!filters.size())return NULL;
|
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++){
|
for(int i=0;i<filters.size();i++){
|
||||||
f[i]=gtk_file_filter_new();
|
f[i]=gtk_file_filter_new();
|
||||||
QString name;
|
QString name;
|
||||||
|
@ -63,12 +62,13 @@ GtkFileFilter** GnomePlugin::parseFilterStrings(const QStringList& filters){
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gtk_file_filter_set_name(f[i],CSTRING(name));
|
gtk_file_filter_set_name(f[i],CSTR(name));
|
||||||
p++;
|
p++;
|
||||||
QString pattern;
|
QString pattern;
|
||||||
for(p;p<filters[i].size()-1;p++){
|
for(p;p<filters[i].size();p++){
|
||||||
if(filters[i][p]==' '){
|
if(filters[i][p]==' ' || filters[i][p]==')'){
|
||||||
gtk_file_filter_add_pattern(f[i],CSTRING(pattern));
|
gtk_file_filter_add_pattern(f[i],CSTR(pattern));
|
||||||
|
qDebug(CSTR(pattern));
|
||||||
pattern=QString();
|
pattern=QString();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -80,4 +80,34 @@ GtkFileFilter** GnomePlugin::parseFilterStrings(const QStringList& filters){
|
||||||
return f;
|
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:
|
public:
|
||||||
virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
|
virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
|
||||||
QStringList Filters);
|
QStringList Filters);
|
||||||
virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
|
virtual QStringList openExistingFilesDialog(QWidget* parent,QString title,QString dir,
|
||||||
QStringList Filters);
|
QStringList Filters);
|
||||||
|
virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
|
||||||
|
QStringList Filters,bool ShowOverwriteWarning=true);
|
||||||
private:
|
private:
|
||||||
GtkFileFilter** parseFilterStrings(const QStringList &Filters);
|
GtkFileFilter** parseFilterStrings(const QStringList &Filters);
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,12 +20,20 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
#ifndef _I_FILE_DIALOG_H_
|
||||||
|
#define _I_FILE_DIALOG_H_
|
||||||
|
|
||||||
class IFileDialog{
|
class IFileDialog{
|
||||||
public:
|
public:
|
||||||
virtual ~IFileDialog(){}
|
virtual ~IFileDialog(){}
|
||||||
virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
|
virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
|
||||||
QStringList Filters)=0;
|
QStringList Filters)=0;
|
||||||
virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
|
virtual QStringList openExistingFilesDialog(QWidget* parent,QString title,QString dir,
|
||||||
QStringList Filters)=0;
|
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 \
|
Database.h \
|
||||||
lib/KdePlugin.h \
|
lib/KdePlugin.h \
|
||||||
lib/AutoType.h \
|
lib/AutoType.h \
|
||||||
|
lib/FileDialogs.h \
|
||||||
global.h \
|
global.h \
|
||||||
main.h \
|
main.h \
|
||||||
lib/GroupView.h \
|
lib/GroupView.h \
|
||||||
|
@ -118,6 +119,7 @@ SOURCES += lib/IniReader.cpp \
|
||||||
lib/KdePlugin.cpp \
|
lib/KdePlugin.cpp \
|
||||||
lib/GroupView.cpp \
|
lib/GroupView.cpp \
|
||||||
lib/EntryView.cpp \
|
lib/EntryView.cpp \
|
||||||
|
lib/FileDialogs.cpp \
|
||||||
crypto/arcfour.cpp \
|
crypto/arcfour.cpp \
|
||||||
lib/KpFileIconProvider.cpp \
|
lib/KpFileIconProvider.cpp \
|
||||||
crypto/aescrypt.c \
|
crypto/aescrypt.c \
|
||||||
|
|
Loading…
Reference in New Issue