diff --git a/src/plugins/texteditor/CMakeLists.txt b/src/plugins/texteditor/CMakeLists.txt index 40d4a3b55ba..8540fd3d644 100644 --- a/src/plugins/texteditor/CMakeLists.txt +++ b/src/plugins/texteditor/CMakeLists.txt @@ -45,7 +45,7 @@ add_qtc_plugin(TextEditor codestyleselectorwidget.cpp codestyleselectorwidget.h colorpreviewhoverhandler.cpp colorpreviewhoverhandler.h colorscheme.cpp colorscheme.h - colorschemeedit.cpp colorschemeedit.h colorschemeedit.ui + colorschemeedit.cpp colorschemeedit.h command.cpp command.h commentssettings.cpp commentssettings.h completionsettings.cpp completionsettings.h diff --git a/src/plugins/texteditor/colorschemeedit.cpp b/src/plugins/texteditor/colorschemeedit.cpp index 72bfbe4a9f1..4d7d5424197 100644 --- a/src/plugins/texteditor/colorschemeedit.cpp +++ b/src/plugins/texteditor/colorschemeedit.cpp @@ -24,33 +24,35 @@ ****************************************************************************/ #include "colorschemeedit.h" -#include "ui_colorschemeedit.h" +#include #include #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include -using namespace TextEditor; -using namespace TextEditor::Internal; +namespace TextEditor::Internal { -namespace { const int layoutSpacing = 6; -} // namespace -static inline QString colorButtonStyleSheet(const QColor &bgColor) +static QString colorButtonStyleSheet(const QColor &bgColor) { - if (bgColor.isValid()) { - QString rc = QLatin1String("border: 2px solid black; border-radius: 2px; background:"); - rc += bgColor.name(); - return rc; - } - return QLatin1String("border: 2px dotted black; border-radius: 2px;"); + QString rc("border-width: 2px; border-radius: 2px; border-color: black; "); + rc += bgColor.isValid() ? "border-style: solid; background:" + bgColor.name() + ";" + : QString("border-style: dotted;"); + return rc; } -namespace TextEditor { -namespace Internal { - class FormatsModel : public QAbstractListModel { public: @@ -142,58 +144,158 @@ private: QFont m_baseFont; }; -} // namespace Internal -} // namespace TextEditor - ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) : QWidget(parent), - m_ui(new Ui::ColorSchemeEdit), m_formatsModel(new FormatsModel(this)) { setContentsMargins(0, layoutSpacing, 0, 0); - m_ui->setupUi(this); - m_ui->detailsScrollArea->viewport()->setAutoFillBackground(false); - m_ui->scrollAreaWidgetContents->setAutoFillBackground(false); - m_ui->itemList->setModel(m_formatsModel); - m_ui->builtinSchemeLabel->setVisible(m_readOnly); + resize(513, 416); + + auto colorButton = [] () { + auto tb = new QToolButton; + tb->setMinimumWidth(56); + return tb; + }; + + auto eraseButton = [] (const QString &toolTip) { + auto tb = new QToolButton; + tb->setText("x"); + tb->setToolTip(toolTip); + tb->setArrowType(Qt::LeftArrow); + return tb; + }; + + auto headlineLabel = [] (const QString &text) { + auto l = new QLabel(text); + l->setContentsMargins(0, layoutSpacing * 2, 0, layoutSpacing / 2); + QFont font = l->font(); + font.setBold(true); + l->setFont(font); + return l; + }; + + auto spinBox = [] () { + auto sb = new QDoubleSpinBox; + sb->setMinimum(-1.); + sb->setMaximum(1.); + sb->setSingleStep(0.05); + return sb; + }; + + m_itemList = new QListView(this); + m_itemList->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_itemList->setSelectionMode(QAbstractItemView::ExtendedSelection); + m_itemList->setUniformItemSizes(true); + + m_builtinSchemeLabel = new QLabel( + tr("

Builtin color schemes need to be copied
" + " before they can be changed

")); + m_builtinSchemeLabel->setScaledContents(false); + + m_fontProperties = new QWidget; + //m_fontProperties->setContentsMargins(0, 0, 0, 0); + m_fontProperties->setMinimumWidth(212); + + m_foregroundLabel = new QLabel(tr("Foreground:")); + m_foregroundToolButton = colorButton(); + m_eraseForegroundToolButton = eraseButton(tr("Erase foreground.")); + m_backgroundLabel = new QLabel(tr("Background:")); + m_backgroundToolButton = colorButton(); + m_eraseBackgroundToolButton = eraseButton(tr("Erase background.")); + + m_relativeForegroundHeadline = headlineLabel(tr("Relative Foreground")); + m_foregroundSaturationLabel = new QLabel(tr("Saturation:")); + m_foregroundSaturationSpinBox = spinBox(); + m_foregroundLightnessLabel = new QLabel(tr("Lightness:")); + m_foregroundLightnessSpinBox = spinBox(); + + m_relativeBackgroundHeadline = headlineLabel(tr("Relative Background")); + m_backgroundSaturationLabel = new QLabel(tr("Saturation:")); + m_backgroundSaturationSpinBox = spinBox(); + m_backgroundLightnessLabel = new QLabel(tr("Lightness:")); + m_backgroundLightnessSpinBox = spinBox(); + + m_fontHeadline = headlineLabel(tr("Font")); + m_boldCheckBox = new QCheckBox(tr("Bold")); + m_italicCheckBox = new QCheckBox(tr("Italic")); + + m_underlineHeadline = headlineLabel(tr("Underline")); + m_underlineLabel = new QLabel(tr("Color:")); + m_underlineColorToolButton = colorButton(); + m_eraseUnderlineColorToolButton = eraseButton(tr("Erase background.")); + m_underlineComboBox = new QComboBox; + + m_itemList->setModel(m_formatsModel); + m_builtinSchemeLabel->setVisible(m_readOnly); + + auto bottomSpacer = new QWidget; + bottomSpacer->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Expanding); + + using namespace Utils::Layouting; + + Row { + m_itemList, + m_builtinSchemeLabel, + m_fontProperties, + }.attachTo(this, false); + + Grid { + m_foregroundLabel, m_foregroundToolButton, m_eraseForegroundToolButton, br, + m_backgroundLabel, m_backgroundToolButton, m_eraseBackgroundToolButton, br, + + Span {3, m_relativeForegroundHeadline}, br, + m_foregroundSaturationLabel, Span {2, m_foregroundSaturationSpinBox}, br, + m_foregroundLightnessLabel, Span {2, m_foregroundLightnessSpinBox}, br, + + Span {3, m_relativeBackgroundHeadline}, br, + m_backgroundSaturationLabel, Span {2, m_backgroundSaturationSpinBox}, br, + m_backgroundLightnessLabel, Span {2, m_backgroundLightnessSpinBox}, br, + + Span {3, m_fontHeadline}, br, + Span {3, Row {m_boldCheckBox, m_italicCheckBox, st}}, br, + + Span {3, m_underlineHeadline}, br, + m_underlineLabel, m_underlineColorToolButton, m_eraseUnderlineColorToolButton, br, + + Span {3, m_underlineComboBox}, br, + + bottomSpacer, br, + }.attachTo(m_fontProperties); populateUnderlineStyleComboBox(); - connect(m_ui->itemList->selectionModel(), &QItemSelectionModel::currentRowChanged, + connect(m_itemList->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &ColorSchemeEdit::currentItemChanged); - connect(m_ui->foregroundToolButton, &QAbstractButton::clicked, + connect(m_foregroundToolButton, &QAbstractButton::clicked, this, &ColorSchemeEdit::changeForeColor); - connect(m_ui->backgroundToolButton, &QAbstractButton::clicked, + connect(m_backgroundToolButton, &QAbstractButton::clicked, this, &ColorSchemeEdit::changeBackColor); - connect(m_ui->eraseBackgroundToolButton, &QAbstractButton::clicked, + connect(m_eraseBackgroundToolButton, &QAbstractButton::clicked, this, &ColorSchemeEdit::eraseBackColor); - connect(m_ui->eraseForegroundToolButton, &QAbstractButton::clicked, + connect(m_eraseForegroundToolButton, &QAbstractButton::clicked, this, &ColorSchemeEdit::eraseForeColor); - connect(m_ui->foregroundSaturationSpinBox, QOverload::of(&QDoubleSpinBox::valueChanged), + connect(m_foregroundSaturationSpinBox, &QDoubleSpinBox::valueChanged, this, &ColorSchemeEdit::changeRelativeForeColor); - connect(m_ui->foregroundLightnessSpinBox, QOverload::of(&QDoubleSpinBox::valueChanged), + connect(m_foregroundLightnessSpinBox, &QDoubleSpinBox::valueChanged, this, &ColorSchemeEdit::changeRelativeForeColor); - connect(m_ui->backgroundSaturationSpinBox, QOverload::of(&QDoubleSpinBox::valueChanged), + connect(m_backgroundSaturationSpinBox, &QDoubleSpinBox::valueChanged, this, &ColorSchemeEdit::changeRelativeBackColor); - connect(m_ui->backgroundLightnessSpinBox, QOverload::of(&QDoubleSpinBox::valueChanged), + connect(m_backgroundLightnessSpinBox, &QDoubleSpinBox::valueChanged, this, &ColorSchemeEdit::changeRelativeBackColor); - connect(m_ui->boldCheckBox, &QAbstractButton::toggled, + connect(m_boldCheckBox, &QAbstractButton::toggled, this, &ColorSchemeEdit::checkCheckBoxes); - connect(m_ui->italicCheckBox, &QAbstractButton::toggled, + connect(m_italicCheckBox, &QAbstractButton::toggled, this, &ColorSchemeEdit::checkCheckBoxes); - connect(m_ui->underlineColorToolButton, &QToolButton::clicked, + connect(m_underlineColorToolButton, &QToolButton::clicked, this, &ColorSchemeEdit::changeUnderlineColor); - connect(m_ui->eraseUnderlineColorToolButton, &QToolButton::clicked, + connect(m_eraseUnderlineColorToolButton, &QToolButton::clicked, this, &ColorSchemeEdit::eraseUnderlineColor); - connect(m_ui->underlineComboBox, QOverload::of(&QComboBox::currentIndexChanged), + connect(m_underlineComboBox, &QComboBox::currentIndexChanged, this, &ColorSchemeEdit::changeUnderlineStyle); - connect(m_ui->builtinSchemeLabel, &QLabel::linkActivated, this, &ColorSchemeEdit::copyScheme); + connect(m_builtinSchemeLabel, &QLabel::linkActivated, this, &ColorSchemeEdit::copyScheme); } -ColorSchemeEdit::~ColorSchemeEdit() -{ - delete m_ui; -} +ColorSchemeEdit::~ColorSchemeEdit() = default; void ColorSchemeEdit::setFormatDescriptions(const FormatDescriptions &descriptions) { @@ -201,7 +303,7 @@ void ColorSchemeEdit::setFormatDescriptions(const FormatDescriptions &descriptio m_formatsModel->setFormatDescriptions(&m_descriptions); if (!m_descriptions.empty()) - m_ui->itemList->setCurrentIndex(m_formatsModel->index(0)); + m_itemList->setCurrentIndex(m_formatsModel->index(0)); } void ColorSchemeEdit::setBaseFont(const QFont &font) @@ -216,8 +318,8 @@ void ColorSchemeEdit::setReadOnly(bool readOnly) m_readOnly = readOnly; - m_ui->detailsScrollArea->setVisible(!readOnly); - m_ui->builtinSchemeLabel->setVisible(readOnly); + m_fontProperties->setVisible(!readOnly); + m_builtinSchemeLabel->setVisible(readOnly); updateControls(); } @@ -261,14 +363,13 @@ void ColorSchemeEdit::updateForegroundControls() bool isVisible = !m_readOnly && formatDescription.showControl(FormatDescription::ShowForegroundControl); - m_ui->relativeForegroundHeadline->setEnabled(isVisible); - m_ui->foregroundLabel->setVisible(isVisible); - m_ui->foregroundToolButton->setVisible(isVisible); - m_ui->eraseForegroundToolButton->setVisible(isVisible); - m_ui->foregroundSpacer->setVisible(isVisible); + m_relativeForegroundHeadline->setEnabled(isVisible); + m_foregroundLabel->setVisible(isVisible); + m_foregroundToolButton->setVisible(isVisible); + m_eraseForegroundToolButton->setVisible(isVisible); - m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(format.foreground())); - m_ui->eraseForegroundToolButton->setEnabled(!m_readOnly + m_foregroundToolButton->setStyleSheet(colorButtonStyleSheet(format.foreground())); + m_eraseForegroundToolButton->setEnabled(!m_readOnly && m_curItem > 0 && format.foreground().isValid()); } @@ -281,14 +382,13 @@ void ColorSchemeEdit::updateBackgroundControls() bool isVisible = !m_readOnly && formatDescription.showControl(FormatDescription::ShowBackgroundControl); - m_ui->relativeBackgroundHeadline->setVisible(isVisible); - m_ui->backgroundLabel->setVisible(isVisible); - m_ui->backgroundToolButton->setVisible(isVisible); - m_ui->eraseBackgroundToolButton->setVisible(isVisible); - m_ui->backgroundSpacer->setVisible(isVisible); + m_relativeBackgroundHeadline->setVisible(isVisible); + m_backgroundLabel->setVisible(isVisible); + m_backgroundToolButton->setVisible(isVisible); + m_eraseBackgroundToolButton->setVisible(isVisible); - m_ui->backgroundToolButton->setStyleSheet(colorButtonStyleSheet(format.background())); - m_ui->eraseBackgroundToolButton->setEnabled(!m_readOnly + m_backgroundToolButton->setStyleSheet(colorButtonStyleSheet(format.background())); + m_eraseBackgroundToolButton->setEnabled(!m_readOnly && m_curItem > 0 && format.background().isValid()); } @@ -298,31 +398,28 @@ void ColorSchemeEdit::updateRelativeForegroundControls() const auto &formatDescription = m_descriptions[m_curItem]; const Format &format = m_scheme.formatFor(formatDescription.id()); - QSignalBlocker saturationSignalBlocker(m_ui->foregroundSaturationSpinBox); - QSignalBlocker lightnessSignalBlocker(m_ui->foregroundLightnessSpinBox); + QSignalBlocker saturationSignalBlocker(m_foregroundSaturationSpinBox); + QSignalBlocker lightnessSignalBlocker(m_foregroundLightnessSpinBox); bool isVisible = !m_readOnly && formatDescription.showControl(FormatDescription::ShowRelativeForegroundControl); - m_ui->relativeForegroundHeadline->setVisible(isVisible); - m_ui->foregroundSaturationLabel->setVisible(isVisible); - m_ui->foregroundLightnessLabel->setVisible(isVisible); - m_ui->foregroundSaturationSpinBox->setVisible(isVisible); - m_ui->foregroundLightnessSpinBox->setVisible(isVisible); - m_ui->relativeForegroundSpacer1->setVisible(isVisible); - m_ui->relativeForegroundSpacer2->setVisible(isVisible); - m_ui->relativeForegroundSpacer3->setVisible(isVisible); + m_relativeForegroundHeadline->setVisible(isVisible); + m_foregroundSaturationLabel->setVisible(isVisible); + m_foregroundLightnessLabel->setVisible(isVisible); + m_foregroundSaturationSpinBox->setVisible(isVisible); + m_foregroundLightnessSpinBox->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_relativeForegroundHeadline->setEnabled(isEnabled); + m_foregroundSaturationLabel->setEnabled(isEnabled); + m_foregroundLightnessLabel->setEnabled(isEnabled); + m_foregroundSaturationSpinBox->setEnabled(isEnabled); + m_foregroundLightnessSpinBox->setEnabled(isEnabled); - m_ui->foregroundSaturationSpinBox->setValue(format.relativeForegroundSaturation()); - m_ui->foregroundLightnessSpinBox->setValue(format.relativeForegroundLightness()); + m_foregroundSaturationSpinBox->setValue(format.relativeForegroundSaturation()); + m_foregroundLightnessSpinBox->setValue(format.relativeForegroundLightness()); } void ColorSchemeEdit::updateRelativeBackgroundControls() @@ -330,31 +427,28 @@ void ColorSchemeEdit::updateRelativeBackgroundControls() const auto &formatDescription = m_descriptions[m_curItem]; const Format &format = m_scheme.formatFor(formatDescription.id()); - QSignalBlocker saturationSignalBlocker(m_ui->backgroundSaturationSpinBox); - QSignalBlocker lightnessSignalBlocker(m_ui->backgroundLightnessSpinBox); + QSignalBlocker saturationSignalBlocker(m_backgroundSaturationSpinBox); + QSignalBlocker lightnessSignalBlocker(m_backgroundLightnessSpinBox); bool isVisible = !m_readOnly && formatDescription.showControl(FormatDescription::ShowRelativeBackgroundControl); - m_ui->relativeBackgroundHeadline->setVisible(isVisible); - m_ui->backgroundSaturationLabel->setVisible(isVisible); - m_ui->backgroundLightnessLabel->setVisible(isVisible); - m_ui->backgroundSaturationSpinBox->setVisible(isVisible); - m_ui->backgroundLightnessSpinBox->setVisible(isVisible); - m_ui->relativeBackgroundSpacer1->setVisible(isVisible); - m_ui->relativeBackgroundSpacer2->setVisible(isVisible); - m_ui->relativeBackgroundSpacer3->setVisible(isVisible); + m_relativeBackgroundHeadline->setVisible(isVisible); + m_backgroundSaturationLabel->setVisible(isVisible); + m_backgroundLightnessLabel->setVisible(isVisible); + m_backgroundSaturationSpinBox->setVisible(isVisible); + m_backgroundLightnessSpinBox->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_relativeBackgroundHeadline->setEnabled(isEnabled); + m_backgroundSaturationLabel->setEnabled(isEnabled); + m_backgroundLightnessLabel->setEnabled(isEnabled); + m_backgroundSaturationSpinBox->setEnabled(isEnabled); + m_backgroundLightnessSpinBox->setEnabled(isEnabled); - m_ui->backgroundSaturationSpinBox->setValue(format.relativeBackgroundSaturation()); - m_ui->backgroundLightnessSpinBox->setValue(format.relativeBackgroundLightness()); + m_backgroundSaturationSpinBox->setValue(format.relativeBackgroundSaturation()); + m_backgroundLightnessSpinBox->setValue(format.relativeBackgroundLightness()); } void ColorSchemeEdit::updateFontControls() @@ -362,20 +456,18 @@ void ColorSchemeEdit::updateFontControls() const auto formatDescription = m_descriptions[m_curItem]; const Format &format = m_scheme.formatFor(formatDescription.id()); - QSignalBlocker boldSignalBlocker(m_ui->boldCheckBox); - QSignalBlocker italicSignalBlocker(m_ui->italicCheckBox); + QSignalBlocker boldSignalBlocker(m_boldCheckBox); + QSignalBlocker italicSignalBlocker(m_italicCheckBox); bool isVisible = !m_readOnly && formatDescription.showControl(FormatDescription::ShowFontControls); - m_ui->fontHeadline->setVisible(isVisible); - m_ui->boldCheckBox->setVisible(isVisible); - m_ui->italicCheckBox->setVisible(isVisible); - m_ui->fontSpacer1->setVisible(isVisible); - m_ui->fontSpacer2->setVisible(isVisible); + m_fontHeadline->setVisible(isVisible); + m_boldCheckBox->setVisible(isVisible); + m_italicCheckBox->setVisible(isVisible); - m_ui->boldCheckBox->setChecked(format.bold()); - m_ui->italicCheckBox->setChecked(format.italic()); + m_boldCheckBox->setChecked(format.bold()); + m_italicCheckBox->setChecked(format.italic()); } @@ -384,25 +476,23 @@ void ColorSchemeEdit::updateUnderlineControls() const auto formatDescription = m_descriptions[m_curItem]; const Format &format = m_scheme.formatFor(formatDescription.id()); - QSignalBlocker comboBoxSignalBlocker(m_ui->underlineComboBox); + QSignalBlocker comboBoxSignalBlocker(m_underlineComboBox); bool isVisible = !m_readOnly && formatDescription.showControl(FormatDescription::ShowUnderlineControl); - m_ui->underlineHeadline->setVisible(isVisible); - m_ui->underlineLabel->setVisible(isVisible); - m_ui->underlineColorToolButton->setVisible(isVisible); - m_ui->eraseUnderlineColorToolButton->setVisible(isVisible); - m_ui->underlineComboBox->setVisible(isVisible); - m_ui->underlineSpacer1->setVisible(isVisible); - m_ui->underlineSpacer2->setVisible(isVisible); + m_underlineHeadline->setVisible(isVisible); + m_underlineLabel->setVisible(isVisible); + m_underlineColorToolButton->setVisible(isVisible); + m_eraseUnderlineColorToolButton->setVisible(isVisible); + m_underlineComboBox->setVisible(isVisible); - m_ui->underlineColorToolButton->setStyleSheet(colorButtonStyleSheet(format.underlineColor())); - m_ui->eraseUnderlineColorToolButton->setEnabled(!m_readOnly + m_underlineColorToolButton->setStyleSheet(colorButtonStyleSheet(format.underlineColor())); + m_eraseUnderlineColorToolButton->setEnabled(!m_readOnly && m_curItem > 0 && format.underlineColor().isValid()); - int index = m_ui->underlineComboBox->findData(QVariant::fromValue(int(format.underlineStyle()))); - m_ui->underlineComboBox->setCurrentIndex(index); + int index = m_underlineComboBox->findData(QVariant::fromValue(int(format.underlineStyle()))); + m_underlineComboBox->setCurrentIndex(index); } void ColorSchemeEdit::changeForeColor() @@ -410,13 +500,13 @@ void ColorSchemeEdit::changeForeColor() if (m_curItem == -1) return; QColor color = m_scheme.formatFor(m_descriptions[m_curItem].id()).foreground(); - const QColor newColor = QColorDialog::getColor(color, m_ui->boldCheckBox->window()); + const QColor newColor = QColorDialog::getColor(color, m_boldCheckBox->window()); if (!newColor.isValid()) return; - m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); - m_ui->eraseForegroundToolButton->setEnabled(true); + m_foregroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); + m_eraseForegroundToolButton->setEnabled(true); - for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) { + for (const QModelIndex &index : m_itemList->selectionModel()->selectedRows()) { const TextStyle category = m_descriptions[index.row()].id(); m_scheme.formatFor(category).setForeground(newColor); m_formatsModel->emitDataChanged(index); @@ -430,13 +520,13 @@ void ColorSchemeEdit::changeBackColor() if (m_curItem == -1) return; QColor color = m_scheme.formatFor(m_descriptions[m_curItem].id()).background(); - const QColor newColor = QColorDialog::getColor(color, m_ui->boldCheckBox->window()); + const QColor newColor = QColorDialog::getColor(color, m_boldCheckBox->window()); if (!newColor.isValid()) return; - m_ui->backgroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); - m_ui->eraseBackgroundToolButton->setEnabled(true); + m_backgroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); + m_eraseBackgroundToolButton->setEnabled(true); - for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) { + for (const QModelIndex &index : m_itemList->selectionModel()->selectedRows()) { const TextStyle category = m_descriptions[index.row()].id(); m_scheme.formatFor(category).setBackground(newColor); m_formatsModel->emitDataChanged(index); @@ -453,10 +543,10 @@ void ColorSchemeEdit::eraseBackColor() if (m_curItem == -1) return; QColor newColor; - m_ui->backgroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); - m_ui->eraseBackgroundToolButton->setEnabled(false); + m_backgroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); + m_eraseBackgroundToolButton->setEnabled(false); - const QList indexes = m_ui->itemList->selectionModel()->selectedRows(); + const QList indexes = m_itemList->selectionModel()->selectedRows(); for (const QModelIndex &index : indexes) { const TextStyle category = m_descriptions[index.row()].id(); m_scheme.formatFor(category).setBackground(newColor); @@ -471,10 +561,10 @@ void ColorSchemeEdit::eraseForeColor() if (m_curItem == -1) return; QColor newColor; - m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); - m_ui->eraseForegroundToolButton->setEnabled(false); + m_foregroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); + m_eraseForegroundToolButton->setEnabled(false); - const QList indexes = m_ui->itemList->selectionModel()->selectedRows(); + const QList indexes = m_itemList->selectionModel()->selectedRows(); for (const QModelIndex &index : indexes) { const TextStyle category = m_descriptions[index.row()].id(); m_scheme.formatFor(category).setForeground(newColor); @@ -489,10 +579,10 @@ void ColorSchemeEdit::changeRelativeForeColor() if (m_curItem == -1) return; - double saturation = m_ui->foregroundSaturationSpinBox->value(); - double lightness = m_ui->foregroundLightnessSpinBox->value(); + double saturation = m_foregroundSaturationSpinBox->value(); + double lightness = m_foregroundLightnessSpinBox->value(); - for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) { + for (const QModelIndex &index : m_itemList->selectionModel()->selectedRows()) { const TextStyle category = m_descriptions[index.row()].id(); m_scheme.formatFor(category).setRelativeForegroundSaturation(saturation); m_scheme.formatFor(category).setRelativeForegroundLightness(lightness); @@ -505,10 +595,10 @@ void ColorSchemeEdit::changeRelativeBackColor() if (m_curItem == -1) return; - double saturation = m_ui->backgroundSaturationSpinBox->value(); - double lightness = m_ui->backgroundLightnessSpinBox->value(); + double saturation = m_backgroundSaturationSpinBox->value(); + double lightness = m_backgroundLightnessSpinBox->value(); - for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) { + for (const QModelIndex &index : m_itemList->selectionModel()->selectedRows()) { const TextStyle category = m_descriptions[index.row()].id(); m_scheme.formatFor(category).setRelativeBackgroundSaturation(saturation); m_scheme.formatFor(category).setRelativeBackgroundLightness(lightness); @@ -521,10 +611,10 @@ void ColorSchemeEdit::eraseRelativeForeColor() if (m_curItem == -1) return; - m_ui->foregroundSaturationSpinBox->setValue(0.0); - m_ui->foregroundLightnessSpinBox->setValue(0.0); + m_foregroundSaturationSpinBox->setValue(0.0); + m_foregroundLightnessSpinBox->setValue(0.0); - for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) { + for (const QModelIndex &index : m_itemList->selectionModel()->selectedRows()) { const TextStyle category = m_descriptions[index.row()].id(); m_scheme.formatFor(category).setRelativeForegroundSaturation(0.0); m_scheme.formatFor(category).setRelativeForegroundLightness(0.0); @@ -537,10 +627,10 @@ void ColorSchemeEdit::eraseRelativeBackColor() if (m_curItem == -1) return; - m_ui->backgroundSaturationSpinBox->setValue(0.0); - m_ui->backgroundLightnessSpinBox->setValue(0.0); + m_backgroundSaturationSpinBox->setValue(0.0); + m_backgroundLightnessSpinBox->setValue(0.0); - const QList indexes = m_ui->itemList->selectionModel()->selectedRows(); + const QList indexes = m_itemList->selectionModel()->selectedRows(); for (const QModelIndex &index : indexes) { const TextStyle category = m_descriptions[index.row()].id(); m_scheme.formatFor(category).setRelativeBackgroundSaturation(0.0); @@ -554,10 +644,10 @@ void ColorSchemeEdit::checkCheckBoxes() if (m_curItem == -1) return; - for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) { + for (const QModelIndex &index : m_itemList->selectionModel()->selectedRows()) { const TextStyle category = m_descriptions[index.row()].id(); - m_scheme.formatFor(category).setBold(m_ui->boldCheckBox->isChecked()); - m_scheme.formatFor(category).setItalic(m_ui->italicCheckBox->isChecked()); + m_scheme.formatFor(category).setBold(m_boldCheckBox->isChecked()); + m_scheme.formatFor(category).setItalic(m_italicCheckBox->isChecked()); m_formatsModel->emitDataChanged(index); } } @@ -567,13 +657,13 @@ void ColorSchemeEdit::changeUnderlineColor() if (m_curItem == -1) return; QColor color = m_scheme.formatFor(m_descriptions[m_curItem].id()).underlineColor(); - const QColor newColor = QColorDialog::getColor(color, m_ui->boldCheckBox->window()); + const QColor newColor = QColorDialog::getColor(color, m_boldCheckBox->window()); if (!newColor.isValid()) return; - m_ui->underlineColorToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); - m_ui->eraseUnderlineColorToolButton->setEnabled(true); + m_underlineColorToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); + m_eraseUnderlineColorToolButton->setEnabled(true); - for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) { + for (const QModelIndex &index : m_itemList->selectionModel()->selectedRows()) { const TextStyle category = m_descriptions[index.row()].id(); m_scheme.formatFor(category).setUnderlineColor(newColor); m_formatsModel->emitDataChanged(index); @@ -585,10 +675,10 @@ void ColorSchemeEdit::eraseUnderlineColor() if (m_curItem == -1) return; QColor newColor; - m_ui->underlineColorToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); - m_ui->eraseUnderlineColorToolButton->setEnabled(false); + m_underlineColorToolButton->setStyleSheet(colorButtonStyleSheet(newColor)); + m_eraseUnderlineColorToolButton->setEnabled(false); - for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) { + for (const QModelIndex &index : m_itemList->selectionModel()->selectedRows()) { const TextStyle category = m_descriptions[index.row()].id(); m_scheme.formatFor(category).setUnderlineColor(newColor); m_formatsModel->emitDataChanged(index); @@ -600,9 +690,9 @@ void ColorSchemeEdit::changeUnderlineStyle(int comboBoxIndex) if (m_curItem == -1) return; - for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) { + for (const QModelIndex &index : m_itemList->selectionModel()->selectedRows()) { const TextStyle category = m_descriptions[index.row()].id(); - auto value = m_ui->underlineComboBox->itemData(comboBoxIndex); + const QVariant value = m_underlineComboBox->itemData(comboBoxIndex); auto enumeratorIndex = static_cast(value.toInt()); m_scheme.formatFor(category).setUnderlineStyle(enumeratorIndex); m_formatsModel->emitDataChanged(index); @@ -613,23 +703,25 @@ void ColorSchemeEdit::setItemListBackground(const QColor &color) { QPalette pal; pal.setColor(QPalette::Base, color); - m_ui->itemList->setPalette(pal); + m_itemList->setPalette(pal); } void ColorSchemeEdit::populateUnderlineStyleComboBox() { - m_ui->underlineComboBox->addItem(tr("No Underline"), + m_underlineComboBox->addItem(tr("No Underline"), QVariant::fromValue(int(QTextCharFormat::NoUnderline))); - m_ui->underlineComboBox->addItem(tr("Single Underline"), + m_underlineComboBox->addItem(tr("Single Underline"), QVariant::fromValue(int(QTextCharFormat::SingleUnderline))); - m_ui->underlineComboBox->addItem(tr("Wave Underline"), + m_underlineComboBox->addItem(tr("Wave Underline"), QVariant::fromValue(int(QTextCharFormat::WaveUnderline))); - m_ui->underlineComboBox->addItem(tr("Dot Underline"), + m_underlineComboBox->addItem(tr("Dot Underline"), QVariant::fromValue(int(QTextCharFormat::DotLine))); - m_ui->underlineComboBox->addItem(tr("Dash Underline"), + m_underlineComboBox->addItem(tr("Dash Underline"), QVariant::fromValue(int(QTextCharFormat::DashUnderline))); - m_ui->underlineComboBox->addItem(tr("Dash-Dot Underline"), + m_underlineComboBox->addItem(tr("Dash-Dot Underline"), QVariant::fromValue(int(QTextCharFormat::DashDotLine))); - m_ui->underlineComboBox->addItem(tr("Dash-Dot-Dot Underline"), + m_underlineComboBox->addItem(tr("Dash-Dot-Dot Underline"), QVariant::fromValue(int(QTextCharFormat::DashDotDotLine))); } + +} // TextEditor::Internal diff --git a/src/plugins/texteditor/colorschemeedit.h b/src/plugins/texteditor/colorschemeedit.h index f7504c170f8..67be8c454ed 100644 --- a/src/plugins/texteditor/colorschemeedit.h +++ b/src/plugins/texteditor/colorschemeedit.h @@ -31,13 +31,17 @@ #include QT_BEGIN_NAMESPACE +class QCheckBox; +class QComboBox; +class QDoubleSpinBox; +class QLabel; +class QListView; class QModelIndex; +class QScrollArea; +class QToolButton; QT_END_NAMESPACE -namespace TextEditor { -namespace Internal { - -namespace Ui { class ColorSchemeEdit; } +namespace TextEditor::Internal { class FormatsModel; @@ -91,11 +95,36 @@ private: FormatDescriptions m_descriptions; ColorScheme m_scheme; int m_curItem = -1; - Ui::ColorSchemeEdit *m_ui; FormatsModel *m_formatsModel; bool m_readOnly = false; + QListView *m_itemList; + QLabel *m_builtinSchemeLabel; + QWidget *m_fontProperties; + QLabel *m_foregroundLabel; + QToolButton *m_foregroundToolButton; + QToolButton *m_eraseForegroundToolButton; + QLabel *m_backgroundLabel; + QToolButton *m_backgroundToolButton; + QToolButton *m_eraseBackgroundToolButton; + QLabel *m_relativeForegroundHeadline; + QLabel *m_foregroundLightnessLabel; + QDoubleSpinBox *m_foregroundLightnessSpinBox; + QLabel *m_foregroundSaturationLabel; + QDoubleSpinBox *m_foregroundSaturationSpinBox; + QLabel *m_relativeBackgroundHeadline; + QLabel *m_backgroundSaturationLabel; + QDoubleSpinBox *m_backgroundSaturationSpinBox; + QLabel *m_backgroundLightnessLabel; + QDoubleSpinBox *m_backgroundLightnessSpinBox; + QLabel *m_fontHeadline; + QCheckBox *m_boldCheckBox; + QCheckBox *m_italicCheckBox; + QLabel *m_underlineHeadline; + QLabel *m_underlineLabel; + QToolButton *m_underlineColorToolButton; + QToolButton *m_eraseUnderlineColorToolButton; + QComboBox *m_underlineComboBox; + }; - -} // namespace Internal -} // namespace TextEditor +} // TextEditor::Internal diff --git a/src/plugins/texteditor/colorschemeedit.ui b/src/plugins/texteditor/colorschemeedit.ui deleted file mode 100644 index ded11ef21f0..00000000000 --- a/src/plugins/texteditor/colorschemeedit.ui +++ /dev/null @@ -1,714 +0,0 @@ - - - TextEditor::Internal::ColorSchemeEdit - - - - 0 - 0 - 513 - 416 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - QAbstractItemView::ExtendedSelection - - - true - - - - - - - <p align='center'><b>Builtin color schemes need to be <a href="copy">copied</a><br/> before they can be changed</b></p> - - - false - - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - Qt::ScrollBarAlwaysOff - - - QAbstractScrollArea::AdjustToContents - - - - - 0 - 0 - 212 - 390 - - - - - QLayout::SetFixedSize - - - 0 - - - 0 - - - 20 - - - 0 - - - 0 - - - - - Qt::Vertical - - - - 200 - 0 - - - - - - - - - 0 - 0 - - - - - 0 - 6 - - - - - 16777215 - 6 - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - Lightness: - - - - - - - - 0 - 0 - - - - - 0 - 18 - - - - - 16777215 - 18 - - - - - - - - - 0 - 0 - - - - Saturation: - - - - - - - - 0 - 0 - - - - - 0 - 6 - - - - - 16777215 - 6 - - - - - - - - - 0 - 0 - - - - - 0 - 6 - - - - - 16777215 - 6 - - - - - - - - - 0 - 0 - - - - Foreground: - - - foregroundToolButton - - - - - - - - 75 - true - - - - Underline - - - - - - - - 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 - - - - - - - - - - - - 0 - 0 - - - - Lightness: - - - - - - - - 75 - true - - - - Relative Background - - - - - - - - 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 - - - - - - - - - 0 - 0 - - - - - 0 - 18 - - - - - 16777215 - 18 - - - - - - - - -1.000000000000000 - - - 1.000000000000000 - - - 0.050000000000000 - - - - - - - -1.000000000000000 - - - 1.000000000000000 - - - 0.050000000000000 - - - - - - - - 0 - 0 - - - - - 0 - 6 - - - - - 16777215 - 6 - - - - - - - - - 0 - 0 - - - - Color: - - - backgroundToolButton - - - - - - - - 0 - 0 - - - - Background: - - - backgroundToolButton - - - - - - - Italic - - - - - - - - 0 - 0 - - - - - 0 - 18 - - - - - 16777215 - 18 - - - - - - - - - - - - itemList - foregroundToolButton - eraseForegroundToolButton - backgroundToolButton - eraseBackgroundToolButton - boldCheckBox - italicCheckBox - underlineColorToolButton - eraseUnderlineColorToolButton - underlineComboBox - - - - diff --git a/src/plugins/texteditor/texteditor.qbs b/src/plugins/texteditor/texteditor.qbs index dad6815fce2..890a4c92e89 100644 --- a/src/plugins/texteditor/texteditor.qbs +++ b/src/plugins/texteditor/texteditor.qbs @@ -49,7 +49,6 @@ Project { "colorscheme.h", "colorschemeedit.cpp", "colorschemeedit.h", - "colorschemeedit.ui", "command.cpp", "command.h", "commentssettings.cpp",