QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
secretlineedit.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 SRC_SECRETLINEEDIT_H_
9#define SRC_SECRETLINEEDIT_H_
10
11#include <QClipboard>
12#include <QLineEdit>
13#include <functional>
14
15class QMenu;
16
44class SecretLineEdit : public QLineEdit {
45 Q_OBJECT
46
47public:
52 explicit SecretLineEdit(QWidget *parent = nullptr);
53
59 [[nodiscard]] auto createSecretContextMenu() -> QMenu *;
60
61signals:
66 void copied(const QString &text);
67
68protected:
75 void keyPressEvent(QKeyEvent *event) override;
76
82 void mouseReleaseEvent(QMouseEvent *event) override;
83
88 void contextMenuEvent(QContextMenuEvent *event) override;
89
90private:
98 void copySelection(QClipboard::Mode mode);
103 void cutSelection();
112 void withoutPlainSelectionCopy(const std::function<void()> &handler);
118 void publishSelection();
119};
120
121#endif // SRC_SECRETLINEEDIT_H_
void mouseReleaseEvent(QMouseEvent *event) override
Fills the primary selection with the marked selection on a left-button release, instead of QLineEdit'...
void copied(const QString &text)
Selected text was copied out of the line edit.
void cutSelection()
Copies the selection through copySelection() and then deletes it. Does nothing when read-only or with...
void withoutPlainSelectionCopy(const std::function< void()> &handler)
Runs a base-class event handler so that it cannot fill the primary selection with plain text: in a re...
auto createSecretContextMenu() -> QMenu *
The standard context menu, with Copy and Cut going through the secret copy.
void publishSelection()
Fills the X11 primary selection with the marked selection, on platforms that have one; called after a...
SecretLineEdit(QWidget *parent=nullptr)
Constructs the line edit.
void contextMenuEvent(QContextMenuEvent *event) override
Shows createSecretContextMenu().
void copySelection(QClipboard::Mode mode)
Puts the selection on the clipboard or in the primary selection as secret-marked MIME data and emits ...
void keyPressEvent(QKeyEvent *event) override
Ctrl+C copies with the hints, Ctrl+X as well before it deletes; after any other key the primary selec...