QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
processoutputpanel.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_PROCESSOUTPUTPANEL_H_
9#define SRC_PROCESSOUTPUTPANEL_H_
10
11#include "enums.h"
12#include <QDockWidget>
13#include <QString>
14
15class QTextEdit;
16class QToolButton;
17
30class ProcessOutputPanel : public QDockWidget {
31 Q_OBJECT
32
33public:
35 static constexpr int MaxLines = 1000;
36
41 explicit ProcessOutputPanel(QWidget *parent = nullptr);
42
54 void append(const QString &output, bool isError,
55 const QString &linePrefix = QString());
56
61 [[nodiscard]] auto lineCount() const -> int { return m_counter; }
62
68 [[nodiscard]] auto autoScroll() const -> bool { return m_autoScroll; }
69
75 static auto processName(Enums::PROCESS pid) -> QString;
76
84 static auto isSensitiveProcess(Enums::PROCESS pid) -> bool;
85
86public slots:
90 void clear();
91
92private:
97 void limitLines();
98
100 QTextEdit *m_edit = nullptr;
102 QToolButton *m_clearButton = nullptr;
107 int m_counter = 0;
113 bool m_autoScroll = true;
114};
115
116#endif // SRC_PROCESSOUTPUTPANEL_H_
static constexpr int MaxLines
Oldest lines are dropped once the document holds more than this.
void limitLines()
Drop the oldest text blocks once the document holds more than MaxLines; called after every append().
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,...
void clear()
Drop all output, reset the counter, re-arm auto-scroll.
int m_counter
Running line number shown in front of each line; reset by clear(). Keeps counting past MaxLines.
ProcessOutputPanel(QWidget *parent=nullptr)
Build the console (Clear button + read-only text edit).
static auto processName(Enums::PROCESS pid) -> QString
Human-readable command label for a process id.
bool m_autoScroll
Whether append() scrolls to the bottom: cleared when the user scrolls up, set again when the scroll b...
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.
QTextEdit * m_edit
Read-only text edit holding the output; child of the dock.
QToolButton * m_clearButton
The "Clear" button wired to clear().
void append(const QString &output, bool isError, const QString &linePrefix=QString())
Append output, one numbered line per non-empty input line.
The Enums namespace: clipboard behaviour and the identifiers of the subprocess kinds QtPass queues.
PROCESS
Identifies different subprocess operations used in QtPass.
Definition enums.h:43