mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Merge pull request #216 from OpenMW/master
Add OpenMW commits up to 12 May 2017
This commit is contained in:
commit
da22639620
25 changed files with 320 additions and 43 deletions
|
@ -110,7 +110,7 @@ opencs_units_noqt (view/tools
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units (view/prefs
|
opencs_units (view/prefs
|
||||||
dialogue pagebase page keybindingpage
|
dialogue pagebase page keybindingpage contextmenulist
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units (model/prefs
|
opencs_units (model/prefs
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
CSMPrefs::BoolSetting::BoolSetting (Category *parent, Settings::Manager *values,
|
CSMPrefs::BoolSetting::BoolSetting (Category *parent, Settings::Manager *values,
|
||||||
QMutex *mutex, const std::string& key, const std::string& label, bool default_)
|
QMutex *mutex, const std::string& key, const std::string& label, bool default_)
|
||||||
: Setting (parent, values, mutex, key, label), mDefault (default_)
|
: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip (const std::string& tooltip)
|
CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip (const std::string& tooltip)
|
||||||
|
@ -22,18 +22,28 @@ CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip (const std::string& too
|
||||||
|
|
||||||
std::pair<QWidget *, QWidget *> CSMPrefs::BoolSetting::makeWidgets (QWidget *parent)
|
std::pair<QWidget *, QWidget *> CSMPrefs::BoolSetting::makeWidgets (QWidget *parent)
|
||||||
{
|
{
|
||||||
QCheckBox *widget = new QCheckBox (QString::fromUtf8 (getLabel().c_str()), parent);
|
mWidget = new QCheckBox (QString::fromUtf8 (getLabel().c_str()), parent);
|
||||||
widget->setCheckState (mDefault ? Qt::Checked : Qt::Unchecked);
|
mWidget->setCheckState (mDefault ? Qt::Checked : Qt::Unchecked);
|
||||||
|
|
||||||
if (!mTooltip.empty())
|
if (!mTooltip.empty())
|
||||||
{
|
{
|
||||||
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
||||||
widget->setToolTip (tooltip);
|
mWidget->setToolTip (tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect (widget, SIGNAL (stateChanged (int)), this, SLOT (valueChanged (int)));
|
connect (mWidget, SIGNAL (stateChanged (int)), this, SLOT (valueChanged (int)));
|
||||||
|
|
||||||
return std::make_pair (static_cast<QWidget *> (0), widget);
|
return std::make_pair (static_cast<QWidget *> (0), mWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::BoolSetting::updateWidget()
|
||||||
|
{
|
||||||
|
if (mWidget)
|
||||||
|
{
|
||||||
|
mWidget->setCheckState(getValues().getBool(getKey(), getParent()->getKey())
|
||||||
|
? Qt::Checked
|
||||||
|
: Qt::Unchecked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::BoolSetting::valueChanged (int value)
|
void CSMPrefs::BoolSetting::valueChanged (int value)
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "setting.hpp"
|
#include "setting.hpp"
|
||||||
|
|
||||||
|
class QCheckBox;
|
||||||
|
|
||||||
namespace CSMPrefs
|
namespace CSMPrefs
|
||||||
{
|
{
|
||||||
class BoolSetting : public Setting
|
class BoolSetting : public Setting
|
||||||
|
@ -11,6 +13,7 @@ namespace CSMPrefs
|
||||||
|
|
||||||
std::string mTooltip;
|
std::string mTooltip;
|
||||||
bool mDefault;
|
bool mDefault;
|
||||||
|
QCheckBox* mWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -22,6 +25,8 @@ namespace CSMPrefs
|
||||||
/// Return label, input widget.
|
/// Return label, input widget.
|
||||||
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
||||||
|
|
||||||
|
virtual void updateWidget();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void valueChanged (int value);
|
void valueChanged (int value);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@
|
||||||
|
|
||||||
CSMPrefs::ColourSetting::ColourSetting (Category *parent, Settings::Manager *values,
|
CSMPrefs::ColourSetting::ColourSetting (Category *parent, Settings::Manager *values,
|
||||||
QMutex *mutex, const std::string& key, const std::string& label, QColor default_)
|
QMutex *mutex, const std::string& key, const std::string& label, QColor default_)
|
||||||
: Setting (parent, values, mutex, key, label), mDefault (default_)
|
: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CSMPrefs::ColourSetting& CSMPrefs::ColourSetting::setTooltip (const std::string& tooltip)
|
CSMPrefs::ColourSetting& CSMPrefs::ColourSetting::setTooltip (const std::string& tooltip)
|
||||||
|
@ -26,18 +27,27 @@ std::pair<QWidget *, QWidget *> CSMPrefs::ColourSetting::makeWidgets (QWidget *p
|
||||||
{
|
{
|
||||||
QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent);
|
QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent);
|
||||||
|
|
||||||
CSVWidget::ColorEditor *widget = new CSVWidget::ColorEditor (mDefault, parent);
|
mWidget = new CSVWidget::ColorEditor (mDefault, parent);
|
||||||
|
|
||||||
if (!mTooltip.empty())
|
if (!mTooltip.empty())
|
||||||
{
|
{
|
||||||
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
||||||
label->setToolTip (tooltip);
|
label->setToolTip (tooltip);
|
||||||
widget->setToolTip (tooltip);
|
mWidget->setToolTip (tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect (widget, SIGNAL (pickingFinished()), this, SLOT (valueChanged()));
|
connect (mWidget, SIGNAL (pickingFinished()), this, SLOT (valueChanged()));
|
||||||
|
|
||||||
return std::make_pair (label, widget);
|
return std::make_pair (label, mWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::ColourSetting::updateWidget()
|
||||||
|
{
|
||||||
|
if (mWidget)
|
||||||
|
{
|
||||||
|
mWidget->setColor(QString::fromStdString
|
||||||
|
(getValues().getString(getKey(), getParent()->getKey())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::ColourSetting::valueChanged()
|
void CSMPrefs::ColourSetting::valueChanged()
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
|
namespace CSVWidget
|
||||||
|
{
|
||||||
|
class ColorEditor;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSMPrefs
|
namespace CSMPrefs
|
||||||
{
|
{
|
||||||
class ColourSetting : public Setting
|
class ColourSetting : public Setting
|
||||||
|
@ -13,6 +18,7 @@ namespace CSMPrefs
|
||||||
|
|
||||||
std::string mTooltip;
|
std::string mTooltip;
|
||||||
QColor mDefault;
|
QColor mDefault;
|
||||||
|
CSVWidget::ColorEditor* mWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -25,6 +31,8 @@ namespace CSMPrefs
|
||||||
/// Return label, input widget.
|
/// Return label, input widget.
|
||||||
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
||||||
|
|
||||||
|
virtual void updateWidget();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void valueChanged();
|
void valueChanged();
|
||||||
|
|
|
@ -16,7 +16,7 @@ CSMPrefs::DoubleSetting::DoubleSetting (Category *parent, Settings::Manager *val
|
||||||
QMutex *mutex, const std::string& key, const std::string& label, double default_)
|
QMutex *mutex, const std::string& key, const std::string& label, double default_)
|
||||||
: Setting (parent, values, mutex, key, label),
|
: Setting (parent, values, mutex, key, label),
|
||||||
mPrecision(2), mMin (0), mMax (std::numeric_limits<double>::max()),
|
mPrecision(2), mMin (0), mMax (std::numeric_limits<double>::max()),
|
||||||
mDefault (default_)
|
mDefault (default_), mWidget(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CSMPrefs::DoubleSetting& CSMPrefs::DoubleSetting::setPrecision(int precision)
|
CSMPrefs::DoubleSetting& CSMPrefs::DoubleSetting::setPrecision(int precision)
|
||||||
|
@ -54,21 +54,29 @@ std::pair<QWidget *, QWidget *> CSMPrefs::DoubleSetting::makeWidgets (QWidget *p
|
||||||
{
|
{
|
||||||
QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent);
|
QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent);
|
||||||
|
|
||||||
QDoubleSpinBox *widget = new QDoubleSpinBox (parent);
|
mWidget = new QDoubleSpinBox (parent);
|
||||||
widget->setDecimals(mPrecision);
|
mWidget->setDecimals(mPrecision);
|
||||||
widget->setRange (mMin, mMax);
|
mWidget->setRange (mMin, mMax);
|
||||||
widget->setValue (mDefault);
|
mWidget->setValue (mDefault);
|
||||||
|
|
||||||
if (!mTooltip.empty())
|
if (!mTooltip.empty())
|
||||||
{
|
{
|
||||||
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
||||||
label->setToolTip (tooltip);
|
label->setToolTip (tooltip);
|
||||||
widget->setToolTip (tooltip);
|
mWidget->setToolTip (tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect (widget, SIGNAL (valueChanged (double)), this, SLOT (valueChanged (double)));
|
connect (mWidget, SIGNAL (valueChanged (double)), this, SLOT (valueChanged (double)));
|
||||||
|
|
||||||
return std::make_pair (label, widget);
|
return std::make_pair (label, mWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::DoubleSetting::updateWidget()
|
||||||
|
{
|
||||||
|
if (mWidget)
|
||||||
|
{
|
||||||
|
mWidget->setValue(getValues().getFloat(getKey(), getParent()->getKey()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::DoubleSetting::valueChanged (double value)
|
void CSMPrefs::DoubleSetting::valueChanged (double value)
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "setting.hpp"
|
#include "setting.hpp"
|
||||||
|
|
||||||
|
class QDoubleSpinBox;
|
||||||
|
|
||||||
namespace CSMPrefs
|
namespace CSMPrefs
|
||||||
{
|
{
|
||||||
class DoubleSetting : public Setting
|
class DoubleSetting : public Setting
|
||||||
|
@ -14,6 +16,7 @@ namespace CSMPrefs
|
||||||
double mMax;
|
double mMax;
|
||||||
std::string mTooltip;
|
std::string mTooltip;
|
||||||
double mDefault;
|
double mDefault;
|
||||||
|
QDoubleSpinBox* mWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -35,6 +38,8 @@ namespace CSMPrefs
|
||||||
/// Return label, input widget.
|
/// Return label, input widget.
|
||||||
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
||||||
|
|
||||||
|
virtual void updateWidget();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void valueChanged (double value);
|
void valueChanged (double value);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ CSMPrefs::EnumValues& CSMPrefs::EnumValues::add (const std::string& value, const
|
||||||
|
|
||||||
CSMPrefs::EnumSetting::EnumSetting (Category *parent, Settings::Manager *values,
|
CSMPrefs::EnumSetting::EnumSetting (Category *parent, Settings::Manager *values,
|
||||||
QMutex *mutex, const std::string& key, const std::string& label, const EnumValue& default_)
|
QMutex *mutex, const std::string& key, const std::string& label, const EnumValue& default_)
|
||||||
: Setting (parent, values, mutex, key, label), mDefault (default_)
|
: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CSMPrefs::EnumSetting& CSMPrefs::EnumSetting::setTooltip (const std::string& tooltip)
|
CSMPrefs::EnumSetting& CSMPrefs::EnumSetting::setTooltip (const std::string& tooltip)
|
||||||
|
@ -72,7 +73,7 @@ std::pair<QWidget *, QWidget *> CSMPrefs::EnumSetting::makeWidgets (QWidget *par
|
||||||
{
|
{
|
||||||
QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent);
|
QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent);
|
||||||
|
|
||||||
QComboBox *widget = new QComboBox (parent);
|
mWidget = new QComboBox (parent);
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
|
@ -81,14 +82,14 @@ std::pair<QWidget *, QWidget *> CSMPrefs::EnumSetting::makeWidgets (QWidget *par
|
||||||
if (mDefault.mValue==mValues.mValues[i].mValue)
|
if (mDefault.mValue==mValues.mValues[i].mValue)
|
||||||
index = i;
|
index = i;
|
||||||
|
|
||||||
widget->addItem (QString::fromUtf8 (mValues.mValues[i].mValue.c_str()));
|
mWidget->addItem (QString::fromUtf8 (mValues.mValues[i].mValue.c_str()));
|
||||||
|
|
||||||
if (!mValues.mValues[i].mTooltip.empty())
|
if (!mValues.mValues[i].mTooltip.empty())
|
||||||
widget->setItemData (i, QString::fromUtf8 (mValues.mValues[i].mTooltip.c_str()),
|
mWidget->setItemData (i, QString::fromUtf8 (mValues.mValues[i].mTooltip.c_str()),
|
||||||
Qt::ToolTipRole);
|
Qt::ToolTipRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->setCurrentIndex (index);
|
mWidget->setCurrentIndex (index);
|
||||||
|
|
||||||
if (!mTooltip.empty())
|
if (!mTooltip.empty())
|
||||||
{
|
{
|
||||||
|
@ -96,9 +97,20 @@ std::pair<QWidget *, QWidget *> CSMPrefs::EnumSetting::makeWidgets (QWidget *par
|
||||||
label->setToolTip (tooltip);
|
label->setToolTip (tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect (widget, SIGNAL (currentIndexChanged (int)), this, SLOT (valueChanged (int)));
|
connect (mWidget, SIGNAL (currentIndexChanged (int)), this, SLOT (valueChanged (int)));
|
||||||
|
|
||||||
return std::make_pair (label, widget);
|
return std::make_pair (label, mWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::EnumSetting::updateWidget()
|
||||||
|
{
|
||||||
|
if (mWidget)
|
||||||
|
{
|
||||||
|
int index = mWidget->findText(QString::fromStdString
|
||||||
|
(getValues().getString(getKey(), getParent()->getKey())));
|
||||||
|
|
||||||
|
mWidget->setCurrentIndex(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::EnumSetting::valueChanged (int value)
|
void CSMPrefs::EnumSetting::valueChanged (int value)
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include "setting.hpp"
|
#include "setting.hpp"
|
||||||
|
|
||||||
|
class QComboBox;
|
||||||
|
|
||||||
namespace CSMPrefs
|
namespace CSMPrefs
|
||||||
{
|
{
|
||||||
struct EnumValue
|
struct EnumValue
|
||||||
|
@ -35,6 +37,7 @@ namespace CSMPrefs
|
||||||
std::string mTooltip;
|
std::string mTooltip;
|
||||||
EnumValue mDefault;
|
EnumValue mDefault;
|
||||||
EnumValues mValues;
|
EnumValues mValues;
|
||||||
|
QComboBox* mWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -53,6 +56,8 @@ namespace CSMPrefs
|
||||||
/// Return label, input widget.
|
/// Return label, input widget.
|
||||||
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
||||||
|
|
||||||
|
virtual void updateWidget();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void valueChanged (int value);
|
void valueChanged (int value);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
CSMPrefs::IntSetting::IntSetting (Category *parent, Settings::Manager *values,
|
CSMPrefs::IntSetting::IntSetting (Category *parent, Settings::Manager *values,
|
||||||
QMutex *mutex, const std::string& key, const std::string& label, int default_)
|
QMutex *mutex, const std::string& key, const std::string& label, int default_)
|
||||||
: Setting (parent, values, mutex, key, label), mMin (0), mMax (std::numeric_limits<int>::max()),
|
: Setting (parent, values, mutex, key, label), mMin (0), mMax (std::numeric_limits<int>::max()),
|
||||||
mDefault (default_)
|
mDefault (default_), mWidget(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CSMPrefs::IntSetting& CSMPrefs::IntSetting::setRange (int min, int max)
|
CSMPrefs::IntSetting& CSMPrefs::IntSetting::setRange (int min, int max)
|
||||||
|
@ -47,20 +47,28 @@ std::pair<QWidget *, QWidget *> CSMPrefs::IntSetting::makeWidgets (QWidget *pare
|
||||||
{
|
{
|
||||||
QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent);
|
QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent);
|
||||||
|
|
||||||
QSpinBox *widget = new QSpinBox (parent);
|
mWidget = new QSpinBox (parent);
|
||||||
widget->setRange (mMin, mMax);
|
mWidget->setRange (mMin, mMax);
|
||||||
widget->setValue (mDefault);
|
mWidget->setValue (mDefault);
|
||||||
|
|
||||||
if (!mTooltip.empty())
|
if (!mTooltip.empty())
|
||||||
{
|
{
|
||||||
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
||||||
label->setToolTip (tooltip);
|
label->setToolTip (tooltip);
|
||||||
widget->setToolTip (tooltip);
|
mWidget->setToolTip (tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect (widget, SIGNAL (valueChanged (int)), this, SLOT (valueChanged (int)));
|
connect (mWidget, SIGNAL (valueChanged (int)), this, SLOT (valueChanged (int)));
|
||||||
|
|
||||||
return std::make_pair (label, widget);
|
return std::make_pair (label, mWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::IntSetting::updateWidget()
|
||||||
|
{
|
||||||
|
if (mWidget)
|
||||||
|
{
|
||||||
|
mWidget->setValue(getValues().getInt(getKey(), getParent()->getKey()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::IntSetting::valueChanged (int value)
|
void CSMPrefs::IntSetting::valueChanged (int value)
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "setting.hpp"
|
#include "setting.hpp"
|
||||||
|
|
||||||
|
class QSpinBox;
|
||||||
|
|
||||||
namespace CSMPrefs
|
namespace CSMPrefs
|
||||||
{
|
{
|
||||||
class IntSetting : public Setting
|
class IntSetting : public Setting
|
||||||
|
@ -13,6 +15,7 @@ namespace CSMPrefs
|
||||||
int mMax;
|
int mMax;
|
||||||
std::string mTooltip;
|
std::string mTooltip;
|
||||||
int mDefault;
|
int mDefault;
|
||||||
|
QSpinBox* mWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -31,6 +34,8 @@ namespace CSMPrefs
|
||||||
/// Return label, input widget.
|
/// Return label, input widget.
|
||||||
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
||||||
|
|
||||||
|
virtual void updateWidget();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void valueChanged (int value);
|
void valueChanged (int value);
|
||||||
|
|
|
@ -32,6 +32,10 @@ namespace CSMPrefs
|
||||||
|
|
||||||
widget->setCheckable(true);
|
widget->setCheckable(true);
|
||||||
widget->installEventFilter(this);
|
widget->installEventFilter(this);
|
||||||
|
|
||||||
|
// right clicking on button sets shortcut to RMB, so context menu should not appear
|
||||||
|
widget->setContextMenuPolicy(Qt::PreventContextMenu);
|
||||||
|
|
||||||
mButton = widget;
|
mButton = widget;
|
||||||
|
|
||||||
connect(widget, SIGNAL(toggled(bool)), this, SLOT(buttonToggled(bool)));
|
connect(widget, SIGNAL(toggled(bool)), this, SLOT(buttonToggled(bool)));
|
||||||
|
@ -39,6 +43,19 @@ namespace CSMPrefs
|
||||||
return std::make_pair(label, widget);
|
return std::make_pair(label, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModifierSetting::updateWidget()
|
||||||
|
{
|
||||||
|
if (mButton)
|
||||||
|
{
|
||||||
|
std::string shortcut = getValues().getString(getKey(), getParent()->getKey());
|
||||||
|
|
||||||
|
int modifier;
|
||||||
|
State::get().getShortcutManager().convertFromString(shortcut, modifier);
|
||||||
|
State::get().getShortcutManager().setModifier(getKey(), modifier);
|
||||||
|
resetState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ModifierSetting::eventFilter(QObject* target, QEvent* event)
|
bool ModifierSetting::eventFilter(QObject* target, QEvent* event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::KeyPress)
|
if (event->type() == QEvent::KeyPress)
|
||||||
|
|
|
@ -21,6 +21,8 @@ namespace CSMPrefs
|
||||||
|
|
||||||
virtual std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent);
|
virtual std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent);
|
||||||
|
|
||||||
|
virtual void updateWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool eventFilter(QObject* target, QEvent* event);
|
bool eventFilter(QObject* target, QEvent* event);
|
||||||
|
|
|
@ -30,6 +30,10 @@ std::pair<QWidget *, QWidget *> CSMPrefs::Setting::makeWidgets (QWidget *parent)
|
||||||
return std::pair<QWidget *, QWidget *> (0, 0);
|
return std::pair<QWidget *, QWidget *> (0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::Setting::updateWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
const CSMPrefs::Category *CSMPrefs::Setting::getParent() const
|
const CSMPrefs::Category *CSMPrefs::Setting::getParent() const
|
||||||
{
|
{
|
||||||
return mParent;
|
return mParent;
|
||||||
|
|
|
@ -47,6 +47,11 @@ namespace CSMPrefs
|
||||||
/// widget.
|
/// widget.
|
||||||
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
||||||
|
|
||||||
|
/// Updates the widget returned by makeWidgets() to the current setting.
|
||||||
|
///
|
||||||
|
/// \note If make_widgets() has not been called yet then nothing happens.
|
||||||
|
virtual void updateWidget();
|
||||||
|
|
||||||
const Category *getParent() const;
|
const Category *getParent() const;
|
||||||
|
|
||||||
const std::string& getKey() const;
|
const std::string& getKey() const;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include "state.hpp"
|
#include "state.hpp"
|
||||||
#include "shortcutmanager.hpp"
|
#include "shortcutmanager.hpp"
|
||||||
|
@ -39,6 +40,10 @@ namespace CSMPrefs
|
||||||
|
|
||||||
widget->setCheckable(true);
|
widget->setCheckable(true);
|
||||||
widget->installEventFilter(this);
|
widget->installEventFilter(this);
|
||||||
|
|
||||||
|
// right clicking on button sets shortcut to RMB, so context menu should not appear
|
||||||
|
widget->setContextMenuPolicy(Qt::PreventContextMenu);
|
||||||
|
|
||||||
mButton = widget;
|
mButton = widget;
|
||||||
|
|
||||||
connect(widget, SIGNAL(toggled(bool)), this, SLOT(buttonToggled(bool)));
|
connect(widget, SIGNAL(toggled(bool)), this, SLOT(buttonToggled(bool)));
|
||||||
|
@ -46,6 +51,19 @@ namespace CSMPrefs
|
||||||
return std::make_pair(label, widget);
|
return std::make_pair(label, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShortcutSetting::updateWidget()
|
||||||
|
{
|
||||||
|
if (mButton)
|
||||||
|
{
|
||||||
|
std::string shortcut = getValues().getString(getKey(), getParent()->getKey());
|
||||||
|
|
||||||
|
QKeySequence sequence;
|
||||||
|
State::get().getShortcutManager().convertFromString(shortcut, sequence);
|
||||||
|
State::get().getShortcutManager().setSequence(getKey(), sequence);
|
||||||
|
resetState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ShortcutSetting::eventFilter(QObject* target, QEvent* event)
|
bool ShortcutSetting::eventFilter(QObject* target, QEvent* event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::KeyPress)
|
if (event->type() == QEvent::KeyPress)
|
||||||
|
|
|
@ -21,6 +21,8 @@ namespace CSMPrefs
|
||||||
|
|
||||||
virtual std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent);
|
virtual std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent);
|
||||||
|
|
||||||
|
virtual void updateWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool eventFilter(QObject* target, QEvent* event);
|
bool eventFilter(QObject* target, QEvent* event);
|
||||||
|
|
|
@ -587,6 +587,41 @@ CSMPrefs::State& CSMPrefs::State::get()
|
||||||
return *sThis;
|
return *sThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::State::resetCategory(const std::string& category)
|
||||||
|
{
|
||||||
|
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 container = mCategories.find(category);
|
||||||
|
if (container != mCategories.end())
|
||||||
|
{
|
||||||
|
Category settings = container->second;
|
||||||
|
for (Category::Iterator i = settings.begin(); i != settings.end(); ++i)
|
||||||
|
{
|
||||||
|
(*i)->updateWidget();
|
||||||
|
update(**i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::State::resetAll()
|
||||||
|
{
|
||||||
|
for (Collection::iterator iter = mCategories.begin(); iter != mCategories.end(); ++iter)
|
||||||
|
{
|
||||||
|
resetCategory(iter->first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CSMPrefs::State& CSMPrefs::get()
|
CSMPrefs::State& CSMPrefs::get()
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,6 +106,10 @@ namespace CSMPrefs
|
||||||
|
|
||||||
static State& get();
|
static State& get();
|
||||||
|
|
||||||
|
void resetCategory(const std::string& category);
|
||||||
|
|
||||||
|
void resetAll();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void settingChanged (const CSMPrefs::Setting *setting);
|
void settingChanged (const CSMPrefs::Setting *setting);
|
||||||
|
|
44
apps/opencs/view/prefs/contextmenulist.cpp
Normal file
44
apps/opencs/view/prefs/contextmenulist.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#include "contextmenulist.hpp"
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QContextMenuEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
#include "../../model/prefs/state.hpp"
|
||||||
|
|
||||||
|
CSVPrefs::ContextMenuList::ContextMenuList(QWidget* parent)
|
||||||
|
:QListWidget(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVPrefs::ContextMenuList::contextMenuEvent(QContextMenuEvent* e)
|
||||||
|
{
|
||||||
|
QMenu* menu = new QMenu();
|
||||||
|
|
||||||
|
menu->addAction("Reset category to default", this, SLOT(resetCategory()));
|
||||||
|
menu->addAction("Reset all to default", this, SLOT(resetAll()));
|
||||||
|
|
||||||
|
menu->exec(e->globalPos());
|
||||||
|
delete menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVPrefs::ContextMenuList::mousePressEvent(QMouseEvent* e)
|
||||||
|
{
|
||||||
|
// enable all buttons except right click
|
||||||
|
// This means that when right-clicking to enable the
|
||||||
|
// context menu, the page doesn't switch at the same time.
|
||||||
|
if (!(e->buttons() & Qt::RightButton))
|
||||||
|
{
|
||||||
|
QListWidget::mousePressEvent(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVPrefs::ContextMenuList::resetCategory()
|
||||||
|
{
|
||||||
|
CSMPrefs::State::get().resetCategory(currentItem()->text().toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVPrefs::ContextMenuList::resetAll()
|
||||||
|
{
|
||||||
|
CSMPrefs::State::get().resetAll();
|
||||||
|
}
|
33
apps/opencs/view/prefs/contextmenulist.hpp
Normal file
33
apps/opencs/view/prefs/contextmenulist.hpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef CSV_PREFS_CONTEXTMENULIST_H
|
||||||
|
#define CSV_PREFS_CONTEXTMENULIST_H
|
||||||
|
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
|
class QContextMenuEvent;
|
||||||
|
class QMouseEvent;
|
||||||
|
|
||||||
|
namespace CSVPrefs
|
||||||
|
{
|
||||||
|
class ContextMenuList : public QListWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
ContextMenuList(QWidget* parent = 0);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void contextMenuEvent(QContextMenuEvent* e);
|
||||||
|
|
||||||
|
void mousePressEvent(QMouseEvent* e);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void resetCategory();
|
||||||
|
|
||||||
|
void resetAll();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -12,16 +12,17 @@
|
||||||
|
|
||||||
#include "page.hpp"
|
#include "page.hpp"
|
||||||
#include "keybindingpage.hpp"
|
#include "keybindingpage.hpp"
|
||||||
|
#include "contextmenulist.hpp"
|
||||||
|
|
||||||
void CSVPrefs::Dialogue::buildCategorySelector (QSplitter *main)
|
void CSVPrefs::Dialogue::buildCategorySelector (QSplitter *main)
|
||||||
{
|
{
|
||||||
mList = new QListWidget (main);
|
CSVPrefs::ContextMenuList* list = new CSVPrefs::ContextMenuList (main);
|
||||||
mList->setMinimumWidth (50);
|
list->setMinimumWidth (50);
|
||||||
mList->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
|
list->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|
||||||
mList->setSelectionBehavior (QAbstractItemView::SelectItems);
|
list->setSelectionBehavior (QAbstractItemView::SelectItems);
|
||||||
|
|
||||||
main->addWidget (mList);
|
main->addWidget (list);
|
||||||
|
|
||||||
QFontMetrics metrics (QApplication::font());
|
QFontMetrics metrics (QApplication::font());
|
||||||
|
|
||||||
|
@ -33,12 +34,12 @@ void CSVPrefs::Dialogue::buildCategorySelector (QSplitter *main)
|
||||||
QString label = QString::fromUtf8 (iter->second.getKey().c_str());
|
QString label = QString::fromUtf8 (iter->second.getKey().c_str());
|
||||||
maxWidth = std::max (maxWidth, metrics.width (label));
|
maxWidth = std::max (maxWidth, metrics.width (label));
|
||||||
|
|
||||||
mList->addItem (label);
|
list->addItem (label);
|
||||||
}
|
}
|
||||||
|
|
||||||
mList->setMaximumWidth (maxWidth + 10);
|
list->setMaximumWidth (maxWidth + 10);
|
||||||
|
|
||||||
connect (mList, SIGNAL (currentItemChanged (QListWidgetItem *, QListWidgetItem *)),
|
connect (list, SIGNAL (currentItemChanged (QListWidgetItem *, QListWidgetItem *)),
|
||||||
this, SLOT (selectionChanged (QListWidgetItem *, QListWidgetItem *)));
|
this, SLOT (selectionChanged (QListWidgetItem *, QListWidgetItem *)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ namespace CSVPrefs
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QListWidget *mList;
|
|
||||||
QStackedWidget *mContent;
|
QStackedWidget *mContent;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
|
|
||||||
#include "pagebase.hpp"
|
#include "pagebase.hpp"
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QContextMenuEvent>
|
||||||
|
|
||||||
#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 +15,24 @@ CSMPrefs::Category& CSVPrefs::PageBase::getCategory()
|
||||||
{
|
{
|
||||||
return mCategory;
|
return mCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVPrefs::PageBase::contextMenuEvent(QContextMenuEvent* e)
|
||||||
|
{
|
||||||
|
QMenu* menu = new QMenu();
|
||||||
|
|
||||||
|
menu->addAction("Reset category to default", this, SLOT(resetCategory()));
|
||||||
|
menu->addAction("Reset all to default", this, SLOT(resetAll()));
|
||||||
|
|
||||||
|
menu->exec(e->globalPos());
|
||||||
|
delete menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVPrefs::PageBase::resetCategory()
|
||||||
|
{
|
||||||
|
CSMPrefs::State::get().resetCategory(getCategory().getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVPrefs::PageBase::resetAll()
|
||||||
|
{
|
||||||
|
CSMPrefs::State::get().resetAll();
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
|
||||||
|
class QContextMenuEvent;
|
||||||
|
|
||||||
namespace CSMPrefs
|
namespace CSMPrefs
|
||||||
{
|
{
|
||||||
class Category;
|
class Category;
|
||||||
|
@ -21,6 +23,16 @@ namespace CSVPrefs
|
||||||
PageBase (CSMPrefs::Category& category, QWidget *parent);
|
PageBase (CSMPrefs::Category& category, QWidget *parent);
|
||||||
|
|
||||||
CSMPrefs::Category& getCategory();
|
CSMPrefs::Category& getCategory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void contextMenuEvent(QContextMenuEvent*);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void resetCategory();
|
||||||
|
|
||||||
|
void resetAll();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue