mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +00:00
added bool settings
This commit is contained in:
parent
9ca5a1b647
commit
b0fb6d56f1
6 changed files with 136 additions and 13 deletions
|
@ -138,7 +138,7 @@ opencs_hdrs_noqt (model/settings
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units (model/prefs
|
opencs_units (model/prefs
|
||||||
state setting intsetting doublesetting
|
state setting intsetting doublesetting boolsetting
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (model/prefs
|
opencs_units_noqt (model/prefs
|
||||||
|
|
42
apps/opencs/model/prefs/boolsetting.cpp
Normal file
42
apps/opencs/model/prefs/boolsetting.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
|
||||||
|
#include "boolsetting.hpp"
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
|
#include "category.hpp"
|
||||||
|
#include "state.hpp"
|
||||||
|
|
||||||
|
CSMPrefs::BoolSetting::BoolSetting (Category *parent, Settings::Manager *values,
|
||||||
|
const std::string& key, const std::string& label, bool default_)
|
||||||
|
: Setting (parent, values, key, label), mDefault (default_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip (const std::string& tooltip)
|
||||||
|
{
|
||||||
|
mTooltip = tooltip;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<QWidget *, QWidget *> CSMPrefs::BoolSetting::makeWidgets (QWidget *parent)
|
||||||
|
{
|
||||||
|
QCheckBox *widget = new QCheckBox (QString::fromUtf8 (getLabel().c_str()), parent);
|
||||||
|
widget->setCheckState (mDefault ? Qt::Checked : Qt::Unchecked);
|
||||||
|
|
||||||
|
if (!mTooltip.empty())
|
||||||
|
{
|
||||||
|
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
||||||
|
widget->setToolTip (tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect (widget, SIGNAL (stateChanged (int)), this, SLOT (valueChanged (int)));
|
||||||
|
|
||||||
|
return std::make_pair (static_cast<QWidget *> (0), widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::BoolSetting::valueChanged (int value)
|
||||||
|
{
|
||||||
|
getValues().setBool (getKey(), getParent()->getKey(), value);
|
||||||
|
getParent()->getState()->update (*this);
|
||||||
|
}
|
31
apps/opencs/model/prefs/boolsetting.hpp
Normal file
31
apps/opencs/model/prefs/boolsetting.hpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef CSM_PREFS_BOOLSETTING_H
|
||||||
|
#define CSM_PREFS_BOOLSETTING_H
|
||||||
|
|
||||||
|
#include "setting.hpp"
|
||||||
|
|
||||||
|
namespace CSMPrefs
|
||||||
|
{
|
||||||
|
class BoolSetting : public Setting
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
std::string mTooltip;
|
||||||
|
bool mDefault;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
BoolSetting (Category *parent, Settings::Manager *values,
|
||||||
|
const std::string& key, const std::string& label, bool default_);
|
||||||
|
|
||||||
|
BoolSetting& setTooltip (const std::string& tooltip);
|
||||||
|
|
||||||
|
/// Return label, input widget.
|
||||||
|
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void valueChanged (int value);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "intsetting.hpp"
|
#include "intsetting.hpp"
|
||||||
#include "doublesetting.hpp"
|
#include "doublesetting.hpp"
|
||||||
|
#include "boolsetting.hpp"
|
||||||
|
|
||||||
CSMPrefs::State *CSMPrefs::State::sThis = 0;
|
CSMPrefs::State *CSMPrefs::State::sThis = 0;
|
||||||
|
|
||||||
|
@ -39,24 +40,47 @@ void CSMPrefs::State::declare()
|
||||||
declareInt ("default-height", "Default window height", 600).
|
declareInt ("default-height", "Default window height", 600).
|
||||||
setTooltip ("Newly opened top-level windows will open with this height.").
|
setTooltip ("Newly opened top-level windows will open with this height.").
|
||||||
setMin (80);
|
setMin (80);
|
||||||
// reuse
|
declareBool ("reuse", "Reuse Subviews", true).
|
||||||
// show-statusbar
|
setTooltip ("When a new subview is requested and a matching subview already "
|
||||||
|
" exist, do not open a new subview and use the existing one instead.");
|
||||||
|
declareBool ("show-statusbar", "Show Status Bar", true).
|
||||||
|
setTooltip ("If a newly open top level window is showing status bars or not. "
|
||||||
|
" Note that this does not affect existing windows.");
|
||||||
declareInt ("max-subviews", "Maximum number of subviews per top-level window", 256).
|
declareInt ("max-subviews", "Maximum number of subviews per top-level window", 256).
|
||||||
setTooltip ("If the maximum number is reached and a new subview is opened "
|
setTooltip ("If the maximum number is reached and a new subview is opened "
|
||||||
"it will be placed into a new top-level window.").
|
"it will be placed into a new top-level window.").
|
||||||
setRange (1, 256);
|
setRange (1, 256);
|
||||||
// hide-subview
|
declareBool ("hide-subview", "Hide single subview", false).
|
||||||
|
setTooltip ("When a view contains only a single subview, hide the subview title "
|
||||||
|
"bar and if this subview is closed also close the view (unless it is the last "
|
||||||
|
"view for this document)");
|
||||||
declareInt ("minimum-width", "Minimum subview width", 325).
|
declareInt ("minimum-width", "Minimum subview width", 325).
|
||||||
setTooltip ("Minimum width of subviews.").
|
setTooltip ("Minimum width of subviews.").
|
||||||
setRange (50, 10000);
|
setRange (50, 10000);
|
||||||
// mainwindow-scrollbar
|
// mainwindow-scrollbar
|
||||||
// grow-limit
|
declareBool ("grow-limit", "Grow Limit Screen", false).
|
||||||
|
setTooltip ("When \"Grow then Scroll\" option is selected, the window size grows to"
|
||||||
|
" the width of the virtual desktop. \nIf this option is selected the the window growth"
|
||||||
|
"is limited to the current screen.");
|
||||||
|
|
||||||
declareCategory ("Records");
|
declareCategory ("Records");
|
||||||
|
|
||||||
declareCategory ("ID Tables");
|
declareCategory ("ID Tables");
|
||||||
|
// double
|
||||||
|
// double-s
|
||||||
|
// double-c
|
||||||
|
// double-sc
|
||||||
|
// jump-to-added
|
||||||
|
declareBool ("extended-config",
|
||||||
|
"Manually specify affected record types for an extended delete/revert", false).
|
||||||
|
setTooltip ("Delete and revert commands have an extended form that also affects "
|
||||||
|
"associated records.\n\n"
|
||||||
|
"If this option is enabled, types of affected records are selected "
|
||||||
|
"manually before a command execution.\nOtherwise, all associated "
|
||||||
|
"records are deleted/reverted immediately.");
|
||||||
|
|
||||||
declareCategory ("ID Dialogues");
|
declareCategory ("ID Dialogues");
|
||||||
|
declareBool ("toolbar", "Show toolbar", true);
|
||||||
|
|
||||||
declareCategory ("Reports");
|
declareCategory ("Reports");
|
||||||
|
|
||||||
|
@ -65,13 +89,15 @@ void CSMPrefs::State::declare()
|
||||||
setTooltip ("Maximum number of character to display in search result before the searched text");
|
setTooltip ("Maximum number of character to display in search result before the searched text");
|
||||||
declareInt ("char-after", "Characters after search string", 10).
|
declareInt ("char-after", "Characters after search string", 10).
|
||||||
setTooltip ("Maximum number of character to display in search result after the searched text");
|
setTooltip ("Maximum number of character to display in search result after the searched text");
|
||||||
// auto-delete
|
declareBool ("auto-delete", "Delete row from result table after a successful replace", true);
|
||||||
|
|
||||||
declareCategory ("Scripts");
|
declareCategory ("Scripts");
|
||||||
// show-linenum
|
declareBool ("show-linenum", "Show Line Numbers", true).
|
||||||
// mono-font
|
setTooltip ("Show line numbers to the left of the script editor window."
|
||||||
|
"The current row and column numbers of the text cursor are shown at the bottom.");
|
||||||
|
declareBool ("mono-font", "Use monospace font", true);
|
||||||
// warnings
|
// warnings
|
||||||
// toolbar
|
declareBool ("toolbar", "Show toolbar", true);
|
||||||
declareInt ("compile-delay", "Delay between updating of source errors", 100).
|
declareInt ("compile-delay", "Delay between updating of source errors", 100).
|
||||||
setTooltip ("Delay in milliseconds").
|
setTooltip ("Delay in milliseconds").
|
||||||
setRange (0, 10000);
|
setRange (0, 10000);
|
||||||
|
@ -80,6 +106,9 @@ void CSMPrefs::State::declare()
|
||||||
// syntax-colouring
|
// syntax-colouring
|
||||||
|
|
||||||
declareCategory ("General Input");
|
declareCategory ("General Input");
|
||||||
|
declareBool ("cycle", "Cyclic next/previous", false).
|
||||||
|
setTooltip ("When using next/previous functions at the last/first item of a "
|
||||||
|
"list go to the first/last item");
|
||||||
|
|
||||||
declareCategory ("3D Scene Input");
|
declareCategory ("3D Scene Input");
|
||||||
// p-navi
|
// p-navi
|
||||||
|
@ -88,7 +117,7 @@ void CSMPrefs::State::declare()
|
||||||
// s-edit
|
// s-edit
|
||||||
// p-select
|
// p-select
|
||||||
// s-select
|
// s-select
|
||||||
// context-select
|
declareBool ("context-select", "Context Sensitive Selection", false);
|
||||||
declareDouble ("drag-factor", "Mouse sensitivity during drag operations", 1.0).
|
declareDouble ("drag-factor", "Mouse sensitivity during drag operations", 1.0).
|
||||||
setRange (0.001, 100.0);
|
setRange (0.001, 100.0);
|
||||||
declareDouble ("drag-wheel-factor", "Mouse wheel sensitivity during drag operations", 1.0).
|
declareDouble ("drag-wheel-factor", "Mouse wheel sensitivity during drag operations", 1.0).
|
||||||
|
@ -99,8 +128,8 @@ void CSMPrefs::State::declare()
|
||||||
setRange (0.001, 100.0);
|
setRange (0.001, 100.0);
|
||||||
|
|
||||||
declareCategory ("Tooltips");
|
declareCategory ("Tooltips");
|
||||||
// scene
|
declareBool ("scene", "Show Tooltips in 3D scenes", true);
|
||||||
// scene-hide-basic
|
declareBool ("scene-hide-basic", "Hide basic 3D scenes tooltips", false);
|
||||||
declareInt ("scene-delay", "Tooltip delay in milliseconds", 500).
|
declareInt ("scene-delay", "Tooltip delay in milliseconds", 500).
|
||||||
setMin (1);
|
setMin (1);
|
||||||
}
|
}
|
||||||
|
@ -160,6 +189,24 @@ CSMPrefs::DoubleSetting& CSMPrefs::State::declareDouble (const std::string& key,
|
||||||
return *setting;
|
return *setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSMPrefs::BoolSetting& CSMPrefs::State::declareBool (const std::string& key,
|
||||||
|
const std::string& label, bool default_)
|
||||||
|
{
|
||||||
|
if (mCurrentCategory==mCategories.end())
|
||||||
|
throw std::logic_error ("no category for setting");
|
||||||
|
|
||||||
|
setDefault (key, default_ ? "true" : "false");
|
||||||
|
|
||||||
|
default_ = mSettings.getBool (key, mCurrentCategory->second.getKey());
|
||||||
|
|
||||||
|
CSMPrefs::BoolSetting *setting =
|
||||||
|
new CSMPrefs::BoolSetting (&mCurrentCategory->second, &mSettings, key, label, default_);
|
||||||
|
|
||||||
|
mCurrentCategory->second.addSetting (setting);
|
||||||
|
|
||||||
|
return *setting;
|
||||||
|
}
|
||||||
|
|
||||||
void CSMPrefs::State::setDefault (const std::string& key, const std::string& default_)
|
void CSMPrefs::State::setDefault (const std::string& key, const std::string& default_)
|
||||||
{
|
{
|
||||||
Settings::CategorySetting fullKey (mCurrentCategory->second.getKey(), key);
|
Settings::CategorySetting fullKey (mCurrentCategory->second.getKey(), key);
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace CSMPrefs
|
||||||
{
|
{
|
||||||
class IntSetting;
|
class IntSetting;
|
||||||
class DoubleSetting;
|
class DoubleSetting;
|
||||||
|
class BoolSetting;
|
||||||
|
|
||||||
class State : public QObject
|
class State : public QObject
|
||||||
{
|
{
|
||||||
|
@ -54,6 +55,8 @@ namespace CSMPrefs
|
||||||
IntSetting& declareInt (const std::string& key, const std::string& label, int default_);
|
IntSetting& declareInt (const std::string& key, const std::string& label, int default_);
|
||||||
DoubleSetting& declareDouble (const std::string& key, const std::string& label, double default_);
|
DoubleSetting& declareDouble (const std::string& key, const std::string& label, double default_);
|
||||||
|
|
||||||
|
BoolSetting& declareBool (const std::string& key, const std::string& label, bool default_);
|
||||||
|
|
||||||
void setDefault (const std::string& key, const std::string& default_);
|
void setDefault (const std::string& key, const std::string& default_);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -31,7 +31,7 @@ void CSVPrefs::Page::addSetting (CSMPrefs::Setting *setting)
|
||||||
}
|
}
|
||||||
else if (widgets.second)
|
else if (widgets.second)
|
||||||
{
|
{
|
||||||
mGrid->addWidget (widgets.second, next, 0, next, 1);
|
mGrid->addWidget (widgets.second, next, 0, 1, 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue