/* Peri4 Paint Copyright (C) 2016 Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef SESSION_MANAGER_H #define SESSION_MANAGER_H #include #include #include #include #include #include #include #include #include #include "spinslider.h" #include "qpiconfig.h" class SessionManager: public QObject { Q_OBJECT public: SessionManager(const QString & file = QString()) {setFile(file);} ~SessionManager() {;} inline void setFile(const QString & file) {file_ = file;} inline void addEntry(QMainWindow * e) {mwindows.push_back(QPair(e->objectName(), e));} inline void addEntry(QCheckBox * e) {checks.push_back(QPair(e->objectName(), e));} inline void addEntry(QLineEdit * e) {lines.push_back(QPair(e->objectName(), e));} inline void addEntry(QComboBox * e) {combos.push_back(QPair(e->objectName(), e));} inline void addEntry(QDoubleSpinBox * e) {dspins.push_back(QPair(e->objectName(), e));} inline void addEntry(QSpinBox * e) {spins.push_back(QPair(e->objectName(), e));} inline void addEntry(SpinSlider * e) {spinsliders.push_back(QPair(e->objectName(), e));} inline void addEntry(QTabWidget * e) {tabs.push_back(QPair(e->objectName(), e));} inline void addEntry(QAction * e) {actions.push_back(QPair(e->objectName(), e));} inline void addMainWidget(QWidget * e) {widgets.push_back(QPair(e->objectName(), e));} inline void addEntry(const QString & name, QMainWindow * e) {mwindows.push_back(QPair(name, e));} inline void addEntry(const QString & name, QCheckBox * e) {checks.push_back(QPair(name, e));} inline void addEntry(const QString & name, QLineEdit * e) {lines.push_back(QPair(name, e));} inline void addEntry(const QString & name, QComboBox * e) {combos.push_back(QPair(name, e));} inline void addEntry(const QString & name, QDoubleSpinBox * e) {dspins.push_back(QPair(name, e));} inline void addEntry(const QString & name, QSpinBox * e) {spins.push_back(QPair(name, e));} inline void addEntry(const QString & name, SpinSlider * e) {spinsliders.push_back(QPair(name, e));} inline void addEntry(const QString & name, QTabWidget * e) {tabs.push_back(QPair(name, e));} inline void addEntry(const QString & name, QAction * e) {actions.push_back(QPair(name, e));} inline void addEntry(const QString & name, QStringList * e) {stringlists.push_back(QPair(name, e));} inline void addEntry(const QString & name, QString * e) {strings.push_back(QPair(name, e));} inline void addEntry(const QString & name, QColor * e) {colors.push_back(QPair(name, e));} inline void addEntry(const QString & name, bool * e) {bools.push_back(QPair(name, e));} inline void addEntry(const QString & name, int * e) {ints.push_back(QPair(name, e));} inline void addEntry(const QString & name, float * e) {floats.push_back(QPair(name, e));} inline void addMainWidget(const QString & name, QWidget * e) {widgets.push_back(QPair(name, e));} void save(); void load(bool onlyMainwindow = false); private: QVector > mwindows; QVector > widgets; QVector > checks; QVector > lines; QVector > combos; QVector > dspins; QVector > spins; QVector > spinsliders; QVector > tabs; QVector > actions; QVector > stringlists; QVector > strings; QVector > colors; QVector > bools; QVector > ints; QVector > floats; QString file_; signals: void loading(QPIConfig & ); void saving(QPIConfig & ); }; #endif // SESSION_MANAGER_H