From 19051506429d22bc948696df374bfd245126fb45 Mon Sep 17 00:00:00 2001 From: tarek_saidi Date: Mon, 14 Apr 2008 20:03:58 +0000 Subject: [PATCH] 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 --- src/dialogs/AutoTypeDlg.cpp | 4 +++- src/forms/AutoTypeDlg.ui | 13 ++++++++--- src/lib/AutoTypeTreeWidget.cpp | 40 ++++++++++++++++++++++++++++++++++ src/lib/AutoTypeTreeWidget.h | 29 ++++++++++++++++++++++++ src/src.pro | 10 +++++---- 5 files changed, 88 insertions(+), 8 deletions(-) create mode 100644 src/lib/AutoTypeTreeWidget.cpp create mode 100644 src/lib/AutoTypeTreeWidget.h diff --git a/src/dialogs/AutoTypeDlg.cpp b/src/dialogs/AutoTypeDlg.cpp index 1d4498b..93ea236 100644 --- a/src/dialogs/AutoTypeDlg.cpp +++ b/src/dialogs/AutoTypeDlg.cpp @@ -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 entries, QList numbers){ qSort(itemList.begin(), itemList.end(), itemLessThan); for (int i=0; iaddTopLevelItem(itemList[i]); + entryList->setCurrentItem(itemList[0]); entryList->resizeColumnToContents(0); entryList->resizeColumnToContents(1); @@ -65,6 +65,7 @@ AutoTypeDlg::AutoTypeDlg(QList entries, QList 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); diff --git a/src/forms/AutoTypeDlg.ui b/src/forms/AutoTypeDlg.ui index bbecf6f..c4e8131 100644 --- a/src/forms/AutoTypeDlg.ui +++ b/src/forms/AutoTypeDlg.ui @@ -37,9 +37,9 @@ - - - PointingHandCursor + + + true false @@ -64,6 +64,13 @@ + + + AutoTypeTreeWidget + QTreeWidget +
lib/AutoTypeTreeWidget.h
+
+
diff --git a/src/lib/AutoTypeTreeWidget.cpp b/src/lib/AutoTypeTreeWidget.cpp new file mode 100644 index 0000000..045c941 --- /dev/null +++ b/src/lib/AutoTypeTreeWidget.cpp @@ -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); + } +} \ No newline at end of file diff --git a/src/lib/AutoTypeTreeWidget.h b/src/lib/AutoTypeTreeWidget.h new file mode 100644 index 0000000..1732435 --- /dev/null +++ b/src/lib/AutoTypeTreeWidget.h @@ -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*); +}; \ No newline at end of file diff --git a/src/src.pro b/src/src.pro index 272b83d..ea6316e 100644 --- a/src/src.pro +++ b/src/src.pro @@ -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