metastreams get correct group IDs (instead of 0),

new CustomIcon metastream format (Rev 2),
alpha blending for banner icons,
new banner standard icon (key.png)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@98 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 19 years ago
parent c980d277f2
commit 5775eaae36
  1. BIN
      share/keepass/icons/key.png
  2. 47
      src/PwManager.cpp
  3. 1
      src/PwManager.h
  4. 244
      src/forms/EditGroupDlg.ui
  5. 3
      src/lib/GroupView.cpp
  6. 8
      src/main.cpp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -49,8 +49,8 @@ else return QString(tr("Unknown Error"));
QString PwDatabase::getErrors(){ QString PwDatabase::getErrors(){
QString r; QString r;
for(int i=0; i<Errors.size(); i++){ for(int i=0; i<Errors.size(); i++){
r+=Errors[i]; r+=Errors[i];
r+='\n'; r+='\n';
} }
Errors.clear(); Errors.clear();
return r; return r;
@ -244,11 +244,21 @@ return true;
} }
bool PwDatabase::parseMetaStream(const CEntry& entry){ bool PwDatabase::parseMetaStream(const CEntry& entry){
if(entry.Additional=="KPX_CUSTOM_ICONS")
if(entry.Additional=="KPX_CUSTOM_ICONS_2")
return parseCustomIconsMetaStream(entry.BinaryData); return parseCustomIconsMetaStream(entry.BinaryData);
/* Old stream format will be ignored*/
if(entry.Additional=="KPX_CUSTOM_ICONS")
return true; //return true to avoid that this stream get saved
return false; //unknown MetaStream
}
return false; //unknown MetaStreams CEntry* PwDatabase::getEntry(const KpxUuid& uuid){
for(int i=0; i<Entries.size();i++)
if(Entries[i].Uuid==uuid)return &Entries[i];
return NULL;
} }
bool PwDatabase::parseCustomIconsMetaStream(const QByteArray& dta){ bool PwDatabase::parseCustomIconsMetaStream(const QByteArray& dta){
@ -275,13 +285,17 @@ for(int i=0;i<NumIcons;i++){
return false;} return false;}
} }
for(int i=0;i<NumEntries;i++){ for(int i=0;i<NumEntries;i++){
quint32 Entry,Icon; quint32 Icon;
memcpyFromLEnd32(&Entry,dta.data()+offset); KpxUuid EntryUuid;
offset+=4; EntryUuid.fromRaw(dta.data()+offset);
offset+=16;
memcpyFromLEnd32(&Icon,dta.data()+offset); memcpyFromLEnd32(&Icon,dta.data()+offset);
offset+=4; offset+=4;
Entries[Entry].OldImgID=Entries[Entry].ImageID; CEntry* entry=getEntry(EntryUuid);
Entries[Entry].ImageID=Icon; if(entry){
entry->OldImgID=entry->ImageID;
entry->ImageID=Icon;
}
} }
for(int i=0;i<NumGroups;i++){ for(int i=0;i<NumGroups;i++){
quint32 Group,Icon; quint32 Group,Icon;
@ -295,17 +309,20 @@ for(int i=0;i<NumGroups;i++){
return true; return true;
} }
void PwDatabase::createCustomIconsMetaStream(CEntry* e){ void PwDatabase::createCustomIconsMetaStream(CEntry* e){
/* Rev 2 */
e->BinaryDesc="bin-stream"; e->BinaryDesc="bin-stream";
e->Title="Meta-Info"; e->Title="Meta-Info";
e->UserName="SYSTEM"; e->UserName="SYSTEM";
e->Additional="KPX_CUSTOM_ICONS"; e->Additional="KPX_CUSTOM_ICONS_2";
e->URL="$"; e->URL="$";
e->ImageID=0; e->ImageID=0;
if(Groups.size())e->GroupID=Groups[0].ID;
int Size=12; int Size=12;
quint32 NumEntries=Entries.size(); quint32 NumEntries=Entries.size();
quint32 NumGroups=Groups.size(); quint32 NumGroups=Groups.size();
Size+=8*(NumEntries+NumGroups); Size+=8*NumGroups+20*NumEntries;
Size+=CustomIcons.size()*1000; // 1KB Size+=CustomIcons.size()*1000; // 1KB
e->BinaryData.reserve(Size); e->BinaryData.reserve(Size);
e->BinaryData.resize(12); e->BinaryData.resize(12);
@ -327,11 +344,11 @@ for(int i=0;i<CustomIcons.size();i++){
e->BinaryData.append(png); e->BinaryData.append(png);
} }
for(quint32 i=0;i<Entries.size();i++){ for(quint32 i=0;i<Entries.size();i++){
char Bin[8]; char Bin[20];
memcpyToLEnd32(Bin,&i); Entries[i].Uuid.toRaw(Bin);
quint32 id=Entries[i].ImageID; quint32 id=Entries[i].ImageID;
memcpyToLEnd32(Bin+4,&id); memcpyToLEnd32(Bin+16,&id);
e->BinaryData.append(QByteArray::fromRawData(Bin,8)); e->BinaryData.append(QByteArray::fromRawData(Bin,20));
} }
for(quint32 i=0;i<Groups.size();i++){ for(quint32 i=0;i<Groups.size();i++){
char Bin[8]; char Bin[8];

@ -68,6 +68,7 @@ public:
QList<int> getChildIds(CGroup* pGroup); QList<int> getChildIds(CGroup* pGroup);
CEntry& entry(unsigned long index); CEntry& entry(unsigned long index);
CEntry* getEntry(const KpxUuid& uuid);
void setEntry(unsigned long index,CEntry& Entry); void setEntry(unsigned long index,CEntry& Entry);
int numEntries(); int numEntries();
CEntry* cloneEntry(CEntry* pEntry); CEntry* cloneEntry(CEntry* pEntry);

@ -8,135 +8,147 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>302</width> <width>350</width>
<height>105</height> <height>120</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" > <property name="minimumSize" >
<size> <size>
<width>302</width> <width>350</width>
<height>105</height> <height>120</height>
</size> </size>
</property> </property>
<property name="maximumSize" > <property name="maximumSize" >
<size> <size>
<width>302</width> <width>350</width>
<height>105</height> <height>120</height>
</size> </size>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
<string>Group Properties</string> <string>Group Properties</string>
</property> </property>
<widget class="QLineEdit" name="EditTitle" > <layout class="QVBoxLayout" >
<property name="geometry" > <property name="margin" >
<rect> <number>9</number>
<x>70</x> </property>
<y>10</y> <property name="spacing" >
<width>230</width> <number>6</number>
<height>21</height> </property>
</rect> <item>
</property> <layout class="QGridLayout" >
</widget> <property name="margin" >
<widget class="QLabel" name="Label1" > <number>0</number>
<property name="geometry" > </property>
<rect> <property name="spacing" >
<x>10</x> <number>6</number>
<y>10</y> </property>
<width>27</width> <item row="1" column="0" >
<height>20</height> <widget class="QLabel" name="Label2" >
</rect> <property name="text" >
</property> <string>Icon:</string>
<property name="text" > </property>
<string>Title:</string> </widget>
</property> </item>
</widget> <item row="0" column="0" >
<widget class="QLabel" name="Label2" > <widget class="QLabel" name="Label1" >
<property name="geometry" > <property name="text" >
<rect> <string>Title:</string>
<x>10</x> </property>
<y>40</y> </widget>
<width>43</width> </item>
<height>20</height> <item row="1" column="1" >
</rect> <widget class="QComboBox" name="ComboIconPicker" />
</property> </item>
<property name="text" > <item row="1" column="3" >
<string>Icon:</string> <spacer>
</property> <property name="orientation" >
</widget> <enum>Qt::Horizontal</enum>
<widget class="Line" name="line1" > </property>
<property name="geometry" > <property name="sizeHint" >
<rect> <size>
<x>10</x> <width>172</width>
<y>62</y> <height>20</height>
<width>290</width> </size>
<height>16</height> </property>
</rect> </spacer>
</property> </item>
<property name="frameShape" > <item row="0" column="1" colspan="3" >
<enum>QFrame::HLine</enum> <widget class="QLineEdit" name="EditTitle" />
</property> </item>
<property name="frameShadow" > <item row="1" column="2" >
<enum>QFrame::Sunken</enum> <widget class="QToolButton" name="Button_Icon" >
</property> <property name="text" >
<property name="orientation" > <string>></string>
<enum>Qt::Horizontal</enum> </property>
</property> </widget>
</widget> </item>
<widget class="QPushButton" name="ButtonOK" > </layout>
<property name="geometry" > </item>
<rect> <item>
<x>140</x> <widget class="Line" name="line1" >
<y>76</y> <property name="frameShape" >
<width>70</width> <enum>QFrame::HLine</enum>
<height>24</height> </property>
</rect> <property name="frameShadow" >
</property> <enum>QFrame::Sunken</enum>
<property name="text" > </property>
<string>O&amp;K</string> <property name="orientation" >
</property> <enum>Qt::Horizontal</enum>
<property name="shortcut" > </property>
<string>Alt+K</string> </widget>
</property> </item>
</widget> <item>
<widget class="QPushButton" name="ButtonCancel" > <layout class="QHBoxLayout" >
<property name="geometry" > <property name="margin" >
<rect> <number>0</number>
<x>220</x> </property>
<y>76</y> <property name="spacing" >
<width>70</width> <number>6</number>
<height>24</height> </property>
</rect> <item>
</property> <spacer>
<property name="text" > <property name="orientation" >
<string>&amp;Cancel</string> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="shortcut" > <property name="sizeHint" >
<string>Alt+C</string> <size>
</property> <width>121</width>
</widget> <height>20</height>
<widget class="QComboBox" name="ComboIconPicker" > </size>
<property name="geometry" > </property>
<rect> </spacer>
<x>68</x> </item>
<y>37</y> <item>
<width>62</width> <widget class="QPushButton" name="ButtonOK" >
<height>26</height> <property name="text" >
</rect> <string>O&amp;K</string>
</property> </property>
</widget> <property name="shortcut" >
<widget class="QPushButton" name="Button_Icon" > <string>Alt+K</string>
<property name="geometry" > </property>
<rect> </widget>
<x>135</x> </item>
<y>38</y> <item>
<width>21</width> <widget class="QPushButton" name="ButtonCancel" >
<height>23</height> <property name="text" >
</rect> <string>&amp;Cancel</string>
</property> </property>
<property name="text" > <property name="shortcut" >
<string>></string> <string>Alt+C</string>
</property> </property>
</widget> </widget>
</item>
</layout>
</item>
</layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11" /> <layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>

@ -89,6 +89,7 @@ if(DragType==GROUP){
item->setFont(0,f); item->setFont(0,f);
LastHoverItem=item; LastHoverItem=item;
event->setAccepted(true); event->setAccepted(true);
///@FIXME does not work for top level groups
} }
else{ else{
LastHoverItem=NULL; LastHoverItem=NULL;
@ -277,7 +278,7 @@ QPen pen(QColor(100,100,100));
pen.setWidth(2); pen.setWidth(2);
pen.setStyle(Qt::DotLine); pen.setStyle(Qt::DotLine);
painter.setPen(pen); painter.setPen(pen);
qDebug("UPDATE: (%i,%i) %ix%i",event->rect().x(),event->rect().y(),event->rect().width(),event->rect().height()); //qDebug("UPDATE: (%i,%i) %ix%i",event->rect().x(),event->rect().y(),event->rect().width(),event->rect().height());
if(!InsertionMarker.isNull()){ if(!InsertionMarker.isNull()){
painter.drawLine(InsertionMarker); painter.drawLine(InsertionMarker);
} }

@ -202,10 +202,14 @@ if(color1!=color2){
else{ else{
banner_pixmap->fill(color1); banner_pixmap->fill(color1);
} }
painter.drawPixmap(10,10,*symbol); QPixmap icon(32,32);
icon.fill(textcolor);
icon.setAlphaChannel(*symbol);
painter.drawPixmap(10,10,icon);
pen.setColor(textcolor); pen.setColor(textcolor);
painter.setPen(pen); painter.setPen(pen);
painter.drawText(50,30,text); painter.drawText(50,35,text);
Banner->setPixmap(*banner_pixmap); Banner->setPixmap(*banner_pixmap);
} }