QtPass
2.0.0
Developer documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
fieldlabel.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
8
#ifndef FIELDLABEL_H_
9
#define FIELDLABEL_H_
10
11
#include <QLabel>
12
#include <QPointer>
13
14
class
QLineEdit;
15
26
class
FieldLabel
:
public
QLabel {
27
Q_OBJECT
28
29
public
:
35
explicit
FieldLabel
(
const
QString &
name
, QWidget *parent =
nullptr
);
36
42
[[nodiscard]]
auto
name
() const -> QString {
return
m_name
; }
47
void
setName
(
const
QString &
name
);
53
~FieldLabel
()
override
;
54
55
public
slots:
59
void
startEdit
();
60
61
signals:
68
void
renamed
(
const
QString &from,
const
QString &to);
72
void
removeRequested
();
77
void
copied
(
const
QString &text);
78
79
protected
:
84
void
mouseDoubleClickEvent
(QMouseEvent *event)
override
;
89
void
contextMenuEvent
(QContextMenuEvent *event)
override
;
96
auto
eventFilter
(QObject *watched, QEvent *event) ->
bool
override
;
97
98
private
:
103
void
finishEdit
(
bool
commit);
104
110
QPointer<QLineEdit>
m_editor
;
112
QString
m_name
;
113
};
114
115
#endif
// FIELDLABEL_H_
FieldLabel
The name of a key: value field in PasswordDialog, editable in place: double-click or the context menu...
Definition
fieldlabel.h:26
FieldLabel::FieldLabel
FieldLabel(const QString &name, QWidget *parent=nullptr)
Label for the field called name.
Definition
fieldlabel.cpp:18
FieldLabel::contextMenuEvent
void contextMenuEvent(QContextMenuEvent *event) override
Menu with Rename field and Remove field.
Definition
fieldlabel.cpp:41
FieldLabel::m_editor
QPointer< QLineEdit > m_editor
The line edit open over the label while a rename is in progress; null otherwise. A sibling in the par...
Definition
fieldlabel.h:110
FieldLabel::copied
void copied(const QString &text)
Text was copied out of the name editor, marked as a secret.
FieldLabel::setName
void setName(const QString &name)
Name the field name and show it.
Definition
fieldlabel.cpp:27
FieldLabel::removeRequested
void removeRequested()
The user chose "Remove field".
FieldLabel::finishEdit
void finishEdit(bool commit)
Close the editor, putting the label back in its place.
Definition
fieldlabel.cpp:117
FieldLabel::renamed
void renamed(const QString &from, const QString &to)
The user typed a different name and confirmed it.
FieldLabel::mouseDoubleClickEvent
void mouseDoubleClickEvent(QMouseEvent *event) override
A left double-click starts editing the name.
Definition
fieldlabel.cpp:33
FieldLabel::startEdit
void startEdit()
Open the in-place editor over the label.
Definition
fieldlabel.cpp:50
FieldLabel::eventFilter
auto eventFilter(QObject *watched, QEvent *event) -> bool override
Escape in the editor cancels the edit.
Definition
fieldlabel.cpp:95
FieldLabel::name
auto name() const -> QString
The field's key, whole; the label shows it through Util::shownName().
Definition
fieldlabel.h:42
FieldLabel::m_name
QString m_name
The field's key, whole (the text shown may be cut).
Definition
fieldlabel.h:112
src
fieldlabel.h
Generated by
1.18.0