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 18 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_TWOFISH 1
class Database{
class Database:public QObject{
public:
Database();
virtual ~Database(){};

@ -343,6 +343,7 @@ return CustomIcons[i-BUILTIN_ICONS];
void PwDatabase::addIcon(const QPixmap& icon){
CustomIcons << icon;
emit modified();
}

@ -41,7 +41,7 @@
#include "Database.h"
class PwDatabase:QObject,public Database{
class PwDatabase:public Database{
Q_OBJECT
public:
PwDatabase();
@ -102,6 +102,9 @@ private:
QList<QPixmap> CustomIcons;
QList<CEntry> UnkownMetaStreams;
signals:
void modified();
};

@ -67,5 +67,12 @@ done(0);
void CEditGroupDialog::OnIconDlg(){
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){
setupUi(this);
db=database;
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++){
QListWidgetItem* item;
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
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())
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_
#define _SELECT_ICON_DLG_
#include <QContextMenuEvent>
#include <QMenu>
#include <QAction>
#include "main.h"
#include "Database.h"
#include "ui_SelectIconDlg.h"
@ -29,13 +32,22 @@ class CSelectIconDlg:public QDialog, public Ui_SelectIconDlg{
Q_OBJECT
public:
CSelectIconDlg(Database* db,QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WFlags fl = 0);
bool CustomIconsModified;
public slots:
void OnAddIcon();
void OnPickIcon();
void OnCancel();
private:
Database* db;
void updateView();
QMenu* CtxMenu;
QAction* DeleteAction;
protected:
virtual void contextMenuEvent(QContextMenuEvent *event);
};

@ -8,105 +8,104 @@
<rect>
<x>0</x>
<y>0</y>
<width>468</width>
<height>272</height>
<width>478</width>
<height>280</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle" >
<string>Dialog</string>
</property>
<widget class="QListWidget" name="List" >
<property name="geometry" >
<rect>
<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>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
</widget>
<widget class="QWidget" name="layoutWidget" >
<property name="geometry" >
<rect>
<x>10</x>
<y>230</y>
<width>451</width>
<height>33</height>
</rect>
<property name="spacing" >
<number>6</number>
</property>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="Button_AddIcon" >
<property name="text" >
<string>Add Custom Icon...</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>131</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="Button_PickIcon" >
<property name="text" >
<string>Pick</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_Cancel" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
<item row="0" column="0" >
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<widget class="QPushButton" name="Button_AddIcon" >
<property name="text" >
<string>Add Custom Icon...</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="Button_PickIcon" >
<property name="text" >
<string>Pick</string>
</property>
</widget>
</item>
<item row="1" column="3" >
<widget class="QPushButton" name="Button_Cancel" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>131</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<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>
<pixmapfunction></pixmapfunction>
<resources/>

@ -267,6 +267,7 @@ Q_ASSERT(r==1);
db = new PwDatabase();
GroupView->db=db;
EntryView->db=db;
connect(db,SIGNAL(modified()),this,SLOT(OnFileModified()));
if(PasswordDlg.password!="" && PasswordDlg.keyfile=="")
db->CalcMasterKeyByPassword(PasswordDlg.password);
if(PasswordDlg.password=="" && PasswordDlg.keyfile!="")