2023-03-24 17:47:17 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-03-17 17:25:50 +08:00
|
|
|
import QtQuick 2.0
|
2023-03-24 17:47:17 +08:00
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import QtQuick.Controls 2.5
|
|
|
|
|
|
|
|
import AppControls2 1.0 as AppControls2
|
|
|
|
import org.ukui.menu.core 1.0
|
|
|
|
import org.ukui.menu.utils 1.0
|
|
|
|
|
|
|
|
Row {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 48
|
|
|
|
layoutDirection: Qt.RightToLeft
|
|
|
|
|
|
|
|
AppControls2.StyleBackground {
|
|
|
|
width: 48; height: width
|
|
|
|
useStyleTransparent: false
|
|
|
|
paletteRole: Palette.Light
|
|
|
|
alpha: powerButtonArea.containsPress ? 0.25 : powerButtonArea.containsMouse ? 0.12 : 0
|
|
|
|
radius: height / 2
|
2023-03-17 17:25:50 +08:00
|
|
|
|
2023-03-24 17:47:17 +08:00
|
|
|
PowerButton {
|
|
|
|
id: powerButtonBase
|
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: Math.floor(parent.width / 2)
|
|
|
|
height: width
|
|
|
|
source: powerButtonBase.icon
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: powerButtonArea
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
ToolTip.visible: containsMouse
|
|
|
|
ToolTip.text: powerButtonBase.toolTip
|
2023-03-29 10:17:33 +08:00
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
property int spacingFromMenu: 8
|
|
|
|
|
2023-03-24 17:47:17 +08:00
|
|
|
onClicked: {
|
2023-03-29 10:17:33 +08:00
|
|
|
var buttonPosition = powerButtonArea.mapToGlobal(width, height);
|
|
|
|
powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x - width - spacingFromMenu, buttonPosition.y + spacingFromMenu, mainWindow.isFullScreen);
|
2023-03-24 17:47:17 +08:00
|
|
|
}
|
|
|
|
}
|
2023-03-17 17:25:50 +08:00
|
|
|
}
|
|
|
|
}
|
2023-03-24 17:47:17 +08:00
|
|
|
|