Harmonizing other log controls with minecraft log

Signed-off-by: Yihe Li <winmikedows@hotmail.com>
This commit is contained in:
Yihe Li 2025-04-15 06:00:49 +08:00
parent 1ee1bab067
commit 5634723ecd
No known key found for this signature in database
3 changed files with 147 additions and 55 deletions

View File

@ -203,6 +203,8 @@ void OtherLogsPage::on_btnReload_clicked()
// Try to determine a level for each line
if (content.back() == '\n')
content = content.removeLast();
ui->text->clear();
m_model->clear();
for (auto& line : content.split('\n')) {
MessageLevel::Enum level = MessageLevel::Unknown;
@ -232,6 +234,11 @@ void OtherLogsPage::on_btnCopy_clicked()
GuiUtil::setClipboardText(ui->text->toPlainText());
}
void OtherLogsPage::on_btnBottom_clicked()
{
ui->text->scrollToBottom();
}
void OtherLogsPage::on_btnDelete_clicked()
{
if (m_currentFile.isEmpty()) {
@ -308,6 +315,24 @@ void OtherLogsPage::on_btnClean_clicked()
}
}
void OtherLogsPage::on_wrapCheckbox_clicked(bool checked)
{
ui->text->setWordWrap(checked);
if (!m_model)
return;
m_model->setLineWrap(checked);
ui->text->scrollToBottom();
}
void OtherLogsPage::on_colorCheckbox_clicked(bool checked)
{
ui->text->setColorLines(checked);
if (!m_model)
return;
m_model->setColorLines(checked);
ui->text->scrollToBottom();
}
void OtherLogsPage::setControlsEnabled(const bool enabled)
{
ui->btnReload->setEnabled(enabled);

View File

@ -72,6 +72,10 @@ class OtherLogsPage : public QWidget, public BasePage {
void on_btnCopy_clicked();
void on_btnDelete_clicked();
void on_btnClean_clicked();
void on_btnBottom_clicked();
void on_wrapCheckbox_clicked(bool checked);
void on_colorCheckbox_clicked(bool checked);
void on_findButton_clicked();
void findActivated();

View File

@ -33,17 +33,41 @@
<string notr="true">Tab 1</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Search:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="searchBar"/>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="findButton">
<property name="text">
<string>Find</string>
<string>&amp;Find</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<item row="2" column="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="btnBottom">
<property name="toolTip">
<string>Scroll all the way to bottom</string>
</property>
<property name="text">
<string>&amp;Bottom</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="5">
<widget class="LogView" name="text">
<property name="enabled">
<bool>false</bool>
@ -65,54 +89,98 @@
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<item row="0" column="0" colspan="5">
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QPushButton" name="btnCopy">
<property name="toolTip">
<string>Copy the whole log into the clipboard</string>
</property>
<property name="text">
<string>&amp;Copy</string>
</property>
</widget>
<item row="2" column="0" colspan="5">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnDelete">
<property name="toolTip">
<string>Delete the selected log</string>
</property>
<property name="text">
<string>&amp;Delete This</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClean">
<property name="toolTip">
<string>Delete all the logs</string>
</property>
<property name="text">
<string>Delete &amp;All</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="btnDelete">
<property name="toolTip">
<string>Clear the log</string>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="btnPaste">
<property name="toolTip">
<string>Upload the log to the paste service configured in preferences.</string>
</property>
<property name="text">
<string>Upload</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QPushButton" name="btnClean">
<property name="toolTip">
<string>Clear the log</string>
</property>
<property name="text">
<string>Clean</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="btnReload">
<property name="text">
<string>Reload</string>
</property>
</widget>
<item row="3" column="0" colspan="5">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="wrapCheckbox">
<property name="text">
<string>Wrap lines</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="colorCheckbox">
<property name="text">
<string>Color lines</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnCopy">
<property name="toolTip">
<string>Copy the whole log into the clipboard</string>
</property>
<property name="text">
<string>&amp;Copy</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnPaste">
<property name="toolTip">
<string>Upload the log to the paste service configured in preferences</string>
</property>
<property name="text">
<string>Upload</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnReload">
<property name="toolTip">
<string>Reload the contents of the log from the disk</string>
</property>
<property name="text">
<string>&amp;Reload</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0" colspan="5">
<widget class="QComboBox" name="selectLogBox">
@ -126,13 +194,6 @@
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Search:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
@ -154,6 +215,8 @@
<tabstop>btnPaste</tabstop>
<tabstop>btnDelete</tabstop>
<tabstop>btnClean</tabstop>
<tabstop>wrapCheckbox</tabstop>
<tabstop>colorCheckbox</tabstop>
<tabstop>text</tabstop>
<tabstop>searchBar</tabstop>
<tabstop>findButton</tabstop>