summaryrefslogtreecommitdiffstats
path: root/application/pages/LogPage.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-12-18 01:19:43 +0100
committerPetr Mrázek <peterix@gmail.com>2017-12-18 01:19:43 +0100
commit9eb0525dab04aa8c41e71db1290daf3e5048746b (patch)
tree4dc1702b08d71906cb0f23737a2dafbd3480568d /application/pages/LogPage.cpp
parentfb7897a6f4f133c41e475b6093830df2baf134a9 (diff)
downloadMultiMC-9eb0525dab04aa8c41e71db1290daf3e5048746b.tar
MultiMC-9eb0525dab04aa8c41e71db1290daf3e5048746b.tar.gz
MultiMC-9eb0525dab04aa8c41e71db1290daf3e5048746b.tar.lz
MultiMC-9eb0525dab04aa8c41e71db1290daf3e5048746b.tar.xz
MultiMC-9eb0525dab04aa8c41e71db1290daf3e5048746b.zip
NOISSUE preserve log page checkbox state when the instance window is closed
Only for a single session, not between sessions.
Diffstat (limited to 'application/pages/LogPage.cpp')
-rw-r--r--application/pages/LogPage.cpp56
1 files changed, 52 insertions, 4 deletions
diff --git a/application/pages/LogPage.cpp b/application/pages/LogPage.cpp
index 009a9f55..0fa1ee67 100644
--- a/application/pages/LogPage.cpp
+++ b/application/pages/LogPage.cpp
@@ -141,13 +141,11 @@ LogPage::LogPage(InstancePtr instance, QWidget *parent)
auto launchTask = m_instance->getLaunchTask();
if(launchTask)
{
- onInstanceLaunchTaskChanged(launchTask);
+ setInstanceLaunchTaskChanged(launchTask, true);
}
connect(m_instance.get(), &BaseInstance::launchTaskChanged, this, &LogPage::onInstanceLaunchTaskChanged);
}
- ui->text->setWordWrap(true);
-
auto findShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this);
connect(findShortcut, SIGNAL(activated()), SLOT(findActivated()));
auto findNextShortcut = new QShortcut(QKeySequence(QKeySequence::FindNext), this);
@@ -162,13 +160,53 @@ LogPage::~LogPage()
delete ui;
}
-void LogPage::onInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc)
+void LogPage::modelStateToUI()
+{
+ if(m_model->wrapLines())
+ {
+ ui->text->setWordWrap(true);
+ ui->wrapCheckbox->setCheckState(Qt::Checked);
+ }
+ else
+ {
+ ui->text->setWordWrap(false);
+ ui->wrapCheckbox->setCheckState(Qt::Unchecked);
+ }
+ if(m_model->suspended())
+ {
+ ui->trackLogCheckbox->setCheckState(Qt::Unchecked);
+ }
+ else
+ {
+ ui->trackLogCheckbox->setCheckState(Qt::Checked);
+ }
+}
+
+void LogPage::UIToModelState()
+{
+ if(!m_model)
+ {
+ return;
+ }
+ m_model->setLineWrap(ui->wrapCheckbox->checkState() == Qt::Checked);
+ m_model->suspend(ui->trackLogCheckbox->checkState() != Qt::Checked);
+}
+
+void LogPage::setInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc, bool initial)
{
m_process = proc;
if(m_process)
{
m_model = proc->getLogModel();
m_proxy->setSourceModel(m_model.get());
+ if(initial)
+ {
+ modelStateToUI();
+ }
+ else
+ {
+ UIToModelState();
+ }
}
else
{
@@ -177,6 +215,11 @@ void LogPage::onInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc)
}
}
+void LogPage::onInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc)
+{
+ setInstanceLaunchTaskChanged(proc, false);
+}
+
bool LogPage::apply()
{
return true;
@@ -228,12 +271,17 @@ void LogPage::on_btnBottom_clicked()
void LogPage::on_trackLogCheckbox_clicked(bool checked)
{
+ if(!m_model)
+ return;
m_model->suspend(!checked);
}
void LogPage::on_wrapCheckbox_clicked(bool checked)
{
ui->text->setWordWrap(checked);
+ if(!m_model)
+ return;
+ m_model->setLineWrap(checked);
}
void LogPage::on_findButton_clicked()