mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Add option to reset settings to default
This commit is contained in:
parent
8d84869432
commit
64879c03e4
6 changed files with 50 additions and 0 deletions
|
@ -5,6 +5,8 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <QMutexLocker>
|
||||||
|
|
||||||
#include "intsetting.hpp"
|
#include "intsetting.hpp"
|
||||||
#include "doublesetting.hpp"
|
#include "doublesetting.hpp"
|
||||||
#include "boolsetting.hpp"
|
#include "boolsetting.hpp"
|
||||||
|
@ -587,6 +589,30 @@ CSMPrefs::State& CSMPrefs::State::get()
|
||||||
return *sThis;
|
return *sThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::State::resetCategory(const std::string& category)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
QMutexLocker lock (&mMutex);
|
||||||
|
for (Settings::CategorySettingValueMap::iterator i = mSettings.mUserSettings.begin(); i != mSettings.mUserSettings.end(); ++i)
|
||||||
|
{
|
||||||
|
// if the category matches
|
||||||
|
if (i->first.first == category)
|
||||||
|
{
|
||||||
|
// mark the setting as changed
|
||||||
|
mSettings.mChangedSettings.insert(std::make_pair(i->first.first, i->first.second));
|
||||||
|
// reset the value to the default
|
||||||
|
i->second = mSettings.mDefaultSettings[i->first];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection::iterator iter = mCategories.find(category);
|
||||||
|
if (iter != mCategories.end())
|
||||||
|
{
|
||||||
|
(*iter).second.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CSMPrefs::State& CSMPrefs::get()
|
CSMPrefs::State& CSMPrefs::get()
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,6 +106,8 @@ namespace CSMPrefs
|
||||||
|
|
||||||
static State& get();
|
static State& get();
|
||||||
|
|
||||||
|
void resetCategory(const std::string& category);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void settingChanged (const CSMPrefs::Setting *setting);
|
void settingChanged (const CSMPrefs::Setting *setting);
|
||||||
|
|
|
@ -6,9 +6,11 @@
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "../../model/prefs/setting.hpp"
|
#include "../../model/prefs/setting.hpp"
|
||||||
#include "../../model/prefs/category.hpp"
|
#include "../../model/prefs/category.hpp"
|
||||||
|
#include "../../model/prefs/state.hpp"
|
||||||
|
|
||||||
namespace CSVPrefs
|
namespace CSVPrefs
|
||||||
{
|
{
|
||||||
|
@ -22,6 +24,10 @@ namespace CSVPrefs
|
||||||
QWidget* topWidget = new QWidget();
|
QWidget* topWidget = new QWidget();
|
||||||
QVBoxLayout* topLayout = new QVBoxLayout(topWidget);
|
QVBoxLayout* topLayout = new QVBoxLayout(topWidget);
|
||||||
|
|
||||||
|
QWidget* resetAll = new QPushButton("Reset all to default", this);
|
||||||
|
connect(resetAll, SIGNAL(clicked()), this, SLOT(resetCategory()));
|
||||||
|
topLayout->addWidget(resetAll);
|
||||||
|
|
||||||
// Allows switching between "pages"
|
// Allows switching between "pages"
|
||||||
QWidget* stackedWidget = new QWidget();
|
QWidget* stackedWidget = new QWidget();
|
||||||
mStackedLayout = new QStackedLayout(stackedWidget);
|
mStackedLayout = new QStackedLayout(stackedWidget);
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
#include "page.hpp"
|
#include "page.hpp"
|
||||||
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "../../model/prefs/setting.hpp"
|
#include "../../model/prefs/setting.hpp"
|
||||||
#include "../../model/prefs/category.hpp"
|
#include "../../model/prefs/category.hpp"
|
||||||
|
#include "../../model/prefs/state.hpp"
|
||||||
|
|
||||||
CSVPrefs::Page::Page (CSMPrefs::Category& category, QWidget *parent)
|
CSVPrefs::Page::Page (CSMPrefs::Category& category, QWidget *parent)
|
||||||
: PageBase (category, parent)
|
: PageBase (category, parent)
|
||||||
|
@ -12,6 +14,10 @@ CSVPrefs::Page::Page (CSMPrefs::Category& category, QWidget *parent)
|
||||||
QWidget *widget = new QWidget (parent);
|
QWidget *widget = new QWidget (parent);
|
||||||
mGrid = new QGridLayout (widget);
|
mGrid = new QGridLayout (widget);
|
||||||
|
|
||||||
|
QWidget* resetAll = new QPushButton("Reset all to default", this);
|
||||||
|
connect (resetAll, SIGNAL (clicked()), this, SLOT (resetCategory()));
|
||||||
|
mGrid->addWidget(resetAll, 0, 0, 1, 2);
|
||||||
|
|
||||||
for (CSMPrefs::Category::Iterator iter = category.begin(); iter!=category.end(); ++iter)
|
for (CSMPrefs::Category::Iterator iter = category.begin(); iter!=category.end(); ++iter)
|
||||||
addSetting (*iter);
|
addSetting (*iter);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "pagebase.hpp"
|
#include "pagebase.hpp"
|
||||||
|
|
||||||
#include "../../model/prefs/category.hpp"
|
#include "../../model/prefs/category.hpp"
|
||||||
|
#include "../../model/prefs/state.hpp"
|
||||||
|
|
||||||
CSVPrefs::PageBase::PageBase (CSMPrefs::Category& category, QWidget *parent)
|
CSVPrefs::PageBase::PageBase (CSMPrefs::Category& category, QWidget *parent)
|
||||||
: QScrollArea (parent), mCategory (category)
|
: QScrollArea (parent), mCategory (category)
|
||||||
|
@ -11,3 +12,8 @@ CSMPrefs::Category& CSVPrefs::PageBase::getCategory()
|
||||||
{
|
{
|
||||||
return mCategory;
|
return mCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVPrefs::PageBase::resetCategory()
|
||||||
|
{
|
||||||
|
CSMPrefs::get().resetCategory(getCategory().getKey());
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,10 @@ namespace CSVPrefs
|
||||||
PageBase (CSMPrefs::Category& category, QWidget *parent);
|
PageBase (CSMPrefs::Category& category, QWidget *parent);
|
||||||
|
|
||||||
CSMPrefs::Category& getCategory();
|
CSMPrefs::Category& getCategory();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void resetCategory();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue