1 #pragma once 2 3 #include <QString> 4 #include <QWidget> 5 #include <QList> 6 7 8 namespace SyntopiaCore { 9 namespace Misc { 10 11 12 /// Util classes for making GUI settings persistent. 13 /// (i.e. remember the state of drop-downs, line-edits, and so on). 14 /// 15 /// Per default, the widget is stored under its objectName, but it possible to specify 16 /// another name (e.g. to share widget data between dialogs). 17 /// 18 /// Notice that widgets must be hardcoded into the cpp-file to be supported 19 class Persistence { 20 public: 21 static void Store(QWidget* widget, QString storageName = QString()); 22 static void Restore(QWidget* widget, QString storageName = QString()); 23 static bool Contains(QString storageName); 24 static QVariant Get(QString storageName); 25 static void Put(QString storageName, QVariant value); 26 private: 27 static QMap<QString, QVariant>& GetStore(); 28 }; 29 30 31 } 32 } 33 34 35