From 22d67d31a48b14e4d6aa2d413931461010eb9c08 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 19 Mar 2019 05:45:13 +0100 Subject: [PATCH] Font style dialog without changing font color --- .../components/settingsfontcomponent.cpp | 19 +- .../components/settingsfontcomponent.h | 1 + .../components/settingsfontcomponent.ui | 193 +++++++++--------- 3 files changed, 115 insertions(+), 98 deletions(-) diff --git a/src/blackgui/components/settingsfontcomponent.cpp b/src/blackgui/components/settingsfontcomponent.cpp index 6e241de41..40cdd7a18 100644 --- a/src/blackgui/components/settingsfontcomponent.cpp +++ b/src/blackgui/components/settingsfontcomponent.cpp @@ -29,9 +29,10 @@ namespace BlackGui this->setMode(CSettingsFontComponent::DirectUpdate); this->initValues(); // most likely default font at ctor call time - connect(ui->tb_SettingsGuiFontColor, &QToolButton::clicked, this, &CSettingsFontComponent::fontColorDialog); - connect(ui->pb_Ok, &QPushButton::clicked, this, &CSettingsFontComponent::changeFont); - connect(ui->pb_CancelOrReset, &QToolButton::pressed, this, &CSettingsFontComponent::resetFont); + connect(ui->tb_SettingsGuiFontColor, &QToolButton::clicked, this, &CSettingsFontComponent::fontColorDialog); + connect(ui->tb_SettingsGuiNoFontColor, &QToolButton::clicked, this, &CSettingsFontComponent::noColor); + connect(ui->pb_Ok, &QPushButton::clicked, this, &CSettingsFontComponent::changeFont); + connect(ui->pb_CancelOrReset, &QToolButton::clicked, this, &CSettingsFontComponent::resetFont); // only after the complete startup style sheet font overrides are available connect(sGui, &CGuiApplication::startUpCompleted, this, &CSettingsFontComponent::initValues); @@ -69,7 +70,7 @@ namespace BlackGui const QString fontSize = ui->cb_SettingsGuiFontSize->currentText().append("pt"); const QString fontFamily = ui->cb_SettingsGuiFont->currentFont().family(); const QString fontStyleCombined = ui->cb_SettingsGuiFontStyle->currentText(); - return QStringList ({ fontFamily, fontSize, fontStyleCombined }); + return QStringList({ fontFamily, fontSize, fontStyleCombined }); } void CSettingsFontComponent::setWithColorSelection(bool withColor) @@ -88,7 +89,8 @@ namespace BlackGui QString fontColor = m_selectedColor.name(); if (!m_selectedColor.isValid() || m_selectedColor.name().isEmpty()) { - fontColor = sGui->getStyleSheetUtility().fontColor(); + // fontColor = sGui->getStyleSheetUtility().fontColor(); + fontColor.clear(); } ui->le_SettingsGuiFontColor->setText(fontColor); m_qss = CStyleSheetUtility::asStylesheet(fontFamily, fontSize, CStyleSheetUtility::fontStyle(fontStyleCombined), CStyleSheetUtility::fontWeight(fontStyleCombined), fontColor); @@ -115,6 +117,12 @@ namespace BlackGui ui->le_SettingsGuiFontColor->setText(m_selectedColor.name()); } + void CSettingsFontComponent::noColor() + { + m_selectedColor = QColor(); // invalid color + ui->le_SettingsGuiFontColor->clear(); + } + void CSettingsFontComponent::initValues() { // Font @@ -135,6 +143,7 @@ namespace BlackGui void CSettingsFontComponent::resetFont() { + if (!sGui || sGui->isShuttingDown()) { return; } this->initUiValues(m_cancelFont, m_cancelColor); if (m_mode == CSettingsFontComponent::DirectUpdate) { diff --git a/src/blackgui/components/settingsfontcomponent.h b/src/blackgui/components/settingsfontcomponent.h index 029acec6f..b0698bf8f 100644 --- a/src/blackgui/components/settingsfontcomponent.h +++ b/src/blackgui/components/settingsfontcomponent.h @@ -75,6 +75,7 @@ namespace BlackGui void changeFont(); void resetFont(); void fontColorDialog(); + void noColor(); void initValues(); void initUiValues(const QFont &font, const QColor &color); }; diff --git a/src/blackgui/components/settingsfontcomponent.ui b/src/blackgui/components/settingsfontcomponent.ui index 28052ca26..e0f9a8e84 100644 --- a/src/blackgui/components/settingsfontcomponent.ui +++ b/src/blackgui/components/settingsfontcomponent.ui @@ -26,27 +26,94 @@ 3 - + + + + + 150 + 16777215 + + + + + normal + + + + + bold + + + + + italic + + + + + bold italic + + + + + + + + + 0 + 20 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ok + + + + + + + cancel + + + + + + + QComboBox::AdjustToMinimumContentsLength - - - - Size/Style: - - - - - - - Font: - - - @@ -111,6 +178,13 @@ + + + + Size/Style: + + + @@ -118,6 +192,13 @@ + + + + Font: + + + @@ -128,85 +209,11 @@ - - - - - 150 - 16777215 - + + + + None - - - normal - - - - - bold - - - - - italic - - - - - bold italic - - - - - - - - - 0 - 20 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - ok - - - - - - - cancel - - - -