mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
531a5db2f1
commit
6d42a99e7f
4 changed files with 15 additions and 2 deletions
|
@ -335,6 +335,11 @@ void MainTab::clearEquipment()
|
||||||
weightModel->clear();
|
weightModel->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainTab::nextInputField(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void MainTab::clearInfo()
|
void MainTab::clearInfo()
|
||||||
{
|
{
|
||||||
ui.sacText->clear();
|
ui.sacText->clear();
|
||||||
|
|
|
@ -66,6 +66,7 @@ public:
|
||||||
void initialUiSetup();
|
void initialUiSetup();
|
||||||
bool isEditing();
|
bool isEditing();
|
||||||
void updateCoordinatesText(qreal lat, qreal lon);
|
void updateCoordinatesText(qreal lat, qreal lon);
|
||||||
|
void nextInputField(QKeyEvent *event);
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void addCylinder_clicked();
|
void addCylinder_clicked();
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QFont>
|
#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(cursorPositionChanged()), this, SLOT(reparse()));
|
||||||
connect(this, SIGNAL(textChanged()), this, SLOT(reparse()));
|
connect(this, SIGNAL(textChanged()), this, SLOT(reparse()));
|
||||||
|
@ -176,6 +177,7 @@ void TagWidget::keyPressEvent(QKeyEvent *e)
|
||||||
{
|
{
|
||||||
QPair<int, int> pos;
|
QPair<int, int> pos;
|
||||||
QAbstractItemView *popup;
|
QAbstractItemView *popup;
|
||||||
|
bool finishedTag = false;
|
||||||
switch (e->key()) {
|
switch (e->key()) {
|
||||||
case Qt::Key_Escape:
|
case Qt::Key_Escape:
|
||||||
pos = getCursorTagPosition();
|
pos = getCursorTagPosition();
|
||||||
|
@ -199,13 +201,17 @@ void TagWidget::keyPressEvent(QKeyEvent *e)
|
||||||
if (popup)
|
if (popup)
|
||||||
popup->hide();
|
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(","));
|
QKeyEvent fakeEvent(e->type(), Qt::Key_Comma, e->modifiers(), QString(","));
|
||||||
GroupedLineEdit::keyPressEvent(&fakeEvent);
|
GroupedLineEdit::keyPressEvent(&fakeEvent);
|
||||||
} else {
|
} else {
|
||||||
GroupedLineEdit::keyPressEvent(e);
|
GroupedLineEdit::keyPressEvent(e);
|
||||||
}
|
}
|
||||||
|
lastFinishedTag = finishedTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagWidget::wheelEvent(QWheelEvent *event)
|
void TagWidget::wheelEvent(QWheelEvent *event)
|
||||||
|
|
|
@ -27,6 +27,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QCompleter *m_completer;
|
QCompleter *m_completer;
|
||||||
|
bool lastFinishedTag;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TAGWIDGET_H
|
#endif // TAGWIDGET_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue