QtPass 2.0.0
Developer documentation
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
14class QLineEdit;
15
26class FieldLabel : public QLabel {
27 Q_OBJECT
28
29public:
35 explicit FieldLabel(const QString &name, QWidget *parent = nullptr);
41 ~FieldLabel() override;
42
43public slots:
47 void startEdit();
48
49signals:
55 void renamed(const QString &from, const QString &to);
60
61protected:
66 void mouseDoubleClickEvent(QMouseEvent *event) override;
71 void contextMenuEvent(QContextMenuEvent *event) override;
78 auto eventFilter(QObject *watched, QEvent *event) -> bool override;
79
80private:
85 void finishEdit(bool commit);
86
92 QPointer<QLineEdit> m_editor;
93};
94
95#endif // FIELDLABEL_H_
FieldLabel(const QString &name, QWidget *parent=nullptr)
Label for the field called name.
void contextMenuEvent(QContextMenuEvent *event) override
Menu with Rename field and Remove field.
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:92
void removeRequested()
The user chose "Remove field".
void finishEdit(bool commit)
Close the editor, putting the label back in its place.
void renamed(const QString &from, const QString &to)
The user typed a different name and confirmed it.
void mouseDoubleClickEvent(QMouseEvent *event) override
A left double-click starts editing the name.
void startEdit()
Open the in-place editor over the label.
auto eventFilter(QObject *watched, QEvent *event) -> bool override
Escape in the editor cancels the edit.