mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Follow up Ref T571, setting a default color for general UI settings, but not dialogs
This commit is contained in:
committed by
Mat Sutcliffe
parent
69306dbf7f
commit
8571feda30
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <QColorDialog>
|
||||
#include <QPushButton>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
@@ -28,7 +29,8 @@ namespace BlackGui
|
||||
ui->setupUi(this);
|
||||
this->setMode(CSettingsFontComponent::DirectUpdate);
|
||||
|
||||
this->initValues(); // most likely default font at ctor call time
|
||||
// due to the problems with overriding a color (e.g T571) we use "no color" as default
|
||||
this->initValues();
|
||||
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, Qt::QueuedConnection);
|
||||
@@ -82,6 +84,13 @@ namespace BlackGui
|
||||
ui->tb_SettingsGuiFontColor->setVisible(withColor);
|
||||
}
|
||||
|
||||
void CSettingsFontComponent::setStyleSheetDefaultColor()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
m_noColorDefault = false;
|
||||
this->initValues();
|
||||
}
|
||||
|
||||
void CSettingsFontComponent::changeFont()
|
||||
{
|
||||
const QString fontSize = ui->cb_SettingsGuiFontSize->currentText().append("pt");
|
||||
@@ -92,7 +101,6 @@ namespace BlackGui
|
||||
QString fontColor = m_selectedColor.name();
|
||||
if (!m_selectedColor.isValid() || m_selectedColor.name().isEmpty())
|
||||
{
|
||||
// fontColor = sGui->getStyleSheetUtility().fontColor();
|
||||
fontColor.clear();
|
||||
}
|
||||
ui->le_SettingsGuiFontColor->setText(fontColor);
|
||||
@@ -122,17 +130,19 @@ namespace BlackGui
|
||||
|
||||
void CSettingsFontComponent::noColor()
|
||||
{
|
||||
m_selectedColor = QColor(); // invalid color
|
||||
m_selectedColor = QColor(); // invalid color
|
||||
m_noColorDefault = true;
|
||||
ui->le_SettingsGuiFontColor->clear();
|
||||
}
|
||||
|
||||
void CSettingsFontComponent::initValues()
|
||||
{
|
||||
// Font
|
||||
if (!sGui) { return; }
|
||||
m_cancelFont = this->font();
|
||||
const QString colorString(sGui->getStyleSheetUtility().fontColorString());
|
||||
m_cancelColor = colorString.isEmpty() ? QColor() : QColor(colorString);
|
||||
this->initUiValues(m_cancelFont, m_cancelColor);
|
||||
this->initUiValues(m_cancelFont, m_noColorDefault ? QColor() : m_cancelColor);
|
||||
}
|
||||
|
||||
void CSettingsFontComponent::initUiValues(const QFont &font, const QColor &color)
|
||||
@@ -141,16 +151,16 @@ namespace BlackGui
|
||||
ui->cb_SettingsGuiFont->setCurrentFont(font);
|
||||
ui->cb_SettingsGuiFontSize->setCurrentText(QString::number(font.pointSize()));
|
||||
|
||||
Q_UNUSED(color); // due to the problems with overriding a color (e.g T571) we use "no color" as default
|
||||
m_selectedColor = QColor(); // invalid, no color
|
||||
ui->le_SettingsGuiFontColor->setText(m_selectedColor.isValid() ? m_selectedColor.name() : "");
|
||||
const bool valid = color.isValid();
|
||||
m_selectedColor = color; // color
|
||||
ui->le_SettingsGuiFontColor->setText(valid ? m_selectedColor.name() : "");
|
||||
m_qss.clear();
|
||||
}
|
||||
|
||||
void CSettingsFontComponent::resetFont()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
this->initUiValues(m_cancelFont, m_cancelColor);
|
||||
this->initUiValues(m_cancelFont, m_noColorDefault ? QColor() : m_cancelColor);
|
||||
if (m_mode == CSettingsFontComponent::DirectUpdate)
|
||||
{
|
||||
sGui->resetFont();
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace BlackGui
|
||||
explicit CSettingsFontComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CSettingsFontComponent();
|
||||
virtual ~CSettingsFontComponent() override;
|
||||
|
||||
//! Set mode
|
||||
void setMode(Mode m);
|
||||
@@ -57,6 +57,9 @@ namespace BlackGui
|
||||
//! With color selection
|
||||
void setWithColorSelection(bool withColor);
|
||||
|
||||
//! Set the default color from style sheet
|
||||
void setStyleSheetDefaultColor();
|
||||
|
||||
signals:
|
||||
//! To be used with dialogs
|
||||
void accept();
|
||||
@@ -70,6 +73,7 @@ namespace BlackGui
|
||||
QColor m_cancelColor;
|
||||
QFont m_cancelFont;
|
||||
QString m_qss;
|
||||
bool m_noColorDefault = true; //!< as of T571 no color default
|
||||
Mode m_mode = DirectUpdate;
|
||||
|
||||
void changeFont();
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace BlackGui
|
||||
explicit CSettingsFontDialog(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CSettingsFontDialog();
|
||||
virtual ~CSettingsFontDialog() override;
|
||||
|
||||
//! Get stylesheet
|
||||
const QString &getQss() const;
|
||||
|
||||
@@ -37,12 +37,13 @@ namespace BlackGui
|
||||
|
||||
// Widget style
|
||||
connect(ui->hs_SettingsGuiOpacity, &QSlider::valueChanged, this, &CSettingsGuiComponent::changedWindowsOpacity);
|
||||
connect(ui->cb_SettingsGuiWidgetStyle, qOverload<const QString &>(&QComboBox::currentIndexChanged),
|
||||
this, &CSettingsGuiComponent::widgetStyleChanged);
|
||||
connect(ui->cb_SettingsGuiWidgetStyle, qOverload<const QString &>(&QComboBox::currentIndexChanged), this, &CSettingsGuiComponent::widgetStyleChanged);
|
||||
|
||||
ui->comp_SettingsFonts->setStyleSheetDefaultColor();
|
||||
|
||||
// selection
|
||||
connect(ui->rb_PreferExtendedSelection, &QRadioButton::released, this, &CSettingsGuiComponent::selectionChanged);
|
||||
connect(ui->rb_PreferMultiSelection, &QRadioButton::released, this, &CSettingsGuiComponent::selectionChanged);
|
||||
connect(ui->rb_PreferMultiSelection, &QRadioButton::released, this, &CSettingsGuiComponent::selectionChanged);
|
||||
|
||||
this->guiSettingsChanged();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user