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

The dockable "Process output" console: numbered, colour-coded lines of git/pass/gpg output with a line cap and sticky auto-scroll. More...

#include <processoutputpanel.h>

Inheritance diagram for ProcessOutputPanel:
Collaboration diagram for ProcessOutputPanel:

Public Slots

void clear ()
 Drop all output, reset the counter, re-arm auto-scroll.

Public Member Functions

 ProcessOutputPanel (QWidget *parent=nullptr)
 Build the console (Clear button + read-only text edit).
void append (const QString &output, bool isError, const QString &linePrefix=QString())
 Append output, one numbered line per non-empty input line.
auto lineCount () const -> int
 Number of lines appended since the last clear().
auto autoScroll () const -> bool
 Whether new output scrolls the view to the bottom.

Static Public Member Functions

static auto processName (Enums::PROCESS pid) -> QString
 Human-readable command label for a process id.
static auto isSensitiveProcess (Enums::PROCESS pid) -> bool
 Whether a process's output may carry secrets and must never reach this long-lived panel (pass show, pass insert; pass grep, should it ever run again).

Static Public Attributes

static constexpr int MaxLines = 1000
 Oldest lines are dropped once the document holds more than this.

Private Member Functions

void limitLines ()
 Drop the oldest text blocks once the document holds more than MaxLines; called after every append().

Private Attributes

QTextEdit * m_edit = nullptr
 Read-only text edit holding the output; child of the dock.
QToolButton * m_clearButton = nullptr
 The "Clear" button wired to clear().
int m_counter = 0
 Running line number shown in front of each line; reset by clear(). Keeps counting past MaxLines.
bool m_autoScroll = true
 Whether append() scrolls to the bottom: cleared when the user scrolls up, set again when the scroll bar reaches its maximum or on clear(). Only updated on slider release while dragging.

Detailed Description

The dockable "Process output" console: numbered, colour-coded lines of git/pass/gpg output with a line cap and sticky auto-scroll.

A QDockWidget at the bottom dock area is the conventional place for an IDE-style console and gives users detach/move for free. The panel knows nothing about settings or the tree; MainWindow decides when to feed it and when to show it.

Definition at line 30 of file processoutputpanel.h.

Constructor & Destructor Documentation

◆ ProcessOutputPanel()

ProcessOutputPanel::ProcessOutputPanel ( QWidget * parent = nullptr)
explicit

Build the console (Clear button + read-only text edit).

Parameters
parentThe main window; it adds the dock to an area itself.

Definition at line 17 of file processoutputpanel.cpp.

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

Member Function Documentation

◆ append()

void ProcessOutputPanel::append ( const QString & output,
bool isError,
const QString & linePrefix = QString() )

Append output, one numbered line per non-empty input line.

Lines are right-trimmed (CR and trailing whitespace), empty ones are skipped, and each gets the running counter and, when given, the command prefix so multi-line output stays attributed. Errors are red. Keeps the view at the bottom unless the user scrolled up.

Parameters
outputRaw stdout/stderr text.
isErrortrue for stderr styling.
linePrefixCommand label, e.g. "git push"; empty for none.

Definition at line 59 of file processoutputpanel.cpp.

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

◆ autoScroll()

auto ProcessOutputPanel::autoScroll ( ) const -> bool
inlinenodiscard

Whether new output scrolls the view to the bottom.

Returns
false after the user scrolled up, true again at the bottom or after clear().

Definition at line 68 of file processoutputpanel.h.

◆ clear

void ProcessOutputPanel::clear ( )
slot

Drop all output, reset the counter, re-arm auto-scroll.

Definition at line 110 of file processoutputpanel.cpp.

Here is the caller graph for this function:

◆ isSensitiveProcess()

auto ProcessOutputPanel::isSensitiveProcess ( Enums::PROCESS pid) -> bool
static

Whether a process's output may carry secrets and must never reach this long-lived panel (pass show, pass insert; pass grep, should it ever run again).

Parameters
pidProcess identifier.
Returns
true when the output must be dropped.

Definition at line 120 of file processoutputpanel.cpp.

Here is the call graph for this function:

◆ limitLines()

void ProcessOutputPanel::limitLines ( )
private

Drop the oldest text blocks once the document holds more than MaxLines; called after every append().

Definition at line 98 of file processoutputpanel.cpp.

Here is the caller graph for this function:

◆ lineCount()

auto ProcessOutputPanel::lineCount ( ) const -> int
inlinenodiscard

Number of lines appended since the last clear().

Returns
The running counter shown as the line number.

Definition at line 61 of file processoutputpanel.h.

◆ processName()

auto ProcessOutputPanel::processName ( Enums::PROCESS pid) -> QString
static

Human-readable command label for a process id.

Parameters
pidProcess identifier.
Returns
e.g. "git push"; empty for processes that are never shown.

Definition at line 116 of file processoutputpanel.cpp.

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

Member Data Documentation

◆ m_autoScroll

bool ProcessOutputPanel::m_autoScroll = true
private

Whether append() scrolls to the bottom: cleared when the user scrolls up, set again when the scroll bar reaches its maximum or on clear(). Only updated on slider release while dragging.

Definition at line 113 of file processoutputpanel.h.

◆ m_clearButton

QToolButton* ProcessOutputPanel::m_clearButton = nullptr
private

The "Clear" button wired to clear().

Definition at line 102 of file processoutputpanel.h.

◆ m_counter

int ProcessOutputPanel::m_counter = 0
private

Running line number shown in front of each line; reset by clear(). Keeps counting past MaxLines.

Definition at line 107 of file processoutputpanel.h.

◆ m_edit

QTextEdit* ProcessOutputPanel::m_edit = nullptr
private

Read-only text edit holding the output; child of the dock.

Definition at line 100 of file processoutputpanel.h.

◆ MaxLines

int ProcessOutputPanel::MaxLines = 1000
staticconstexpr

Oldest lines are dropped once the document holds more than this.

Definition at line 35 of file processoutputpanel.h.


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