Added status check for settings read/write operations.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2018-09-09 12:39:19 +03:00
parent 2858122d9d
commit 8a3d50520f
2 changed files with 50 additions and 22 deletions

View File

@ -2797,15 +2797,23 @@ void TMainWindow::MeasurementGUI()
void TMainWindow::ReadSettings() void TMainWindow::ReadSettings()
{ {
const VTapeSettings *settings = qApp->TapeSettings(); const VTapeSettings *settings = qApp->TapeSettings();
restoreGeometry(settings->GetGeometry());
restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION);
// Text under tool buton icon if (settings->status() == QSettings::NoError)
ToolBarStyles(); {
restoreGeometry(settings->GetGeometry());
restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION);
// Stack limit // Text under tool buton icon
//qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount()); ToolBarStyles();
// Stack limit
//qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount());
}
else
{
qWarning() << tr("Cannot read settings from a malformed INI file.");
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -2815,6 +2823,12 @@ void TMainWindow::WriteSettings()
settings->SetGeometry(saveGeometry()); settings->SetGeometry(saveGeometry());
settings->SetWindowState(saveState()); settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(APP_VERSION)); settings->SetToolbarsState(saveState(APP_VERSION));
settings->sync();
if (settings->status() == QSettings::AccessError)
{
qWarning() << tr("Cannot save settings. Access denied.");
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -3700,21 +3700,29 @@ void MainWindow::ReadSettings()
{ {
qCDebug(vMainWindow, "Reading settings."); qCDebug(vMainWindow, "Reading settings.");
const VSettings *settings = qApp->ValentinaSettings(); const VSettings *settings = qApp->ValentinaSettings();
restoreGeometry(settings->GetGeometry());
restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION);
// Scene antialiasing if (settings->status() == QSettings::NoError)
ui->view->SetAntialiasing(settings->GetGraphicalOutput()); {
restoreGeometry(settings->GetGeometry());
restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION);
// Stack limit // Scene antialiasing
qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount()); ui->view->SetAntialiasing(settings->GetGraphicalOutput());
// Text under tool buton icon // Stack limit
ToolBarStyles(); qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount());
isDockToolOptionsVisible = ui->dockWidgetToolOptions->isVisible(); // Text under tool buton icon
isDockGroupsVisible = ui->dockWidgetGroups->isVisible(); ToolBarStyles();
isDockToolOptionsVisible = ui->dockWidgetToolOptions->isVisible();
isDockGroupsVisible = ui->dockWidgetGroups->isVisible();
}
else
{
qWarning() << tr("Cannot read settings from a malformed INI file.");
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -3725,10 +3733,16 @@ void MainWindow::WriteSettings()
{ {
ActionDraw(true); ActionDraw(true);
VSettings *setings = qApp->ValentinaSettings(); VSettings *settings = qApp->ValentinaSettings();
setings->SetGeometry(saveGeometry()); settings->SetGeometry(saveGeometry());
setings->SetWindowState(saveState()); settings->SetWindowState(saveState());
setings->SetToolbarsState(saveState(APP_VERSION)); settings->SetToolbarsState(saveState(APP_VERSION));
settings->sync();
if (settings->status() == QSettings::AccessError)
{
qWarning() << tr("Cannot save settings. Access denied.");
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------