ukui-menu/qml/AppUI/Sidebar.qml

96 lines
2.9 KiB
QML
Raw Normal View History

/*
* 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/>.
*
*/
import QtQml 2.12
import QtQuick 2.12
import QtQuick.Layouts 1.12
2023-02-13 09:31:11 +08:00
import QtQuick.Controls 2.5
2023-02-13 09:31:11 +08:00
import org.ukui.menu.core 1.0
import org.ukui.menu.utils 1.0
import org.ukui.menu.extension 1.0
2023-11-28 16:58:37 +08:00
import org.ukui.quick.items 1.0 as UkuiItems
2022-12-23 11:32:21 +08:00
Item {
ColumnLayout {
id: sidebarLayout
anchors.fill: parent
2023-02-09 16:07:51 +08:00
anchors.topMargin: 12
2023-11-28 16:58:37 +08:00
anchors.bottomMargin: 12
2023-02-13 13:40:44 +08:00
spacing: 0
2023-02-09 16:07:51 +08:00
2023-11-29 15:50:17 +08:00
UkuiItems.Button {
2023-11-28 16:58:37 +08:00
id: fullScreenbutton
2023-11-29 15:50:17 +08:00
visible: !isLiteMode
2023-11-28 16:58:37 +08:00
Layout.preferredWidth: 36
Layout.preferredHeight: 36
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
2023-11-28 16:58:37 +08:00
ToolTip.delay: 500
ToolTip.text: qsTr("Expand")
ToolTip.visible: containsMouse
2023-11-28 16:58:37 +08:00
onClicked: mainWindow.isFullScreen = true
Keys.onPressed: {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
mainWindow.isFullScreen = true;
}
}
2023-02-09 16:07:51 +08:00
2023-11-29 15:50:17 +08:00
background.radius: 4
icon.mode: UkuiItems.Icon.AutoHighlight
icon.source: "view-fullscreen-symbolic"
2023-02-09 16:07:51 +08:00
}
2023-11-29 15:50:17 +08:00
UkuiItems.Button {
2023-11-28 16:58:37 +08:00
id: powerButton
Layout.preferredWidth: 36
Layout.preferredHeight: 36
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
2023-11-28 16:58:37 +08:00
ToolTip.delay: 500
ToolTip.visible: containsMouse
ToolTip.text: powerButtonBase.toolTip
2023-11-29 15:50:17 +08:00
PowerButton {
id: powerButtonBase
}
2023-11-28 16:58:37 +08:00
acceptedButtons: Qt.LeftButton | Qt.RightButton
property int spacingFromMenu: 16
Keys.onPressed: {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
2023-11-28 16:58:37 +08:00
powerButtonBase.clicked(true, 0, 0, mainWindow.isFullScreen);
}
}
2023-11-28 16:58:37 +08:00
onClicked: {
var buttonPosition = mapToGlobal(width, height);
powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x + spacingFromMenu, buttonPosition.y + spacingFromMenu, mainWindow.isFullScreen);
}
2023-11-29 15:50:17 +08:00
background.radius: 4
icon.mode: UkuiItems.Icon.AutoHighlight
icon.source: powerButtonBase.icon
}
}
2022-12-23 11:32:21 +08:00
}