2025-08-22 00:12:26 +00:00
|
|
|
/*
|
|
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2026-01-17 21:13:47 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2025 - 2026 Chris Rizzitello <sithlord48@gmail.com>
|
2025-08-22 00:12:26 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "LogWidget.h"
|
2025-11-05 21:34:53 +00:00
|
|
|
#include "common/PlatformInfo.h"
|
2025-08-22 00:12:26 +00:00
|
|
|
|
|
|
|
|
#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));
|
2025-11-05 21:34:53 +00:00
|
|
|
if (deskflow::platform::isMac()) {
|
|
|
|
|
auto f = m_textLog->font();
|
|
|
|
|
f.setPixelSize(12);
|
|
|
|
|
m_textLog->setFont(f);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-22 00:12:26 +00:00
|
|
|
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);
|
|
|
|
|
}
|
2026-01-17 21:13:47 +00:00
|
|
|
|
|
|
|
|
void LogWidget::findNext(const QString &text)
|
|
|
|
|
{
|
|
|
|
|
if (text.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!m_textLog->find(text)) {
|
|
|
|
|
m_textLog->moveCursor(QTextCursor::Start);
|
|
|
|
|
m_textLog->find(text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LogWidget::findPrevious(const QString &text)
|
|
|
|
|
{
|
|
|
|
|
if (text.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!m_textLog->find(text, QTextDocument::FindBackward)) {
|
|
|
|
|
m_textLog->moveCursor(QTextCursor::End);
|
|
|
|
|
m_textLog->find(text, QTextDocument::FindBackward);
|
|
|
|
|
}
|
|
|
|
|
}
|