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