Save and restore of Designer widget have been fixed

This commit is contained in:
Arin Alexander 2019-02-12 22:28:16 +03:00
parent b839694e59
commit edbba49114
3 changed files with 21 additions and 12 deletions

View File

@ -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"));

View File

@ -112,7 +112,7 @@ public:
bool emitSaveReport();
bool emitSaveReportAs();
bool emitLoadReport();
void saveState(QSettings *settings);
void saveState();
void loadState();
void applySettings();
void applyUseGrid();

View File

@ -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()