fixed problem with config saving,

main-window size an splitter position are restored on start-up,
loading icons on demand by QIcon class instead of preload,
column resizing stuff (not finished)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@50 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent f89372b0c5
commit d6ea6e8971
  1. BIN
      share/keepass/icons/nuvola/32x32/filesystems/desktop.png
  2. BIN
      share/keepass/icons/nuvola/32x32/filesystems/folder.png
  3. BIN
      share/keepass/icons/nuvola/32x32/filesystems/folder_home.png
  4. BIN
      share/keepass/icons/nuvola/32x32/filesystems/network_local.png
  5. BIN
      share/keepass/icons/nuvola/32x32/filesystems/trashcan_full.png
  6. 45
      src/PwmConfig.cpp
  7. 8
      src/PwmConfig.h
  8. 18
      src/forms/MainWindow.ui
  9. 68
      src/forms/SettingsDlg.ui
  10. 10
      src/lib/EntryView.cpp
  11. 2
      src/lib/EntryView.h
  12. 19
      src/lib/KpFileIconProvider.cpp
  13. 28
      src/lib/KpFileIconProvider.h
  14. 70
      src/main.cpp
  15. 10
      src/mainwindow.cpp
  16. 6
      src/src.pro

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

@ -25,7 +25,7 @@
using namespace std;
bool CConfig::loadFromIni(QString filename){
CIniFile ini((char*)filename.data());
ini.SetPath((const char*)filename);
ini.ReadFile();
ClipboardTimeOut=ini.GetValueI("Options","ClipboardTimeOut",20);
Toolbar=ini.GetValueB("UI","ShowToolbar",true);
@ -47,12 +47,15 @@ PwGenLength=ini.GetValueI("Options","PwGenLength",25);
PwGenCharList=ini.GetValue("Options","PwGenCharList","").c_str();
ExpandGroupTree=ini.GetValueB("Options","ExpandGroupTree",true);
EnableKdePlugin=ini.GetValueB("KDE Plugin","Enabled",false);
MainWinHeight=ini.GetValueI("UI","MainWinHeight",550);
MainWinWidth=ini.GetValueI("UI","MainWinWidth",900);
MainWinSplit1=ini.GetValueI("UI","MainWinSplit1",100);
MainWinSplit2=ini.GetValueI("UI","MainWinSplit2",300);
ParseIntString(ini.GetValue("UI","ColumnSizes","15,10,10,10,10,10,10,10,10,10").c_str(),ColumnSizes,10);
return true;
}
bool CConfig::saveToIni(QString filename){
CIniFile ini((const char*)filename);
ini.ReadFile();
ini.SetValueI("Options","ClipboardTimeOut",ClipboardTimeOut);
ini.SetValueB("UI","ShowToolbar",Toolbar);
ini.SetValueB("UI","ShowEntryDetails",EntryDetails);
@ -73,6 +76,11 @@ ini.SetValueI("Options","PwGenLength",PwGenLength,true);
ini.SetValue("Options","PwGenCharList",(const char*)PwGenCharList,true);
ini.SetValueB("Options","ExpandGroupTree",ExpandGroupTree,true);
ini.SetValueB("KDE Plugin","Enabled",EnableKdePlugin,true);
ini.SetValueI("UI","MainWinHeight",MainWinHeight);
ini.SetValueI("UI","MainWinWidth",MainWinWidth);
ini.SetValueI("UI","MainWinSplit1",MainWinSplit1);
ini.SetValueI("UI","MainWinSplit2",MainWinSplit2);
ini.SetValue("UI","ColumnSizes",(const char*)CreateIntString(ColumnSizes,10),true);
if(!ini.WriteFile())return false;
else return true;
}
@ -136,3 +144,34 @@ else str+="0";
}
return str;
}
#define DEFAULT_INT_VAL 20
void CConfig::ParseIntString(const QString &str,int* dst, int count){
QStringList lst=str.split(",");
if(lst.size()!=count)
qWarning("Warnig: CConfig::ParseIntString(): unexpected item count.\n");
int* values=new int[count];
bool err;
for(int i=0;i<lst.size() && i<count;i++){
values[i]=lst[i].toUInt(&err);
if(!err){
qWarning("Warnig: CConfig::ParseIntString(): invalid int value.\n");
values[i]=DEFAULT_INT_VAL;}
}
if(count > lst.size()){
for(int i=lst.size(); i<count; i++)
values[i]=DEFAULT_INT_VAL;}
memcpy(dst,values,count);
delete [] values;
}
QString CConfig::CreateIntString(int* src, int count){
QString str;
for(int i=0;i<count;i++){
str+=QString::number(src[i]);
if(i<(count-1))str+=",";
}
return str;
}

