6 #include <QColorDialog>
8 #include <QStringBuilder>
10 #include "ui_settingsfontcomponent.h"
27 connect(ui->tb_SettingsGuiFontColor, &QToolButton::clicked,
this, &CSettingsFontComponent::fontColorDialog);
28 connect(ui->tb_SettingsGuiNoFontColor, &QToolButton::clicked,
this, &CSettingsFontComponent::noColor);
29 connect(ui->pb_Ok, &QPushButton::clicked,
this, &CSettingsFontComponent::changeFont, Qt::QueuedConnection);
30 connect(ui->pb_CancelOrReset, &QToolButton::clicked,
this, &CSettingsFontComponent::resetFontAndReject,
31 Qt::QueuedConnection);
32 connect(ui->pb_Reset, &QToolButton::clicked,
this, &CSettingsFontComponent::clearQssAndResetFont,
33 Qt::QueuedConnection);
46 ui->pb_CancelOrReset->setText(
"reset");
47 ui->pb_Reset->setVisible(
false);
51 ui->pb_CancelOrReset->setText(
"cancel");
52 ui->pb_Reset->setVisible(
true);
66 const QString fontSize = ui->cb_SettingsGuiFontSize->currentText().append(
"pt");
67 const QString fontFamily = ui->cb_SettingsGuiFont->currentFont().family();
68 const QString fontStyleCombined = ui->cb_SettingsGuiFontStyle->currentText();
69 return QStringList({ fontFamily, fontSize, fontStyleCombined });
74 ui->le_SettingsGuiFontColor->setVisible(withColor);
75 ui->tb_SettingsGuiFontColor->setVisible(withColor);
81 m_noColorDefault =
false;
85 void CSettingsFontComponent::changeFont()
88 const QString fontSize = ui->cb_SettingsGuiFontSize->currentText().append(
"pt");
89 const QString fontFamily = ui->cb_SettingsGuiFont->currentFont().family();
90 const QString fontStyleCombined = ui->cb_SettingsGuiFontStyle->currentText();
92 QString fontColor = m_selectedColor.name();
93 if (!m_selectedColor.isValid() || m_selectedColor.name().isEmpty()) { fontColor.clear(); }
94 ui->le_SettingsGuiFontColor->setText(fontColor);
106 void CSettingsFontComponent::fontColorDialog()
109 QColorDialog::getColor(m_selectedColor.isValid() ? m_selectedColor : m_cancelColor,
this,
"Font color");
110 if (c == m_selectedColor) {
return; }
112 ui->le_SettingsGuiFontColor->setText(m_selectedColor.name());
115 void CSettingsFontComponent::noColor()
117 m_selectedColor = QColor();
118 m_noColorDefault =
true;
119 ui->le_SettingsGuiFontColor->clear();
122 void CSettingsFontComponent::initValues()
125 if (!
sGui) {
return; }
126 m_cancelFont = this->font();
128 m_cancelColor = colorString.isEmpty() ? QColor() : QColor(colorString);
129 this->initUiValues(m_cancelFont, m_noColorDefault ? QColor() : m_cancelColor);
132 void CSettingsFontComponent::initUiValues(
const QFont &font,
const QColor &color)
135 ui->cb_SettingsGuiFont->setCurrentFont(font);
136 ui->cb_SettingsGuiFontSize->setCurrentText(QString::number(font.pointSize()));
138 const bool valid = color.isValid();
139 m_selectedColor = color;
140 ui->le_SettingsGuiFontColor->setText(valid ? m_selectedColor.name() :
"");
144 void CSettingsFontComponent::resetFont()
147 this->initUiValues(m_cancelFont, m_noColorDefault ? QColor() : m_cancelColor);
151 void CSettingsFontComponent::resetFontAndReject()
157 void CSettingsFontComponent::clearQssAndResetFont()
bool isShuttingDown() const
Is application shutting down?
void startUpCompleted(bool success)
Startup has been completed Will be triggered shortly before starting the event loop.
const CStyleSheetUtility & getStyleSheetUtility() const
Style sheet handling.
bool resetFont()
Reset the font to default.
bool updateFont(const QString &fontFamily, const QString &fontSize, const QString &fontStyle, const QString &fontWeight, const QString &fontColor)
Update the fonts.
static QString asStylesheet(const QString &fontFamily, const QString &fontSize, const QString &fontStyle, const QString &fontWeight, const QString &fontColorString={})
Parameters as stylesheet.
static QString fontStyle(const QString &combinedStyleAndWeight)
Get the font style.
static QString fontAsCombinedWeightStyle(const QFont &font)
Font as combined weight and style.
QString fontColorString() const
Current font color from style sheet.
static QString fontWeight(const QString &combinedStyleAndWeight)
Get the font weight.
void reject()
To be used with dialogs.
void setFont(const QFont &font)
Set the current font.
void accept()
To be used with dialogs.
void setMode(Mode m)
Set mode.
void setWithColorSelection(bool withColor)
With color selection.
QStringList getFamilySizeStyle() const
Strings such as.
@ DirectUpdate
directly updating a font qss file
virtual ~CSettingsFontComponent()
Destructor.
QFont getFont() const
Get font selection.
void setStyleSheetDefaultColor()
Set the default color from style sheet.
Class for emitting a log message.
Derived & warning(const char16_t(&format)[N])
Set the severity to warning, providing a format string.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
High level reusable GUI components.
Free functions in swift::misc.