mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 02:06:08 +08:00
#28 Use a hash of toolbar and dockwidget names as crosscheck of window geometry format
This commit is contained in:
@@ -59,6 +59,7 @@
|
|||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
|
#include <QToolBar>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
@@ -411,12 +412,26 @@ namespace BlackGui
|
|||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CGuiApplication::hashForStateSettingsSchema(const QMainWindow *window)
|
||||||
|
{
|
||||||
|
unsigned int hash = 0;
|
||||||
|
for (auto obj : window->findChildren<QToolBar *>(QString(), Qt::FindDirectChildrenOnly))
|
||||||
|
{
|
||||||
|
hash ^= qHash(obj->objectName());
|
||||||
|
}
|
||||||
|
for (auto obj : window->findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly))
|
||||||
|
{
|
||||||
|
hash ^= qHash(obj->objectName());
|
||||||
|
}
|
||||||
|
return static_cast<int>((hash & 0xffff) ^ (hash >> 16));
|
||||||
|
}
|
||||||
|
|
||||||
bool CGuiApplication::saveWindowGeometryAndState(const QMainWindow *window) const
|
bool CGuiApplication::saveWindowGeometryAndState(const QMainWindow *window) const
|
||||||
{
|
{
|
||||||
if (!window) { return false; }
|
if (!window) { return false; }
|
||||||
QSettings settings(fileForWindowGeometryAndStateSettings(), QSettings::IniFormat);
|
QSettings settings(fileForWindowGeometryAndStateSettings(), QSettings::IniFormat);
|
||||||
settings.setValue("geometry", window->saveGeometry());
|
settings.setValue("geometry", window->saveGeometry());
|
||||||
settings.setValue("windowState", window->saveState());
|
settings.setValue("windowState", window->saveState(hashForStateSettingsSchema(window)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,7 +481,7 @@ namespace BlackGui
|
|||||||
logSub.changeSubscription(pattern);
|
logSub.changeSubscription(pattern);
|
||||||
|
|
||||||
window->restoreGeometry(g);
|
window->restoreGeometry(g);
|
||||||
window->restoreState(s);
|
window->restoreState(s, hashForStateSettingsSchema(window));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -399,6 +399,9 @@ namespace BlackGui
|
|||||||
|
|
||||||
//! Settings ini filename
|
//! Settings ini filename
|
||||||
static const QString &fileForWindowGeometryAndStateSettings();
|
static const QString &fileForWindowGeometryAndStateSettings();
|
||||||
|
|
||||||
|
//! Hash of names of toolbars and dockwidgets
|
||||||
|
static int hashForStateSettingsSchema(const QMainWindow *window);
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user