mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-15 05:22:53 +08:00
Fixes for some UI glitches
This commit is contained in:
parent
8e5d45f39f
commit
521b1a8fef
@ -65,6 +65,7 @@ Item {
|
||||
minimumWidth: 640
|
||||
minimumHeight: 480
|
||||
title: externalLoader.widgetTitle
|
||||
extraFlags: Qt.WindowStaysOnTopHint
|
||||
titlebarText: Cpp_ThemeManager.text
|
||||
titlebarColor: Cpp_ThemeManager.widgetWindowBackground
|
||||
backgroundColor: Cpp_ThemeManager.widgetWindowBackground
|
||||
|
@ -27,7 +27,7 @@ import QtGraphicalEffects 1.0
|
||||
Window {
|
||||
id: root
|
||||
color: "transparent"
|
||||
flags: root.customFlags
|
||||
flags: root.customFlags | root.extraFlags
|
||||
|
||||
//
|
||||
// Custom signals
|
||||
@ -41,12 +41,13 @@ Window {
|
||||
// Window radius control
|
||||
//
|
||||
property int borderWidth: 2
|
||||
readonly property int handleSize: radius + 5 + shadowMargin
|
||||
readonly property int handleSize: radius > 0 ? radius + 5 + shadowMargin : 0
|
||||
readonly property int radius: ((root.visibility === Window.Maximized && maximizeEnabled) || fullScreen) ? 0 : 10
|
||||
|
||||
//
|
||||
// Visibility properties
|
||||
//
|
||||
property int extraFlags: 0
|
||||
property bool firstChange: true
|
||||
property bool windowMaximized: false
|
||||
property bool windowMinimized: false
|
||||
@ -76,6 +77,13 @@ Window {
|
||||
//
|
||||
property int shadowMargin: root.radius > 0 ? 20 : 0
|
||||
|
||||
//
|
||||
// Titlebar left/right margins for custom controls
|
||||
//
|
||||
property alias leftTitlebarMargin: border.leftMargin
|
||||
property alias rightTitlebarMargin: border.rightMargin
|
||||
property alias showMacControls: border.showMacControls
|
||||
|
||||
//
|
||||
// Background color of the window & the titlebar
|
||||
//
|
||||
@ -160,6 +168,14 @@ Window {
|
||||
// Maximize window fixes
|
||||
//
|
||||
onVisibilityChanged: {
|
||||
// Hard-reset window flags on macOS to fix most glitches
|
||||
if (Cpp_IsMac)
|
||||
root.flags = Qt.Window
|
||||
|
||||
// Ensure that correct window flags are still used
|
||||
root.flags = root.customFlags | root.extraFlags
|
||||
|
||||
// Window has been just maximized, update internal variables
|
||||
if (visibility === Window.Maximized) {
|
||||
if (!root.windowMaximized)
|
||||
root.firstChange = false
|
||||
@ -168,11 +184,13 @@ Window {
|
||||
root.windowMaximized = true
|
||||
}
|
||||
|
||||
// Window has been just minimized, update internal variables
|
||||
else if (visibility === Window.Minimized) {
|
||||
root.fullScreen = false
|
||||
root.windowMaximized = false
|
||||
}
|
||||
|
||||
// Window has been just switched to full-screen, update internal variables
|
||||
else if (visibility === Window.FullScreen) {
|
||||
if (!root.fullScreen)
|
||||
root.firstChange = false
|
||||
@ -181,6 +199,7 @@ Window {
|
||||
root.windowMaximized = false
|
||||
}
|
||||
|
||||
// Window was just restored to "normal" mode, recover previous geometry
|
||||
else if (visibility !== Window.Hidden) {
|
||||
if (windowMaximized || fullScreen && firstChange) {
|
||||
root.width = root.minimumWidth
|
||||
@ -191,7 +210,6 @@ Window {
|
||||
|
||||
root.fullScreen = false
|
||||
root.windowMaximized = false
|
||||
root.flags = root.customFlags
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,24 @@ Rectangle {
|
||||
property bool maximizeEnabled: true
|
||||
property bool fullscreenEnabled: false
|
||||
property color textColor: palette.text
|
||||
readonly property bool showMacControls: Cpp_IsMac
|
||||
property bool showMacControls: Cpp_IsMac
|
||||
|
||||
//
|
||||
// Access to titlebar button widths (e.g. for implementing custom controls over the
|
||||
// window titlebar, such as the main window menubar)
|
||||
//
|
||||
readonly property real leftMargin: {
|
||||
if (showMacControls)
|
||||
return 4 + (3 * 20) + 4
|
||||
|
||||
return 8 + 24 + 8
|
||||
}
|
||||
readonly property real rightMargin: {
|
||||
if (showMacControls)
|
||||
return 18 + 8 + 4
|
||||
|
||||
return 8 + (3 * 24) + 8
|
||||
}
|
||||
|
||||
//
|
||||
// Toggle maximized
|
||||
|
@ -41,6 +41,7 @@ FramelessWindow.CustomWindow {
|
||||
title: qsTr("About")
|
||||
width: minimumWidth
|
||||
height: minimumHeight
|
||||
extraFlags: Qt.WindowStaysOnTopHint
|
||||
x: (Screen.desktopAvailableWidth - width) / 2
|
||||
y: (Screen.desktopAvailableHeight - height) / 2
|
||||
minimumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin
|
||||
|
@ -39,6 +39,7 @@ FramelessWindow.CustomWindow {
|
||||
minimizeEnabled: false
|
||||
maximizeEnabled: false
|
||||
title: qsTr("Acknowledgements")
|
||||
extraFlags: Qt.WindowStaysOnTopHint
|
||||
titlebarText: Cpp_ThemeManager.text
|
||||
x: (Screen.desktopAvailableWidth - width) / 2
|
||||
y: (Screen.desktopAvailableHeight - height) / 2
|
||||
|
@ -39,6 +39,7 @@ FramelessWindow.CustomWindow {
|
||||
minimizeEnabled: false
|
||||
maximizeEnabled: false
|
||||
title: qsTr("CSV Player")
|
||||
extraFlags: Qt.WindowStaysOnTopHint
|
||||
titlebarText: Cpp_ThemeManager.text
|
||||
x: (Screen.desktopAvailableWidth - width) / 2
|
||||
y: (Screen.desktopAvailableHeight - height) / 2
|
||||
|
@ -40,6 +40,7 @@ FramelessWindow.CustomWindow {
|
||||
height: minimumHeight
|
||||
minimizeEnabled: false
|
||||
maximizeEnabled: false
|
||||
extraFlags: Qt.WindowStaysOnTopHint
|
||||
titlebarText: Cpp_ThemeManager.text
|
||||
x: (Screen.desktopAvailableWidth - width) / 2
|
||||
y: (Screen.desktopAvailableHeight - height) / 2
|
||||
|
@ -231,29 +231,41 @@ FramelessWindow.CustomWindow {
|
||||
//
|
||||
// Windows + Linux menubar loader
|
||||
//
|
||||
Item {
|
||||
enabled: !Cpp_IsMac
|
||||
visible: !Cpp_IsMac
|
||||
RowLayout {
|
||||
spacing: app.spacing
|
||||
height: titlebar.height
|
||||
enabled: !root.showMacControls
|
||||
visible: !root.showMacControls
|
||||
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
margins: root.shadowMargin
|
||||
rightMargin: root.shadowMargin + 128
|
||||
leftMargin: root.leftTitlebarMargin + root.shadowMargin
|
||||
rightMargin: root.rightTitlebarMargin + root.shadowMargin
|
||||
}
|
||||
|
||||
PlatformDependent.Menubar {
|
||||
id: menubar
|
||||
opacity: 0.8
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
leftMargin: 14 + 24
|
||||
verticalCenter: parent.verticalCenter
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
|
||||
FramelessWindow.WindowButton {
|
||||
width: 18
|
||||
height: 18
|
||||
textColor: root.titlebarText
|
||||
visible: root.fullscreenEnabled
|
||||
enabled: root.fullscreenEnabled
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
onClicked: root.toggleFullscreen()
|
||||
highlightColor: Cpp_ThemeManager.highlight
|
||||
name: root.fullScreen ? "restore" : "fullscreen"
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,10 @@ Item {
|
||||
Loader {
|
||||
asynchronous: true
|
||||
sourceComponent: Windows.MainWindow {
|
||||
Component.onCompleted: app.mainWindow = this
|
||||
Component.onCompleted: {
|
||||
forceActiveFocus()
|
||||
app.mainWindow = this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user