refs #304, changed font settings

* QFontDialog is not working, as it is affected by the style sheets itself
* Added font settings to the GUI settings tab
* Added font color dialog for fonts
* Several utility methods
This commit is contained in:
Klaus Basan
2014-08-14 01:28:22 +02:00
parent bbb342b905
commit 98942a6395
10 changed files with 489 additions and 46 deletions

View File

@@ -261,6 +261,12 @@ namespace BlackGui
this->selectArea(static_cast<InfoArea>(index));
}
void CMainInfoAreaComponent::selectSettingsTab(int index)
{
this->selectArea(InfoAreaSettings);
this->ui->comp_Settings->setSettingsTab(static_cast<CSettingsComponent::SettingTab>(index));
}
void CMainInfoAreaComponent::ps_setDockArea(Qt::DockWidgetArea area)
{
for (CDockWidgetInfoArea *dw : this->m_dockableWidgets)

View File

@@ -115,6 +115,9 @@ namespace BlackGui
//! Select area
void selectArea(int index);
//! Select settings with given area
void selectSettingsTab(int index);
protected:
//! Override close event
virtual void closeEvent(QCloseEvent *event) override;

View File

@@ -42,8 +42,8 @@
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Aircrafts">
<property name="minimumSize">
<size>
<width>127</width>
<height>38</height>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="features">
@@ -103,8 +103,8 @@
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_AtcStations">
<property name="minimumSize">
<size>
<width>127</width>
<height>38</height>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="floating">
@@ -162,6 +162,12 @@
</widget>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Users">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>
@@ -202,6 +208,12 @@
</widget>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_TextMessages">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>
@@ -242,6 +254,12 @@
</widget>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Simulator">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>
@@ -282,6 +300,12 @@
</widget>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_FlightPlan">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>
@@ -322,6 +346,12 @@
</widget>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Weather">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>
@@ -365,6 +395,12 @@
</widget>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Mappings">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>
@@ -405,6 +441,12 @@
</widget>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Log">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>
@@ -445,6 +487,12 @@
</widget>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Settings">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>

View File

@@ -10,10 +10,12 @@
#include "settingscomponent.h"
#include "ui_settingscomponent.h"
#include "blackgui/models/atcstationlistmodel.h"
#include "blackgui/stylesheetutility.h"
#include "blackcore/dbus_server.h"
#include "blackcore/context_network.h"
#include "blackmisc/hwkeyboardkeylist.h"
#include "blackmisc/setaudio.h"
#include <QColorDialog>
using namespace BlackCore;
using namespace BlackMisc;
@@ -147,23 +149,35 @@ namespace BlackGui
this->ui->cb_SettingsAudioNotificationVoiceRoom->setChecked(as.getNotificationFlag(BlackSound::CNotificationSounds::NotificationVoiceRoomJoined));
}
/*
* Set tab
*/
void CSettingsComponent::setSettingsTab(CSettingsComponent::SettingTab tab)
{
this->setCurrentIndex(static_cast<int>(tab));
}
/*
* Runtime set
*/
void CSettingsComponent::runtimeHasBeenSet()
{
if (!this->getIContextSettings()) qFatal("Settings missing");
this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsComponent::changedSettings);
this->connect(this->m_timerAudioTests, &QTimer::timeout, this, &CSettingsComponent::audioTestUpdate);
this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsComponent::ps_changedSettings);
this->connect(this->m_timerAudioTests, &QTimer::timeout, this, &CSettingsComponent::ps_audioTestUpdate);
// based on audio context
Q_ASSERT(this->getIContextAudio());
bool connected = false;
if (this->getIContextAudio())
{
this->initAudioDeviceLists();
bool connected = this->connect(this->getIContextAudio(), &IContextAudio::audioTestCompleted, this, &CSettingsComponent::audioTestUpdate);
connected = this->connect(this->getIContextAudio(), &IContextAudio::audioTestCompleted, this, &CSettingsComponent::ps_audioTestUpdate);
Q_ASSERT(connected);
connected = this->connect(this->ui->cb_SettingsAudioInputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(audioDeviceSelected(int)));
connected = this->connect(this->ui->cb_SettingsAudioInputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_audioDeviceSelected(int)));
Q_ASSERT(connected);
connected = this->connect(this->ui->cb_SettingsAudioOutputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(audioDeviceSelected(int)));
connected = this->connect(this->ui->cb_SettingsAudioOutputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_audioDeviceSelected(int)));
Q_ASSERT(connected);
this->connect(this->ui->pb_SettingsAudioMicrophoneTest, &QPushButton::clicked, this, &CSettingsComponent::ps_startAudioTest);
this->connect(this->ui->pb_SettingsAudioSquelchTest, &QPushButton::clicked, this, &CSettingsComponent::ps_startAudioTest);
@@ -186,6 +200,20 @@ namespace BlackGui
this->connect(this->ui->pb_SettingsMiscSave, &QPushButton::clicked, this, &CSettingsComponent::ps_saveHotkeys);
this->connect(this->ui->pb_SettingsMiscRemove, &QPushButton::clicked, this, &CSettingsComponent::ps_clearHotkey);
// Font
const QFont font = this->font();
this->ui->cb_SettingsGuiFontStyle->setCurrentText(CStyleSheetUtility::fontAsCombinedWeightStyle(font));
this->ui->cb_SettingsGuiFont->setCurrentFont(font);
this->ui->cb_SettingsGuiFontSize->setCurrentText(QString::number(font.pointSize()));
this->m_fontColor = QColor(CStyleSheetUtility::instance().fontColor());
this->ui->le_SettingsGuiFontColor->setText(this->m_fontColor.name());
connected = this->connect(this->ui->cb_SettingsGuiFont, SIGNAL(currentFontChanged(QFont)), this, SLOT(ps_fontChanged()));
Q_ASSERT(connected);
connected = this->connect(this->ui->cb_SettingsGuiFontSize, SIGNAL(currentIndexChanged(QString)), this, SLOT(ps_fontChanged()));
Q_ASSERT(connected);
connected = this->connect(this->ui->cb_SettingsGuiFontStyle, SIGNAL(currentIndexChanged(QString)), this, SLOT(ps_fontChanged()));
Q_ASSERT(connected);
this->connect(this->ui->tb_SettingsGuiFontColor, &QToolButton::clicked, this, &CSettingsComponent::ps_fontColorDialog);
}
/*
@@ -335,6 +363,43 @@ namespace BlackGui
}
}
/*
* Font has been changed
*/
void CSettingsComponent::ps_fontChanged()
{
QString fontSize = this->ui->cb_SettingsGuiFontSize->currentText().append("pt");
QString fontFamily = this->ui->cb_SettingsGuiFont->currentFont().family();
QString fontStyleCombined = this->ui->cb_SettingsGuiFontStyle->currentText();
QString fontColor = this->m_fontColor.name();
if (!this->m_fontColor.isValid() || this->m_fontColor.name().isEmpty())
{
fontColor = CStyleSheetUtility::instance().fontColor();
}
this->ui->le_SettingsGuiFontColor->setText(fontColor);
bool ok = CStyleSheetUtility::instance().updateFonts(fontFamily, fontSize, CStyleSheetUtility::fontStyle(fontStyleCombined), CStyleSheetUtility::fontWeight(fontStyleCombined), fontColor);
if (ok)
{
this->sendStatusMessage(CStatusMessage::getInfoMessage("Updated font style", CStatusMessage::TypeSettings));
}
else
{
this->sendStatusMessage(CStatusMessage::getErrorMessage("Updating style failed", CStatusMessage::TypeSettings));
}
}
/*
* Font color dialog
*/
void CSettingsComponent::ps_fontColorDialog()
{
QColor c = QColorDialog::getColor(this->m_fontColor, this, "Font color");
if (c == this->m_fontColor) return;
this->m_fontColor = c;
this->ui->le_SettingsGuiFontColor->setText(this->m_fontColor.name());
this->ps_fontChanged();
}
/*
* Start the voice tests
*/

