mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 11:05:44 +08:00
Ref T369, font setting improvements
- color can be hidden - access to QFont value/getter for family/style/size - renaming
This commit is contained in:
@@ -54,17 +54,38 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingsFontComponent::setCurrentFont(const QFont &font)
|
void CSettingsFontComponent::setFont(const QFont &font)
|
||||||
{
|
{
|
||||||
m_cancelFont = font;
|
m_cancelFont = font;
|
||||||
this->resetFont();
|
this->resetFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QFont CSettingsFontComponent::getFont() const
|
||||||
|
{
|
||||||
|
return ui->cb_SettingsGuiFont->font();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList CSettingsFontComponent::getFamilySizeStyle() const
|
||||||
|
{
|
||||||
|
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 });
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsFontComponent::setWithColorSelection(bool withColor)
|
||||||
|
{
|
||||||
|
ui->le_SettingsGuiFontColor->setVisible(withColor);
|
||||||
|
ui->tb_SettingsGuiFontColor->setVisible(withColor);
|
||||||
|
}
|
||||||
|
|
||||||
void CSettingsFontComponent::changeFont()
|
void CSettingsFontComponent::changeFont()
|
||||||
{
|
{
|
||||||
const QString fontSize = ui->cb_SettingsGuiFontSize->currentText().append("pt");
|
const QString fontSize = ui->cb_SettingsGuiFontSize->currentText().append("pt");
|
||||||
const QString fontFamily = ui->cb_SettingsGuiFont->currentFont().family();
|
const QString fontFamily = ui->cb_SettingsGuiFont->currentFont().family();
|
||||||
const QString fontStyleCombined = ui->cb_SettingsGuiFontStyle->currentText();
|
const QString fontStyleCombined = ui->cb_SettingsGuiFontStyle->currentText();
|
||||||
|
|
||||||
|
const QStringList familySizeStyle = this->getFamilySizeStyle();
|
||||||
QString fontColor = m_selectedColor.name();
|
QString fontColor = m_selectedColor.name();
|
||||||
if (!m_selectedColor.isValid() || m_selectedColor.name().isEmpty())
|
if (!m_selectedColor.isValid() || m_selectedColor.name().isEmpty())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,7 +47,16 @@ namespace BlackGui
|
|||||||
const QString &getQss() const { return m_qss; }
|
const QString &getQss() const { return m_qss; }
|
||||||
|
|
||||||
//! Set the current font
|
//! Set the current font
|
||||||
void setCurrentFont(const QFont &font);
|
void setFont(const QFont &font);
|
||||||
|
|
||||||
|
//! Get font selection
|
||||||
|
QFont getFont() const;
|
||||||
|
|
||||||
|
//! Strings such as
|
||||||
|
QStringList getFamilySizeStyle() const;
|
||||||
|
|
||||||
|
//! With color selection
|
||||||
|
void setWithColorSelection(bool withColor);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! To be used with dialogs
|
//! To be used with dialogs
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace BlackGui
|
|||||||
ui(new Ui::CSettingsFontDialog)
|
ui(new Ui::CSettingsFontDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
ui->comp_FontSettings->setMode(CSettingsFontComponent::GenerateQssOnly);
|
ui->comp_FontSettings->setMode(CSettingsFontComponent::GenerateQssOnly);
|
||||||
|
|
||||||
connect(ui->comp_FontSettings, &CSettingsFontComponent::accept, this, &CSettingsFontDialog::accept);
|
connect(ui->comp_FontSettings, &CSettingsFontComponent::accept, this, &CSettingsFontDialog::accept);
|
||||||
@@ -33,9 +34,24 @@ namespace BlackGui
|
|||||||
return ui->comp_FontSettings->getQss();
|
return ui->comp_FontSettings->getQss();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingsFontDialog::setCurrentFont(const QFont &font)
|
void CSettingsFontDialog::setFont(const QFont &font)
|
||||||
{
|
{
|
||||||
ui->comp_FontSettings->setCurrentFont(font);
|
ui->comp_FontSettings->setFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
QFont CSettingsFontDialog::getFont() const
|
||||||
|
{
|
||||||
|
return ui->comp_FontSettings->getFont();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList CSettingsFontDialog::getFamilySizeStyle() const
|
||||||
|
{
|
||||||
|
return ui->comp_FontSettings->getFamilySizeStyle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsFontDialog::setWithColorSelection(bool withColor)
|
||||||
|
{
|
||||||
|
ui->comp_FontSettings->setWithColorSelection(withColor);
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#define BLACKGUI_COMPONENTS_SETTINGSFONTDIALOG_H
|
#define BLACKGUI_COMPONENTS_SETTINGSFONTDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
namespace Ui { class CSettingsFontDialog; }
|
namespace Ui { class CSettingsFontDialog; }
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
@@ -38,7 +40,16 @@ namespace BlackGui
|
|||||||
const QString &getQss() const;
|
const QString &getQss() const;
|
||||||
|
|
||||||
//! Set the current font
|
//! Set the current font
|
||||||
void setCurrentFont(const QFont &font);
|
void setFont(const QFont &font);
|
||||||
|
|
||||||
|
//! Get font
|
||||||
|
QFont getFont() const;
|
||||||
|
|
||||||
|
//! Family, size and style
|
||||||
|
QStringList getFamilySizeStyle() const;
|
||||||
|
|
||||||
|
//! With color selection
|
||||||
|
void setWithColorSelection(bool withColor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CSettingsFontDialog> ui;
|
QScopedPointer<Ui::CSettingsFontDialog> ui;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace BlackGui
|
|||||||
m_dialog.reset(new CSettingsFontDialog(m_widget));
|
m_dialog.reset(new CSettingsFontDialog(m_widget));
|
||||||
m_dialog->setModal(true);
|
m_dialog->setModal(true);
|
||||||
}
|
}
|
||||||
m_dialog->setCurrentFont(m_widget->font());
|
m_dialog->setFont(m_widget->font());
|
||||||
const int r = m_dialog->exec();
|
const int r = m_dialog->exec();
|
||||||
if (r == QDialog::Rejected) { return; }
|
if (r == QDialog::Rejected) { return; }
|
||||||
const QString qss(m_dialog->getQss());
|
const QString qss(m_dialog->getQss());
|
||||||
|
|||||||
Reference in New Issue
Block a user