work on custom icons feature
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@67 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
parent
df8a6969af
commit
baac763ff0
|
@ -77,7 +77,7 @@ static bool UI_ExpandByDefault;
|
||||||
#define ALGO_AES 0
|
#define ALGO_AES 0
|
||||||
#define ALGO_TWOFISH 1
|
#define ALGO_TWOFISH 1
|
||||||
|
|
||||||
class Database{
|
class Database:public QObject{
|
||||||
public:
|
public:
|
||||||
Database();
|
Database();
|
||||||
virtual ~Database(){};
|
virtual ~Database(){};
|
||||||
|
|
|
@ -343,6 +343,7 @@ return CustomIcons[i-BUILTIN_ICONS];
|
||||||
|
|
||||||
void PwDatabase::addIcon(const QPixmap& icon){
|
void PwDatabase::addIcon(const QPixmap& icon){
|
||||||
CustomIcons << icon;
|
CustomIcons << icon;
|
||||||
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include "Database.h"
|
#include "Database.h"
|
||||||
|
|
||||||
|
|
||||||
class PwDatabase:QObject,public Database{
|
class PwDatabase:public Database{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
PwDatabase();
|
PwDatabase();
|
||||||
|
@ -102,6 +102,9 @@ private:
|
||||||
QList<QPixmap> CustomIcons;
|
QList<QPixmap> CustomIcons;
|
||||||
QList<CEntry> UnkownMetaStreams;
|
QList<CEntry> UnkownMetaStreams;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void modified();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,5 +67,12 @@ done(0);
|
||||||
|
|
||||||
void CEditGroupDialog::OnIconDlg(){
|
void CEditGroupDialog::OnIconDlg(){
|
||||||
CSelectIconDlg dlg(db,this);
|
CSelectIconDlg dlg(db,this);
|
||||||
dlg.exec();
|
int r=dlg.exec();
|
||||||
|
if(r!=-1){
|
||||||
|
ComboIconPicker->clear();
|
||||||
|
for(int i=0;i<db->numIcons();i++)
|
||||||
|
ComboIconPicker->insertItem(db->icon(i),"",i);
|
||||||
|
IconID=r;
|
||||||
|
ComboIconPicker->setCurrentItem(IconID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,14 +31,24 @@
|
||||||
CSelectIconDlg::CSelectIconDlg(Database* database,QWidget* parent,const char* name, bool modal, Qt::WFlags fl):QDialog(parent,name,modal,fl){
|
CSelectIconDlg::CSelectIconDlg(Database* database,QWidget* parent,const char* name, bool modal, Qt::WFlags fl):QDialog(parent,name,modal,fl){
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
db=database;
|
db=database;
|
||||||
|
|
||||||
connect(Button_AddIcon, SIGNAL(clicked()), this, SLOT(OnAddIcon()));
|
connect(Button_AddIcon, SIGNAL(clicked()), this, SLOT(OnAddIcon()));
|
||||||
|
connect(Button_PickIcon, SIGNAL(clicked()), this, SLOT(OnPickIcon()));
|
||||||
|
connect(Button_Cancel, SIGNAL(clicked()), this, SLOT(OnCancel()));
|
||||||
|
CtxMenu=new QMenu(this);
|
||||||
|
DeleteAction=CtxMenu->addAction(*Icon_EditDelete,tr("Delete"));
|
||||||
|
CustomIconsModified=false;
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSelectIconDlg::updateView(){
|
||||||
|
List->clear();
|
||||||
for(int i=0; i<db->numIcons(); i++){
|
for(int i=0; i<db->numIcons(); i++){
|
||||||
|
QListWidgetItem* item;
|
||||||
if(i<BUILTIN_ICONS)
|
if(i<BUILTIN_ICONS)
|
||||||
List->addItem(new QListWidgetItem(QIcon(db->icon(i)),QString::number(i)));
|
List->addItem(item=new QListWidgetItem(QIcon(db->icon(i)),QString::number(i)));
|
||||||
else
|
else
|
||||||
List->addItem(new QListWidgetItem(QIcon(db->icon(i)),"["+QString::number(i)+"]"));
|
List->addItem(item=new QListWidgetItem(QIcon(db->icon(i)),"["+QString::number(i)+"]"));
|
||||||
|
item->setData(32,i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,4 +65,27 @@ for(int i=0;i<filenames.size();i++){
|
||||||
}
|
}
|
||||||
if(errors.size())
|
if(errors.size())
|
||||||
QMessageBox::warning(this,tr("Error"),tr("An error occured while loading the icon(s):\n"));
|
QMessageBox::warning(this,tr("Error"),tr("An error occured while loading the icon(s):\n"));
|
||||||
|
CustomIconsModified=true;
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSelectIconDlg::contextMenuEvent(QContextMenuEvent *event){
|
||||||
|
|
||||||
|
QListWidgetItem* item=List->itemAt(List->mapFromParent(event->pos()));
|
||||||
|
|
||||||
|
if(!item)return;
|
||||||
|
if(item->data(32).toInt()<BUILTIN_ICONS)
|
||||||
|
DeleteAction->setDisabled(true);
|
||||||
|
else
|
||||||
|
DeleteAction->setDisabled(false);
|
||||||
|
event->accept();
|
||||||
|
CtxMenu->popup(event->globalPos());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSelectIconDlg::OnPickIcon(){
|
||||||
|
done(List->currentItem()->data(32).toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSelectIconDlg::OnCancel(){
|
||||||
|
done(-1);
|
||||||
}
|
}
|
|
@ -21,6 +21,9 @@
|
||||||
#ifndef _SELECT_ICON_DLG_
|
#ifndef _SELECT_ICON_DLG_
|
||||||
#define _SELECT_ICON_DLG_
|
#define _SELECT_ICON_DLG_
|
||||||
|
|
||||||
|
#include <QContextMenuEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QAction>
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "Database.h"
|
#include "Database.h"
|
||||||
#include "ui_SelectIconDlg.h"
|
#include "ui_SelectIconDlg.h"
|
||||||
|
@ -29,13 +32,22 @@ class CSelectIconDlg:public QDialog, public Ui_SelectIconDlg{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CSelectIconDlg(Database* db,QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WFlags fl = 0);
|
CSelectIconDlg(Database* db,QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WFlags fl = 0);
|
||||||
|
bool CustomIconsModified;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnAddIcon();
|
void OnAddIcon();
|
||||||
|
void OnPickIcon();
|
||||||
|
void OnCancel();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Database* db;
|
Database* db;
|
||||||
|
void updateView();
|
||||||
|
QMenu* CtxMenu;
|
||||||
|
QAction* DeleteAction;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,105 +8,104 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>468</width>
|
<width>478</width>
|
||||||
<height>272</height>
|
<height>280</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy" >
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QListWidget" name="List" >
|
<layout class="QGridLayout" >
|
||||||
<property name="geometry" >
|
<property name="margin" >
|
||||||
<rect>
|
<number>9</number>
|
||||||
<x>10</x>
|
|
||||||
<y>10</y>
|
|
||||||
<width>451</width>
|
|
||||||
<height>211</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="horizontalScrollBarPolicy" >
|
<property name="spacing" >
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionMode" >
|
<item row="0" column="0" >
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
<layout class="QGridLayout" >
|
||||||
</property>
|
<property name="margin" >
|
||||||
<property name="iconSize" >
|
<number>0</number>
|
||||||
<size>
|
</property>
|
||||||
<width>16</width>
|
<property name="spacing" >
|
||||||
<height>16</height>
|
<number>6</number>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<item row="1" column="0" >
|
||||||
<property name="textElideMode" >
|
<widget class="QPushButton" name="Button_AddIcon" >
|
||||||
<enum>Qt::ElideRight</enum>
|
<property name="text" >
|
||||||
</property>
|
<string>Add Custom Icon...</string>
|
||||||
<property name="movement" >
|
</property>
|
||||||
<enum>QListView::Static</enum>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="flow" >
|
<item row="1" column="2" >
|
||||||
<enum>QListView::LeftToRight</enum>
|
<widget class="QPushButton" name="Button_PickIcon" >
|
||||||
</property>
|
<property name="text" >
|
||||||
<property name="gridSize" >
|
<string>Pick</string>
|
||||||
<size>
|
</property>
|
||||||
<width>32</width>
|
</widget>
|
||||||
<height>44</height>
|
</item>
|
||||||
</size>
|
<item row="1" column="3" >
|
||||||
</property>
|
<widget class="QPushButton" name="Button_Cancel" >
|
||||||
<property name="viewMode" >
|
<property name="text" >
|
||||||
<enum>QListView::IconMode</enum>
|
<string>Cancel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="layoutWidget" >
|
</item>
|
||||||
<property name="geometry" >
|
<item row="1" column="1" >
|
||||||
<rect>
|
<spacer>
|
||||||
<x>10</x>
|
<property name="orientation" >
|
||||||
<y>230</y>
|
<enum>Qt::Horizontal</enum>
|
||||||
<width>451</width>
|
</property>
|
||||||
<height>33</height>
|
<property name="sizeHint" >
|
||||||
</rect>
|
<size>
|
||||||
</property>
|
<width>131</width>
|
||||||
<layout class="QHBoxLayout" >
|
<height>31</height>
|
||||||
<property name="margin" >
|
</size>
|
||||||
<number>0</number>
|
</property>
|
||||||
</property>
|
</spacer>
|
||||||
<property name="spacing" >
|
</item>
|
||||||
<number>6</number>
|
<item row="0" column="0" colspan="4" >
|
||||||
</property>
|
<widget class="QListWidget" name="List" >
|
||||||
<item>
|
<property name="iconSize" >
|
||||||
<widget class="QPushButton" name="Button_AddIcon" >
|
<size>
|
||||||
<property name="text" >
|
<width>16</width>
|
||||||
<string>Add Custom Icon...</string>
|
<height>16</height>
|
||||||
</property>
|
</size>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
<property name="movement" >
|
||||||
<item>
|
<enum>QListView::Static</enum>
|
||||||
<spacer>
|
</property>
|
||||||
<property name="orientation" >
|
<property name="flow" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>QListView::LeftToRight</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="isWrapping" stdset="0" >
|
||||||
<size>
|
<bool>true</bool>
|
||||||
<width>131</width>
|
</property>
|
||||||
<height>31</height>
|
<property name="resizeMode" >
|
||||||
</size>
|
<enum>QListView::Adjust</enum>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
<property name="gridSize" >
|
||||||
</item>
|
<size>
|
||||||
<item>
|
<width>32</width>
|
||||||
<widget class="QPushButton" name="Button_PickIcon" >
|
<height>44</height>
|
||||||
<property name="text" >
|
</size>
|
||||||
<string>Pick</string>
|
</property>
|
||||||
</property>
|
<property name="viewMode" >
|
||||||
</widget>
|
<enum>QListView::IconMode</enum>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
</widget>
|
||||||
<widget class="QPushButton" name="Button_Cancel" >
|
</item>
|
||||||
<property name="text" >
|
</layout>
|
||||||
<string>Cancel</string>
|
</item>
|
||||||
</property>
|
</layout>
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
<pixmapfunction></pixmapfunction>
|
<pixmapfunction></pixmapfunction>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
@ -267,6 +267,7 @@ Q_ASSERT(r==1);
|
||||||
db = new PwDatabase();
|
db = new PwDatabase();
|
||||||
GroupView->db=db;
|
GroupView->db=db;
|
||||||
EntryView->db=db;
|
EntryView->db=db;
|
||||||
|
connect(db,SIGNAL(modified()),this,SLOT(OnFileModified()));
|
||||||
if(PasswordDlg.password!="" && PasswordDlg.keyfile=="")
|
if(PasswordDlg.password!="" && PasswordDlg.keyfile=="")
|
||||||
db->CalcMasterKeyByPassword(PasswordDlg.password);
|
db->CalcMasterKeyByPassword(PasswordDlg.password);
|
||||||
if(PasswordDlg.password=="" && PasswordDlg.keyfile!="")
|
if(PasswordDlg.password=="" && PasswordDlg.keyfile!="")
|
||||||
|
|
Loading…
Reference in New Issue