diff --git a/src/plugins/texteditor/colorschemeedit.cpp b/src/plugins/texteditor/colorschemeedit.cpp index 5a6ecf654a0..8049c191a35 100644 --- a/src/plugins/texteditor/colorschemeedit.cpp +++ b/src/plugins/texteditor/colorschemeedit.cpp @@ -278,6 +278,7 @@ void ColorSchemeEdit::updateForegroundControls() bool isVisible = formatDescription.showControl(FormatDescription::ShowForegroundControl); + m_ui->relativeForegroundHeadline->setEnabled(isVisible); m_ui->foregroundLabel->setVisible(isVisible); m_ui->foregroundToolButton->setVisible(isVisible); m_ui->eraseForegroundToolButton->setVisible(isVisible); @@ -296,6 +297,7 @@ void ColorSchemeEdit::updateBackgroundControls() bool isVisible = formatDescription.showControl(FormatDescription::ShowBackgroundControl); + m_ui->relativeBackgroundHeadline->setVisible(isVisible); m_ui->backgroundLabel->setVisible(isVisible); m_ui->backgroundToolButton->setVisible(isVisible); m_ui->eraseBackgroundToolButton->setVisible(isVisible); @@ -326,6 +328,14 @@ void ColorSchemeEdit::updateRelativeForegroundControls() m_ui->relativeForegroundSpacer2->setVisible(isVisible); m_ui->relativeForegroundSpacer3->setVisible(isVisible); + bool isEnabled = !m_readOnly && !format.foreground().isValid(); + + m_ui->relativeForegroundHeadline->setEnabled(isEnabled); + m_ui->foregroundSaturationLabel->setEnabled(isEnabled); + m_ui->foregroundLightnessLabel->setEnabled(isEnabled); + m_ui->foregroundSaturationSpinBox->setEnabled(isEnabled); + m_ui->foregroundLightnessSpinBox->setEnabled(isEnabled); + m_ui->foregroundSaturationSpinBox->setValue(format.relativeForegroundSaturation()); m_ui->foregroundLightnessSpinBox->setValue(format.relativeForegroundLightness()); } @@ -349,6 +359,14 @@ void ColorSchemeEdit::updateRelativeBackgroundControls() m_ui->relativeBackgroundSpacer2->setVisible(isVisible); m_ui->relativeBackgroundSpacer3->setVisible(isVisible); + bool isEnabled = !m_readOnly && !format.background().isValid(); + + m_ui->relativeBackgroundHeadline->setEnabled(isEnabled); + m_ui->backgroundSaturationLabel->setEnabled(isEnabled); + m_ui->backgroundLightnessLabel->setEnabled(isEnabled); + m_ui->backgroundSaturationSpinBox->setEnabled(isEnabled); + m_ui->backgroundLightnessSpinBox->setEnabled(isEnabled); + m_ui->backgroundSaturationSpinBox->setValue(format.relativeBackgroundSaturation()); m_ui->backgroundLightnessSpinBox->setValue(format.relativeBackgroundLightness()); } @@ -415,6 +433,8 @@ void ColorSchemeEdit::changeForeColor() m_scheme.formatFor(category).setForeground(newColor); m_formatsModel->emitDataChanged(index); } + + updateControls(); } void ColorSchemeEdit::changeBackColor() @@ -436,6 +456,8 @@ void ColorSchemeEdit::changeBackColor() if (index.row() == 0) setItemListBackground(newColor); } + + updateControls(); } void ColorSchemeEdit::eraseBackColor() @@ -451,6 +473,8 @@ void ColorSchemeEdit::eraseBackColor() m_scheme.formatFor(category).setBackground(newColor); m_formatsModel->emitDataChanged(index); } + + updateControls(); } void ColorSchemeEdit::eraseForeColor() @@ -466,6 +490,8 @@ void ColorSchemeEdit::eraseForeColor() m_scheme.formatFor(category).setForeground(newColor); m_formatsModel->emitDataChanged(index); } + + updateControls(); } void ColorSchemeEdit::changeRelativeForeColor() diff --git a/src/plugins/texteditor/fontsettingspage.h b/src/plugins/texteditor/fontsettingspage.h index ab507a45506..9f696b3ee81 100644 --- a/src/plugins/texteditor/fontsettingspage.h +++ b/src/plugins/texteditor/fontsettingspage.h @@ -58,36 +58,40 @@ public: ShowUnderlineControl = 0x8, ShowRelativeForegroundControl = 0x10, ShowRelativeBackgroundControl = 0x20, + ShowRelativeControls = ShowRelativeForegroundControl | ShowRelativeBackgroundControl, ShowFontUnderlineAndRelativeControls = ShowFontControls | ShowUnderlineControl - | ShowRelativeForegroundControl - | ShowRelativeBackgroundControl, - AllControls = 0xF, - AllControlsExceptUnderline = AllControls & ~ShowUnderlineControl, + | ShowRelativeControls, + ShowAllAbsoluteControls = ShowForegroundControl + | ShowBackgroundControl + | ShowFontControls + | ShowUnderlineControl, + ShowAllAbsoluteControlsExceptUnderline = ShowAllAbsoluteControls & ~ShowUnderlineControl, + ShowAllControls = ShowAllAbsoluteControls | ShowRelativeControls }; FormatDescription() = default; FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText, - ShowControls showControls = AllControls); + ShowControls showControls = ShowAllAbsoluteControls); FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText, const QColor &foreground, - ShowControls showControls = AllControls); + ShowControls showControls = ShowAllAbsoluteControls); FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText, const Format &format, - ShowControls showControls = AllControls); + ShowControls showControls = ShowAllAbsoluteControls); FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText, const QColor &underlineColor, const QTextCharFormat::UnderlineStyle underlineStyle, - ShowControls showControls = AllControls); + ShowControls showControls = ShowAllAbsoluteControls); TextStyle id() const { return m_id; } @@ -110,7 +114,7 @@ private: Format m_format; // Default format QString m_displayName; // Displayed name of the category QString m_tooltipText; // Description text for category - ShowControls m_showControls = AllControls; + ShowControls m_showControls = ShowAllAbsoluteControls; }; typedef std::vector FormatDescriptions; diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index 0c02eb3cd12..f5cc088f22a 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -103,7 +103,7 @@ TextEditorSettings::TextEditorSettings() p.color(QPalette::HighlightedText)); formatDescr.emplace_back(C_LINE_NUMBER, tr("Line Number"), tr("Line numbers located on the left side of the editor."), - FormatDescription::AllControlsExceptUnderline); + FormatDescription::ShowAllAbsoluteControlsExceptUnderline); formatDescr.emplace_back(C_SEARCH_RESULT, tr("Search Result"), tr("Highlighted search results inside the editor."), FormatDescription::ShowBackgroundControl); @@ -128,7 +128,7 @@ TextEditorSettings::TextEditorSettings() tr("Line number located on the left side of the " "editor where the cursor is placed in."), Qt::darkGray, - FormatDescription::AllControlsExceptUnderline); + FormatDescription::ShowAllAbsoluteControlsExceptUnderline); currentLineNumber.format().setBold(true); formatDescr.push_back(std::move(currentLineNumber)); @@ -168,6 +168,18 @@ TextEditorSettings::TextEditorSettings() functionFormat.setForeground(QColor(0, 103, 124)); formatDescr.emplace_back(C_FUNCTION, tr("Function"), tr("Name of a function."), functionFormat); + Format declarationFormat = Format::createMixinFormat(); + declarationFormat.setBold(true); + formatDescr.emplace_back(C_DECLARATION, + tr("Function Declaration"), + tr("Style adjustments to (function) declarations."), + declarationFormat, + FormatDescription::ShowAllControls); + formatDescr.emplace_back(C_FUNCTION_DEFINITION, + tr("Function Definition"), + tr("Name of function at its definition."), + Format::createMixinFormat(), + FormatDescription::ShowAllControls); functionFormat.setItalic(true); formatDescr.emplace_back(C_VIRTUAL_METHOD, tr("Virtual Function"), tr("Name of function declared as virtual."), @@ -229,11 +241,13 @@ TextEditorSettings::TextEditorSettings() formatDescr.emplace_back(C_OPERATOR, tr("Operator"), tr("Non user-defined language operators.\n" "To style user-defined operators, use Overloaded Operator."), - Format::createMixinFormat()); + Format::createMixinFormat(), + FormatDescription::ShowAllControls); formatDescr.emplace_back(C_OVERLOADED_OPERATOR, tr("Overloaded Operators"), tr("Calls and declarations of overloaded (user-defined) operators."), - Format::createMixinFormat()); + Format::createMixinFormat(), + FormatDescription::ShowAllControls); formatDescr.emplace_back(C_PREPROCESSOR, tr("Preprocessor"), tr("Preprocessor directives."), Qt::darkBlue); formatDescr.emplace_back(C_LABEL, tr("Label"), tr("Labels for goto statements."), @@ -301,43 +315,32 @@ TextEditorSettings::TextEditorSettings() tr("Underline color of error diagnostics."), QColor(255,0, 0), QTextCharFormat::SingleUnderline, - FormatDescription::ShowUnderlineControl); + FormatDescription::ShowAllControls); formatDescr.emplace_back(C_ERROR_CONTEXT, tr("Error Context"), tr("Underline color of the contexts of error diagnostics."), QColor(255,0, 0), QTextCharFormat::DotLine, - FormatDescription::ShowUnderlineControl); + FormatDescription::ShowAllControls); formatDescr.emplace_back(C_WARNING, tr("Warning"), tr("Underline color of warning diagnostics."), QColor(255, 190, 0), QTextCharFormat::SingleUnderline, - FormatDescription::ShowUnderlineControl); + FormatDescription::ShowAllControls); formatDescr.emplace_back(C_WARNING_CONTEXT, tr("Warning Context"), tr("Underline color of the contexts of warning diagnostics."), QColor(255, 190, 0), QTextCharFormat::DotLine, - FormatDescription::ShowUnderlineControl); - Format declarationFormat = Format::createMixinFormat(); - declarationFormat.setBold(true); - formatDescr.emplace_back(C_DECLARATION, - tr("Function Declaration"), - tr("Style adjustments to (function) declarations."), - declarationFormat, - FormatDescription::ShowFontUnderlineAndRelativeControls); - formatDescr.emplace_back(C_FUNCTION_DEFINITION, - tr("Function Definition"), - tr("Name of function at its definition."), - Format::createMixinFormat()); + FormatDescription::ShowAllControls); Format outputArgumentFormat = Format::createMixinFormat(); outputArgumentFormat.setItalic(true); formatDescr.emplace_back(C_OUTPUT_ARGUMENT, tr("Output Argument"), tr("Writable arguments of a function call."), outputArgumentFormat, - FormatDescription::ShowFontUnderlineAndRelativeControls); + FormatDescription::ShowAllControls); d->m_fontSettingsPage = new FontSettingsPage(formatDescr, Constants::TEXT_EDITOR_FONT_SETTINGS,