QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
QtPass Class Reference

Application-level glue between the pass backends and whatever shows their results: turns the backends' completion signals into UI-neutral signals (formatted output, status messages, "the operation is over"), owns the ClipboardManager, migrates the settings of older versions on start-up and renders QR codes. It knows nothing about the main window; the window connects to the signals below. More...

#include <qtpass.h>

Inheritance diagram for QtPass:
Collaboration diagram for QtPass:

Public Slots

void showTextAsQRCode (const QString &text)
 Render text as a QR code with qrencode and show it in a popup at the cursor; failures are reported through statusMessage().

Signals

void outputReady (const QString &html)
 Formatted output (see formatOutput()) or an error rendered in colour, ready for the text browser.
void operationFinished ()
 A backend operation is over, successfully or not; the interface can be enabled again.
void statusMessage (const QString &message, int timeout)
 A short message for the status bar.
void pushRequested ()
 The store changed and the settings ask for an automatic push.
void entryInserted ()
 An entry was written; the view of the current entry is stale.

Public Member Functions

 QtPass (QObject *parent=nullptr)
 Construct the glue and connect it to both pass backends.
 ~QtPass () override
 Destroy the QtPass instance and clean up signal connections.
void init ()
 Resolve the password store and the executables and migrate the settings of an older version (fresh-install defaults, the native-OTP switch). Whether the resulting configuration is usable is the caller's question: see Util::configIsValid().
auto clipboard () -> ClipboardManager &
 The clipboard handling for this application instance.

Static Public Member Functions

static auto formatOutput (QString output, const QString &prefix=QString(), const QString &postfix=QString()) -> QString
 Turn a process' plain-text output into the HTML the text browser shows: http(s) URLs become links, everything else is escaped, line breaks become <br />.
static QDialog * createQRCodePopup (const QPixmap &image)
 Create a frameless popup dialog, placed at the cursor, showing the given QR code. Split out of showTextAsQRCode() so tests can inspect the dialog without running qrencode.

Private Slots

void processErrorExit (int exitCode, const QString &error)
 Slot for Pass::processErrorExit: report the error in red and emit operationFinished().
void processFinished (const QString &output, const QString &errout)
 Slot for Pass::finishedGitPull / finishedGitPush and the common tail of the other slots: emit the stdout as formatted output (if any), the stderr as grey chatter, then operationFinished().
void passStoreChanged (const QString &output, const QString &errout)
 Slot for the backend signals that change the store on disk (git init, remove, init, move, copy): processFinished() followed by doGitPush().
void doGitPush ()
 Emit pushRequested() when the settings ask for automatic push.
void finishedInsert (const QString &output, const QString &errout)
 Slot for Pass::finishedInsert: like passStoreChanged(), then emit entryInserted() so the window refreshes the shown entry.
void onKeyGenerationComplete (const QString &output, const QString &errout)
 Slot for Pass::finishedGenerateGPGKeys: a status message followed by processFinished(). The KeygenDialog listens to the same signal and closes itself.

Private Member Functions

void connectPassSignalHandlers (Pass *pass)
 Connect the completion signals of one backend to the slots that turn them into output, status and "finished" signals. Both backends are wired up at construction because the active one can change through the configuration dialog.
void reportError (int exitCode, const QString &error)
 Show a process' stderr in colour through outputReady(): red for a failure, dark grey for the chatter a successful command prints (see issue #111). Nothing is shown for empty output.

Private Attributes

ClipboardManager m_clipboard
 The clipboard handling for this application instance, exposed through clipboard(); parented to this object.

Detailed Description

Application-level glue between the pass backends and whatever shows their results: turns the backends' completion signals into UI-neutral signals (formatted output, status messages, "the operation is over"), owns the ClipboardManager, migrates the settings of older versions on start-up and renders QR codes. It knows nothing about the main window; the window connects to the signals below.

Definition at line 28 of file qtpass.h.

Constructor & Destructor Documentation

◆ QtPass()

QtPass::QtPass ( QObject * parent = nullptr)
explicit

Construct the glue and connect it to both pass backends.

Parameters
parentOwner.

Definition at line 22 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~QtPass()

QtPass::~QtPass ( )
overridedefault

Destroy the QtPass instance and clean up signal connections.

Here is the call graph for this function:

Member Function Documentation

◆ clipboard()

auto QtPass::clipboard ( ) -> ClipboardManager &
inline

The clipboard handling for this application instance.

Returns
The manager; lives as long as this object.

Definition at line 54 of file qtpass.h.

Here is the caller graph for this function:

◆ connectPassSignalHandlers()

void QtPass::connectPassSignalHandlers ( Pass * pass)
private

Connect the completion signals of one backend to the slots that turn them into output, status and "finished" signals. Both backends are wired up at construction because the active one can change through the configuration dialog.

