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 16 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. 10
      src/src.pro

@ -4,7 +4,6 @@
* 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 *
@ -53,6 +52,7 @@ AutoTypeDlg::AutoTypeDlg(QList<IEntryHandle*> entries, QList<int> numbers){
qSort(itemList.begin(), itemList.end(), itemLessThan);
for (int i=0; i<itemList.size(); i++)
entryList->addTopLevelItem(itemList[i]);
entryList->setCurrentItem(itemList[0]);
entryList->resizeColumnToContents(0);
entryList->resizeColumnToContents(1);
@ -65,6 +65,7 @@ AutoTypeDlg::AutoTypeDlg(QList<IEntryHandle*> entries, QList<int> numbers){
connect(ButtonBox, SIGNAL(rejected()), SLOT(close()));
connect(entryList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), SLOT(itemSelected(QTreeWidgetItem*)));
connect(entryList, SIGNAL(returnPressed(QTreeWidgetItem*)), SLOT(itemSelected(QTreeWidgetItem*)));
}
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);
}
void AutoTypeDlg::paintEvent(QPaintEvent* event){
QWidget::paintEvent(event);
QPainter painter(this);

@ -37,9 +37,9 @@
</widget>
</item>
<item>
<widget class="QTreeWidget" name="entryList" >
<property name="cursor" stdset="0" >
<cursorShape>PointingHandCursor</cursorShape>
<widget class="AutoTypeTreeWidget" name="entryList" >
<property name="mouseTracking" >
<bool>true</bool>
</property>
<property name="rootIsDecorated" >
<bool>false</bool>
@ -64,6 +64,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>AutoTypeTreeWidget</class>
<extends>QTreeWidget</extends>
<header>lib/AutoTypeTreeWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</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,12 +76,12 @@ macx {
QMAKE_BUNDLE_DATA += data
ICON = ../share/macx_bundle/icon.icns
CONFIG += app_bundle
isEqual(ARCH,UNIVERSAL) {
isEqual(ARCH,UNIVERSAL){
CONFIG += x86 ppc
# lipo cannot handle precompiled headers (yet)
CONFIG -= precompile_header
QMAKE_CXXFLAGS += -include keepassx.h
}
}
isEqual(ARCH,INTEL): CONFIG += x86
isEqual(ARCH,PPC): CONFIG += ppc
SOURCES += main_macx.cpp
@ -202,7 +202,8 @@ HEADERS += lib/UrlLabel.h \
KpxConfig.h \
dialogs/AddBookmarkDlg.h \
lib/bookmarks.h \
dialogs/ManageBookmarksDlg.h
dialogs/ManageBookmarksDlg.h \
lib/AutoTypeTreeWidget.h
SOURCES += lib/UrlLabel.cpp \
main.cpp \
@ -253,7 +254,8 @@ SOURCES += lib/UrlLabel.cpp \
crypto/aescrypt.c \
crypto/aeskey.c \
crypto/aes_modes.c \
crypto/aestab.c
crypto/aestab.c \
lib/AutoTypeTreeWidget.cpp
PRECOMPILED_HEADER = keepassx.h