work on custom icons feature

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@67 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent df8a6969af
commit baac763ff0
  1. 2
      src/Database.h
  2. 1
      src/PwManager.cpp
  3. 5
      src/PwManager.h
  4. 9
      src/dialogs/EditGroupDlg.cpp
  5. 39
      src/dialogs/SelectIconDlg.cpp
  6. 12
      src/dialogs/SelectIconDlg.h
  7. 183
      src/forms/SelectIconDlg.ui
  8. 1
      src/mainwindow.cpp

@ -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 name="horizontalScrollBarPolicy" >
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="selectionMode" >
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="iconSize" >
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="textElideMode" >
<enum>Qt::ElideRight</enum>
</property>
<property name="movement" >
<enum>QListView::Static</enum>
</property>
<property name="flow" >
<enum>QListView::LeftToRight</enum>
</property>
<property name="gridSize" >
<size>
<width>32</width>
<height>44</height>
</size>
</property>
<property name="viewMode" >
<enum>QListView::IconMode</enum>
</property> </property>
</widget> <property name="spacing" >
<widget class="QWidget" name="layoutWidget" > <number>6</number>
<property name="geometry" >
<rect>
<x>10</x>
<y>230</y>
<width>451</width>
<height>33</height>
</rect>
</property> </property>
<layout class="QHBoxLayout" > <item row="0" column="0" >
<property name="margin" > <layout class="QGridLayout" >
<number>0</number> <property name="margin" >
</property> <number>0</number>
<property name="spacing" > </property>
<number>6</number> <property name="spacing" >
</property> <number>6</number>
<item> </property>
<widget class="QPushButton" name="Button_AddIcon" > <item row="1" column="0" >
<property name="text" > <widget class="QPushButton" name="Button_AddIcon" >
<string>Add Custom Icon...</string> <property name="text" >
</property> <string>Add Custom Icon...</string>
</widget> </property>
</item> </widget>
<item> </item>
<spacer> <item row="1" column="2" >
<property name="orientation" > <widget class="QPushButton" name="Button_PickIcon" >
<enum>Qt::Horizontal</enum> <property name="text" >
</property> <string>Pick</string>
<property name="sizeHint" > </property>
<size> </widget>
<width>131</width> </item>
<height>31</height> <item row="1" column="3" >
</size> <widget class="QPushButton" name="Button_Cancel" >
</property> <property name="text" >
</spacer> <string>Cancel</string>
</item> </property>
<item> </widget>
<widget class="QPushButton" name="Button_PickIcon" > </item>
<property name="text" > <item row="1" column="1" >
<string>Pick</string> <spacer>
</property> <property name="orientation" >
</widget> <enum>Qt::Horizontal</enum>
</item> </property>
<item> <property name="sizeHint" >
<widget class="QPushButton" name="Button_Cancel" > <size>
<property name="text" > <width>131</width>
<string>Cancel</string> <height>31</height>
</property> </size>
</widget> </property>
</item> </spacer>
</layout> </item>
</widget> <item row="0" column="0" colspan="4" >
<widget class="QListWidget" name="List" >
<property name="iconSize" >
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="movement" >
<enum>QListView::Static</enum>
</property>
<property name="flow" >
<enum>QListView::LeftToRight</enum>
</property>
<property name="isWrapping" stdset="0" >
<bool>true</bool>
</property>
<property name="resizeMode" >
<enum>QListView::Adjust</enum>
</property>
<property name="gridSize" >
<size>
<width>32</width>
<height>44</height>
</size>
</property>
<property name="viewMode" >
<enum>QListView::IconMode</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</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!="")