You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw/apps/opencs/view/prefs/page.cpp

60 lines
1.3 KiB
C++

#include "page.hpp"
#include <QGridLayout>
#include <QPushButton>
#include "../../model/prefs/setting.hpp"
#include "../../model/prefs/category.hpp"
CSVPrefs::Page::Page (CSMPrefs::Category& category, QWidget *parent)
: PageBase (category, parent)
, mParent (parent)
{
init();
}
void CSVPrefs::Page::addSetting (CSMPrefs::Setting *setting)
{
std::pair<QWidget *, QWidget *> widgets = setting->makeWidgets (this);
int next = mGrid->rowCount();
if (widgets.first)
{
mGrid->addWidget (widgets.first, next, 0);
mGrid->addWidget (widgets.second, next, 1);
}
else if (widgets.second)
{
mGrid->addWidget (widgets.second, next, 0, 1, 2);
}
else
{
mGrid->addWidget (new QWidget (this), next, 0);
}
}
void CSVPrefs::Page::refresh()
{
delete mWidget;
// reinitialize
init();
}
void CSVPrefs::Page::init()
{
mWidget = new QWidget(mParent);
mGrid = new QGridLayout(mWidget);
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 = getCategory().begin(); iter!=getCategory().end(); ++iter)
addSetting (*iter);
setWidget(mWidget);
}