frontend-tools: Add "Clear" button to script log window
This commit is contained in:
parent
b1e6af319c
commit
00e7a84050
@ -4,8 +4,10 @@
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QScrollBar>
|
||||
#include <QPushButton>
|
||||
#include <QFontDatabase>
|
||||
#include <QFont>
|
||||
#include <QDialogButtonBox>
|
||||
@ -87,13 +89,21 @@ ScriptLogWindow::ScriptLogWindow() : QWidget(nullptr)
|
||||
edit->setFont(fixedFont);
|
||||
edit->setWordWrapMode(QTextOption::NoWrap);
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(
|
||||
QDialogButtonBox::Close);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QWidget::hide);
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
||||
QPushButton *clearButton = new QPushButton(tr("Clear"));
|
||||
connect(clearButton, &QPushButton::clicked,
|
||||
this, &ScriptLogWindow::ClearWindow);
|
||||
QPushButton *closeButton = new QPushButton(tr("Close"));
|
||||
connect(closeButton, &QPushButton::clicked,
|
||||
this, &QDialog::hide);
|
||||
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addWidget(clearButton);
|
||||
buttonLayout->addWidget(closeButton);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
layout->addWidget(edit);
|
||||
layout->addWidget(buttonBox);
|
||||
layout->addLayout(buttonLayout);
|
||||
|
||||
setLayout(layout);
|
||||
scriptLogWidget = edit;
|
||||
@ -156,6 +166,12 @@ void ScriptLogWindow::AddLogMsg(int log_level, QString msg)
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptLogWindow::ClearWindow()
|
||||
{
|
||||
Clear();
|
||||
scriptLogWidget->setPlainText(QString());
|
||||
}
|
||||
|
||||
void ScriptLogWindow::Clear()
|
||||
{
|
||||
lines.clear();
|
||||
|
@ -17,6 +17,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void AddLogMsg(int log_level, QString msg);
|
||||
void ClearWindow();
|
||||
void Clear();
|
||||
void ScrollChanged(int val);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user