Bookmarks

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@146 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
tarek_saidi
2007-08-16 20:43:48 +00:00
parent 13c5615698
commit 65e5da4649
32 changed files with 1173 additions and 363 deletions

View File

@@ -1,11 +1,10 @@
/***************************************************************************
* Copyright (C) 2005-2006 by Tarek Saidi *
* Copyright (C) 2005-2007 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 *
@@ -48,18 +47,18 @@ AboutDialog::AboutDialog(QWidget* parent):QDialog(parent)
QString str;
str+="<b>"+tr("Team")+"</b><br>";
str+="<div style='margin-left:10px;'>";
str+="<u>"+tr("Tarek Saidi")+"</u><br>"+tr("Developer, Project Admin")+"<br>"+tr("tariq@users.berlios.de")+"<br>";
str+="<u>"+tr("Tarek Saidi")+"</u><br>"+tr("Developer, Project Admin")+"<br>"+tr("tarek_saidi@users.sf.net")+"<br>";
str+="<br>";
str+="<u>"+tr("Eugen Gorschenin")+"</u><br>"+tr("Web Designer")+"<br>"+tr("geugen@users.berlios.de")+"<br>";
str+="<u>"+tr("Eugen Gorschenin")+"</u><br>"+tr("Web Designer")+"<br>"+tr("geugen@users.sf.de")+"<br>";
str+="<br>";
str+="<u>"+tr("Jota Jota")+"</u><br>"+tr("Developer")+"<br>"+tr("myxself@users.sf.de")+"<br>";
str+="</div><br><div style='margin-left:0px;'>";
str+="<b>"+tr("Thanks To")+"</b>";
str+="</div><div style='margin-left:10px;'>";
str+="<u>"+tr("Matthias Miller")+"</u><br>"+tr("Patches for better MacOS X support")+"<br>"+tr("www.outofhanwell.com")+"<br></div>";
str+="<br>";
str+="</div><div style='margin-left:10px;'>";
str+="<u>"+tr("James Nicholls")+"</u><br>"+tr("Main Application Icon")/*+"<br>"+tr("mailto:???")*/+"<br></div>";
str+="<br>";
str+="</div><div style='margin-left:10px;'>";
str+="<u>"+tr("Constantin Makshin")+"</u><br>"+tr("Various fixes and improvements")+"<br>"+tr("dinosaur-rus@users.sourceforge.net")+"<br></div>";
Edit_Thanks->setHtml(str);
}

View File

@@ -0,0 +1,58 @@
/***************************************************************************
* Copyright (C) 2007 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 <QFileInfo>
#include "AddBookmarkDlg.h"
#include "lib/FileDialogs.h"
#include "lib/bookmarks.h"
AddBookmarkDlg::AddBookmarkDlg(QWidget* parent, QString DefaultFilename, int _ItemID):QDialog(parent)
{
setupUi(this);
ItemID=_ItemID;
connect(Button_Browse,SIGNAL(clicked()),this,SLOT(OnButtonBrowse()));
connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),this,SLOT(OnButtonOk()));
connect(buttonBox->button(QDialogButtonBox::Cancel),SIGNAL(clicked()),this,SLOT(reject()));
if(ItemID==-1){
if(DefaultFilename==QString())
OnButtonBrowse();
else
Edit_Filename->setText(DefaultFilename);
}
else {
Edit_Title->setText(KpxBookmarks::title(ItemID));
Edit_Filename->setText(KpxBookmarks::path(ItemID));
setWindowTitle(tr("Edit Bookmark"));
}
}
void AddBookmarkDlg::OnButtonBrowse(){
QString path=KpxFileDialogs::openExistingFile(this,"AddBookmarkDlg", tr("Add Bookmark"),
QStringList() << tr("KeePass Databases (*.kdb)") << tr("All Files (*)"));
if(path!=QString())
Edit_Filename->setText(path);
}
void AddBookmarkDlg::OnButtonOk(){
if(ItemID==-1)
ItemID=KpxBookmarks::add(Edit_Title->text(),Edit_Filename->text());
else
KpxBookmarks::edit(Edit_Title->text(),Edit_Filename->text(),ItemID);
accept();
}

View File

@@ -0,0 +1,41 @@
/***************************************************************************
* Copyright (C) 2007 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. *
***************************************************************************/
#ifndef _ADDBOOKMARKDLG_H_
#define _ADDBOOKMARKDLG_H_
#include <QDialog>
#include "ui_AddBookmarkDlg.h"
class AddBookmarkDlg : public QDialog, private Ui::AddBookmarkDlg
{
Q_OBJECT
public:
AddBookmarkDlg (QWidget* parent=0, QString DefaultFilename=QString(), int ItemID=-1);
int ItemID;
private slots:
void OnButtonOk();
void OnButtonBrowse();
};
#endif

View File

