Commit e78324dc authored by Tobias Hunger's avatar Tobias Hunger
Browse files

ColorSchemaEdit: Make layout of color selection dialog cleaner



Add some section headers, make widgets align with more other widgets,
get rid of useless margins and make hiding elements not leave random
amounts of space between elements.

Change-Id: I3d2ce7a00a92cdff5af5b7aa5e2784460d388c85
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent 190f2d9e
......@@ -34,6 +34,10 @@
using namespace TextEditor;
using namespace TextEditor::Internal;
namespace {
const int layoutSpacing = 6;
} // namespace
static inline QString colorButtonStyleSheet(const QColor &bgColor)
{
if (bgColor.isValid()) {
......@@ -145,11 +149,10 @@ private:
ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) :
QWidget(parent),
m_curItem(-1),
m_ui(new Ui::ColorSchemeEdit),
m_formatsModel(new FormatsModel(this)),
m_readOnly(false)
m_formatsModel(new FormatsModel(this))
{
setContentsMargins(0, layoutSpacing, 0, 0);
setPalette(Utils::Theme::initialPalette());
m_ui->setupUi(this);
m_ui->itemList->setModel(m_formatsModel);
......@@ -219,18 +222,21 @@ void ColorSchemeEdit::setReadOnly(bool readOnly)
m_ui->backgroundToolButton->setEnabled(enabled);
m_ui->eraseBackgroundToolButton->setEnabled(enabled);
m_ui->eraseForegroundToolButton->setEnabled(enabled);
m_ui->relativeForegroundLabel->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->relativeBackgroundLabel->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);
......@@ -278,6 +284,7 @@ void ColorSchemeEdit::updateForegroundControls()
m_ui->foregroundLabel->setVisible(isVisible);
m_ui->foregroundToolButton->setVisible(isVisible);
m_ui->eraseForegroundToolButton->setVisible(isVisible);
m_ui->foregroundSpacer->setVisible(isVisible);
m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(format.foreground()));
m_ui->eraseForegroundToolButton->setEnabled(!m_readOnly
......@@ -295,6 +302,7 @@ void ColorSchemeEdit::updateBackgroundControls()
m_ui->backgroundLabel->setVisible(isVisible);
m_ui->backgroundToolButton->setVisible(isVisible);
m_ui->eraseBackgroundToolButton->setVisible(isVisible);
m_ui->backgroundSpacer->setVisible(isVisible);
m_ui->backgroundToolButton->setStyleSheet(colorButtonStyleSheet(format.background()));
m_ui->eraseBackgroundToolButton->setEnabled(!m_readOnly
......@@ -312,11 +320,14 @@ void ColorSchemeEdit::updateRelativeForegroundControls()
bool isVisible = formatDescription.showControl(FormatDescription::ShowRelativeForegroundControl);
m_ui->relativeForegroundLabel->setVisible(isVisible);
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_ui->foregroundSaturationSpinBox->setValue(format.relativeForegroundSaturation());
m_ui->foregroundLightnessSpinBox->setValue(format.relativeForegroundLightness());
......@@ -332,11 +343,14 @@ void ColorSchemeEdit::updateRelativeBackgroundControls()
bool isVisible = formatDescription.showControl(FormatDescription::ShowRelativeBackgroundControl);
m_ui->relativeBackgroundLabel->setVisible(isVisible);
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_ui->backgroundSaturationSpinBox->setValue(format.relativeBackgroundSaturation());
m_ui->backgroundLightnessSpinBox->setValue(format.relativeBackgroundLightness());
......@@ -352,8 +366,11 @@ void ColorSchemeEdit::updateFontControls()
bool isVisible= 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_ui->boldCheckBox->setChecked(format.bold());
m_ui->italicCheckBox->setChecked(format.italic());
......@@ -369,10 +386,13 @@ void ColorSchemeEdit::updateUnderlineControls()
bool isVisible= 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_ui->underlineColorToolButton->setStyleSheet(colorButtonStyleSheet(format.underlineColor()));
m_ui->eraseUnderlineColorToolButton->setEnabled(!m_readOnly
......
......@@ -87,10 +87,10 @@ private:
private:
FormatDescriptions m_descriptions;
ColorScheme m_scheme;
int m_curItem;
int m_curItem = -1;
Ui::ColorSchemeEdit *m_ui;
FormatsModel *m_formatsModel;
bool m_readOnly;
bool m_readOnly = false;
};
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>547</width>
<width>614</width>
<height>306</height>
</rect>
</property>
......@@ -17,6 +17,39 @@
<string>Font</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="4">
<widget class="QLabel" name="sizeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QLabel" name="zoomLabel">
<property name="text">
<string>Zoom:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="familyLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Family:</string>
</property>
</widget>
</item>
<item row="0" column="6">
<spacer>
<property name="orientation">
......@@ -33,6 +66,19 @@
</property>
</spacer>
</item>
<item row="0" column="9">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="antialias">
<property name="text">
......@@ -56,19 +102,6 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="familyLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Family:</string>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QSpinBox" name="zoomSpinBox">
<property name="suffix">
......@@ -88,25 +121,8 @@
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QLabel" name="zoomLabel">
<property name="text">
<string>Zoom:</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="sizeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size:</string>
</property>
</widget>
<item row="0" column="1">
<widget class="QFontComboBox" name="fontComboBox"/>
</item>
<item row="0" column="5">
<widget class="QComboBox" name="sizeComboBox">
......@@ -118,22 +134,6 @@
</property>
</widget>
</item>
<item row="0" column="9">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QFontComboBox" name="fontComboBox"/>
</item>
</layout>
</widget>
</item>
......@@ -142,39 +142,35 @@
<property name="title">
<string>Color Scheme</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="schemeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="copyButton">
<property name="text">
<string>Copy...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QComboBox" name="schemeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="copyButton">
<property name="text">
<string>Copy...</string>
</property>
</widget>
</item>
<item>
<item row="0" column="2">
<widget class="QPushButton" name="deleteButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="TextEditor::Internal::ColorSchemeEdit" name="schemeEdit" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment