From be3c8b0bdd228f059fb70f71e0d69bc210fc7575 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 5 Jul 2017 02:39:02 +0200 Subject: [PATCH] Ref T30, using font settings in GUI component --- .../components/settingsguicomponent.cpp | 56 +----- .../components/settingsguicomponent.h | 10 -- .../components/settingsguicomponent.ui | 169 ++---------------- 3 files changed, 18 insertions(+), 217 deletions(-) diff --git a/src/blackgui/components/settingsguicomponent.cpp b/src/blackgui/components/settingsguicomponent.cpp index 1834e6139..4a561686f 100644 --- a/src/blackgui/components/settingsguicomponent.cpp +++ b/src/blackgui/components/settingsguicomponent.cpp @@ -35,34 +35,16 @@ namespace BlackGui ui->cb_SettingsGuiWidgetStyle->clear(); ui->cb_SettingsGuiWidgetStyle->insertItems(0, QStyleFactory::keys()); - // Font - const QFont font = this->font(); - this->m_fontColor = QColor(sGui->getStyleSheetUtility().fontColor()); - ui->cb_SettingsGuiFontStyle->setCurrentText(CStyleSheetUtility::fontAsCombinedWeightStyle(font)); - ui->cb_SettingsGuiFont->setCurrentFont(font); - ui->cb_SettingsGuiFontSize->setCurrentText(QString::number(font.pointSize())); - ui->le_SettingsGuiFontColor->setText(this->m_fontColor.name()); - - connect(ui->tb_SettingsGuiFontColor, &QToolButton::clicked, this, &CSettingsGuiComponent::ps_fontColorDialog); - bool connected = this->connect(ui->cb_SettingsGuiFont, SIGNAL(currentFontChanged(QFont)), this, SLOT(ps_fontChanged())); - Q_ASSERT(connected); - connected = connect(ui->cb_SettingsGuiFontSize, SIGNAL(currentIndexChanged(QString)), this, SLOT(ps_fontChanged())); - Q_ASSERT(connected); - connected = connect(ui->cb_SettingsGuiFontStyle, SIGNAL(currentIndexChanged(QString)), this, SLOT(ps_fontChanged())); - Q_ASSERT(connected); - - // Widget style and rest + // Widget style connect(ui->hs_SettingsGuiOpacity, &QSlider::valueChanged, this, &CSettingsGuiComponent::changedWindowsOpacity); connect(ui->cb_SettingsGuiWidgetStyle, static_cast(&QComboBox::currentIndexChanged), this, &CSettingsGuiComponent::widgetStyleChanged); - connect(ui->tb_ResetFont, &QToolButton::pressed, this, &CSettingsGuiComponent::ps_resetFont); // selection connect(ui->rb_PreferExtendedSelection, &QRadioButton::released, this, &CSettingsGuiComponent::ps_selectionChanged); connect(ui->rb_PreferMultiSelection, &QRadioButton::released, this, &CSettingsGuiComponent::ps_selectionChanged); this->guiSettingsChanged(); - Q_UNUSED(connected); } CSettingsGuiComponent::~CSettingsGuiComponent() @@ -79,42 +61,6 @@ namespace BlackGui ui->hs_SettingsGuiOpacity->setValue(static_cast(value)); } - void CSettingsGuiComponent::ps_fontChanged() - { - const QString fontSize = ui->cb_SettingsGuiFontSize->currentText().append("pt"); - const QString fontFamily = ui->cb_SettingsGuiFont->currentFont().family(); - const QString fontStyleCombined = ui->cb_SettingsGuiFontStyle->currentText(); - QString fontColor = this->m_fontColor.name(); - if (!this->m_fontColor.isValid() || this->m_fontColor.name().isEmpty()) - { - fontColor = sGui->getStyleSheetUtility().fontColor(); - } - ui->le_SettingsGuiFontColor->setText(fontColor); - const bool ok = sGui->updateFont(fontFamily, fontSize, CStyleSheetUtility::fontStyle(fontStyleCombined), CStyleSheetUtility::fontWeight(fontStyleCombined), fontColor); - if (ok) - { - CLogMessage(this).info("Updated font style"); - } - else - { - CLogMessage(this).info("Updating style failed"); - } - } - - void CSettingsGuiComponent::ps_fontColorDialog() - { - const QColor c = QColorDialog::getColor(this->m_fontColor, this, "Font color"); - if (c == this->m_fontColor) return; - this->m_fontColor = c; - ui->le_SettingsGuiFontColor->setText(this->m_fontColor.name()); - this->ps_fontChanged(); - } - - void CSettingsGuiComponent::ps_resetFont() - { - sGui->resetFont(); - } - void CSettingsGuiComponent::ps_selectionChanged() { QAbstractItemView::SelectionMode sm = QAbstractItemView::NoSelection; diff --git a/src/blackgui/components/settingsguicomponent.h b/src/blackgui/components/settingsguicomponent.h index 19d2921c5..5f4147204 100644 --- a/src/blackgui/components/settingsguicomponent.h +++ b/src/blackgui/components/settingsguicomponent.h @@ -49,15 +49,6 @@ namespace BlackGui void changedWindowsOpacity(int opacity); private slots: - //! Font has been changed - void ps_fontChanged(); - - //! Font color dialof - void ps_fontColorDialog(); - - //! Reset font - void ps_resetFont(); - //! Selection radio buttons changed void ps_selectionChanged(); @@ -69,7 +60,6 @@ namespace BlackGui void widgetStyleChanged(const QString &widgetStyle); QScopedPointer ui; - QColor m_fontColor; BlackMisc::CSetting m_guiSettings { this, &CSettingsGuiComponent::guiSettingsChanged }; }; } // ns diff --git a/src/blackgui/components/settingsguicomponent.ui b/src/blackgui/components/settingsguicomponent.ui index 3f3e53af4..c7e8bddb9 100644 --- a/src/blackgui/components/settingsguicomponent.ui +++ b/src/blackgui/components/settingsguicomponent.ui @@ -6,8 +6,8 @@ 0 0 - 209 - 236 + 204 + 235 @@ -37,7 +37,7 @@ Font - + 3 @@ -50,155 +50,14 @@ 3 - - 4 - - - - - Font size (pt) - - - - - - + + + - 150 - 16777215 + 0 + 100 - - - 6 - - - - - 7 - - - - - 8 - - - - - 9 - - - - - 10 - - - - - 11 - - - - - 12 - - - - - 14 - - - - - 16 - - - - - - - - Font style - - - - - - - Font color - - - - - - - Font - - - - - - - ... - - - - - - - 200 - - - true - - - - - - - QComboBox::AdjustToMinimumContentsLength - - - - - - - - 150 - 16777215 - - - - - normal - - - - - bold - - - - - italic - - - - - bold italic - - - - - - - - reset font attributes - - - - :/pastel/icons/pastel/16/cancel.png:/pastel/icons/pastel/16/cancel.png - @@ -320,8 +179,14 @@ - - - + + + BlackGui::Components::CSettingsFontComponent + QFrame +
blackgui/components/settingsfontcomponent.h
+ 1 +
+
+