Skip to content

Commit

Permalink
+ skip FreeCAD version when saving&reading main window state
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Apr 9, 2016
1 parent 1d75efe commit 384316f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Gui/MainWindow.cpp
Expand Up @@ -1095,17 +1095,21 @@ void MainWindow::loadWindowSettings()
{
QString vendor = QString::fromLatin1(App::Application::Config()["ExeVendor"].c_str());
QString application = QString::fromLatin1(App::Application::Config()["ExeName"].c_str());
QString version = QString::fromLatin1(App::Application::Config()["ExeVersion"].c_str());
int major = (QT_VERSION >> 0x10) & 0xff;
int minor = (QT_VERSION >> 0x08) & 0xff;
QString qtver = QString::fromLatin1("Qt%1.%2").arg(major).arg(minor);
QSettings config(vendor, application);

config.beginGroup(version);
QRect rect = QApplication::desktop()->availableGeometry();
int maxHeight = rect.height();
int maxWidth = rect.width();

config.beginGroup(qtver);
this->resize(config.value(QString::fromLatin1("Size"), this->size()).toSize());
QPoint pos = config.value(QString::fromLatin1("Position"), this->pos()).toPoint();
QRect rect = QApplication::desktop()->availableGeometry();
maxWidth -= pos.x();
maxHeight -= pos.y();
this->resize(config.value(QString::fromLatin1("Size"), QSize(maxWidth, maxHeight)).toSize());

int x1,x2,y1,y2;
// make sure that the main window is not totally out of the visible rectangle
rect.getCoords(&x1, &y1, &x2, &y2);
Expand All @@ -1124,7 +1128,6 @@ void MainWindow::loadWindowSettings()

statusBar()->setVisible(config.value(QString::fromLatin1("StatusBar"), true).toBool());
config.endGroup();
config.endGroup();

ToolBarManager::getInstance()->restoreState();
std::clog << "Toolbars restored" << std::endl;
Expand All @@ -1134,21 +1137,18 @@ void MainWindow::saveWindowSettings()
{
QString vendor = QString::fromLatin1(App::Application::Config()["ExeVendor"].c_str());
QString application = QString::fromLatin1(App::Application::Config()["ExeName"].c_str());
QString version = QString::fromLatin1(App::Application::Config()["ExeVersion"].c_str());
int major = (QT_VERSION >> 0x10) & 0xff;
int minor = (QT_VERSION >> 0x08) & 0xff;
QString qtver = QString::fromLatin1("Qt%1.%2").arg(major).arg(minor);
QSettings config(vendor, application);

config.beginGroup(version);
config.beginGroup(qtver);
config.setValue(QString::fromLatin1("Size"), this->size());
config.setValue(QString::fromLatin1("Position"), this->pos());
config.setValue(QString::fromLatin1("Maximized"), this->isMaximized());
config.setValue(QString::fromLatin1("MainWindowState"), this->saveState());
config.setValue(QString::fromLatin1("StatusBar"), this->statusBar()->isVisible());
config.endGroup();
config.endGroup();

DockWindowManager::instance()->saveState();
ToolBarManager::getInstance()->saveState();
Expand Down

0 comments on commit 384316f

Please sign in to comment.