forked from qt-creator/qt-creator
Utils: Change individual TriStateAspect display strings individually
Seems to be the more common case. Change-Id: Iff6b236983e37ebe74845a9013bac4a2b659edbb Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -2511,9 +2511,9 @@ void DoubleAspect::setSingleStep(double step)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
TriStateAspect::TriStateAspect(AspectContainer *container,
|
TriStateAspect::TriStateAspect(AspectContainer *container,
|
||||||
const QString &onString,
|
const QString &enabledDisplay,
|
||||||
const QString &offString,
|
const QString &disabledDisplay,
|
||||||
const QString &defaultString)
|
const QString &defaultDisplay)
|
||||||
: SelectionAspect(container)
|
: SelectionAspect(container)
|
||||||
{
|
{
|
||||||
setDisplayStyle(DisplayStyle::ComboBox);
|
setDisplayStyle(DisplayStyle::ComboBox);
|
||||||
@@ -2521,17 +2521,26 @@ TriStateAspect::TriStateAspect(AspectContainer *container,
|
|||||||
SelectionAspect::addOption({});
|
SelectionAspect::addOption({});
|
||||||
SelectionAspect::addOption({});
|
SelectionAspect::addOption({});
|
||||||
SelectionAspect::addOption({});
|
SelectionAspect::addOption({});
|
||||||
setOptionTexts(onString, offString, defaultString);
|
setOptionText(TriState::EnabledValue, enabledDisplay);
|
||||||
|
setOptionText(TriState::DisabledValue, disabledDisplay);
|
||||||
|
setOptionText(TriState::DefaultValue, defaultDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriStateAspect::setOptionTexts(const QString &onString,
|
static QString defaultTristateDisplay(TriState::Value tristate)
|
||||||
const QString &offString,
|
|
||||||
const QString &defaultString)
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->m_options.size() == 3, return);
|
switch (tristate) {
|
||||||
d->m_options[0].displayName = onString.isEmpty() ? Tr::tr("Enable") : onString;
|
case TriState::EnabledValue: return Tr::tr("Enable");
|
||||||
d->m_options[1].displayName = offString.isEmpty() ? Tr::tr("Disable") : offString;
|
case TriState::DisabledValue: return Tr::tr("Disable");
|
||||||
d->m_options[2].displayName = defaultString.isEmpty() ? Tr::tr("Leave at Default") : defaultString;
|
case TriState::DefaultValue: return Tr::tr("Default");
|
||||||
|
}
|
||||||
|
QTC_CHECK(false);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriStateAspect::setOptionText(const TriState::Value tristate, const QString &display)
|
||||||
|
{
|
||||||
|
d->m_options[tristate].displayName = display.isEmpty()
|
||||||
|
? defaultTristateDisplay(tristate) : display;
|
||||||
}
|
}
|
||||||
|
|
||||||
TriState TriStateAspect::value() const
|
TriState TriStateAspect::value() const
|
||||||
|
|||||||
@@ -773,11 +773,11 @@ private:
|
|||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT TriState
|
class QTCREATOR_UTILS_EXPORT TriState
|
||||||
{
|
{
|
||||||
enum Value { EnabledValue, DisabledValue, DefaultValue };
|
|
||||||
explicit TriState(Value v) : m_value(v) {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum Value { EnabledValue, DisabledValue, DefaultValue };
|
||||||
|
|
||||||
TriState() = default;
|
TriState() = default;
|
||||||
|
explicit TriState(Value v) : m_value(v) {}
|
||||||
|
|
||||||
int toInt() const { return int(m_value); }
|
int toInt() const { return int(m_value); }
|
||||||
QVariant toVariant() const { return int(m_value); }
|
QVariant toVariant() const { return int(m_value); }
|
||||||
@@ -801,9 +801,9 @@ class QTCREATOR_UTILS_EXPORT TriStateAspect : public SelectionAspect
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TriStateAspect(AspectContainer *container = nullptr,
|
TriStateAspect(AspectContainer *container = nullptr,
|
||||||
const QString &onString = {},
|
const QString &enabledDisplay = {},
|
||||||
const QString &offString = {},
|
const QString &disabledDisplay = {},
|
||||||
const QString &defaultString = {});
|
const QString &defaultDisplay = {});
|
||||||
|
|
||||||
TriState operator()() const { return value(); }
|
TriState operator()() const { return value(); }
|
||||||
TriState value() const;
|
TriState value() const;
|
||||||
@@ -812,9 +812,8 @@ public:
|
|||||||
TriState defaultValue() const;
|
TriState defaultValue() const;
|
||||||
void setDefaultValue(TriState setting);
|
void setDefaultValue(TriState setting);
|
||||||
|
|
||||||
void setOptionTexts(const QString &onString,
|
void setOptionText(const TriState::Value tristate, const QString &display);
|
||||||
const QString &offString,
|
|
||||||
const QString &defaultString);
|
|
||||||
private:
|
private:
|
||||||
void addOption(const QString &displayName, const QString &toolTip = {}) = delete;
|
void addOption(const QString &displayName, const QString &toolTip = {}) = delete;
|
||||||
void addOption(const Option &option) = delete;
|
void addOption(const Option &option) = delete;
|
||||||
|
|||||||
@@ -111,15 +111,15 @@ DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(Target *target)
|
|||||||
|
|
||||||
m_cppAspect.setSettingsKey("RunConfiguration.UseCppDebugger");
|
m_cppAspect.setSettingsKey("RunConfiguration.UseCppDebugger");
|
||||||
m_cppAspect.setLabelText(Tr::tr("C++ debugger:"));
|
m_cppAspect.setLabelText(Tr::tr("C++ debugger:"));
|
||||||
m_cppAspect.setOptionTexts(Tr::tr("Enabled"), Tr::tr("Disabled"), Tr::tr("Automatic"));
|
m_cppAspect.setOptionText(TriState::DefaultValue, Tr::tr("Automatic"));
|
||||||
|
|
||||||
m_qmlAspect.setSettingsKey("RunConfiguration.UseQmlDebugger");
|
m_qmlAspect.setSettingsKey("RunConfiguration.UseQmlDebugger");
|
||||||
m_qmlAspect.setLabelText(Tr::tr("QML debugger:"));
|
m_qmlAspect.setLabelText(Tr::tr("QML debugger:"));
|
||||||
m_qmlAspect.setOptionTexts(Tr::tr("Enabled"), Tr::tr("Disabled"), Tr::tr("Automatic"));
|
m_qmlAspect.setOptionText(TriState::DefaultValue, Tr::tr("Automatic"));
|
||||||
|
|
||||||
m_pythonAspect.setSettingsKey("RunConfiguration.UsePythonDebugger");
|
m_pythonAspect.setSettingsKey("RunConfiguration.UsePythonDebugger");
|
||||||
m_pythonAspect.setLabelText(Tr::tr("Python debugger:"));
|
m_pythonAspect.setLabelText(Tr::tr("Python debugger:"));
|
||||||
m_pythonAspect.setOptionTexts(Tr::tr("Enabled"), Tr::tr("Disabled"), Tr::tr("Automatic"));
|
m_pythonAspect.setOptionText(TriState::DefaultValue, Tr::tr("Automatic"));
|
||||||
|
|
||||||
// Make sure at least one of the debuggers is set to be active.
|
// Make sure at least one of the debuggers is set to be active.
|
||||||
connect(&m_cppAspect, &TriStateAspect::changed, this, [this] {
|
connect(&m_cppAspect, &TriStateAspect::changed, this, [this] {
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ GdbSettings::GdbSettings()
|
|||||||
|
|
||||||
useDebugInfoD.setSettingsKey("UseDebugInfoD");
|
useDebugInfoD.setSettingsKey("UseDebugInfoD");
|
||||||
useDebugInfoD.setLabelText(Tr::tr("Use debug info daemon"));
|
useDebugInfoD.setLabelText(Tr::tr("Use debug info daemon"));
|
||||||
useDebugInfoD.setOptionTexts({}, {}, tr("Use system settings"));
|
useDebugInfoD.setOptionText(TriState::DefaultValue, tr("Use system settings"));
|
||||||
useDebugInfoD.setToolTip(Tr::tr("Lets GDB attempt to automatically retrieve "
|
useDebugInfoD.setToolTip(Tr::tr("Lets GDB attempt to automatically retrieve "
|
||||||
"debug information for system packages."));
|
"debug information for system packages."));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user