diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-16 15:12:46 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-18 14:32:15 +0900 |
commit | 6d42a99e7f6d3ea3a9c977604c7cc980a4215f18 (patch) | |
tree | 8fed51d0cf5bac1fa64dcdd8fb35b15da97b0dd5 /qt-ui | |
parent | 531a5db2f182164e5344344e3678245215a430d0 (diff) | |
download | subsurface-6d42a99e7f6d3ea3a9c977604c7cc980a4215f18.tar.gz |
Improve the tag widget to allow us to tab to the next field
If the last key that went in ended a tag and the next key is a tab -
deliver that to the TabWidget instead so we can navigate between input
fields.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/maintab.cpp | 5 | ||||
-rw-r--r-- | qt-ui/maintab.h | 1 | ||||
-rw-r--r-- | qt-ui/tagwidget.cpp | 10 | ||||
-rw-r--r-- | qt-ui/tagwidget.h | 1 |
4 files changed, 15 insertions, 2 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 172e4e2d7..5ed1b6704 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -335,6 +335,11 @@ void MainTab::clearEquipment() weightModel->clear(); } +void MainTab::nextInputField(QKeyEvent *event) +{ + keyPressEvent(event); +} + void MainTab::clearInfo() { ui.sacText->clear(); diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index d201d2a47..241f4c7e6 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -66,6 +66,7 @@ public: void initialUiSetup(); bool isEditing(); void updateCoordinatesText(qreal lat, qreal lon); + void nextInputField(QKeyEvent *event); public slots: void addCylinder_clicked(); diff --git a/qt-ui/tagwidget.cpp b/qt-ui/tagwidget.cpp index dfeeac537..432aea923 100644 --- a/qt-ui/tagwidget.cpp +++ b/qt-ui/tagwidget.cpp @@ -4,8 +4,9 @@ #include <QAbstractItemView> #include <QSettings> #include <QFont> +#include "mainwindow.h" -TagWidget::TagWidget(QWidget *parent) : GroupedLineEdit(parent), m_completer(NULL) +TagWidget::TagWidget(QWidget *parent) : GroupedLineEdit(parent), m_completer(NULL), lastFinishedTag(false) { connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(reparse())); connect(this, SIGNAL(textChanged()), this, SLOT(reparse())); @@ -176,6 +177,7 @@ void TagWidget::keyPressEvent(QKeyEvent *e) { QPair<int, int> pos; QAbstractItemView *popup; + bool finishedTag = false; switch (e->key()) { case Qt::Key_Escape: pos = getCursorTagPosition(); @@ -199,13 +201,17 @@ void TagWidget::keyPressEvent(QKeyEvent *e) if (popup) popup->hide(); } + finishedTag = true; } - if (e->key() == Qt::Key_Tab || e->key() == Qt::Key_Return) { // let's pretend this is a comma instead + if (e->key() == Qt::Key_Tab && lastFinishedTag) { // if we already end in comma, go to next/prev field + MainWindow::instance()->information()->nextInputField(e); // by sending the key event to the MainTab widget + } else if (e->key() == Qt::Key_Tab || e->key() == Qt::Key_Return) { // otherwise let's pretend this is a comma instead QKeyEvent fakeEvent(e->type(), Qt::Key_Comma, e->modifiers(), QString(",")); GroupedLineEdit::keyPressEvent(&fakeEvent); } else { GroupedLineEdit::keyPressEvent(e); } + lastFinishedTag = finishedTag; } void TagWidget::wheelEvent(QWheelEvent *event) diff --git a/qt-ui/tagwidget.h b/qt-ui/tagwidget.h index 62fa36f30..003e9283d 100644 --- a/qt-ui/tagwidget.h +++ b/qt-ui/tagwidget.h @@ -27,6 +27,7 @@ protected: private: QCompleter *m_completer; + bool lastFinishedTag; }; #endif // TAGWIDGET_H |