2025-08-22 00:12:26 +00:00
|
|
|
/*
|
|
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
|
|
|
|
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "LogWidget.h"
|
|
|
|
|
|
|
|
|
|
#include <gui/Logger.h>
|
|
|
|
|
|
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
LogWidget::LogWidget(QWidget *parent) : QWidget{parent}, m_textLog{new QPlainTextEdit(this)}
|
|
|
|
|
{
|
|
|
|
|
m_textLog->setReadOnly(true);
|
|
|
|
|
m_textLog->setMaximumBlockCount(10000);
|
|
|
|
|
m_textLog->setLineWrapMode(QPlainTextEdit::NoWrap);
|
|
|
|
|
|
|
|
|
|
// setup the log font
|
|
|
|
|
m_textLog->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
auto f = m_textLog->font();
|
|
|
|
|
f.setPixelSize(12);
|
|
|
|
|
m_textLog->setFont(f);
|
|
|
|
|
#endif
|
|
|
|
|
auto layout = new QVBoxLayout;
|
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
layout->addWidget(m_textLog);
|
|
|
|
|
|
|
|
|
|
setLayout(layout);
|
|
|
|
|
|
|
|
|
|
connect(
|
2025-11-04 00:54:03 +00:00
|
|
|
deskflow::gui::Logger::instance(), &deskflow::gui::Logger::newLine, m_textLog, &QPlainTextEdit::appendPlainText
|
2025-08-22 00:12:26 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LogWidget::appendLine(const QString &msg)
|
|
|
|
|
{
|
|
|
|
|
m_textLog->appendPlainText(msg);
|
|
|
|
|
}
|