mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 02:55:44 +08:00
Ref T30, using font settings in GUI component
This commit is contained in:
committed by
Mathew Sutcliffe
parent
bf573f0f20
commit
be3c8b0bdd
@@ -35,34 +35,16 @@ namespace BlackGui
|
|||||||
ui->cb_SettingsGuiWidgetStyle->clear();
|
ui->cb_SettingsGuiWidgetStyle->clear();
|
||||||
ui->cb_SettingsGuiWidgetStyle->insertItems(0, QStyleFactory::keys());
|
ui->cb_SettingsGuiWidgetStyle->insertItems(0, QStyleFactory::keys());
|
||||||
|
|
||||||
// Font
|
// Widget style
|
||||||
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
|
|
||||||
connect(ui->hs_SettingsGuiOpacity, &QSlider::valueChanged, this, &CSettingsGuiComponent::changedWindowsOpacity);
|
connect(ui->hs_SettingsGuiOpacity, &QSlider::valueChanged, this, &CSettingsGuiComponent::changedWindowsOpacity);
|
||||||
connect(ui->cb_SettingsGuiWidgetStyle, static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
connect(ui->cb_SettingsGuiWidgetStyle, static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||||
this, &CSettingsGuiComponent::widgetStyleChanged);
|
this, &CSettingsGuiComponent::widgetStyleChanged);
|
||||||
connect(ui->tb_ResetFont, &QToolButton::pressed, this, &CSettingsGuiComponent::ps_resetFont);
|
|
||||||
|
|
||||||
// selection
|
// selection
|
||||||
connect(ui->rb_PreferExtendedSelection, &QRadioButton::released, this, &CSettingsGuiComponent::ps_selectionChanged);
|
connect(ui->rb_PreferExtendedSelection, &QRadioButton::released, this, &CSettingsGuiComponent::ps_selectionChanged);
|
||||||
connect(ui->rb_PreferMultiSelection, &QRadioButton::released, this, &CSettingsGuiComponent::ps_selectionChanged);
|
connect(ui->rb_PreferMultiSelection, &QRadioButton::released, this, &CSettingsGuiComponent::ps_selectionChanged);
|
||||||
|
|
||||||
this->guiSettingsChanged();
|
this->guiSettingsChanged();
|
||||||
Q_UNUSED(connected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSettingsGuiComponent::~CSettingsGuiComponent()
|
CSettingsGuiComponent::~CSettingsGuiComponent()
|
||||||
@@ -79,42 +61,6 @@ namespace BlackGui
|
|||||||
ui->hs_SettingsGuiOpacity->setValue(static_cast<int>(value));
|
ui->hs_SettingsGuiOpacity->setValue(static_cast<int>(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()
|
void CSettingsGuiComponent::ps_selectionChanged()
|
||||||
{
|
{
|
||||||
QAbstractItemView::SelectionMode sm = QAbstractItemView::NoSelection;
|
QAbstractItemView::SelectionMode sm = QAbstractItemView::NoSelection;
|
||||||
|
|||||||
@@ -49,15 +49,6 @@ namespace BlackGui
|
|||||||
void changedWindowsOpacity(int opacity);
|
void changedWindowsOpacity(int opacity);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Font has been changed
|
|
||||||
void ps_fontChanged();
|
|
||||||
|
|
||||||
//! Font color dialof
|
|
||||||
void ps_fontColorDialog();
|
|
||||||
|
|
||||||
//! Reset font
|
|
||||||
void ps_resetFont();
|
|
||||||
|
|
||||||
//! Selection radio buttons changed
|
//! Selection radio buttons changed
|
||||||
void ps_selectionChanged();
|
void ps_selectionChanged();
|
||||||
|
|
||||||
@@ -69,7 +60,6 @@ namespace BlackGui
|
|||||||
void widgetStyleChanged(const QString &widgetStyle);
|
void widgetStyleChanged(const QString &widgetStyle);
|
||||||
|
|
||||||
QScopedPointer<Ui::CSettingsGuiComponent> ui;
|
QScopedPointer<Ui::CSettingsGuiComponent> ui;
|
||||||
QColor m_fontColor;
|
|
||||||
BlackMisc::CSetting<BlackGui::Settings::TGeneralGui> m_guiSettings { this, &CSettingsGuiComponent::guiSettingsChanged };
|
BlackMisc::CSetting<BlackGui::Settings::TGeneralGui> m_guiSettings { this, &CSettingsGuiComponent::guiSettingsChanged };
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>209</width>
|
<width>204</width>
|
||||||
<height>236</height>
|
<height>235</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Font</string>
|
<string>Font</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gl_SettingsGuiComponent">
|
<layout class="QVBoxLayout" name="vl_FontSettings">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -50,155 +50,14 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing">
|
<item>
|
||||||
<number>4</number>
|
<widget class="BlackGui::Components::CSettingsFontComponent" name="comp_SettingsFonts">
|
||||||
</property>
|
<property name="minimumSize">
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="lbl_SettingsGuiFontSize">
|
|
||||||
<property name="text">
|
|
||||||
<string>Font size (pt)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QComboBox" name="cb_SettingsGuiFontSize">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
<size>
|
||||||
<width>150</width>
|
<width>0</width>
|
||||||
<height>16777215</height>
|
<height>100</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>6</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>7</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>8</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>9</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>10</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>11</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>12</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>14</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>16</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="lbl_SettingsGuiFontStyle">
|
|
||||||
<property name="text">
|
|
||||||
<string>Font style</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="lbl_SettingsGuiFontColor">
|
|
||||||
<property name="text">
|
|
||||||
<string>Font color</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="lbl_SettingsGuiFont">
|
|
||||||
<property name="text">
|
|
||||||
<string>Font</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="2">
|
|
||||||
<widget class="QToolButton" name="tb_SettingsGuiFontColor">
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QLineEdit" name="le_SettingsGuiFontColor">
|
|
||||||
<property name="maxLength">
|
|
||||||
<number>200</number>
|
|
||||||
</property>
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1" colspan="2">
|
|
||||||
<widget class="QFontComboBox" name="cb_SettingsGuiFont">
|
|
||||||
<property name="sizeAdjustPolicy">
|
|
||||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1" colspan="2">
|
|
||||||
<widget class="QComboBox" name="cb_SettingsGuiFontStyle">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>150</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>normal</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>bold</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>italic</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>bold italic</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QToolButton" name="tb_ResetFont">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>reset font attributes</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../../blackmisc/blackmisc.qrc">
|
|
||||||
<normaloff>:/pastel/icons/pastel/16/cancel.png</normaloff>:/pastel/icons/pastel/16/cancel.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -320,8 +179,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<customwidgets>
|
||||||
<include location="../../blackmisc/blackmisc.qrc"/>
|
<customwidget>
|
||||||
</resources>
|
<class>BlackGui::Components::CSettingsFontComponent</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>blackgui/components/settingsfontcomponent.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user