summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-13 21:15:07 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-13 21:18:54 -0800
commitd117becad83a42f49e17bc151ce5ecc11e4dc8cf (patch)
treed742da993346f3278c7f6f4f40aad85f4f7150ac
parentcd0a90014d43cc07211af41f8cc8ce6cbf032d56 (diff)
downloadsubsurface-d117becad83a42f49e17bc151ce5ecc11e4dc8cf.tar.gz
Improve MainTab behavior when using the scroll wheel
This gets the behavior close to what we really want. - scroll wheel no longer enters edit mode when over the tabWidget - scroll wheel doesn't modify dateTimeEdit, nor does it enter edit mode - scroll wheel still scrolls both the notes and the full widget The only oddity is that when clicking on either the dateTimeEdit or the tabWidget we don't immediately turn on the 'being edited' warning (as we do for all the other widgets). For those two widgets the user has to press a key before edit mode starts. I think this Fixes #176 Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Ideas-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/maintab.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index edc425bfb..81187dcf8 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -281,19 +281,23 @@ void MainTab::enableEdition(EditMode newEditMode)
bool MainTab::eventFilter(QObject* object, QEvent* event)
{
- if (isEnabled() && event->type() == QEvent::KeyPress && object == ui.dateTimeEdit) {
- tabBar()->setTabIcon(currentIndex(), QIcon(":warning"));
- enableEdition();
- }
-
- if (isEnabled() && event->type() == QEvent::FocusIn && (object == ui.rating ||
- object == ui.visibility ||
- object == ui.tagWidget)) {
- tabBar()->setTabIcon(currentIndex(), QIcon(":warning"));
- enableEdition();
- }
-
- if (isEnabled() && event->type() == QEvent::MouseButtonPress ) {
+ // we want to prevent the user from accidentally enabling editMode:
+ // for the tagWidget we ignore FocusIn - that's both a click and starting the scroll wheel
+ // this means a click by itself won't start edit mode - but typing something will
+ if (isEnabled() && editMode == NONE && object->objectName() == "tagWidget" &&
+ event->type() == QEvent::FocusIn)
+ return true;
+ // for the dateTimeEdit widget we need to ignore Wheel events as well (as long as we aren't editing)
+ if (isEnabled() && editMode == NONE && object->objectName() == "dateTimeEdit" &&
+ (event->type() == QEvent::FocusIn || event->type() == QEvent::Wheel))
+ return true;
+ // MouseButtonPress in any widget (not all will ever get this), KeyPress in the dateTimeEdit,
+ // FocusIn for the starWidgets or RequestSoftwareInputPanel for tagWidget start the editing
+ if (isEnabled() && editMode == NONE &&
+ (event->type() == QEvent::MouseButtonPress) ||
+ (event->type() == QEvent::KeyPress && object == ui.dateTimeEdit) ||
+ (event->type() == QEvent::FocusIn && (object == ui.rating || object == ui.visibility)) ||
+ (event->type() == QEvent::RequestSoftwareInputPanel && object == ui.tagWidget)) {
tabBar()->setTabIcon(currentIndex(), QIcon(":warning"));
enableEdition();
}