@@ -37,6 +37,7 @@
#include <qtoolbutton.h>
#include <QShowEvent>
#include <QResizeEvent>
#include <math.h>
#include "SelectIconDlg.h"
#include "PasswordGenDlg.h"
@@ -348,27 +349,27 @@ void CEditEntryDlg::OnNewAttachment()
int prec;
if (entry->binarySize() < 1024)
{
unit = "Bytes";
unit = tr("Bytes");
faktor = 1;
prec = 0;
}
else
{
if (entry->binarySize() < 1048576)
if (entry->binarySize() < pow(2,20))
{
unit = "kB";
unit = tr("kiB");
faktor = 1024;
}
else
if (entry->binarySize() < 1073741824)
if (entry->binarySize() < pow(2,30))
{
unit = "MB";
faktor = 1048576;
unit = tr("MiB");
faktor = pow(2,20);
}
else
{
unit = "GB";
faktor = 1073741824;
unit = tr("GiB");
faktor = pow(2,30);
}
prec = 1;
}

View File

@@ -0,0 +1,117 @@
/***************************************************************************
* Copyright (C) 2007 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 <QListWidget>
#include "main.h"
#include "ManageBookmarksDlg.h"
#include "lib/bookmarks.h"
#include "dialogs/AddBookmarkDlg.h"
ManageBookmarksDlg::ManageBookmarksDlg(QWidget* parent):QDialog(parent)
{
setupUi(this);
for(int i=0;i<KpxBookmarks::count();i++){
QListWidgetItem* item=new QListWidgetItem(ListWidget);
item->setData(Qt::UserRole,i);
item->setText(KpxBookmarks::title(i));
}
connect(Button_Up,SIGNAL(clicked()),this,SLOT(OnButtonUp()));
connect(Button_Down,SIGNAL(clicked()),this,SLOT(OnButtonDown()));
connect(Button_Delete,SIGNAL(clicked()),this,SLOT(OnButtonDelete()));
connect(Button_Add,SIGNAL(clicked()),this,SLOT(OnButtonAdd()));
connect(Button_Edit,SIGNAL(clicked()),this,SLOT(OnButtonEdit()));
connect(ListWidget,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(edit(QListWidgetItem*)));
connect(buttonBox->button(QDialogButtonBox::Close),SIGNAL(clicked()),this,SLOT(close()));
Button_Up->setIcon(getIcon("up"));
Button_Down->setIcon(getIcon("down"));
Button_Delete->setIcon(getIcon("delete"));
Button_Edit->setIcon(getIcon("bookmark_edit"));
Button_Add->setIcon(getIcon("bookmark_add"));
}
void ManageBookmarksDlg::OnButtonUp(){
int row=ListWidget->currentRow();
QListWidgetItem* item=ListWidget->currentItem();
if(row==-1 || !item || row==0)return;
ListWidget->takeItem(row);
row--;
ListWidget->insertItem(row,item);
ListWidget->setCurrentRow(row);
}
void ManageBookmarksDlg::OnButtonDown(){
int row=ListWidget->currentRow();
QListWidgetItem* item=ListWidget->currentItem();
if(row==-1 || !item || row==ListWidget->count()-1)return;
ListWidget->takeItem(row);
row++;
ListWidget->insertItem(row,item);
ListWidget->setCurrentRow(row);
}
void ManageBookmarksDlg::OnButtonDelete(){
QListWidgetItem* item=ListWidget->currentItem();
if(!item)return;
int index=item->data(Qt::UserRole).toInt();
KpxBookmarks::remove(index);
delete item;
for(int i=0;i<ListWidget->count();i++){
int itemindex=ListWidget->item(i)->data(Qt::UserRole).toInt();
if(itemindex>index)
ListWidget->item(i)->setData(Qt::UserRole,itemindex-1);
}
}
void ManageBookmarksDlg::OnButtonEdit(){
QListWidgetItem* item=ListWidget->currentItem();
if(!item)return;
edit(item);
}
void ManageBookmarksDlg::edit(QListWidgetItem* item){
int i=item->data(Qt::UserRole).toInt();
AddBookmarkDlg dlg(this,QString(),i);
dlg.exec();
item->setText(KpxBookmarks::title(i));
}
void ManageBookmarksDlg::OnButtonAdd(){
AddBookmarkDlg dlg(this);
if(dlg.exec()){
int i=dlg.ItemID;
QListWidgetItem* item=new QListWidgetItem(ListWidget);
item->setData(Qt::UserRole,i);
item->setText(KpxBookmarks::title(i));
}
return;
}
void ManageBookmarksDlg::closeEvent(QCloseEvent * event){
QList<int> Order;
// Creating a list with the new indices
// Order[OldIndex]==NewIndex
for(int i=0;i<KpxBookmarks::count();i++){
Order<<ListWidget->item(i)->data(Qt::UserRole).toInt();
}
KpxBookmarks::resort(Order);
event->accept();
}

View File

@@ -0,0 +1,44 @@
/***************************************************************************
* Copyright (C) 2007 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. *
***************************************************************************/
#ifndef MANAGEBOOKMARKSDLG_H
#define MANAGEBOOKMARKSDLG_H
#include <QDialog>
#include <QCloseEvent>
#include "ui_ManageBookmarksDlg.h"
class ManageBookmarksDlg : public QDialog, private Ui::ManageBookmarksDlg
{
Q_OBJECT
public:
ManageBookmarksDlg(QWidget* parent=0);
private:
virtual void closeEvent(QCloseEvent* event);
private slots:
void OnButtonUp();
void OnButtonDown();
void OnButtonDelete();
void OnButtonAdd();
void OnButtonEdit();
void edit(QListWidgetItem*);
};
#endif

View File

@@ -1,11 +1,10 @@
/***************************************************************************
* Copyright (C) 2005-2006 by Tarek Saidi *
* Copyright (C) 2005-2007 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 *
@@ -27,26 +26,31 @@
#include <QPushButton>
#include <QMessageBox>
#include <QStringList>
#include <QPainter>
#include <QPalette>
#include <QMenu>
#include "main.h"
#include "KpxConfig.h"
#include "PasswordDlg.h"
#include "lib/FileDialogs.h"
#include "lib/bookmarks.h"
CPasswordDialog::CPasswordDialog(QWidget* parent,IDatabase* DB,bool ShowExitButton,bool ChangeKeyMode)
CPasswordDialog::CPasswordDialog(QWidget* parent,QString filename,IDatabase* DB,bool IsAuto,bool ChangeKeyMode)
: QDialog(parent)
{
setupUi(this);
createBanner(Banner,getPixmap("key"),tr("Database Key"));
createBanner(&BannerPixmap,getPixmap("key"),tr("Database Key"),width());
Button_Bookmarks->setIcon(getIcon("bookmark"));
db=DB;
LastFile=filename;
setWindowTitle(LastFile);
QString mountDir=config->mountDir();
QDir media(mountDir);
if(media.exists()){
QStringList Paths;
Paths=media.entryList(QStringList()<<"*",QDir::Dirs);
Paths.erase(Paths.begin()); // delete "."
Paths.erase(Paths.begin()); // delete ".."
Paths=media.entryList(QStringList()<<"*",QDir::Dirs | QDir::NoDotAndDotDot);
for(int i=0;i<Paths.count();i++)
Combo_Dirs->addItem(mountDir+Paths[i]);
}
@@ -66,17 +70,47 @@ CPasswordDialog::CPasswordDialog(QWidget* parent,IDatabase* DB,bool ShowExitButt
}
// if(LastKeyType==Password){... is not required because it is already the default state.
}
// Bookmarks //
QPalette palette=Button_Bookmarks->palette();
palette.setColor(QPalette::Active,QPalette::Button,config->bannerColor1());
palette.setColor(QPalette::Active,QPalette::Window,config->bannerColor2());
Button_Bookmarks->setPalette(palette);
palette=Label_Bookmark->palette();
palette.setColor(QPalette::Active,QPalette::WindowText,config->bannerTextColor());
Label_Bookmark->setPalette(palette);
QMenu* BookmarkMenu=new QMenu(this);
QAction* action=new QAction(this);
action->setData(QString());
action->setText(tr("Last File"));
action->setIcon(getIcon("document"));
BookmarkMenu->addAction(action);
BookmarkMenu->addSeparator();
for(int i=0;i<KpxBookmarks::count();i++){
QAction* action=new QAction(this);
action->setData(KpxBookmarks::path(i));
action->setText(KpxBookmarks::title(i));
action->setIcon(getIcon("document"));
BookmarkMenu->addAction(action);
}
Button_Bookmarks->setMenu(BookmarkMenu);
if(!IsAuto || !config->featureBookmarks()){
Button_Bookmarks->hide();
Label_Bookmark->hide();
}
connect(Combo_Dirs, SIGNAL( editTextChanged(const QString&) ),this, SLOT( OnComboTextChanged(const QString&)));
connect(ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
connect(Edit_Password, SIGNAL( textChanged(const QString&) ), this, SLOT( OnPasswordChanged(const QString&) ) );
connect(CheckBox_Both, SIGNAL( stateChanged(int) ), this, SLOT( OnCheckBox_BothChanged(int) ) );
connect(ButtonChangeEchoMode, SIGNAL( clicked() ), this, SLOT( ChangeEchoModeDatabaseKey() ) );
connect(Edit_Password, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) );
connect(Edit_PasswordRep, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) );
connect(ButtonExit, SIGNAL( clicked()),this,SLOT(OnButtonExit()));
connect(BookmarkMenu,SIGNAL(triggered(QAction*)),this,SLOT(OnBookmarkTriggered(QAction*)));
connect( Combo_Dirs, SIGNAL( editTextChanged(const QString&) ),this, SLOT( OnComboTextChanged(const QString&)));
connect( ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
connect( Edit_Password, SIGNAL( textChanged(const QString&) ), this, SLOT( OnPasswordChanged(const QString&) ) );
connect( CheckBox_Both, SIGNAL( stateChanged(int) ), this, SLOT( OnCheckBox_BothChanged(int) ) );
connect( ButtonChangeEchoMode, SIGNAL( clicked() ), this, SLOT( ChangeEchoModeDatabaseKey() ) );
connect( Edit_Password, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) );
connect( Edit_PasswordRep, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) );
connect( ButtonExit, SIGNAL( clicked()),this,SLOT(OnButtonExit()));
ButtonExit->setVisible(ShowExitButton);
ButtonExit->setVisible(IsAuto);
Mode_Set=ChangeKeyMode;
if(!ChangeKeyMode){
Edit_PasswordRep->hide();
@@ -342,3 +376,18 @@ void CPasswordDialog::OnButtonExit(){
done(2);
}
void CPasswordDialog::paintEvent(QPaintEvent* event){
QDialog::paintEvent(event);
QPainter painter(this);
painter.setClipRegion(event->region());
painter.drawPixmap(QPoint(0,0),BannerPixmap);
}
void CPasswordDialog::OnBookmarkTriggered(QAction* action){
BookmarkFilename=action->data().toString();
if(action->data().toString()==QString())
setWindowTitle(LastFile);
else
setWindowTitle(action->data().toString());
Label_Bookmark->setText(action->text());
}

View File

@@ -23,6 +23,8 @@
#include "main.h"
#include "lib/UrlLabel.h"
#include "Database.h"
#include <QPixmap>
#include <QPaintEvent>
class CPasswordDialog : public QDialog, public Ui_PasswordDlg
@@ -32,17 +34,21 @@ class CPasswordDialog : public QDialog, public Ui_PasswordDlg
private:
bool Mode_Set; //true = Set, false = Get
IDatabase* db;
QPixmap BannerPixmap;
void setStatePasswordOnly();
void setStateKeyFileOnly();
void setStateBoth();
bool doAuth();
virtual void paintEvent(QPaintEvent*);
QString LastFile;
public:
QString keyfile;
QString password;
QString BookmarkFilename;
tKeyType KeyType;
bool OverwriteKeyFile;
CPasswordDialog(QWidget* parent,IDatabase* DB,bool ShowExitButton = false, bool KeyMode_Set=false);
CPasswordDialog(QWidget* parent,QString filename,IDatabase* DB,bool ShowExitButton = false, bool KeyMode_Set=false);
public slots:
void OnOK();
@@ -55,6 +61,7 @@ class CPasswordDialog : public QDialog, public Ui_PasswordDlg
void OnCheckBox_BothChanged(int state);
void ChangeEchoModeDatabaseKey();
void OnComboTextChanged(const QString&);
void OnBookmarkTriggered(QAction* action);
};
#endif

View File

@@ -103,6 +103,9 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
SpinBox_ClipboardTime->setValue(config->clipboardTimeOut());
CheckBox_ShowPasswords->setChecked(config->showPasswords());
CheckBox_ShowPasswords_PasswordDlg->setChecked(config->showPasswordsPasswordDlg());
//Features
CheckBox_FeatureBookmarks->setChecked(config->featureBookmarks());
//Desktop Integration
@@ -186,7 +189,6 @@ void CSettingsDlg::apply(){
config->setShowSysTrayIcon(checkBox_ShowSysTrayIcon->isChecked());
config->setMinimizeToTray(checkBox_MinimizeToTray->isChecked());
config->setSaveFileDlgHistory(checkBox_SaveFileDlgHistory->isChecked());
config->setEnableBookmarkMenu(checkBox_EnableBookmarkMenu->isChecked());
if(Radio_GroupTreeRestore->isChecked())config->setGroupTreeState(KpxConfig::RestoreLast);
else if(Radio_GroupTreeExpand->isChecked())config->setGroupTreeState(KpxConfig::ExpandAll);
else config->setGroupTreeState(KpxConfig::DoNothing);
@@ -204,6 +206,9 @@ void CSettingsDlg::apply(){
config->setClipboardTimeOut(SpinBox_ClipboardTime->value());
config->setShowPasswords(CheckBox_ShowPasswords->isChecked());
config->setShowPasswordsPasswordDlg(CheckBox_ShowPasswords_PasswordDlg->isChecked());
//Features
config->setFeatureBookmarks(CheckBox_FeatureBookmarks->isChecked());
//Desktop Integration
PluginsModified=Label_IntPlugin_Info->isVisible();