Puts secrets on the system clipboard and takes them off again.
More...
#include <clipboardmanager.h>
|
| void | copyText (const QString &text) |
| | Copy text into the system clipboard (or the X11 primary selection when configured) and arm the autoclear timer when enabled.
|
| void | trackCopied (const QString &text) |
| | Track text that got onto the clipboard some other way.
|
| void | clear () |
| | Remove the tracked text from the clipboard if it is still there. Silent no-op when nothing is tracked.
|
|
| void | statusMessage (const QString &message) |
| | Something worth showing in the status bar happened.
|
|
| | ClipboardManager (QObject *parent=nullptr) |
| | Construct a manager that also clears its text when the application quits.
|
| void | setAutoclearTimer () |
| | Re-read the autoclear delay from the settings.
|
| void | copyIfAlways (const QString &text, const QString &p_output=QString()) |
| | Handle clipboard copying for a shown entry.
|
| auto | trackedText () const -> QString |
| | The text this manager last put on the clipboard and still tracks.
|
|
| void | forgetIfSaved (const QString &text) |
| | Empty a saved previous text equal to text, now copied as a secret, so clear() does not put the secret back.
|
| void | saveWhatWasThere (QClipboard *clip, QClipboard::Mode mode, const QString &text) |
| | Save what mode holds before the first secret of an autoclear window, for clear() to put back; saved as nothing when it is a secret itself (ours, text, or marked by another password manager).
|
| void | makeRoomInOtherCopies () |
| | Keep m_otherCopies below its cap before trackCopied() appends: drop the oldest text that is neither on the clipboard nor in the selection.
|
Puts secrets on the system clipboard and takes them off again.
Remembers what it copied so the autoclear timer (and the quit handler) only remove that text, never something the user copied in the meantime. Settings (selection vs. clipboard, autoclear on/off, delay) are read from QtPassSettings; call setAutoclearTimer() after they change. Status text for the main window's status bar is emitted, not shown, so this class has no UI dependency and is unit-testable.
Definition at line 48 of file clipboardmanager.h.
◆ ClipboardManager()
| ClipboardManager::ClipboardManager |
( |
QObject * | parent = nullptr | ) |
|
|
explicit |
Construct a manager that also clears its text when the application quits.
- Parameters
-
Definition at line 17 of file clipboardmanager.cpp.
◆ clear
| void ClipboardManager::clear |
( |
| ) |
|
|
slot |
Remove the tracked text from the clipboard if it is still there. Silent no-op when nothing is tracked.
Definition at line 238 of file clipboardmanager.cpp.
◆ copyIfAlways()
| void ClipboardManager::copyIfAlways |
( |
const QString & | text, |
|
|
const QString & | p_output = QString() ) |
Handle clipboard copying for a shown entry.
In "always copy" mode (and only then) this copies text via copyText(), which also arms the autoclear timer and records the clipboard contents. In other modes it does nothing, leaving any pending autoclear tracking intact.
- Parameters
-
| text | Password (or value) of the entry being shown. |
| p_output | Full decrypted output; copying is skipped when it is empty. |
Definition at line 102 of file clipboardmanager.cpp.
◆ copyText
| void ClipboardManager::copyText |
( |
const QString & | text | ) |
|
|
slot |
Copy text into the system clipboard (or the X11 primary selection when configured) and arm the autoclear timer when enabled.
- Parameters
-
Definition at line 116 of file clipboardmanager.cpp.
◆ forgetIfSaved()
| void ClipboardManager::forgetIfSaved |
( |
const QString & | text | ) |
|
|
private |
Empty a saved previous text equal to text, now copied as a secret, so clear() does not put the secret back.
- Parameters
-
| text | The text that has just been copied as a secret. |
Definition at line 172 of file clipboardmanager.cpp.
◆ makeRoomInOtherCopies()
| void ClipboardManager::makeRoomInOtherCopies |
( |
| ) |
|
|
private |
Keep m_otherCopies below its cap before trackCopied() appends: drop the oldest text that is neither on the clipboard nor in the selection.
Definition at line 218 of file clipboardmanager.cpp.
◆ saveWhatWasThere()
| void ClipboardManager::saveWhatWasThere |
( |
QClipboard * | clip, |
|
|
QClipboard::Mode | mode, |
|
|
const QString & | text ) |
|
private |
Save what mode holds before the first secret of an autoclear window, for clear() to put back; saved as nothing when it is a secret itself (ours, text, or marked by another password manager).
- Parameters
-
| clip | The application clipboard. |
| mode | The buffer about to be written. |
| text | The secret about to be copied. |
Definition at line 152 of file clipboardmanager.cpp.
◆ setAutoclearTimer()
| void ClipboardManager::setAutoclearTimer |
( |
| ) |
|
◆ statusMessage
| void ClipboardManager::statusMessage |
( |
const QString & | message | ) |
|
|
signal |
Something worth showing in the status bar happened.
- Parameters
-
◆ trackCopied
| void ClipboardManager::trackCopied |
( |
const QString & | text | ) |
|
|
slot |
Track text that got onto the clipboard some other way.
For a copy QtPass did not make through copyText(): text selected and copied from a widget showing a secret (Ctrl+C, the context menu, a drag, or the X11 primary selection that a mouse selection fills). The text is cleared with the rest when the autoclear timer runs; what copyText() tracks stays tracked too.
- Parameters
-
| text | The copied text; nothing happens when it is empty. |
Definition at line 184 of file clipboardmanager.cpp.
◆ trackedText()
| auto ClipboardManager::trackedText |
( |
| ) |
const -> QString |
|
inlinenodiscard |
The text this manager last put on the clipboard and still tracks.
- Returns
- Tracked text, empty once cleared.
Definition at line 80 of file clipboardmanager.h.
◆ m_clearTimer
| QTimer ClipboardManager::m_clearTimer |
|
private |
◆ m_clippedText
| QString ClipboardManager::m_clippedText |
|
private |
◆ m_otherCopies
| QStringList ClipboardManager::m_otherCopies |
|
private |
◆ m_previousClipboard
| std::optional<QString> ClipboardManager::m_previousClipboard |
|
private |
What was on the clipboard and in the selection before copyText() first put a secret there, for clear() to put back (restoreClipboard). Text only, as pass -c keeps it; absent when nothing was saved.
Definition at line 129 of file clipboardmanager.h.
◆ m_previousSelection
| std::optional<QString> ClipboardManager::m_previousSelection |
|
private |
As m_previousClipboard, for the X11 primary selection.
Definition at line 131 of file clipboardmanager.h.
The documentation for this class was generated from the following files: