Falkon
Develop
Cross-platform Qt-based web browser
focusselectlineedit.cpp
Go to the documentation of this file.
1
/* ============================================================
2
* Falkon - Qt web browser
3
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
* ============================================================ */
18
#include "
focusselectlineedit.h
"
19
20
#include <QFocusEvent>
21
22
FocusSelectLineEdit::FocusSelectLineEdit
(QWidget* parent)
23
: QLineEdit(parent)
24
, m_mouseFocusReason(false)
25
{
26
}
27
28
void
FocusSelectLineEdit::setFocus
()
29
{
30
selectAll();
31
32
QLineEdit::setFocus();
33
}
34
35
void
FocusSelectLineEdit::focusInEvent
(QFocusEvent* event)
36
{
37
m_mouseFocusReason
=
event
->reason() == Qt::MouseFocusReason;
38
selectAll();
39
40
QLineEdit::focusInEvent(event);
41
}
42
43
void
FocusSelectLineEdit::mousePressEvent
(QMouseEvent* event)
44
{
45
if
(
m_mouseFocusReason
) {
46
m_mouseFocusReason
=
false
;
47
return
;
48
}
49
50
QLineEdit::mousePressEvent(event);
51
}
FocusSelectLineEdit::FocusSelectLineEdit
FocusSelectLineEdit(QWidget *parent=nullptr)
Definition:
focusselectlineedit.cpp:22
FocusSelectLineEdit::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition:
focusselectlineedit.cpp:43
FocusSelectLineEdit::setFocus
void setFocus()
Definition:
focusselectlineedit.cpp:28
FocusSelectLineEdit::focusInEvent
void focusInEvent(QFocusEvent *event) override
Definition:
focusselectlineedit.cpp:35
FocusSelectLineEdit::m_mouseFocusReason
bool m_mouseFocusReason
Definition:
focusselectlineedit.h:38
focusselectlineedit.h
src
lib
tools
focusselectlineedit.cpp
Generated by
1.9.3