summaryrefslogtreecommitdiffstats
path: root/application
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
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')
-rw-r--r--application/pages/LogPage.cpp56
-rw-r--r--application/pages/LogPage.h5
2 files changed, 57 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()
diff --git a/application/pages/LogPage.h b/application/pages/LogPage.h
index 3ca47b8a..8d90541f 100644
--- a/application/pages/LogPage.h
+++ b/application/pages/LogPage.h
@@ -72,6 +72,11 @@ private slots:
void onInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc);
private:
+ void modelStateToUI();
+ void UIToModelState();
+ void setInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc, bool initial);
+
+private:
Ui::LogPage *ui;
InstancePtr m_instance;
std::shared_ptr<LaunchTask> m_process;