View File

@@ -17,7 +17,6 @@
#include <QModelIndex>
#include <QTimer>
namespace Ui { class CSettingsComponent; }
namespace BlackGui
@@ -31,6 +30,18 @@ namespace BlackGui
Q_OBJECT
public:
//! Tabs
enum SettingTab
{
SettingTabNetwork = 0,
SettingTabAircraft,
SettingTabAircraftAudio,
SettingTabSimulator,
SettingTabGui,
SettingTabMisc
};
//! Constructor
explicit CSettingsComponent(QWidget *parent = nullptr);
@@ -81,6 +92,9 @@ namespace BlackGui
//! Reload settings
void reloadSettings();
//! Set the tab
void setSettingsTab(SettingTab tab);
protected:
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
virtual void runtimeHasBeenSet() override;
@@ -123,6 +137,12 @@ namespace BlackGui
*/
void ps_audioDeviceSelected(int index);
//! Font has been changed
void ps_fontChanged();
//! Font color dialof
void ps_fontColorDialog();
private:
//! Audio test modes
enum AudioTest
@@ -135,9 +155,11 @@ namespace BlackGui
Ui::CSettingsComponent *ui;
QTimer *m_timerAudioTests; //!< audio tests: progress bar, disable/enable buttons
AudioTest m_audioTestRunning;
QColor m_fontColor;
//! Audio device lists from settings
void initAudioDeviceLists();
};
}
} // namespace

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<width>354</width>
<height>323</height>
</rect>
</property>
@@ -20,7 +20,7 @@
<string>Settings</string>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tb_SettingsTrafficNetwork">
<attribute name="title">
@@ -190,6 +190,12 @@
</property>
<item>
<widget class="QPushButton" name="pb_SettingsTnSaveServer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Save</string>
</property>
@@ -197,6 +203,12 @@
</item>
<item>
<widget class="QPushButton" name="pb_SettingsTnRemoveServer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
</property>
@@ -204,6 +216,12 @@
</item>
<item>
<widget class="QPushButton" name="pb_SettingsTnCurrentServer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Current server</string>
</property>
@@ -423,6 +441,12 @@
<layout class="QHBoxLayout" name="hl_SettingsAudioTests">
<item>
<widget class="QPushButton" name="pb_SettingsAudioSquelchTest">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
@@ -433,12 +457,18 @@
<bool>false</bool>
</property>
<property name="text">
<string>Start squelch test</string>
<string>Squelch test</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SettingsAudioMicrophoneTest">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
@@ -446,7 +476,7 @@
</size>
</property>
<property name="text">
<string>Start microphone test</string>
<string>Mic. test</string>
</property>
</widget>
</item>
@@ -563,6 +593,12 @@
</item>
<item row="0" column="1">
<widget class="QSlider" name="hs_SettingsGuiOpacity">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>100</number>
</property>
@@ -586,6 +622,12 @@
</item>
<item row="1" column="1">
<widget class="QSlider" name="hs_SettingsGuiAircraftRefreshTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>5</number>
</property>
@@ -618,6 +660,12 @@
</item>
<item row="2" column="1">
<widget class="QSlider" name="hs_SettingsGuiAtcRefreshTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>5</number>
</property>
@@ -647,6 +695,12 @@
</item>
<item row="3" column="1">
<widget class="QSlider" name="hs_SettingsGuiUserRefreshTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>5</number>
</property>
@@ -667,6 +721,135 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_SettingsGuiFont">
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QFontComboBox" name="cb_SettingsGuiFont">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lbl_SettingsGuiFontSize">
<property name="text">
<string>Font size (pt)</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="cb_SettingsGuiFontSize">
<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="6" column="0">
<widget class="QLabel" name="lbl_SettingsGuiFontStyle">
<property name="text">
<string>Font style</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="cb_SettingsGuiFontStyle">
<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="7" column="0">
<widget class="QLabel" name="lbl_SettingsGuiFontColor">
<property name="text">
<string>Font color</string>
</property>
</widget>
</item>
<item row="7" column="1">
<layout class="QHBoxLayout" name="hl_SettingsGuiFontColor">
<item>
<widget class="QToolButton" name="tb_SettingsGuiFontColor">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="le_SettingsGuiFontColor">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
@@ -719,6 +902,12 @@
</item>
<item>
<widget class="QPushButton" name="pb_SettingsMiscRemove">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
</property>
@@ -726,6 +915,12 @@
</item>
<item>
<widget class="QPushButton" name="pb_SettingsMiscCancel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>

View File

@@ -72,6 +72,12 @@
<layout class="QHBoxLayout" name="hl_SettingsSimconnectCfgButtons">
<item>
<widget class="QPushButton" name="pb_SettingsFsxOpenSimconnectCfg">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Open</string>
</property>
@@ -79,6 +85,12 @@
</item>
<item>
<widget class="QPushButton" name="pb_SettingsFsxDeleteSimconnectCfg">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Delete</string>
</property>
@@ -86,6 +98,12 @@
</item>
<item>
<widget class="QPushButton" name="pb_SettingsFsxSaveSimconnectCfg">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Save</string>
</property>
@@ -93,8 +111,14 @@
</item>
<item>
<widget class="QPushButton" name="pb_SettingsFsxTestConnection">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Test connection</string>
<string extracomment="Test connection">Test con.</string>
</property>
</widget>
</item>
@@ -134,6 +158,12 @@
</item>
<item>
<widget class="QPushButton" name="pb_SettingsFsxExistsSimconncetCfg">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Check</string>
</property>