[vlc-commits] [Git][videolan/vlc][master] qt: Update CSD Icons to Segoe Fonts available in different Windows Version
François Cartegnie (@fcartegnie)
gitlab at videolan.org
Tue Mar 5 16:07:32 UTC 2024
François Cartegnie pushed to branch master at VideoLAN / VLC
Commits:
4aecd897 by darshan jain at 2024-03-05T15:35:53+00:00
qt: Update CSD Icons to Segoe Fonts available in different Windows Version
- - - - -
4 changed files:
- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/widgets/qml/CSDWindowButton.qml
- modules/gui/qt/widgets/qml/CSDWindowButtonSet.qml
Changes:
=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -62,6 +62,9 @@
#include <QWindow>
#include <QScreen>
+
+#include <QOperatingSystemVersion>
+
#ifdef _WIN32
#include <QFileInfo>
#endif
@@ -129,6 +132,19 @@ MainCtx::MainCtx(qt_intf_t *_p_intf)
m_sort = new SortCtx(this);
m_search = new SearchCtx(this);
+ // getOSInfo();
+ QOperatingSystemVersion currentOS = QOperatingSystemVersion::current();
+ switch (currentOS.type()) {
+ case QOperatingSystemVersion::OSType::Windows:
+ m_osName = Windows;
+ break;
+
+ default:
+ m_osName = Unknown;
+ break;
+ }
+ m_osVersion = (currentOS.majorVersion());
+
loadPrefs(false);
loadFromSettingsImpl(false);
=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -123,6 +123,10 @@ class MainCtx : public QObject
Q_PROPERTY(CSDButtonModel *csdButtonModel READ csdButtonModel CONSTANT FINAL)
+ //Property to get Operating System info
+ Q_PROPERTY(OsType osName READ getOSName CONSTANT)
+ Q_PROPERTY(int osVersion READ getOSVersion CONSTANT)
+
// This Property only works if hasAcrylicSurface is set
Q_PROPERTY(bool acrylicActive READ acrylicActive WRITE setAcrylicActive NOTIFY acrylicActiveChanged FINAL)
@@ -170,9 +174,15 @@ public:
GROUPING_NAME,
GROUPING_FOLDER
};
-
Q_ENUM(Grouping)
+ enum OsType
+ {
+ Windows,
+ Unknown
+ };
+ Q_ENUM(OsType)
+
inline bool isInterfaceFullScreen() const { return m_windowVisibility == QWindow::FullScreen; }
inline bool isInterfaceVisible() const { return m_windowVisibility != QWindow::Hidden; }
bool isMediaLibraryVisible() { return m_mediaLibraryVisible; }
@@ -215,6 +225,9 @@ public:
inline float safeArea() const { return m_safeArea; }
+ inline OsType getOSName() const {return m_osName;}
+ inline int getOSVersion() const {return m_osVersion;}
+
inline bool windowSuportExtendedFrame() const { return m_windowSuportExtendedFrame; }
inline unsigned windowExtendedMargin() const { return m_windowExtendedMargin; }
void setWindowSuportExtendedFrame(bool support);
@@ -327,6 +340,9 @@ protected:
float m_safeArea = 0.0;
+ OsType m_osName;
+ int m_osVersion;
+
bool m_windowSuportExtendedFrame = false;
unsigned m_windowExtendedMargin = 0;
=====================================
modules/gui/qt/widgets/qml/CSDWindowButton.qml
=====================================
@@ -33,6 +33,8 @@ T.Button {
property bool showHovered: false
property bool isThemeDark: false
+ readonly property bool useWinIcons: ((MainCtx.osName === MainCtx.Windows)&&(MainCtx.osVersion >= 10))
+
readonly property bool _paintHovered: control.hovered || showHovered
padding: 0
@@ -65,6 +67,14 @@ T.Button {
id: icon
anchors.centerIn: parent
text: control.iconTxt
+
+ font.family:{
+ if (useWinIcons)
+ return "Segoe Fluent Icons, Segoe MDL2 Assets"
+
+ return VLCIcons.fontFamily
+ }
+
font.pixelSize: VLCStyle.icon_CSD
color: control.color
}
=====================================
modules/gui/qt/widgets/qml/CSDWindowButtonSet.qml
=====================================
@@ -66,20 +66,39 @@ Row {
isThemeDark: theme.palette.isDark
- iconTxt: {
+ iconTxt:{
switch (modelData.type) {
case CSDButton.Minimize:
- return VLCIcons.window_minimize
+ {
+ if (useWinIcons)
+ return "\uE921"
+
+ else
+ return VLCIcons.window_minimize
+ }
case CSDButton.MaximizeRestore:
- return (MainCtx.intfMainWindow.visibility === Window.Maximized)
- ? VLCIcons.window_restore
- : VLCIcons.window_maximize
+ {
+ if (useWinIcons)
+ return (MainCtx.intfMainWindow.visibility === Window.Maximized)
+ ? "\uE923"
+ : "\uE922"
+
+ else
+ return (MainCtx.intfMainWindow.visibility === Window.Maximized)
+ ? VLCIcons.window_restore
+ : VLCIcons.window_maximize
+ }
case CSDButton.Close:
- return VLCIcons.window_close
- }
+ {
+ if (useWinIcons)
+ return "\uE8BB"
+ else
+ return VLCIcons.window_close
+ }
+ }
console.assert(false, "unreachable")
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/4aecd897f708d8f41e35b9d50081d82dd70c63f6
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/4aecd897f708d8f41e35b9d50081d82dd70c63f6
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list