forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DlgTrackInfo/UpDown: Change focus when pressing Up/Down on WBasicLine…
…Edit
- Loading branch information
1 parent
395697b
commit 4085793
Showing
4 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "widget/wbasiclineedit.h" | ||
|
||
#include <QKeyEvent> | ||
|
||
#include "moc_wbasiclineedit.cpp" | ||
|
||
WBasicLineEdit::WBasicLineEdit(QWidget* parent) | ||
: QLineEdit(parent) { | ||
} | ||
|
||
WBasicLineEdit::WBasicLineEdit(const QString& text, QWidget* parent) | ||
: QLineEdit(text, parent) { | ||
} | ||
|
||
void WBasicLineEdit::keyPressEvent(QKeyEvent* event) { | ||
bool noModifiersPressed = !(event->modifiers() & | ||
(Qt::ControlModifier | Qt::AltModifier | | ||
Qt::ShiftModifier | Qt::MetaModifier)); | ||
|
||
if (event->key() == Qt::Key_Up && noModifiersPressed) { | ||
if (focusPreviousChild()) { | ||
event->accept(); | ||
return; | ||
} | ||
} else if (event->key() == Qt::Key_Down && noModifiersPressed) { | ||
if (focusNextChild()) { | ||
event->accept(); | ||
return; | ||
} | ||
} | ||
|
||
QLineEdit::keyPressEvent(event); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <QLineEdit> | ||
|
||
/// Subclass of QLineEdit that allows the Up and Down arrow keys | ||
/// to be used like the Tab/Backtab keys. | ||
class WBasicLineEdit : public QLineEdit { | ||
Q_OBJECT | ||
public: | ||
explicit WBasicLineEdit(QWidget* parent = nullptr); | ||
explicit WBasicLineEdit(const QString& text, QWidget* parent = nullptr); | ||
|
||
protected: | ||
void keyPressEvent(QKeyEvent* event) override; | ||
}; |