mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-31 17:42:55 +08:00
Let macOS WM draw frameless window shadow
This commit is contained in:
parent
441bc2788f
commit
a12fdc3c6d
@ -42,7 +42,7 @@ Window {
|
|||||||
// Window radius control
|
// Window radius control
|
||||||
//
|
//
|
||||||
property int borderWidth: 2
|
property int borderWidth: 2
|
||||||
readonly property int handleSize: radius > 0 ? radius + 10 + shadowMargin : 0
|
readonly property int handleSize: radius > 0 ? radius + 10 : 0
|
||||||
readonly property int radius: ((root.visibility === Window.Maximized && maximizeEnabled) || isFullscreen) ? 0 : 10
|
readonly property int radius: ((root.visibility === Window.Maximized && maximizeEnabled) || isFullscreen) ? 0 : 10
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -54,13 +54,30 @@ Window {
|
|||||||
property bool isMinimized: false
|
property bool isMinimized: false
|
||||||
property alias showIcon: _title.showIcon
|
property alias showIcon: _title.showIcon
|
||||||
property alias isFullscreen: _title.isFullscreen
|
property alias isFullscreen: _title.isFullscreen
|
||||||
readonly property int customFlags: Qt.Window |
|
readonly property int customFlags: {
|
||||||
|
// Setup frameless window flags
|
||||||
|
var flags = Qt.Window |
|
||||||
Qt.CustomizeWindowHint |
|
Qt.CustomizeWindowHint |
|
||||||
Qt.FramelessWindowHint |
|
Qt.FramelessWindowHint |
|
||||||
Qt.WindowSystemMenuHint |
|
Qt.WindowSystemMenuHint |
|
||||||
Qt.NoDropShadowWindowHint |
|
|
||||||
Qt.WindowMinMaxButtonsHint
|
Qt.WindowMinMaxButtonsHint
|
||||||
|
|
||||||
|
//
|
||||||
|
// The macOS window manager is able to generate shadows for Qt frameless
|
||||||
|
// windows. Other operating systems have varied mileage, so we draw the
|
||||||
|
// shadow ourselves to avoid ugly surprises.
|
||||||
|
//
|
||||||
|
// Also, disabling the custom shadow on macOS is a good idea so that users can
|
||||||
|
// move the window freely over all the desktop without being blocked by the
|
||||||
|
// menubar or dock due to the custom shadow border.
|
||||||
|
//
|
||||||
|
if (!Cpp_IsMac)
|
||||||
|
flags |= Qt.NoDropShadowWindowHint
|
||||||
|
|
||||||
|
// Return "calculated" window flags
|
||||||
|
return flags
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Toggle fullscreen state
|
// Toggle fullscreen state
|
||||||
//
|
//
|
||||||
@ -80,7 +97,7 @@ Window {
|
|||||||
//
|
//
|
||||||
// Size of the shadow object
|
// Size of the shadow object
|
||||||
//
|
//
|
||||||
property int shadowMargin: root.radius > 0 ? 20 : 0
|
property int shadowMargin: Cpp_IsMac ? 0 : (root.radius > 0 ? 20 : 0)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Titlebar left/right margins for custom controls
|
// Titlebar left/right margins for custom controls
|
||||||
@ -134,7 +151,8 @@ Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shadow implementation
|
// Custom shadow implementation for non-macOS systems. The shadow shall be disabled
|
||||||
|
// when the window is maximized.
|
||||||
//
|
//
|
||||||
Widgets.Shadow {
|
Widgets.Shadow {
|
||||||
opacity: 0.2
|
opacity: 0.2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user