removed some unused files,

made file dialog wrapper use native dialogs again,
fixed password dialog not remembering last key location/type,
disabled precompiled headers when buidling universal binaries,
updated changelog,
fixed size problems of some dialogs


git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@179 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
tarek_saidi
2008-03-11 17:40:31 +00:00
parent ed3baff013
commit 8446ef1f75
19 changed files with 123 additions and 519 deletions

View File

@@ -5,7 +5,6 @@
* 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; version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
@@ -70,40 +69,51 @@ QString KpxFileDialogs::saveFile(QWidget* Parent, const QString& Name, const QSt
return result;
}
QString QtStandardFileDialogs::openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter){
if(SelectedFilter >= Filters.size())
SelectedFilter=0;
QFileDialog FileDlg(parent,title,dir);
FileDlg.setFilters(Filters);
FileDlg.setFileMode(QFileDialog::ExistingFile);
FileDlg.selectFilter(Filters[SelectedFilter]);
if(!FileDlg.exec())return QString();
if(!FileDlg.selectedFiles().size())return QString();
LastFilter=FileDlg.filters().indexOf(FileDlg.selectedFilter());
return FileDlg.selectedFiles()[0];
QString QtStandardFileDialogs::toSingleStringFilter(const QStringList& filterList){
if(!filterList.size())
return QString();
QString SingleString;
for(int i=0;i<filterList.size()-1;i++){
SingleString += filterList[i] + ";;";
}
SingleString += filterList.back();
return SingleString;
}
QStringList QtStandardFileDialogs::openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter){
QFileDialog FileDlg(parent,title,dir);
FileDlg.setFilters(Filters);
FileDlg.setFileMode(QFileDialog::ExistingFiles);
if(!FileDlg.exec())return QStringList();
LastFilter=FileDlg.filters().indexOf(FileDlg.selectedFilter());
return FileDlg.selectedFiles();
}
QString QtStandardFileDialogs::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter, bool ShowOverwriteWarning){
QFileDialog FileDlg(parent,title,dir);
FileDlg.setFilters(Filters);
FileDlg.setFileMode(QFileDialog::AnyFile);
FileDlg.setAcceptMode(QFileDialog::AcceptSave);
FileDlg.setConfirmOverwrite(ShowOverwriteWarning);
if(!FileDlg.exec())return QString();
LastFilter=FileDlg.filters().indexOf(FileDlg.selectedFilter());
QString QtStandardFileDialogs::openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilterIndex){
QString SelectedFilter;
if(SelectedFilterIndex < Filters.size())
SelectedFilter=Filters[SelectedFilterIndex];
QString filename = QFileDialog::getOpenFileName(parent,title,dir,toSingleStringFilter(Filters),&SelectedFilter);
LastFilter=Filters.indexOf(SelectedFilter);
return filename;
}
QStringList QtStandardFileDialogs::openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilterIndex){
QString SelectedFilter;
if(SelectedFilterIndex < Filters.size())
SelectedFilter=Filters[SelectedFilterIndex];
QStringList filenames = QFileDialog::getOpenFileNames(parent,title,dir,toSingleStringFilter(Filters),&SelectedFilter);
LastFilter=Filters.indexOf(SelectedFilter);
return filenames;
}
QString QtStandardFileDialogs::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilterIndex, bool ShowOverwriteWarning){
QString SelectedFilter;
if(SelectedFilterIndex < Filters.size())
SelectedFilter=Filters[SelectedFilterIndex];
QString filepath = QFileDialog::getSaveFileName(parent,title,dir,toSingleStringFilter(Filters),&SelectedFilter,
ShowOverwriteWarning ? (QFileDialog::Option)0 : QFileDialog::DontConfirmOverwrite);
LastFilter=Filters.indexOf(SelectedFilter);
//Check whether the file has an extension which fits to the selected filter
QString filepath=FileDlg.selectedFiles()[0];
QString filename=filepath.right(filepath.length()-filepath.lastIndexOf("/")-1);
QFileInfo file(filepath);
QString filename=file.fileName();
int a=Filters[LastFilter].indexOf('(');
int b=Filters[LastFilter].indexOf(')');
QStringList Extensions=Filters[LastFilter].mid(a+1,b-a-1).split(" ");
@@ -113,10 +123,8 @@ QString QtStandardFileDialogs::saveFileDialog(QWidget* parent,QString title,QStr
for(int i=0;i<Extensions.size();i++)
Extensions[i].remove(0,2); //remove the *. from the extensions
if(filename.contains(".")){
int p=filename.lastIndexOf(".");
QString ext=filename.right(filename.size()-p-1).toLower();
if(Extensions.contains(ext))
if(!file.suffix().isEmpty()){
if(Extensions.contains(file.suffix()))
return filepath;
else
return filepath+"."+Extensions[0];

View File

@@ -39,8 +39,12 @@ class FileDlgHistory:public QObject{
Entry(){Filter=-1;}
QString Dir;
int Filter;
bool isNull(){if(Filter==-1)return true;
else return false;}
bool isNull(){
if(Filter==-1)
return true;
else
return false;
}
};
QHash<QString,Entry>History;
@@ -50,42 +54,39 @@ class FileDlgHistory:public QObject{
class KpxFileDialogs{
public:
static void setPlugin(IFileDialog* FileDlgPlugin);
static QString openExistingFile(QWidget* parent, const QString& Name,
const QString& Title,
const QStringList& Filters,
QString Dir=QString(),
int SelectedFilter=-1);
static QStringList openExistingFiles(QWidget* parent, const QString& Name,
const QString& Title,
const QStringList& Filters,
const QString Dir=QString(),
int SelectedFilter=-1);
static QString saveFile(QWidget* parent, const QString& Name,
const QString& Title,
const QStringList& Filters,
bool ShowOverwriteWarning=true,
QString Dir=QString(),
int SelectedFilter=-1);
static void setPlugin(IFileDialog* FileDlgPlugin);
static QString openExistingFile(QWidget* parent, const QString& Name,
const QString& Title,
const QStringList& Filters,
QString Dir=QString(),
int SelectedFilter=-1);
static QStringList openExistingFiles(QWidget* parent, const QString& Name,
const QString& Title,
const QStringList& Filters,
const QString Dir=QString(),
int SelectedFilter=-1);
static QString saveFile(QWidget* parent, const QString& Name,
const QString& Title,
const QStringList& Filters,
bool ShowOverwriteWarning=true,
QString Dir=QString(),
int SelectedFilter=-1);
private:
static IFileDialog* iFileDialog;
static IFileDialog* iFileDialog;
};
class QtStandardFileDialogs:public QObject,public IFileDialog{
Q_OBJECT
Q_INTERFACES(IFileDialog);
public:
QString openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter);
QStringList openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter);
QString saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter,bool ShowOverwriteWarning);
int getLastFilter();
private:
int LastFilter;
public:
QString openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter);
QStringList openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter);
QString saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter,bool ShowOverwriteWarning);
int getLastFilter();
private:
static QString toSingleStringFilter(const QStringList& filterList);
int LastFilter;
};
extern FileDlgHistory fileDlgHistory;

View File

@@ -1,8 +0,0 @@
#include "KdePlugin.h"
bool CKdePlugin::resolveSymbols(QLibrary& lib){
getAppObj=(QApplication*(*)(int,char**))lib.resolve("getAppObj");
if(getAppObj == NULL) return false;
return true;
}

View File

@@ -1,13 +0,0 @@
#ifndef _KDEPLUGIN_H_
#define _KDEPLUGIN_H_
#include <qlibrary.h>
#include <qapplication.h>
class CKdePlugin{
public:
bool resolveSymbols(QLibrary& lib);
QApplication*(*getAppObj)(int,char**);
};
#endif

View File

@@ -1,19 +0,0 @@
/***************************************************************************
* 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; version 2 of the License. *
* *
* 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. *
***************************************************************************/

View File

@@ -1,28 +0,0 @@
/***************************************************************************
* 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; version 2 of the License. *
* *
* 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 <QFileIconProvider>
#include <QIcon>
class KpFileIconProvider : public QFileIconProvider{
public:
virtual QIcon icon(IconType type) const;
virtual QIcon icon(const QFileInfo& info) const;
};