git-svn-id: svn://db.shs.com.ru/libs@1 a8b55f48-bf90-11e4-a774-851b48703e85
104 lines
4.9 KiB
C++
104 lines
4.9 KiB
C++
/*
|
|
Peri4 Paint
|
|
Copyright (C) 2011 Ivan Pelipenko peri4ko@gmail.com
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "session_manager.h"
|
|
|
|
|
|
void SessionManager::save() {
|
|
if (file_.isEmpty()) return;
|
|
QPIConfig sr(file_);
|
|
for (int i = 0; i < mwindows.size(); ++i) {
|
|
sr.setValue(mwindows[i].first + " state", mwindows[i].second->saveState(), false);
|
|
sr.setValue(mwindows[i].first + " window state", (int)mwindows[i].second->windowState(), false);
|
|
sr.setValue(mwindows[i].first + " geometry " + QString::number((int)mwindows[i].second->windowState()), mwindows[i].second->saveGeometry(), false);
|
|
QList<QSplitter * > sp = mwindows[i].second->findChildren<QSplitter * >();
|
|
foreach (QSplitter * s, sp)
|
|
sr.setValue(mwindows[i].first + " splitter " + s->objectName(), s->saveState(), false);
|
|
}
|
|
for (int i = 0; i < checks.size(); ++i)
|
|
sr.setValue(checks[i].first, checks[i].second->isChecked(), false);
|
|
for (int i = 0; i < lines.size(); ++i)
|
|
sr.setValue(lines[i].first, lines[i].second->text(), "s", false);
|
|
for (int i = 0; i < combos.size(); ++i)
|
|
sr.setValue(combos[i].first, combos[i].second->currentIndex(), false);
|
|
for (int i = 0; i < dspins.size(); ++i)
|
|
sr.setValue(dspins[i].first, dspins[i].second->value(), false);
|
|
for (int i = 0; i < spins.size(); ++i)
|
|
sr.setValue(spins[i].first, spins[i].second->value(), false);
|
|
for (int i = 0; i < tabs.size(); ++i)
|
|
sr.setValue(tabs[i].first, tabs[i].second->currentIndex(), false);
|
|
for (int i = 0; i < actions.size(); ++i)
|
|
sr.setValue(actions[i].first, actions[i].second->isChecked(), false);
|
|
for (int i = 0; i < stringlists.size(); ++i)
|
|
sr.setValue(stringlists[i].first, *stringlists[i].second, false);
|
|
for (int i = 0; i < strings.size(); ++i)
|
|
sr.setValue(strings[i].first, *strings[i].second, "s", false);
|
|
for (int i = 0; i < colors.size(); ++i)
|
|
sr.setValue(colors[i].first, *colors[i].second, false);
|
|
for (int i = 0; i < bools.size(); ++i)
|
|
sr.setValue(bools[i].first, *bools[i].second, false);
|
|
for (int i = 0; i < ints.size(); ++i)
|
|
sr.setValue(ints[i].first, *ints[i].second, false);
|
|
for (int i = 0; i < floats.size(); ++i)
|
|
sr.setValue(floats[i].first, *floats[i].second, false);
|
|
sr.writeAll();
|
|
emit saving(sr);
|
|
}
|
|
|
|
|
|
void SessionManager::load(bool onlyMainwindow) {
|
|
if (file_.isEmpty()) return;
|
|
QPIConfig sr(file_);
|
|
for (int i = 0; i < mwindows.size(); ++i) {
|
|
mwindows[i].second->restoreState(sr.getValue(mwindows[i].first + " state", QByteArray()));
|
|
mwindows[i].second->restoreGeometry(sr.getValue(mwindows[i].first + " geometry " + QString::number((int)mwindows[i].second->windowState()), QByteArray()));
|
|
mwindows[i].second->setWindowState((Qt::WindowState)(int)sr.getValue(mwindows[i].first + " window state", 0));
|
|
QList<QSplitter * > sp = mwindows[i].second->findChildren<QSplitter * >();
|
|
foreach (QSplitter * s, sp)
|
|
s->restoreState(sr.getValue(mwindows[i].first + " splitter " + s->objectName(), QByteArray()));
|
|
}
|
|
if (onlyMainwindow) return;
|
|
for (int i = 0; i < checks.size(); ++i)
|
|
checks[i].second->setChecked(sr.getValue(checks[i].first, true));
|
|
for (int i = 0; i < lines.size(); ++i)
|
|
lines[i].second->setText(sr.getValue(lines[i].first, QString()));
|
|
for (int i = 0; i < combos.size(); ++i)
|
|
combos[i].second->setCurrentIndex(sr.getValue(combos[i].first, 0));
|
|
for (int i = 0; i < dspins.size(); ++i)
|
|
dspins[i].second->setValue(sr.getValue(dspins[i].first, 0.));
|
|
for (int i = 0; i < spins.size(); ++i)
|
|
spins[i].second->setValue(sr.getValue(spins[i].first, 0));
|
|
for (int i = 0; i < tabs.size(); ++i)
|
|
tabs[i].second->setCurrentIndex(sr.getValue(tabs[i].first, 0));
|
|
for (int i = 0; i < actions.size(); ++i)
|
|
actions[i].second->setChecked(sr.getValue(actions[i].first, true));
|
|
for (int i = 0; i < stringlists.size(); ++i)
|
|
*stringlists[i].second = sr.getValue(stringlists[i].first, QStringList());
|
|
for (int i = 0; i < strings.size(); ++i)
|
|
*strings[i].second = sr.getValue(strings[i].first, QString()).stringValue();
|
|
for (int i = 0; i < colors.size(); ++i)
|
|
*colors[i].second = sr.getValue(colors[i].first, QString());
|
|
for (int i = 0; i < bools.size(); ++i)
|
|
*bools[i].second = sr.getValue(bools[i].first, true);
|
|
for (int i = 0; i < ints.size(); ++i)
|
|
*ints[i].second = sr.getValue(ints[i].first, 0);
|
|
for (int i = 0; i < floats.size(); ++i)
|
|
*floats[i].second = sr.getValue(floats[i].first, 0);
|
|
emit loading(sr);
|
|
}
|