2023-02-27 18:46:39 +08:00
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Window 2.15
|
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
import FluentUI 1.0
|
|
|
|
|
|
|
|
|
|
Rectangle{
|
|
|
|
|
|
2023-03-06 14:22:13 +08:00
|
|
|
|
id:root
|
2023-03-06 18:08:01 +08:00
|
|
|
|
|
|
|
|
|
property color borerlessColor : FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
|
|
|
|
color: {
|
|
|
|
|
if(Window.window == null)
|
|
|
|
|
return borerlessColor
|
|
|
|
|
return Window.window.active ? borerlessColor : Qt.lighter(FluTheme.primaryColor.lightest,1.1)
|
|
|
|
|
}
|
2023-02-27 18:46:39 +08:00
|
|
|
|
height: 50
|
|
|
|
|
width: {
|
2023-02-28 23:57:55 +08:00
|
|
|
|
if(parent==null)
|
|
|
|
|
return 200
|
|
|
|
|
return parent.width
|
2023-02-27 18:46:39 +08:00
|
|
|
|
}
|
2023-03-06 12:09:06 +08:00
|
|
|
|
z: 65535
|
2023-02-27 18:46:39 +08:00
|
|
|
|
property string title: "标题"
|
2023-03-06 14:22:13 +08:00
|
|
|
|
property color textColor: FluTheme.isDark ? "#000000" : "#FFFFFF"
|
2023-03-03 18:19:48 +08:00
|
|
|
|
property bool showDark: false
|
|
|
|
|
property bool showFps: false
|
|
|
|
|
|
2023-03-06 18:08:01 +08:00
|
|
|
|
property var window: Window.window
|
|
|
|
|
|
2023-03-02 00:35:58 +08:00
|
|
|
|
property bool resizable: {
|
2023-03-06 18:08:01 +08:00
|
|
|
|
if(window == null){
|
2023-03-02 00:35:58 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-06 18:08:01 +08:00
|
|
|
|
return !(window.minimumHeight === window.maximumHeight && window.maximumWidth === window.minimumWidth)
|
2023-03-02 00:35:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 18:08:01 +08:00
|
|
|
|
TapHandler {
|
|
|
|
|
onTapped: if (tapCount === 2) toggleMaximized()
|
|
|
|
|
gesturePolicy: TapHandler.DragThreshold
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DragHandler {
|
|
|
|
|
target: null
|
|
|
|
|
grabPermissions: TapHandler.CanTakeOverFromAnything
|
|
|
|
|
onActiveChanged: if (active) { window.startSystemMove(); }
|
2023-02-27 18:46:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleMaximized() {
|
2023-03-06 18:08:01 +08:00
|
|
|
|
if (window.visibility === Window.Maximized) {
|
|
|
|
|
window.showNormal();
|
2023-02-27 18:46:39 +08:00
|
|
|
|
} else {
|
2023-03-06 18:08:01 +08:00
|
|
|
|
window.showMaximized();
|
2023-02-27 18:46:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FluText {
|
|
|
|
|
text: title
|
|
|
|
|
anchors{
|
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
|
left: parent.left
|
|
|
|
|
leftMargin: 14
|
|
|
|
|
}
|
2023-03-06 14:22:13 +08:00
|
|
|
|
color:root.textColor
|
2023-02-27 18:46:39 +08:00
|
|
|
|
fontStyle: FluText.Title
|
|
|
|
|
font.pixelSize: 14
|
|
|
|
|
font.bold: true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RowLayout{
|
|
|
|
|
anchors.right: parent.right;
|
2023-03-06 12:09:06 +08:00
|
|
|
|
anchors.rightMargin: 10
|
2023-02-27 18:46:39 +08:00
|
|
|
|
height: parent.height
|
2023-03-06 14:22:13 +08:00
|
|
|
|
spacing: 5
|
2023-02-27 18:46:39 +08:00
|
|
|
|
|
2023-03-01 11:58:30 +08:00
|
|
|
|
TFpsMonitor{
|
2023-03-02 00:35:58 +08:00
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
Layout.rightMargin: 12
|
|
|
|
|
Layout.topMargin: 5
|
2023-03-06 14:22:13 +08:00
|
|
|
|
color:root.textColor
|
2023-03-03 18:19:48 +08:00
|
|
|
|
visible: showFps
|
2023-03-01 11:58:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-27 18:46:39 +08:00
|
|
|
|
RowLayout{
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
spacing: 5
|
2023-03-03 18:19:48 +08:00
|
|
|
|
visible: showDark
|
2023-02-27 18:46:39 +08:00
|
|
|
|
FluText{
|
|
|
|
|
text:"夜间模式"
|
2023-03-06 14:22:13 +08:00
|
|
|
|
color:root.textColor
|
2023-02-27 18:46:39 +08:00
|
|
|
|
fontStyle: FluText.Body
|
|
|
|
|
}
|
|
|
|
|
FluToggleSwitch{
|
2023-03-06 14:22:13 +08:00
|
|
|
|
checked: FluTheme.isDark
|
2023-02-28 18:29:00 +08:00
|
|
|
|
onClickFunc:function(){
|
2023-03-06 14:22:13 +08:00
|
|
|
|
FluTheme.isDark = !FluTheme.isDark
|
2023-02-27 18:46:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 14:22:13 +08:00
|
|
|
|
FluIconButton{
|
2023-02-27 18:46:39 +08:00
|
|
|
|
icon : FluentIcons.FA_window_minimize
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
iconSize: 15
|
2023-03-06 14:22:13 +08:00
|
|
|
|
text:"最小化"
|
|
|
|
|
textColor: root.textColor
|
|
|
|
|
color:hovered ? "#20000000" : "#00000000"
|
|
|
|
|
onClicked: {
|
2023-03-06 18:08:01 +08:00
|
|
|
|
window.showMinimized()
|
2023-02-27 18:46:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-06 14:22:13 +08:00
|
|
|
|
FluIconButton{
|
|
|
|
|
property bool isRestore:{
|
2023-03-06 18:08:01 +08:00
|
|
|
|
if(window == null)
|
2023-02-27 18:46:39 +08:00
|
|
|
|
return false
|
2023-03-06 18:08:01 +08:00
|
|
|
|
return Window.Maximized === window.visibility
|
2023-03-06 12:09:06 +08:00
|
|
|
|
}
|
2023-03-06 14:22:13 +08:00
|
|
|
|
icon : isRestore ? FluentIcons.FA_window_restore : FluentIcons.FA_window_maximize
|
|
|
|
|
color:hovered ? "#20000000" : "#00000000"
|
2023-02-27 18:46:39 +08:00
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-03-02 00:35:58 +08:00
|
|
|
|
visible: resizable
|
2023-03-06 14:22:13 +08:00
|
|
|
|
textColor: root.textColor
|
|
|
|
|
text:isRestore?"向下还原":"最大化"
|
2023-02-27 18:46:39 +08:00
|
|
|
|
iconSize: 15
|
2023-03-06 14:22:13 +08:00
|
|
|
|
onClicked: {
|
|
|
|
|
toggleMaximized()
|
2023-02-27 18:46:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-06 14:22:13 +08:00
|
|
|
|
FluIconButton{
|
2023-02-27 18:46:39 +08:00
|
|
|
|
icon : FluentIcons.FA_close
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-03-06 14:22:13 +08:00
|
|
|
|
text:"关闭"
|
|
|
|
|
textColor: root.textColor
|
|
|
|
|
color:hovered ? "#20000000" : "#00000000"
|
|
|
|
|
onClicked: {
|
|
|
|
|
Window.window.close()
|
2023-02-27 18:46:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-28 18:29:00 +08:00
|
|
|
|
FluDivider{
|
2023-02-27 18:46:39 +08:00
|
|
|
|
width: parent.width;
|
|
|
|
|
height: 1;
|
|
|
|
|
anchors.bottom: parent.bottom;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|