Parameters
passThe backend to listen to.

Definition at line 84 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createQRCodePopup()

QDialog * QtPass::createQRCodePopup ( const QPixmap & image)
static

Create a frameless popup dialog, placed at the cursor, showing the given QR code. Split out of showTextAsQRCode() so tests can inspect the dialog without running qrencode.

Parameters
imagePixmap containing the rendered QR code.
Returns
Pointer to a QDialog showing the image; it deletes itself on close, the caller shows it.

Definition at line 201 of file qtpass.cpp.

Here is the caller graph for this function:

◆ doGitPush

void QtPass::doGitPush ( )
privateslot

Emit pushRequested() when the settings ask for automatic push.

Definition at line 151 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ entryInserted

void QtPass::entryInserted ( )
signal

An entry was written; the view of the current entry is stale.

Here is the caller graph for this function:

◆ finishedInsert

void QtPass::finishedInsert ( const QString & output,
const QString & errout )
privateslot

Slot for Pass::finishedInsert: like passStoreChanged(), then emit entryInserted() so the window refreshes the shown entry.

Parameters
outputstdout of the process.
erroutstderr of the process.

Definition at line 129 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatOutput()

auto QtPass::formatOutput ( QString output,
const QString & prefix = QString(),
const QString & postfix = QString() ) -> QString
static

Turn a process' plain-text output into the HTML the text browser shows: http(s) URLs become links, everything else is escaped, line breaks become <br />.

Parameters
outputPlain text from a process.
prefixHTML placed before the converted output.
postfixHTML placed after it.
Returns
The HTML.

Definition at line 142 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

void QtPass::init ( )

Resolve the password store and the executables and migrate the settings of an older version (fresh-install defaults, the native-OTP switch). Whether the resulting configuration is usable is the caller's question: see Util::configIsValid().

Definition at line 31 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onKeyGenerationComplete

void QtPass::onKeyGenerationComplete ( const QString & output,
const QString & errout )
privateslot

Slot for Pass::finishedGenerateGPGKeys: a status message followed by processFinished(). The KeygenDialog listens to the same signal and closes itself.

Parameters
outputstdout of the key generation process.
erroutstderr of the key generation process.

Definition at line 135 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operationFinished

void QtPass::operationFinished ( )
signal

A backend operation is over, successfully or not; the interface can be enabled again.

Here is the caller graph for this function:

◆ outputReady

void QtPass::outputReady ( const QString & html)
signal

Formatted output (see formatOutput()) or an error rendered in colour, ready for the text browser.

Parameters
htmlThe HTML to show.
Here is the caller graph for this function:

◆ passStoreChanged

void QtPass::passStoreChanged ( const QString & output,
const QString & errout )
privateslot

Slot for the backend signals that change the store on disk (git init, remove, init, move, copy): processFinished() followed by doGitPush().

Parameters
outputstdout of the process.
erroutstderr of the process.

Definition at line 124 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processErrorExit

void QtPass::processErrorExit ( int exitCode,
const QString & error )
privateslot

Slot for Pass::processErrorExit: report the error in red and emit operationFinished().

Parameters
exitCodeThe exit code of the failed process.
errorIts stderr.

Definition at line 109 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processFinished

void QtPass::processFinished ( const QString & output,
const QString & errout )
privateslot

Slot for Pass::finishedGitPull / finishedGitPush and the common tail of the other slots: emit the stdout as formatted output (if any), the stderr as grey chatter, then operationFinished().

Parameters
outputstdout of the process.
erroutstderr of the process.

Definition at line 114 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushRequested

void QtPass::pushRequested ( )
signal

The store changed and the settings ask for an automatic push.

Here is the caller graph for this function:

◆ reportError()

void QtPass::reportError ( int exitCode,
const QString & error )
private

Show a process' stderr in colour through outputReady(): red for a failure, dark grey for the chatter a successful command prints (see issue #111). Nothing is shown for empty output.

Parameters
exitCodeThe process exit code; 0 selects grey.
errorThe stderr text.

Definition at line 98 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showTextAsQRCode

void QtPass::showTextAsQRCode ( const QString & text)
slot

Render text as a QR code with qrencode and show it in a popup at the cursor; failures are reported through statusMessage().

Parameters
textText to convert into a QR code.

Definition at line 157 of file qtpass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ statusMessage

void QtPass::statusMessage ( const QString & message,
int timeout )
signal

A short message for the status bar.

Parameters
messageThe text.
timeoutMilliseconds to keep it, as QStatusBar::showMessage().
Here is the caller graph for this function:

Member Data Documentation

◆ m_clipboard

ClipboardManager QtPass::m_clipboard
private

The clipboard handling for this application instance, exposed through clipboard(); parented to this object.

Definition at line 118 of file qtpass.h.


The documentation for this class was generated from the following files: