added 'relative path' option,

fixed missing browser start function,
added option for using the system's default browser.

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@129 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 18 years ago
parent 2b54ded391
commit 88f42dfe6b
  1. 1
      src/StandardDatabase.cpp
  2. 35
      src/dialogs/PasswordDlg.cpp
  3. 130
      src/dialogs/SettingsDlg.cpp
  4. 3
      src/dialogs/SettingsDlg.h
  5. 41
      src/forms/SettingsDlg.ui
  6. 16
      src/lib/EntryView.cpp
  7. 1
      src/lib/EntryView.h
  8. 30
      src/main.cpp
  9. 1
      src/main.h
  10. 37
      src/mainwindow.cpp
  11. 2
      src/mainwindow.h

@ -27,6 +27,7 @@
#include <qdatetime.h> #include <qdatetime.h>
#include <QSysInfo> #include <QSysInfo>
#include <QBuffer> #include <QBuffer>
#include <QDir>
#include "crypto/twoclass.h" #include "crypto/twoclass.h"
#include "crypto/aescpp.h" #include "crypto/aescpp.h"
#include "crypto/sha256.h" #include "crypto/sha256.h"

@ -51,17 +51,18 @@ CPasswordDialog::CPasswordDialog(QWidget* parent,IDatabase* DB,bool ShowExitButt
} }
Combo_Dirs->setEditText(QString()); Combo_Dirs->setEditText(QString());
if(config.RememberLastKey && !ChangeKeyMode){ if(settings->value("RememberLastKey",true).toBool() && !ChangeKeyMode){
switch(config.LastKeyType){ QString LastKeyType=settings->value("LastKeyType","").toString();
//case PASSWORD: setStatePasswordOnly(); break; //Password-Only is already the default if(LastKeyType=="KeyFile"){
case KEYFILE: setStateKeyFileOnly(); setStateKeyFileOnly();
Combo_Dirs->setEditText(config.LastKeyLocation); Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(settings->value("LastKeyFile","").toString())));
break; }
case BOTH: setStateBoth(); else if(LastKeyType=="Composite"){
setStateBoth();
CheckBox_Both->setChecked(true); CheckBox_Both->setChecked(true);
Combo_Dirs->setEditText(config.LastKeyLocation); Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(settings->value("LastKeyFile","").toString())));
break;
} }
// if(LastKeyType==Password){... is not required because it is already the default state.
} }
connect( Combo_Dirs, SIGNAL( editTextChanged(const QString&) ),this, SLOT( OnComboTextChanged(const QString&))); connect( Combo_Dirs, SIGNAL( editTextChanged(const QString&) ),this, SLOT( OnComboTextChanged(const QString&)));
@ -277,9 +278,19 @@ bool CPasswordDialog::doAuth(){
if(!DbAuth->authByFile(keyfile))return false; if(!DbAuth->authByFile(keyfile))return false;
} }
if(config.RememberLastKey){ if(settings->value("RememberLastKey",true).toBool()){
config.LastKeyLocation=keyfile; QString KeyLocation=keyfile;
config.LastKeyType=KeyType; if(settings->value("SaveRelativePaths",true).toBool()){
KeyLocation=KeyLocation.left(KeyLocation.lastIndexOf("/"));
KeyLocation=makePathRelative(KeyLocation,QDir::currentPath())+keyfile.right(keyfile.length()-keyfile.lastIndexOf("/")-1);
}
settings->setValue("LastKeyFile",KeyLocation);
if(KeyType==PASSWORD)
settings->setValue("LastKeyType","Password");
if(KeyType==KEYFILE)
settings->setValue("LastKeyType","KeyFile");
if(KeyType==BOTH)
settings->setValue("LastKeyType","Composite");
} }
return true; return true;

@ -43,18 +43,41 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
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(OnCheckBoxOpenLastChanged(int)));
connect(Button_MountDirBrowse,SIGNAL(clicked()),this,SLOT(OnMountDirBrowse())); connect(Button_MountDirBrowse,SIGNAL(clicked()),this,SLOT(OnMountDirBrowse()));
connect(Radio_IntPlugin_None,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginNone(bool))); connect(Radio_IntPlugin_None,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginNone(bool)));
connect(Radio_IntPlugin_Gnome,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginGnome(bool))); connect(Radio_IntPlugin_Gnome,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginGnome(bool)));
connect(Radio_IntPlugin_Kde,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginKde(bool))); connect(Radio_IntPlugin_Kde,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginKde(bool)));
connect(CheckBox_BrowserDefault,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxBrowserDefaultChanged(int)));
createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width()); createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width());
CheckBox_OpenLast->setChecked(config.OpenLast);
SpinBox_ClipboardTime->setValue(config.ClipboardTimeOut);
//General
CheckBox_OpenLast->setChecked(settings->value("OpenLastFile",true).toBool());
CheckBox_RememberLastKey->setChecked(settings->value("RememberLastKey",true).toBool());
checkBox_ShowSysTrayIcon->setChecked(config.ShowSysTrayIcon);
checkBox_MinimizeToTray->setChecked(config.MinimizeToTray);
checkBox_SaveFileDlgHistory->setChecked(config.SaveFileDlgHistory);
switch(config.GroupTreeRestore){
case 1:
Radio_GroupTreeRestore->setChecked(true);
break;
case 2:
Radio_GroupTreeExpand->setChecked(true);
break;
case 3:
Radio_GroupTreeDoNothing->setChecked(true);
}
if(settings->value("GroupTreeState","ExpandAll")=="ExpandAll")Radio_GroupTreeExpand->setChecked(true);
if(settings->value("GroupTreeState","ExpandAll")=="Restore")Radio_GroupTreeRestore->setChecked(true);
if(settings->value("GroupTreeState","ExpandAll")=="ExpandNone")Radio_GroupTreeDoNothing->setChecked(true);
//Appearance
QPixmap *pxt=new QPixmap(pixmTextColor->width(),pixmTextColor->height()); QPixmap *pxt=new QPixmap(pixmTextColor->width(),pixmTextColor->height());
pxt->fill(config.BannerTextColor); pxt->fill(config.BannerTextColor);
pixmTextColor->clear(); pixmTextColor->clear();
@ -73,28 +96,16 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
color1=config.BannerColor1; color1=config.BannerColor1;
color2=config.BannerColor2; color2=config.BannerColor2;
textcolor=config.BannerTextColor; textcolor=config.BannerTextColor;
CheckBox_AlternatingRowColors->setChecked(config.AlternatingRowColors);
//Security
SpinBox_ClipboardTime->setValue(config.ClipboardTimeOut);
CheckBox_ShowPasswords->setChecked(config.ShowPasswords); CheckBox_ShowPasswords->setChecked(config.ShowPasswords);
CheckBox_ShowPasswords_PasswordDlg->setChecked(config.ShowPasswordsPasswordDlg); CheckBox_ShowPasswords_PasswordDlg->setChecked(config.ShowPasswordsPasswordDlg);
checkBox_ShowSysTrayIcon->setChecked(config.ShowSysTrayIcon);
checkBox_MinimizeToTray->setChecked(config.MinimizeToTray);
checkBox_SaveFileDlgHistory->setChecked(config.SaveFileDlgHistory);
Edit_BrowserCmd->setText(config.OpenUrlCommand);
switch(config.GroupTreeRestore){
case 1:
Radio_GroupTreeRestore->setChecked(true);
break;
case 2:
Radio_GroupTreeExpand->setChecked(true);
break;
case 3:
Radio_GroupTreeDoNothing->setChecked(true);
}
CheckBox_AlternatingRowColors->setChecked(config.AlternatingRowColors);
Edit_MountDir->setText(config.MountDir);
CheckBox_RememberLastKey->setChecked(config.RememberLastKey);
//Desktop Integration
if(PluginLoadError==QString()) if(PluginLoadError==QString())
Label_IntPlugin_Error->hide(); Label_IntPlugin_Error->hide();
else else
@ -106,13 +117,24 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
case CConfig::GNOME: Radio_IntPlugin_Gnome->setChecked(true); break; case CConfig::GNOME: Radio_IntPlugin_Gnome->setChecked(true); break;
case CConfig::KDE: Radio_IntPlugin_Kde->setChecked(true); break; case CConfig::KDE: Radio_IntPlugin_Kde->setChecked(true); break;
} }
if(settings->value("GroupTreeState","ExpandAll")=="ExpandAll")Radio_GroupTreeExpand->setChecked(true);
if(settings->value("GroupTreeState","ExpandAll")=="Restore")Radio_GroupTreeRestore->setChecked(true);
if(settings->value("GroupTreeState","ExpandAll")=="ExpandNone")Radio_GroupTreeDoNothing->setChecked(true);
if(!PluginsModified) if(!PluginsModified)
Label_IntPlugin_Info->hide(); Label_IntPlugin_Info->hide();
//Advanced
QString BrowserCmd=settings->value("BrowserCmd","<<default>>").toString();
if(BrowserCmd=="<<default>>"){
CheckBox_BrowserDefault->setChecked(true);
Edit_BrowserCmd->setDisabled(true);
}
else{
Edit_BrowserCmd->setText(BrowserCmd);
CheckBox_BrowserDefault->setChecked(false);
}
Edit_MountDir->setText(config.MountDir);
CheckBox_SaveRelativePaths->setChecked(settings->value("SaveRelativePaths",true).toBool());
} }
CSettingsDlg::~CSettingsDlg() CSettingsDlg::~CSettingsDlg()
@ -126,7 +148,15 @@ void CSettingsDlg::paintEvent(QPaintEvent *event){
painter.drawPixmap(QPoint(0,0),BannerPixmap); painter.drawPixmap(QPoint(0,0),BannerPixmap);
} }
void CSettingsDlg::OnCheckBoxBrowserDefaultChanged(int state){
if(state==Qt::Checked){
Edit_BrowserCmd->setDisabled(true);
Edit_BrowserCmd->setText("");
}
else{
Edit_BrowserCmd->setDisabled(false);
}
}
void CSettingsDlg::OnOK() void CSettingsDlg::OnOK()
{ {
@ -145,36 +175,46 @@ void CSettingsDlg::OnOtherButton(QAbstractButton* button){
} }
void CSettingsDlg::apply(){ void CSettingsDlg::apply(){
config.OpenLast=CheckBox_OpenLast->isChecked();
config.ClipboardTimeOut=SpinBox_ClipboardTime->value(); //General
config.BannerColor1=color1;
config.BannerColor2=color2;
config.BannerTextColor=textcolor;
config.ShowPasswords=CheckBox_ShowPasswords->isChecked();
config.ShowPasswordsPasswordDlg=CheckBox_ShowPasswords_PasswordDlg->isChecked();
config.OpenUrlCommand=Edit_BrowserCmd->text();
config.AlternatingRowColors=CheckBox_AlternatingRowColors->isChecked();
config.MountDir=Edit_MountDir->text();
config.ShowSysTrayIcon=checkBox_ShowSysTrayIcon->isChecked(); config.ShowSysTrayIcon=checkBox_ShowSysTrayIcon->isChecked();
config.MinimizeToTray=checkBox_MinimizeToTray->isChecked(); config.MinimizeToTray=checkBox_MinimizeToTray->isChecked();
config.SaveFileDlgHistory=checkBox_SaveFileDlgHistory->isChecked(); config.SaveFileDlgHistory=checkBox_SaveFileDlgHistory->isChecked();
config.EnableBookmarkMenu=checkBox_EnableBookmarkMenu->isChecked(); config.EnableBookmarkMenu=checkBox_EnableBookmarkMenu->isChecked();
if(Radio_GroupTreeRestore->isChecked())config.GroupTreeRestore=0; if(Radio_GroupTreeRestore->isChecked())config.GroupTreeRestore=0;
if(Radio_GroupTreeExpand->isChecked())config.GroupTreeRestore=1; if(Radio_GroupTreeExpand->isChecked())config.GroupTreeRestore=1;
if(Radio_GroupTreeDoNothing->isChecked())config.GroupTreeRestore=2; if(Radio_GroupTreeDoNothing->isChecked())config.GroupTreeRestore=2;
settings->setValue("OpenLastFile",CheckBox_OpenLast->isChecked());
settings->setValue("RememberLastKey",CheckBox_RememberLastKey->isChecked());
if(Radio_GroupTreeExpand->isChecked())settings->setValue("GroupTreeState","ExpandAll");
if(Radio_GroupTreeDoNothing->isChecked())settings->setValue("GroupTreeState","ExpandNone");
if(Radio_GroupTreeRestore->isChecked())settings->setValue("GroupTreeState","Restore");
if(config.MountDir!="" && config.MountDir.right(1)!="/") //Appearence
config.MountDir+="/"; config.BannerColor1=color1;
config.RememberLastKey=CheckBox_RememberLastKey->isChecked(); config.BannerColor2=color2;
config.BannerTextColor=textcolor;
config.AlternatingRowColors=CheckBox_AlternatingRowColors->isChecked();
//Security
config.ClipboardTimeOut=SpinBox_ClipboardTime->value();
config.ShowPasswords=CheckBox_ShowPasswords->isChecked();
config.ShowPasswordsPasswordDlg=CheckBox_ShowPasswords_PasswordDlg->isChecked();
//Desktop Integration
PluginsModified=Label_IntPlugin_Info->isVisible(); PluginsModified=Label_IntPlugin_Info->isVisible();
if(Radio_IntPlugin_None->isChecked())config.IntegrPlugin=CConfig::NONE; if(Radio_IntPlugin_None->isChecked())config.IntegrPlugin=CConfig::NONE;
if(Radio_IntPlugin_Gnome->isChecked())config.IntegrPlugin=CConfig::GNOME; if(Radio_IntPlugin_Gnome->isChecked())config.IntegrPlugin=CConfig::GNOME;
if(Radio_IntPlugin_Kde->isChecked())config.IntegrPlugin=CConfig::KDE; if(Radio_IntPlugin_Kde->isChecked())config.IntegrPlugin=CConfig::KDE;
if(Radio_GroupTreeExpand->isChecked())settings->setValue("GroupTreeState","ExpandAll"); //Advanced
if(Radio_GroupTreeDoNothing->isChecked())settings->setValue("GroupTreeState","ExpandNone"); config.OpenUrlCommand=Edit_BrowserCmd->text();
if(Radio_GroupTreeRestore->isChecked())settings->setValue("GroupTreeState","Restore"); config.MountDir=Edit_MountDir->text();
if(config.MountDir!="" && config.MountDir.right(1)!="/")
config.MountDir+="/";
if(CheckBox_BrowserDefault->isChecked())settings->setValue("BrowserCmd","<<default>>");
else settings->setValue("BrowserCmd",Edit_BrowserCmd->text());
settings->setValue("SaveRelativePaths",CheckBox_SaveRelativePaths->isChecked());
} }
@ -219,7 +259,7 @@ void CSettingsDlg::OnColor1()
} }
} }
void CSettingsDlg::OnCeckBoxOpenLastChanged(int state){ void CSettingsDlg::OnCheckBoxOpenLastChanged(int state){
if(state==Qt::Checked){ if(state==Qt::Checked){
CheckBox_RememberLastKey->setEnabled(true); CheckBox_RememberLastKey->setEnabled(true);
}else{ }else{

@ -45,7 +45,8 @@ class CSettingsDlg : public QDialog, public Ui_SettingsDialog
void OnIntPluginNone(bool); void OnIntPluginNone(bool);
void OnIntPluginGnome(bool); void OnIntPluginGnome(bool);
void OnIntPluginKde(bool); void OnIntPluginKde(bool);
void OnCeckBoxOpenLastChanged(int state); void OnCheckBoxOpenLastChanged(int state);
void OnCheckBoxBrowserDefaultChanged(int state);
void OnMountDirBrowse(); void OnMountDirBrowse();
private: private:

@ -893,6 +893,9 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" >
<widget class="QLineEdit" name="Edit_MountDir" />
</item>
<item row="1" column="0" > <item row="1" column="0" >
<widget class="QLabel" name="label_2" > <widget class="QLabel" name="label_2" >
<property name="text" > <property name="text" >
@ -907,18 +910,46 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" >
<widget class="QLineEdit" name="Edit_MountDir" />
</item>
<item row="0" column="1" > <item row="0" column="1" >
<widget class="QLineEdit" name="Edit_BrowserCmd" /> <widget class="QLineEdit" name="Edit_BrowserCmd" />
</item> </item>
<item row="1" column="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2" colspan="2" >
<widget class="QCheckBox" name="CheckBox_BrowserDefault" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>System Default</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBox_VerifyAfterSaving" > <widget class="QCheckBox" name="CheckBox_SaveRelativePaths" >
<property name="text" > <property name="text" >
<string>Verify database content and structure after saving</string> <string>Save relative paths</string>
</property> </property>
</widget> </widget>
</item> </item>

@ -264,19 +264,12 @@ void KeepassEntryView::OnNewEntry(){
} }
void KeepassEntryView::OnEntryActivated(QTreeWidgetItem* item,int Column){ void KeepassEntryView::OnEntryActivated(QTreeWidgetItem* item,int Column){
int i=0; switch(columnListIndex(Column)){
int c=-1;
for(i;i<NUM_COLUMNS;i++){
if(config.Columns[i])c++;
if(c==Column)break;
}
if(c==-1)return;
switch(i){
case 0: editEntry((EntryViewItem*)item); case 0: editEntry((EntryViewItem*)item);
break; break;
case 1: OnUsernameToClipboard(); case 1: OnUsernameToClipboard();
break; break;
case 2: //OnEditOpenUrl(); case 2: OnEditOpenUrl();
break; break;
case 3: OnPasswordToClipboard(); case 3: OnPasswordToClipboard();
break; break;
@ -289,6 +282,11 @@ void KeepassEntryView::OnEditEntry(){
editEntry((EntryViewItem*)selectedItems()[0]); editEntry((EntryViewItem*)selectedItems()[0]);
} }
void KeepassEntryView::OnEditOpenUrl(){
Q_ASSERT(selectedItems().size()==1);
openBrowser(((EntryViewItem*)selectedItems()[0])->text(logicalColIndex(2)));
}
void KeepassEntryView::OnUsernameToClipboard(){ void KeepassEntryView::OnUsernameToClipboard(){
Clipboard->setText(((EntryViewItem*)selectedItems()[0])->EntryHandle->username(), QClipboard::Clipboard); Clipboard->setText(((EntryViewItem*)selectedItems()[0])->EntryHandle->username(), QClipboard::Clipboard);
ClipboardTimer.setSingleShot(true); ClipboardTimer.setSingleShot(true);

@ -94,6 +94,7 @@ class KeepassEntryView:public QTreeWidget{
void OnAutoType(); void OnAutoType();
void removeDragItems(); void removeDragItems();
void OnColumnMoved(int LogIndex,int OldVisIndex,int NewVisIndex); void OnColumnMoved(int LogIndex,int OldVisIndex,int NewVisIndex);
void OnEditOpenUrl();
signals: signals:
void fileModified(); void fileModified();
void selectionChanged(SelectionState); void selectionChanged(SelectionState);

@ -31,6 +31,8 @@
#include <QProcess> #include <QProcess>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QPluginLoader> #include <QPluginLoader>
#include <QDesktopServices>
#include <QUrl>
#include "plugins/interfaces/IFileDialog.h" #include "plugins/interfaces/IFileDialog.h"
#include "plugins/interfaces/IKdeInit.h" #include "plugins/interfaces/IKdeInit.h"
@ -280,11 +282,19 @@ QString decodeFileError(QFile::FileError Code){
} }
} }
void openBrowser(QString url){ void openBrowser(QString UrlString){
QStringList args=config.OpenUrlCommand.arg(url).split(' '); QUrl url(UrlString);
if(url.scheme().isEmpty())
url=QUrl("http://"+UrlString);
if(settings->value("BrowserCmd","<<default>>").toString() == "<<default>>"){
QDesktopServices::openUrl(url);
}
else{
QStringList args=settings->value("BrowserCmd","<<default>>").toString().arg(url.toString()).split(' ');
QString cmd=args.takeFirst(); QString cmd=args.takeFirst();
QProcess::startDetached(cmd,args); QProcess::startDetached(cmd,args);
} }
}
void loadImg(QString name,QPixmap& Img){ void loadImg(QString name,QPixmap& Img){
@ -427,3 +437,19 @@ QString findPlugin(const QString& filename){
return QString(); return QString();
} }
QString makePathRelative(const QString& AbsDir,const QString& CurDir){
QStringList abs=AbsDir.split('/');
QStringList cur=CurDir.split('/');
QString rel="./";
int common=0;
for(common; common < abs.size() && common < cur.size(); common++){
if(abs[common]!=cur[common])break;
}
for(int i=0;i<cur.size()-common;i++)
rel.append("../");
for(int i=common;i<abs.size();i++)
rel.append(abs[i]+"/");
return rel;
}

@ -41,6 +41,7 @@ void openBrowser(QString url);
void showErrMsg(const QString& msg,QWidget* parent=NULL); void showErrMsg(const QString& msg,QWidget* parent=NULL);
QString decodeFileError(QFile::FileError Code); QString decodeFileError(QFile::FileError Code);
QString findPlugin(const QString& filename); QString findPlugin(const QString& filename);
QString makePathRelative(const QString& Abs,const QString& Cur);
extern QString PluginLoadError; extern QString PluginLoadError;
extern CConfig config; extern CConfig config;

@ -91,16 +91,16 @@ KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,QWidget *parent, Qt:
setupConnections(); setupConnections();
FileOpen=false; FileOpen=false;
if(ArgFile!=QString()) if(ArgFile!=QString())
openDatabase(ArgFile,false); openDatabase(QDir::cleanPath(QDir::current().absoluteFilePath(ArgFile)),false);
else if(config.OpenLast && (config.LastFile!=QString()) ){ else if(settings->value("OpenLastFile",true).toBool() && (settings->value("LastFile","").toString()!=QString())){
QFileInfo file(config.LastFile); QFileInfo file(settings->value("LastFile","").toString());
if(file.exists()) if(file.exists())
openDatabase(config.LastFile,true); openDatabase(QDir::cleanPath(QDir::current().absoluteFilePath(settings->value("LastFile","").toString())),true);
else else
config.LastFile=QString(); settings->setValue("LastFile","");
} }
/*
//dbusServer=new QDBusServer("unix:path=/tmp/KpxBus",this); //dbusServer=new QDBusServer("unix:path=/tmp/KpxBus",this);
//qDebug("DBUS: %s",dbusServer->lastError().message().toAscii().data()); //qDebug("DBUS: %s",dbusServer->lastError().message().toAscii().data());
//QDBusConnection::connectToBus("unix:path=/tmp/KpxBus","MyKpxConnection"); //QDBusConnection::connectToBus("unix:path=/tmp/KpxBus","MyKpxConnection");
@ -111,6 +111,7 @@ KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,QWidget *parent, Qt:
QDBusConnection::sessionBus().registerService("org.keepassx.firefoxservice"); QDBusConnection::sessionBus().registerService("org.keepassx.firefoxservice");
QDBusConnection::sessionBus().registerObject("/KpxFirefox",fox); QDBusConnection::sessionBus().registerObject("/KpxFirefox",fox);
qDebug("DBUS: %s",QDBusConnection::sessionBus().lastError().message().toAscii().data()); qDebug("DBUS: %s",QDBusConnection::sessionBus().lastError().message().toAscii().data());
*/
} }
@ -135,7 +136,7 @@ void KeepassMainWindow::setupConnections(){
connect(EditDeleteEntryAction, SIGNAL(triggered()), EntryView, SLOT(OnDeleteEntry())); connect(EditDeleteEntryAction, SIGNAL(triggered()), EntryView, SLOT(OnDeleteEntry()));
connect(EditUsernameToClipboardAction, SIGNAL(triggered()), EntryView, SLOT(OnUsernameToClipboard())); connect(EditUsernameToClipboardAction, SIGNAL(triggered()), EntryView, SLOT(OnUsernameToClipboard()));
connect(EditPasswordToClipboardAction, SIGNAL(triggered()), EntryView, SLOT(OnPasswordToClipboard())); connect(EditPasswordToClipboardAction, SIGNAL(triggered()), EntryView, SLOT(OnPasswordToClipboard()));
connect(EditOpenUrlAction, SIGNAL(triggered()), this, SLOT(OnEditOpenUrl())); connect(EditOpenUrlAction, SIGNAL(triggered()), EntryView, SLOT(OnEditOpenUrl()));
connect(EditSaveAttachmentAction, SIGNAL(triggered()),EntryView, SLOT(OnSaveAttachment())); connect(EditSaveAttachmentAction, SIGNAL(triggered()),EntryView, SLOT(OnSaveAttachment()));
connect(EditSearchAction, SIGNAL(triggered()), this, SLOT(OnSearch())); connect(EditSearchAction, SIGNAL(triggered()), this, SLOT(OnSearch()));
connect(EditGroupSearchAction, SIGNAL(triggered()), this, SLOT(OnGroupSearch())); connect(EditGroupSearchAction, SIGNAL(triggered()), this, SLOT(OnGroupSearch()));
@ -340,7 +341,7 @@ void KeepassMainWindow::openDatabase(QString filename,bool IsAuto){
QString err; QString err;
StatusBarGeneral->setText(tr("Loading Database...")); StatusBarGeneral->setText(tr("Loading Database..."));
if(db->load(filename)==true){ if(db->load(filename)==true){
if(config.OpenLast)config.LastFile=filename; saveLastFilename(filename);
setWindowTitle(tr("%1 - KeePassX").arg(filename)); setWindowTitle(tr("%1 - KeePassX").arg(filename));
GroupView->createItems(); GroupView->createItems();
EntryView->showGroup(NULL); EntryView->showGroup(NULL);
@ -639,7 +640,7 @@ else Q_ASSERT(false);
bool KeepassMainWindow::OnFileSave(){ bool KeepassMainWindow::OnFileSave(){
if(!db->file()) if(!db->file())
return OnFileSaveAs(); return OnFileSaveAs();
config.LastFile=db->file()->fileName(); saveLastFilename(db->file()->fileName());
if(db->save()) if(db->save())
setStateFileModified(false); setStateFileModified(false);
else{ else{
@ -724,10 +725,6 @@ for(int i=0; i<SearchResults.size();i++){
} }
void KeepassMainWindow::OnEditOpenUrl(){
//openBrowser(currentEntry()->URL);
}
void KeepassMainWindow::search(IGroupHandle* group){ void KeepassMainWindow::search(IGroupHandle* group){
CSearchDlg dlg(db,group,this,"SearchDialog",false); CSearchDlg dlg(db,group,this,"SearchDialog",false);
if(dlg.exec()){ if(dlg.exec()){
@ -886,3 +883,17 @@ void KeepassMainWindow::OnExtrasPasswordGen(){
CGenPwDialog dlg(this,true); CGenPwDialog dlg(this,true);
dlg.exec(); dlg.exec();
} }
void KeepassMainWindow::saveLastFilename(const QString& filename){
if(settings->value("OpenLastFile",true).toBool()){
if(settings->value("SaveRelativePath",true).toBool()){
QString Path=filename.left(filename.lastIndexOf("/"));
Path=makePathRelative(Path,QDir::currentPath());
settings->setValue("LastFile",Path+filename.right(filename.length()-filename.lastIndexOf("/")-1));
}
else
settings->setValue("LastFile",filename);
}
}

@ -67,7 +67,6 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
void OnFileSettings(); void OnFileSettings();
void OnFileChangeKey(); void OnFileChangeKey();
void OnFileExit(); void OnFileExit();
void OnEditOpenUrl();
void OnSearch(); void OnSearch();
void OnGroupSearch(); void OnGroupSearch();
void OnViewShowToolbar(bool); void OnViewShowToolbar(bool);
@ -113,6 +112,7 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
void removeFromSearchResults(int sID); void removeFromSearchResults(int sID);
void updateDetailView(); void updateDetailView();
void exportDatabase(IExport* exporter,QStringList filters); void exportDatabase(IExport* exporter,QStringList filters);
void saveLastFilename(const QString& filename);
QLineEdit* QuickSearchEdit; QLineEdit* QuickSearchEdit;
QLabel* StatusBarGeneral; QLabel* StatusBarGeneral;
QLabel* StatusBarSelection; QLabel* StatusBarSelection;