mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-15 16:59:18 +01:00
LogWidget: Remove scrollbar tampering code (doesn't seem to do anything), clear text queue on clearing log
This commit is contained in:
parent
eb7d42dfe8
commit
7cec8601f1
@ -11,7 +11,6 @@
|
|||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QScrollBar>
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
@ -68,32 +67,11 @@ void LogWidget::UpdateLog()
|
|||||||
if (m_log_queue.empty())
|
if (m_log_queue.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto* vscroll = m_log_text->verticalScrollBar();
|
|
||||||
auto* hscroll = m_log_text->horizontalScrollBar();
|
|
||||||
|
|
||||||
// If the vertical scrollbar is within 50 units of the maximum value, count it as being at the
|
|
||||||
// bottom
|
|
||||||
bool vscroll_bottom = vscroll->maximum() - vscroll->value() < 50;
|
|
||||||
|
|
||||||
int old_horizontal = hscroll->value();
|
|
||||||
int old_vertical = vscroll->value();
|
|
||||||
|
|
||||||
for (size_t i = 0; !m_log_queue.empty() && i < MAX_LOG_LINES_TO_UPDATE; i++)
|
for (size_t i = 0; !m_log_queue.empty() && i < MAX_LOG_LINES_TO_UPDATE; i++)
|
||||||
{
|
{
|
||||||
m_log_text->appendHtml(m_log_queue.front());
|
m_log_text->appendHtml(m_log_queue.front());
|
||||||
m_log_queue.pop();
|
m_log_queue.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hscroll->value() != old_horizontal)
|
|
||||||
hscroll->setValue(old_horizontal);
|
|
||||||
|
|
||||||
if (vscroll->value() != old_vertical)
|
|
||||||
{
|
|
||||||
if (vscroll_bottom)
|
|
||||||
vscroll->setValue(vscroll->maximum());
|
|
||||||
else
|
|
||||||
vscroll->setValue(old_vertical);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogWidget::UpdateFont()
|
void LogWidget::UpdateFont()
|
||||||
@ -148,13 +126,15 @@ void LogWidget::CreateWidgets()
|
|||||||
|
|
||||||
void LogWidget::ConnectWidgets()
|
void LogWidget::ConnectWidgets()
|
||||||
{
|
{
|
||||||
connect(m_log_clear, &QPushButton::clicked, m_log_text, &QPlainTextEdit::clear);
|
connect(m_log_clear, &QPushButton::clicked, [this] {
|
||||||
|
m_log_text->clear();
|
||||||
|
m_log_queue = {};
|
||||||
|
});
|
||||||
connect(m_log_wrap, &QCheckBox::toggled, this, &LogWidget::SaveSettings);
|
connect(m_log_wrap, &QCheckBox::toggled, this, &LogWidget::SaveSettings);
|
||||||
connect(m_log_font, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
connect(m_log_font, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||||
&LogWidget::SaveSettings);
|
&LogWidget::SaveSettings);
|
||||||
connect(this, &QDockWidget::topLevelChanged, this, &LogWidget::SaveSettings);
|
connect(this, &QDockWidget::topLevelChanged, this, &LogWidget::SaveSettings);
|
||||||
connect(&Settings::Instance(), &Settings::LogVisibilityChanged, this,
|
connect(&Settings::Instance(), &Settings::LogVisibilityChanged, this, &LogWidget::setVisible);
|
||||||
[this](bool visible) { setHidden(!visible); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogWidget::LoadSettings()
|
void LogWidget::LoadSettings()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user