@ -46,17 +46,25 @@ public:
QString PwGenCharList;
bool ExpandGroupTree;
bool EnableKdePlugin;
int MainWinHeight;
int MainWinWidth;
int MainWinSplit1;
int MainWinSplit2;
int ColumnSizes[10];
bool loadFromIni(QString filename);
bool saveToIni(QString filename);
private:
CIniFile ini;
void ParseColumnString(QString str, bool* dst);
void ParseBoolString(const QString &str,bool* dst, int count);
void ParseIntString(const QString &str,int* dst, int count);
QString CreateBoolString(bool* src, int count);
QColor ParseColorString(QString str);
QString CreateColumnString();
QString CreateColorString(QColor);
QString CreateIntString(int* src, int count);
};
#endif

@ -90,11 +90,17 @@
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
<vsizetype>4</vsizetype>
<horstretch>0</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
</widget>
</item>
</layout>
@ -105,7 +111,7 @@
<x>0</x>
<y>0</y>
<width>724</width>
<height>30</height>
<height>29</height>
</rect>
</property>
<widget class="QMenu" name="menuHilfe" >
@ -469,16 +475,16 @@
<pixmapfunction></pixmapfunction>
<customwidgets>
<customwidget>
<class>KeepassEntryView</class>
<class>KeepassGroupView</class>
<extends>QTreeWidget</extends>
<header>../../src/lib/EntryView.h</header>
<header>../../src/lib/GroupView.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
<customwidget>
<class>KeepassGroupView</class>
<class>KeepassEntryView</class>
<extends>QTreeWidget</extends>
<header>../../src/lib/GroupView.h</header>
<header>../../src/lib/EntryView.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>

@ -27,38 +27,6 @@
<property name="windowTitle" >
<string>Einstellungen</string>
</property>
<widget class="QPushButton" name="ButtonCancel" >
<property name="geometry" >
<rect>
<x>470</x>
<y>310</y>
<width>90</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>Abbre&amp;chen</string>
</property>
<property name="shortcut" >
<string>Alt+C</string>
</property>
</widget>
<widget class="QPushButton" name="ButtonOK" >
<property name="geometry" >
<rect>
<x>380</x>
<y>310</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>O&amp;K</string>
</property>
<property name="shortcut" >
<string>Alt+K</string>
</property>
</widget>
<widget class="QLabel" name="Banner" >
<property name="geometry" >
<rect>
@ -79,9 +47,9 @@
<property name="geometry" >
<rect>
<x>10</x>
<y>59</y>
<y>60</y>
<width>550</width>
<height>251</height>
<height>241</height>
</rect>
</property>
<widget class="QWidget" name="tab" >
@ -355,6 +323,38 @@
</widget>
</widget>
</widget>
<widget class="QPushButton" name="ButtonOK" >
<property name="geometry" >
<rect>
<x>380</x>
<y>310</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>O&amp;K</string>
</property>
<property name="shortcut" >
<string>Alt+K</string>
</property>
</widget>
<widget class="QPushButton" name="ButtonCancel" >
<property name="geometry" >
<rect>
<x>470</x>
<y>310</y>
<width>90</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>Abbre&amp;chen</string>
</property>
<property name="shortcut" >
<string>Alt+C</string>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 by Tarek Saidi *
* Copyright (C) 2005-2006 by Tarek Saidi *
* tarek.saidi@arcor.de *
* *
* This program is free software; you can redistribute it and/or modify *
@ -34,8 +34,10 @@
KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){
CurrentGroup=0;
updateColumns();
header()->setResizeMode(QHeaderView::Stretch);
header()->setResizeMode(QHeaderView::Interactive);
header()->setStretchLastSection(false);
ContextMenu=new QMenu(this);
}
@ -66,6 +68,10 @@ e->accept();
ContextMenu->popup(e->globalPos());
}
void KeepassEntryView::resizeEvent(QResizeEvent* e){
e->accept();
}
void KeepassEntryView::updateItems(unsigned int GroupID){

@ -40,9 +40,11 @@ public:
private:
void setEntry(CEntry* entry);
int CurrentGroup;
QList<float>ColumnSizes;
protected:
virtual void contextMenuEvent(QContextMenuEvent *event);
virtual void paintEvent(QPaintEvent* event);
virtual void resizeEvent(QResizeEvent* event);
};

@ -0,0 +1,19 @@
/***************************************************************************
* Copyright (C) 2005-2006 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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. *
***************************************************************************/

