From 51e24f5ad4fda308f6d6875969318ccf7158bffa Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 21 Feb 2019 13:25:17 +0100 Subject: [PATCH] TextEditor: Hide controls in scheme editor for builtin schemes Show a label instead with a link that copies the current color scheme. Fixes: QTCREATORBUG-21874 Change-Id: I74083bac8d7124341b4b63d8e172172235c5e184 Reviewed-by: Leena Miettinen Reviewed-by: Eike Ziller --- src/plugins/texteditor/colorschemeedit.cpp | 48 +- src/plugins/texteditor/colorschemeedit.h | 3 + src/plugins/texteditor/colorschemeedit.ui | 790 ++++++++++---------- src/plugins/texteditor/fontsettingspage.cpp | 2 + 4 files changed, 422 insertions(+), 421 deletions(-) diff --git a/src/plugins/texteditor/colorschemeedit.cpp b/src/plugins/texteditor/colorschemeedit.cpp index 5f999835c53..76fcf7b29b7 100644 --- a/src/plugins/texteditor/colorschemeedit.cpp +++ b/src/plugins/texteditor/colorschemeedit.cpp @@ -155,6 +155,7 @@ ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) : m_ui->detailsScrollArea->viewport()->setAutoFillBackground(false); m_ui->scrollAreaWidgetContents->setAutoFillBackground(false); m_ui->itemList->setModel(m_formatsModel); + m_ui->builtinSchemeLabel->setVisible(m_readOnly); populateUnderlineStyleComboBox(); @@ -186,6 +187,7 @@ ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) : this, &ColorSchemeEdit::eraseUnderlineColor); connect(m_ui->underlineComboBox, static_cast(&QComboBox::currentIndexChanged), this, &ColorSchemeEdit::changeUnderlineStyle); + connect(m_ui->builtinSchemeLabel, &QLabel::linkActivated, this, &ColorSchemeEdit::copyScheme); } ColorSchemeEdit::~ColorSchemeEdit() @@ -214,31 +216,9 @@ void ColorSchemeEdit::setReadOnly(bool readOnly) m_readOnly = readOnly; - const bool enabled = !readOnly; - m_ui->foregroundLabel->setEnabled(enabled); - m_ui->foregroundToolButton->setEnabled(enabled); - m_ui->backgroundLabel->setEnabled(enabled); - m_ui->backgroundToolButton->setEnabled(enabled); - m_ui->eraseBackgroundToolButton->setEnabled(enabled); - m_ui->eraseForegroundToolButton->setEnabled(enabled); - m_ui->relativeForegroundHeadline->setEnabled(enabled); - m_ui->foregroundSaturationLabel->setEnabled(enabled); - m_ui->foregroundLightnessLabel->setEnabled(enabled); - m_ui->foregroundSaturationSpinBox->setEnabled(enabled); - m_ui->foregroundLightnessSpinBox->setEnabled(enabled); - m_ui->relativeBackgroundHeadline->setEnabled(enabled); - m_ui->backgroundSaturationLabel->setEnabled(enabled); - m_ui->backgroundLightnessLabel->setEnabled(enabled); - m_ui->backgroundSaturationSpinBox->setEnabled(enabled); - m_ui->backgroundLightnessSpinBox->setEnabled(enabled); - m_ui->fontHeadline->setEnabled(enabled); - m_ui->boldCheckBox->setEnabled(enabled); - m_ui->italicCheckBox->setEnabled(enabled); - m_ui->underlineHeadline->setEnabled(enabled); - m_ui->underlineLabel->setEnabled(enabled); - m_ui->underlineColorToolButton->setEnabled(enabled); - m_ui->eraseUnderlineColorToolButton->setEnabled(enabled); - m_ui->underlineComboBox->setEnabled(enabled); + m_ui->detailsScrollArea->setVisible(!readOnly); + m_ui->builtinSchemeLabel->setVisible(readOnly); + updateControls(); } void ColorSchemeEdit::setColorScheme(const ColorScheme &colorScheme) @@ -278,7 +258,8 @@ void ColorSchemeEdit::updateForegroundControls() const auto &formatDescription = m_descriptions[m_curItem]; const Format &format = m_scheme.formatFor(formatDescription.id()); - bool isVisible = formatDescription.showControl(FormatDescription::ShowForegroundControl); + bool isVisible = !m_readOnly + && formatDescription.showControl(FormatDescription::ShowForegroundControl); m_ui->relativeForegroundHeadline->setEnabled(isVisible); m_ui->foregroundLabel->setVisible(isVisible); @@ -297,7 +278,8 @@ void ColorSchemeEdit::updateBackgroundControls() const auto formatDescription = m_descriptions[m_curItem]; const Format &format = m_scheme.formatFor(formatDescription.id()); - bool isVisible = formatDescription.showControl(FormatDescription::ShowBackgroundControl); + bool isVisible = !m_readOnly + && formatDescription.showControl(FormatDescription::ShowBackgroundControl); m_ui->relativeBackgroundHeadline->setVisible(isVisible); m_ui->backgroundLabel->setVisible(isVisible); @@ -319,7 +301,8 @@ void ColorSchemeEdit::updateRelativeForegroundControls() QSignalBlocker saturationSignalBlocker(m_ui->foregroundSaturationSpinBox); QSignalBlocker lightnessSignalBlocker(m_ui->foregroundLightnessSpinBox); - bool isVisible = formatDescription.showControl(FormatDescription::ShowRelativeForegroundControl); + bool isVisible = !m_readOnly + && formatDescription.showControl(FormatDescription::ShowRelativeForegroundControl); m_ui->relativeForegroundHeadline->setVisible(isVisible); m_ui->foregroundSaturationLabel->setVisible(isVisible); @@ -350,7 +333,8 @@ void ColorSchemeEdit::updateRelativeBackgroundControls() QSignalBlocker saturationSignalBlocker(m_ui->backgroundSaturationSpinBox); QSignalBlocker lightnessSignalBlocker(m_ui->backgroundLightnessSpinBox); - bool isVisible = formatDescription.showControl(FormatDescription::ShowRelativeBackgroundControl); + bool isVisible = !m_readOnly + && formatDescription.showControl(FormatDescription::ShowRelativeBackgroundControl); m_ui->relativeBackgroundHeadline->setVisible(isVisible); m_ui->backgroundSaturationLabel->setVisible(isVisible); @@ -381,7 +365,8 @@ void ColorSchemeEdit::updateFontControls() QSignalBlocker boldSignalBlocker(m_ui->boldCheckBox); QSignalBlocker italicSignalBlocker(m_ui->italicCheckBox); - bool isVisible= formatDescription.showControl(FormatDescription::ShowFontControls); + bool isVisible = !m_readOnly + && formatDescription.showControl(FormatDescription::ShowFontControls); m_ui->fontHeadline->setVisible(isVisible); m_ui->boldCheckBox->setVisible(isVisible); @@ -401,7 +386,8 @@ void ColorSchemeEdit::updateUnderlineControls() QSignalBlocker comboBoxSignalBlocker(m_ui->underlineComboBox); - bool isVisible= formatDescription.showControl(FormatDescription::ShowUnderlineControl); + bool isVisible = !m_readOnly + && formatDescription.showControl(FormatDescription::ShowUnderlineControl); m_ui->underlineHeadline->setVisible(isVisible); m_ui->underlineLabel->setVisible(isVisible); diff --git a/src/plugins/texteditor/colorschemeedit.h b/src/plugins/texteditor/colorschemeedit.h index 6a1356609bf..f7504c170f8 100644 --- a/src/plugins/texteditor/colorschemeedit.h +++ b/src/plugins/texteditor/colorschemeedit.h @@ -59,6 +59,9 @@ public: void setColorScheme(const ColorScheme &colorScheme); const ColorScheme &colorScheme() const; +signals: + void copyScheme(); + private: void currentItemChanged(const QModelIndex &index); void changeForeColor(); diff --git a/src/plugins/texteditor/colorschemeedit.ui b/src/plugins/texteditor/colorschemeedit.ui index e9bb34596ba..ded11ef21f0 100644 --- a/src/plugins/texteditor/colorschemeedit.ui +++ b/src/plugins/texteditor/colorschemeedit.ui @@ -6,7 +6,7 @@ 0 0 - 462 + 513 416 @@ -39,6 +39,16 @@ + + + + <p align='center'><b>Builtin color schemes need to be <a href="copy">copied</a><br/> before they can be changed</b></p> + + + false + + + @@ -87,36 +97,68 @@ 0 - - - - - 75 - true - + + + + Qt::Vertical - - Relative Foreground + + + 200 + 0 + + + + + + + + + 0 + 0 + + + + + 0 + 6 + + + + + 16777215 + 6 + - - + + - + 0 0 - Foreground: - - - foregroundToolButton + - + + + + + 0 + 0 + + + + Lightness: + + + + @@ -138,251 +180,7 @@ - - - - - 0 - 0 - - - - Lightness: - - - - - - - - 0 - 0 - - - - - - - - - - - Qt::Vertical - - - - 200 - 0 - - - - - - - - - 0 - 0 - - - - Erase background. - - - x - - - Qt::LeftArrow - - - - - - - - 0 - 0 - - - - - 0 - 6 - - - - - 16777215 - 6 - - - - - - - - -1.000000000000000 - - - 1.000000000000000 - - - 0.050000000000000 - - - - - - - - 0 - 0 - - - - Lightness: - - - - - - - - 0 - 0 - - - - Erase foreground. - - - x - - - Qt::LeftArrow - - - - - - - - 0 - 0 - - - - Saturation: - - - - - - - Italic - - - - - - - -1.000000000000000 - - - 1.000000000000000 - - - 0.050000000000000 - - - - - - - - 0 - 0 - - - - - 0 - 6 - - - - - 16777215 - 6 - - - - - - - - -1.000000000000000 - - - 1.000000000000000 - - - 0.050000000000000 - - - - - - - - 0 - 0 - - - - Background: - - - backgroundToolButton - - - - - - - - 0 - 0 - - - - - 0 - 18 - - - - - 16777215 - 18 - - - - - - - - - 75 - true - - - - Font - - - - + @@ -395,14 +193,7 @@ - - - - Bold - - - - + @@ -424,73 +215,7 @@ - - - - - 0 - 0 - - - - - 0 - 6 - - - - - 16777215 - 6 - - - - - - - - - 0 - 0 - - - - - 0 - 18 - - - - - 16777215 - 18 - - - - - - - - - 0 - 0 - - - - - 0 - 6 - - - - - 16777215 - 6 - - - - - + @@ -512,20 +237,23 @@ - - + + - + 0 0 - + Foreground: + + + foregroundToolButton - + @@ -538,23 +266,122 @@ - - + + + + + 75 + true + + + + Relative Foreground + + + + + - + + 0 + 0 + + + + + 0 + 6 + + + + + 16777215 + 6 + + + + + + + + -1.000000000000000 + + + 1.000000000000000 + + + 0.050000000000000 + + + + + + + + 0 + 0 + + + + Erase background. + + + x + + + Qt::LeftArrow + + + + + + + + 0 + 0 + + + + + 0 + 6 + + + + + 16777215 + 6 + + + + + + + + 0 0 - Color: - - - backgroundToolButton + - + + + + + 0 + 0 + + + + Lightness: + + + + @@ -567,7 +394,173 @@ - + + + + + 75 + true + + + + Font + + + + + + + + 0 + 0 + + + + Saturation: + + + + + + + -1.000000000000000 + + + 1.000000000000000 + + + 0.050000000000000 + + + + + + + + 0 + 0 + + + + Erase background. + + + x + + + Qt::LeftArrow + + + + + + + + + + + 0 + 0 + + + + Erase foreground. + + + x + + + Qt::LeftArrow + + + + + + + + 0 + 0 + + + + + 0 + 6 + + + + + 16777215 + 6 + + + + + + + + Bold + + + + + + + + 0 + 0 + + + + + 0 + 18 + + + + + 16777215 + 18 + + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + + 0 + 6 + + + + + 16777215 + 6 + + + + + @@ -589,8 +582,8 @@ - - + + -1.000000000000000 @@ -602,42 +595,20 @@ - - - - - 0 - 0 - + + + + -1.000000000000000 - - + + 1.000000000000000 + + + 0.050000000000000 - - - - - 0 - 0 - - - - Erase background. - - - x - - - Qt::LeftArrow - - - - - - - + @@ -659,8 +630,47 @@ - - + + + + + 0 + 0 + + + + Color: + + + backgroundToolButton + + + + + + + + 0 + 0 + + + + Background: + + + backgroundToolButton + + + + + + + Italic + + + + + 0 @@ -670,13 +680,13 @@ 0 - 6 + 18 16777215 - 6 + 18 diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp index 1a6235789e2..36ee3ac6c6d 100644 --- a/src/plugins/texteditor/fontsettingspage.cpp +++ b/src/plugins/texteditor/fontsettingspage.cpp @@ -377,6 +377,8 @@ QWidget *FontSettingsPage::widget() this, &FontSettingsPage::colorSchemeSelected); connect(d_ptr->m_ui->copyButton, &QPushButton::clicked, this, &FontSettingsPage::openCopyColorSchemeDialog); + connect(d_ptr->m_ui->schemeEdit, &ColorSchemeEdit::copyScheme, + this, &FontSettingsPage::openCopyColorSchemeDialog); connect(d_ptr->m_ui->deleteButton, &QPushButton::clicked, this, &FontSettingsPage::confirmDeleteColorScheme);