mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +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 <QStyle>
|
||||
#include <QSysInfo>
|
||||
#include <QToolBar>
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
#include <QWindow>
|
||||
@@ -411,12 +412,26 @@ namespace BlackGui
|
||||
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
|
||||
{
|
||||
if (!window) { return false; }
|
||||
QSettings settings(fileForWindowGeometryAndStateSettings(), QSettings::IniFormat);
|
||||
settings.setValue("geometry", window->saveGeometry());
|
||||
settings.setValue("windowState", window->saveState());
|
||||
settings.setValue("windowState", window->saveState(hashForStateSettingsSchema(window)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -466,7 +481,7 @@ namespace BlackGui
|
||||
logSub.changeSubscription(pattern);
|
||||
|
||||
window->restoreGeometry(g);
|
||||
window->restoreState(s);
|
||||
window->restoreState(s, hashForStateSettingsSchema(window));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -399,6 +399,9 @@ namespace BlackGui
|
||||
|
||||
//! Settings ini filename
|
||||
static const QString &fileForWindowGeometryAndStateSettings();
|
||||
|
||||
//! Hash of names of toolbars and dockwidgets
|
||||
static int hashForStateSettingsSchema(const QMainWindow *window);
|
||||
};
|
||||
} // ns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user