@ -0,0 +1,28 @@
/***************************************************************************
* Copyright (C) 2005-2006 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 <QFileIconProvider>
#include <QIcon>
class KpFileIconProvider : public QFileIconProvider{
public:
virtual QIcon icon(IconType type) const;
virtual QIcon icon(const QFileInfo& info) const;
};

@ -88,6 +88,7 @@ else{
config.loadFromIni(IniFilename);}
//Internationalization
QLocale loc=QLocale::system();
QTranslator* translator = 0;
@ -207,15 +208,21 @@ if(Img.load(AppDir+"/../share/keepass/icons/"+name)==false){
}
#define _loadIcon(_VAR,_NAME)\
_VAR=new QIcon(ThemeDir+_NAME);
void loadImages(){
QString ThemeDir="nuvola/32x32";
bool small=true;
QString ThemeDir=AppDir+"/../share/keepass/icons/nuvola/32x32";
QPixmap tmpImg;
//-----------------------
loadImg("clientic.png",tmpImg);
EntryIcons=new QPixmap[NUM_CLIENT_ICONS];
for(int i=0;i<NUM_CLIENT_ICONS;i++){
EntryIcons[i]=tmpImg.copy(i*16,0,16,16);}
//--------------------------
loadImg("key.png",tmpImg);
Icon_Key32x32=new QPixmap;
@ -237,50 +244,23 @@ loadImg("search.png",tmpImg);
Icon_Search32x32=new QPixmap;
*Icon_Search32x32=tmpImg;
//--------------------------
loadImg(ThemeDir+"/actions/filenew.png",tmpImg);
Icon_FileNew=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/fileopen.png",tmpImg);
Icon_FileOpen=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/filesave.png",tmpImg);
Icon_FileSave=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/filesaveas.png",tmpImg);
Icon_FileSaveAs=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/fileclose.png",tmpImg);
Icon_FileClose=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/exit.png",tmpImg);
Icon_Exit=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/editdelete.png",tmpImg);
Icon_EditDelete=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/edit_add.png",tmpImg);
Icon_EditAdd=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/edit.png",tmpImg);
Icon_EditEdit=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/identity.png",tmpImg);
Icon_EditUsernameToCb=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/klipper_dock.png",tmpImg);
Icon_EditPasswordToCb=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/editcopy.png",tmpImg);
Icon_EditClone=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/run.png",tmpImg);
Icon_EditOpenUrl=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/find.png",tmpImg);
Icon_EditSearch=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/configure.png",tmpImg);
Icon_Configure=new QIcon(tmpImg);
_loadIcon(Icon_FileNew,"/actions/filenew.png");
_loadIcon(Icon_FileOpen,"/actions/fileopen.png");
_loadIcon(Icon_FileSave,"/actions/filesave.png");
_loadIcon(Icon_FileSaveAs,"/actions/filesaveas.png");
_loadIcon(Icon_FileClose,"/actions/fileclose.png");
_loadIcon(Icon_Exit,"/actions/exit.png");
_loadIcon(Icon_EditDelete,"/actions/editdelete.png");
_loadIcon(Icon_EditAdd,"/actions/edit_add.png");
_loadIcon(Icon_EditEdit,"/actions/edit.png");
_loadIcon(Icon_EditUsernameToCb,"/actions/identity.png");
_loadIcon(Icon_EditPasswordToCb,"/actions/klipper_dock.png");
_loadIcon(Icon_EditClone,"/actions/editcopy.png");
_loadIcon(Icon_EditOpenUrl,"/actions/run.png");
_loadIcon(Icon_EditSearch,"/actions/find.png");
_loadIcon(Icon_Configure,"/actions/configure.png");
}

@ -60,7 +60,8 @@
KeepassMainWindow::KeepassMainWindow(QWidget *parent, Qt::WFlags flags):QMainWindow(parent,flags){
setupUi(this);
setGeometry(geometry().x(),geometry().y(),config.MainWinWidth,config.MainWinHeight);
splitter->setSizes(QList<int>() << config.MainWinSplit1 << config.MainWinSplit2);
QuickSearchEdit=new QLineEdit(toolBar);
QuickSearchEdit->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
setupIcons();
@ -530,8 +531,6 @@ if(dlg.exec()) setStateFileModified(true);
}
void KeepassMainWindow::OnFileExit(){
if(FileOpen)
if(!closeDatabase())return;
close();
}
@ -765,6 +764,11 @@ setStateFileModified(true);
}
void KeepassMainWindow::closeEvent(QCloseEvent* e){
config.MainWinHeight=geometry().height();
config.MainWinWidth=geometry().width();
config.MainWinSplit1=splitter->sizes()[0];
config.MainWinSplit2=splitter->sizes()[1];
if(FileOpen){
if(!closeDatabase())
e->ignore();

@ -51,7 +51,8 @@ HEADERS += lib/IniReader.h \
main.h \
lib/GroupView.h \
lib/EntryView.h \
crypto/arcfour.h
crypto/arcfour.h \
lib/KpFileIconProvider.h
SOURCES += lib/IniReader.cpp \
lib/UrlLabel.cpp \
main.cpp \
@ -83,7 +84,8 @@ SOURCES += lib/IniReader.cpp \
lib/KdePlugin.cpp \
lib/GroupView.cpp \
lib/EntryView.cpp \
crypto/arcfour.cpp
crypto/arcfour.cpp \
lib/KpFileIconProvider.cpp
QT += xml \
qt3support
MOC_DIR = ../build/moc