From edbba49114be2cf4d77515aa578fbb349733fa22 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 12 Feb 2019 22:28:16 +0300 Subject: [PATCH] Save and restore of Designer widget have been fixed --- limereport/lrreportdesignwidget.cpp | 26 +++++++++++++++++--------- limereport/lrreportdesignwidget.h | 2 +- limereport/lrreportdesignwindow.cpp | 5 +++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index f13ed02..343789a 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -178,16 +178,16 @@ void ReportDesignWidget::setUseMagnet(bool useMagnet) } } -void ReportDesignWidget::saveState(QSettings* settings) +void ReportDesignWidget::saveState() { - settings->beginGroup("DesignerWidget"); - settings->setValue("hGridStep",m_horizontalGridStep); - settings->setValue("vGridStep",m_verticalGridStep); - settings->setValue("defaultFont",m_defaultFont); - settings->setValue("useGrid",m_useGrid); - settings->setValue("useDarkTheme",m_useDarkTheme); - settings->setValue("ScriptEditorState", m_scriptEditor->saveState()); - settings->endGroup(); + m_settings->beginGroup("DesignerWidget"); + m_settings->setValue("hGridStep",m_horizontalGridStep); + m_settings->setValue("vGridStep",m_verticalGridStep); + m_settings->setValue("defaultFont",m_defaultFont); + m_settings->setValue("useGrid",m_useGrid); + m_settings->setValue("useDarkTheme",m_useDarkTheme); + m_settings->setValue("ScriptEditorState", m_scriptEditor->saveState()); + m_settings->endGroup(); } void ReportDesignWidget::applySettings() @@ -284,6 +284,14 @@ void ReportDesignWidget::createTabs(){ } m_scriptEditor = new ScriptEditor(this); + +// m_settings->beginGroup("DesignerWidget"); +// QVariant v = m_settings->value("ScriptEditorState"); +// if (v.isValid()){ +// m_scriptEditor->restoreState(v.toByteArray()); +// } +// m_settings->endGroup(); + connect(m_scriptEditor, SIGNAL(textChanged()), this, SLOT(slotScriptTextChanged())); m_scriptEditor->setReportEngine(m_report); pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script")); diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index f1b092c..7f41456 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -112,7 +112,7 @@ public: bool emitSaveReport(); bool emitSaveReportAs(); bool emitLoadReport(); - void saveState(QSettings *settings); + void saveState(); void loadState(); void applySettings(); void applyUseGrid(); diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index 3aa1660..a6524c9 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -650,6 +650,7 @@ void ReportDesignWindow::updateRedoUndo() void ReportDesignWindow::startNewReport() { + m_reportDesignWidget->saveState(); m_reportDesignWidget->clear(); m_reportDesignWidget->createStartPage(); m_lblReportName->setText(""); @@ -663,6 +664,7 @@ void ReportDesignWindow::startNewReport() showDefaultToolBars(); m_reportDesignWidget->report()->dataManager()->dropChanges(); m_reportDesignWidget->report()->scriptContext()->dropChanges(); + m_reportDesignWidget->loadState(); } @@ -670,7 +672,6 @@ void ReportDesignWindow::writePosition() { settings()->beginGroup("DesignerWindow"); settings()->setValue("Geometry",saveGeometry()); -// settings()->setValue("State",saveState()); settings()->endGroup(); } @@ -706,7 +707,7 @@ void ReportDesignWindow::writeState() ++it; } settings()->endGroup(); - m_reportDesignWidget->saveState(settings()); + m_reportDesignWidget->saveState(); } void ReportDesignWindow::createRecentFilesMenu()