improved AutoTypeDlg (keyboard only usage, visual selection feedback)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@195 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 17 years ago
parent 96ac6e31f1
commit 1905150642
  1. 4
      src/dialogs/AutoTypeDlg.cpp
  2. 13
      src/forms/AutoTypeDlg.ui
  3. 40
      src/lib/AutoTypeTreeWidget.cpp
  4. 29
      src/lib/AutoTypeTreeWidget.h
  5. 8
      src/src.pro

@ -4,7 +4,6 @@
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; version 2 of the License. * * the Free Software Foundation; version 2 of the License. *
* * * *
* This program is distributed in the hope that it will be useful, * * This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
@ -53,6 +52,7 @@ AutoTypeDlg::AutoTypeDlg(QList<IEntryHandle*> entries, QList<int> numbers){
qSort(itemList.begin(), itemList.end(), itemLessThan); qSort(itemList.begin(), itemList.end(), itemLessThan);
for (int i=0; i<itemList.size(); i++) for (int i=0; i<itemList.size(); i++)
entryList->addTopLevelItem(itemList[i]); entryList->addTopLevelItem(itemList[i]);
entryList->setCurrentItem(itemList[0]);
entryList->resizeColumnToContents(0); entryList->resizeColumnToContents(0);
entryList->resizeColumnToContents(1); entryList->resizeColumnToContents(1);
@ -65,6 +65,7 @@ AutoTypeDlg::AutoTypeDlg(QList<IEntryHandle*> entries, QList<int> numbers){
connect(ButtonBox, SIGNAL(rejected()), SLOT(close())); connect(ButtonBox, SIGNAL(rejected()), SLOT(close()));
connect(entryList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), SLOT(itemSelected(QTreeWidgetItem*))); connect(entryList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), SLOT(itemSelected(QTreeWidgetItem*)));
connect(entryList, SIGNAL(returnPressed(QTreeWidgetItem*)), SLOT(itemSelected(QTreeWidgetItem*)));
} }
bool AutoTypeDlg::itemLessThan(QTreeWidgetItem* i1, QTreeWidgetItem* i2){ bool AutoTypeDlg::itemLessThan(QTreeWidgetItem* i1, QTreeWidgetItem* i2){
@ -76,6 +77,7 @@ bool AutoTypeDlg::itemLessThan(QTreeWidgetItem* i1, QTreeWidgetItem* i2){
return i1->text(2) < i2->text(2); return i1->text(2) < i2->text(2);
} }
void AutoTypeDlg::paintEvent(QPaintEvent* event){ void AutoTypeDlg::paintEvent(QPaintEvent* event){
QWidget::paintEvent(event); QWidget::paintEvent(event);
QPainter painter(this); QPainter painter(this);

@ -37,9 +37,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTreeWidget" name="entryList" > <widget class="AutoTypeTreeWidget" name="entryList" >
<property name="cursor" stdset="0" > <property name="mouseTracking" >
<cursorShape>PointingHandCursor</cursorShape> <bool>true</bool>
</property> </property>
<property name="rootIsDecorated" > <property name="rootIsDecorated" >
<bool>false</bool> <bool>false</bool>
@ -64,6 +64,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>AutoTypeTreeWidget</class>
<extends>QTreeWidget</extends>
<header>lib/AutoTypeTreeWidget.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

@ -0,0 +1,40 @@
/***************************************************************************
* Copyright (C) 2005-2008 by Tarek Saidi *
* *
* 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; version 2 of the License. *
* *
* 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 "lib/AutoTypeTreeWidget.h"
void AutoTypeTreeWidget::mouseMoveEvent(QMouseEvent* event){
QTreeWidgetItem* item = itemAt(event->pos());
if(item){
setCurrentItem(item);
setCursor(Qt::PointingHandCursor);
}
else {
unsetCursor();
}
}
void AutoTypeTreeWidget::keyPressEvent(QKeyEvent* event){
if(event->key()==Qt::Key_Return){
emit returnPressed(currentItem());
event->accept();
}
else {
QTreeWidget::keyPressEvent(event);
}
}

@ -0,0 +1,29 @@
/***************************************************************************
* Copyright (C) 2005-2008 by Tarek Saidi *
* *
* 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; version 2 of the License. *
* *
* 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. *
***************************************************************************/
class AutoTypeTreeWidget : public QTreeWidget {
Q_OBJECT
public:
AutoTypeTreeWidget(QWidget* parent):QTreeWidget(parent){}
signals:
void returnPressed(QTreeWidgetItem*);
private:
void mouseMoveEvent(QMouseEvent*);
void keyPressEvent(QKeyEvent*);
};

@ -76,7 +76,7 @@ macx {
QMAKE_BUNDLE_DATA += data QMAKE_BUNDLE_DATA += data
ICON = ../share/macx_bundle/icon.icns ICON = ../share/macx_bundle/icon.icns
CONFIG += app_bundle CONFIG += app_bundle
isEqual(ARCH,UNIVERSAL) { isEqual(ARCH,UNIVERSAL){
CONFIG += x86 ppc CONFIG += x86 ppc
# lipo cannot handle precompiled headers (yet) # lipo cannot handle precompiled headers (yet)
CONFIG -= precompile_header CONFIG -= precompile_header
@ -202,7 +202,8 @@ HEADERS += lib/UrlLabel.h \
KpxConfig.h \ KpxConfig.h \
dialogs/AddBookmarkDlg.h \ dialogs/AddBookmarkDlg.h \
lib/bookmarks.h \ lib/bookmarks.h \
dialogs/ManageBookmarksDlg.h dialogs/ManageBookmarksDlg.h \
lib/AutoTypeTreeWidget.h
SOURCES += lib/UrlLabel.cpp \ SOURCES += lib/UrlLabel.cpp \
main.cpp \ main.cpp \
@ -253,7 +254,8 @@ SOURCES += lib/UrlLabel.cpp \
crypto/aescrypt.c \ crypto/aescrypt.c \
crypto/aeskey.c \ crypto/aeskey.c \
crypto/aes_modes.c \ crypto/aes_modes.c \
crypto/aestab.c crypto/aestab.c \
lib/AutoTypeTreeWidget.cpp
PRECOMPILED_HEADER = keepassx.h PRECOMPILED_HEADER = keepassx.h