mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
Make widget style configurable with Fusion as default
Up to now the UI appearance on all platforms was aligned as much as possible with stylesheets. Since the base widget styles still were platform dependent defaults, there were many small differences in details and controls. Some of them were even broken. Instead of trying to tweak all platform specific styles, default to one on all platforms. This guarantees that the UI is truly cross platform and all styles and fixes cover all platforms at the same time. For users who want to change the default style, they have now a gui setting. But it is strongly recommended to stick with the default. refs #683
This commit is contained in:
committed by
Mathew Sutcliffe
parent
10810f5003
commit
b78b40bbc0
@@ -457,7 +457,7 @@ namespace BlackCore
|
||||
#ifdef BLACK_USE_CRASHPAD
|
||||
std::unique_ptr<crashpad::CrashpadClient> m_crashpadClient;
|
||||
std::unique_ptr<crashpad::CrashReportDatabase> m_crashReportDatabase;
|
||||
BlackMisc::CSetting<BlackCore::Application::TCrashDumpUploadEnabled> m_crashDumpUploadEnabled { this, &CApplication::crashDumpUploadEnabledChanged };
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Application::TCrashDumpUploadEnabled> m_crashDumpUploadEnabled { this, &CApplication::crashDumpUploadEnabledChanged };
|
||||
#endif
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <QLineEdit>
|
||||
#include <QSlider>
|
||||
#include <QString>
|
||||
#include <QStyleFactory>
|
||||
#include <QTabBar>
|
||||
#include <QToolButton>
|
||||
#include <QtGlobal>
|
||||
@@ -43,6 +44,9 @@ namespace BlackGui
|
||||
ui(new Ui::CSettingsComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->cb_SettingsGuiWidgetStyle->clear();
|
||||
ui->cb_SettingsGuiWidgetStyle->insertItems(0, QStyleFactory::keys());
|
||||
|
||||
this->tabBar()->setExpanding(false);
|
||||
this->tabBar()->setUsesScrollButtons(true);
|
||||
|
||||
@@ -66,7 +70,11 @@ namespace BlackGui
|
||||
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);
|
||||
this->connect(this->ui->cb_SettingsGuiWidgetStyle, static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &CSettingsComponent::widgetStyleChanged);
|
||||
Q_UNUSED(connected);
|
||||
|
||||
reloadWidgetStyleFromSettings();
|
||||
}
|
||||
|
||||
CSettingsComponent::~CSettingsComponent()
|
||||
@@ -132,5 +140,21 @@ namespace BlackGui
|
||||
this->ui->le_SettingsGuiFontColor->setText(this->m_fontColor.name());
|
||||
this->ps_fontChanged();
|
||||
}
|
||||
|
||||
void CSettingsComponent::reloadWidgetStyleFromSettings()
|
||||
{
|
||||
int index = ui->cb_SettingsGuiWidgetStyle->findText(m_settingsWidgetStyle.get());
|
||||
ui->cb_SettingsGuiWidgetStyle->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void CSettingsComponent::widgetStyleChanged(const QString &widgetStyle)
|
||||
{
|
||||
if (widgetStyle == m_settingsWidgetStyle.get()) { return; }
|
||||
auto availableStyles = QStyleFactory::keys();
|
||||
if (availableStyles.contains(widgetStyle))
|
||||
{
|
||||
m_settingsWidgetStyle.set(widgetStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKGUI_COMPONENTS_SETTINGSCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/settings/guisettings.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QObject>
|
||||
@@ -92,8 +93,12 @@ namespace BlackGui
|
||||
void ps_fontColorDialog();
|
||||
|
||||
private:
|
||||
void reloadWidgetStyleFromSettings();
|
||||
void widgetStyleChanged(const QString &widgetStyle);
|
||||
|
||||
QScopedPointer<Ui::CSettingsComponent> ui;
|
||||
QColor m_fontColor;
|
||||
BlackMisc::CSetting<BlackGui::Settings::TWidgetStyle> m_settingsWidgetStyle { this, &CSettingsComponent::reloadWidgetStyleFromSettings };
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -290,14 +290,14 @@
|
||||
<string>General</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="fl_GuiGeneral">
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsGuiOpacity">
|
||||
<property name="text">
|
||||
<string>Opacity (0-100%)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QSlider" name="hs_SettingsGuiOpacity">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
@@ -319,6 +319,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cb_SettingsGuiWidgetStyle"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsGuiWidgetStyle">
|
||||
<property name="text">
|
||||
<string>Widget Style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCoreApplication>
|
||||
#include <QApplication>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QEventLoop>
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QRegExp>
|
||||
#include <QSplashScreen>
|
||||
#include <QStyleFactory>
|
||||
#include <QStringList>
|
||||
#include <QStyle>
|
||||
#include <QUrl>
|
||||
@@ -76,6 +77,7 @@ namespace BlackGui
|
||||
this->setWindowIcon(icon);
|
||||
sGui = this;
|
||||
connect(&this->m_styleSheetUtility, &CStyleSheetUtility::styleSheetsChanged, this, &CGuiApplication::styleSheetsChanged);
|
||||
reloadWidgetStyleFromSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,4 +544,14 @@ namespace BlackGui
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGuiApplication::reloadWidgetStyleFromSettings()
|
||||
{
|
||||
auto widgetStyle = m_settingsWidgetStyle.get();
|
||||
auto availableStyles = QStyleFactory::keys();
|
||||
if (availableStyles.contains(widgetStyle))
|
||||
{
|
||||
QApplication::setStyle(QStyleFactory::create(widgetStyle));
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/enableforframelesswindow.h"
|
||||
#include "blackgui/mainwindowaccess.h"
|
||||
#include "blackgui/settings/guisettings.h"
|
||||
#include "blackgui/stylesheetutility.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
@@ -193,8 +194,13 @@ namespace BlackGui
|
||||
QScopedPointer<QSplashScreen> m_splashScreen; //!< splash screen
|
||||
BlackGui::Components::CApplicationCloseDialog *m_closeDialog = nullptr; //!< close dialog (no QScopedPointer because I need to set parent)
|
||||
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TWidgetStyle> m_settingsWidgetStyle{ this, &CGuiApplication::reloadWidgetStyleFromSettings };
|
||||
|
||||
//! Qt help message to formatted HTML
|
||||
static QString beautifyHelpMessage(const QString &helpText);
|
||||
|
||||
//! Reload widget style from settings
|
||||
void reloadWidgetStyleFromSettings();
|
||||
};
|
||||
} // ns
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Settings
|
||||
@@ -26,6 +28,17 @@ namespace BlackGui
|
||||
//! Key in data cache
|
||||
static const char *key() { return "guinownaircraftmodel"; }
|
||||
};
|
||||
|
||||
//! Widget Style
|
||||
struct TWidgetStyle : public BlackMisc::TSettingTrait<QString>
|
||||
{
|
||||
//! \copydoc BlackCore::TSettingTrait::key
|
||||
static const char *key() { return "application/widgetstyle"; }
|
||||
|
||||
//! \copydoc BlackCore::TSettingTrait::defaultValue
|
||||
static QString defaultValue() { return QStringLiteral("Fusion"); }
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user