BibleTime
btlocationedit.cpp
Go to the documentation of this file.
1/*********
2*
3* In the name of the Father, and of the Son, and of the Holy Spirit.
4*
5* This file is part of BibleTime's source code, https://bibletime.info/
6*
7* Copyright 1999-2026 by the BibleTime developers.
8* The BibleTime source code is licensed under the GNU General Public License
9* version 2.0.
10*
11**********/
12
13#include "btlocationedit.h"
14
15#include <QFocusEvent>
16#include <QKeyCombination>
17#include <QKeyEvent>
18#include <QKeySequence>
19#include "../../backend/config/btconfig.h"
20
21
22void BtLocationEdit::focusInEvent(QFocusEvent * const event) {
23 Qt::FocusReason reason = event->reason();
24 if (reason == Qt::OtherFocusReason)
25 selectAll();
26
27 QWidget::focusInEvent(event);
28}
29
30void BtLocationEdit::keyPressEvent(QKeyEvent * const event) {
31 auto const shortcuts =
32 btConfig().getShortcuts(QStringLiteral("Displaywindow shortcuts"));
33 if (auto const it = shortcuts.find("openLocation"); it != shortcuts.end()) {
34 for (auto const & keySequence : it.value()) {
35 if (keySequence.count() == 1) {
36 if (event->keyCombination() == keySequence[0]) {
37 selectAll();
38 return;
39 }
40 }
41 }
42 } else if (event->keyCombination()
43 == QKeyCombination(Qt::ControlModifier, Qt::Key_L))
44 {
45 selectAll();
46 return;
47 }
48 QLineEdit::keyPressEvent(event);
49}
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
Definition btconfig.h:305
ShortcutsMap getShortcuts(QString const &shortcutGroup)
Gets the shortcuts for the given group.
Definition btconfig.cpp:232
void focusInEvent(QFocusEvent *event) override
void keyPressEvent(QKeyEvent *event) override