1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-18 08:22:33 +02:00

Add custom window navigation drawing

This commit is contained in:
Elias Steurer 2021-12-27 11:58:03 +01:00
parent be370a0ad4
commit f0495d7713
3 changed files with 221 additions and 112 deletions

View File

@ -117,6 +117,8 @@ public slots:
QString version() const;
void exit();
QPointF cursorPos() { return QCursor::pos(); }
void setGlobalVariables(GlobalVariables* globalVariables)
{
if (m_globalVariables.get() == globalVariables)

View File

@ -55,6 +55,8 @@ ApplicationWindow {
title: "ScreenPlay Alpha - " + ScreenPlay.version()
minimumHeight: 450
minimumWidth: 1050
flags: Qt.FramelessWindowHint |Qt.Window
// Partial workaround for
// https://bugreports.qt.io/browse/QTBUG-86047
Material.accent: Material.color(Material.Orange)
@ -79,6 +81,12 @@ ApplicationWindow {
}
Item {
anchors.fill: parent
anchors.margins: 1
Connections {
function onThemeChanged(theme) {
setTheme(theme);
@ -188,7 +196,6 @@ ApplicationWindow {
Installed.Sidebar {
id: sidebar
objectName: "installedSidebar"
navHeight: nav.height
anchors {
@ -202,17 +209,18 @@ ApplicationWindow {
Navigation.Navigation {
id: nav
window: root
width:parent.width
anchors {
top: parent.top
right: parent.right
left: parent.left
}
onChangePage: (name)=> {
monitors.close();
switchPage(name);
}
anchors {
top: parent.top
right: parent.right
left: parent.left
}
}
@ -220,4 +228,81 @@ ApplicationWindow {
id: monitors
}
}
Rectangle {
height: 1
color:"#222"
anchors{
top:parent.top
right:parent.right
left:parent.left
}
}
Rectangle {
height: 1
color:"#222"
anchors{
bottom:parent.bottom
right:parent.right
left:parent.left
}
}
Rectangle {
width: 1
color:"#222"
anchors{
left:parent.left
bottom:parent.bottom
top:parent.top
}
}
Rectangle {
width: 1
color:"#222"
anchors{
right:parent.right
bottom:parent.bottom
top:parent.top
}
}
Rectangle {
width: 15
height:width
color:"#555"
anchors{
right:parent.right
bottom:parent.bottom
margins: 1
}
MouseArea {
id: maResize
anchors.fill: parent
cursorShape: Qt.SizeFDiagCursor
property point clickPosition
property size originalSize
onPressed: {
maResize.clickPosition = Qt.point(maResize.mouseX, maResize.mouseY);
maResize.clickPosition = maResize.mapToGlobal(maResize.clickPosition.x , maResize.clickPosition.y )
maResize.originalSize = Qt.size(root.width, root.height)
}
onPositionChanged: {
if (maResize.pressed){
let newPos = maResize.mapToGlobal(maResize.mouseX, maResize.mouseY)
let newPosX = newPos.x - maResize.clickPosition.x
let newPosY = newPos.y - maResize.clickPosition.y
root.setGeometry(root.x,root.y, maResize.originalSize.width + newPosX,
maResize.originalSize.height + newPosY)
}
}
}
}
}

View File

@ -54,7 +54,28 @@ Rectangle {
color: Material.theme === Material.Light ? "white" : Material.background
layer.enabled: true
MouseHoverBlocker {}
MouseArea {
id: mouseArea
property var clickPos
anchors.fill: parent
hoverEnabled: true
onPressed: (mouse)=>{
clickPos = {
"x": mouse.x,
"y": mouse.y
};
}
onPositionChanged: {
if (mouseArea.pressed){
let pos = ScreenPlay.cursorPos();
window.setX(pos.x - clickPos.x)
window.setY(pos.y - clickPos.y)
}
}
}
Connections {
function onRequestNavigationActive(isActive) {
@ -267,6 +288,7 @@ Rectangle {
title: qsTr("Are you sure you want to exit ScreenPlay? \nThis will shut down all Wallpaper and Widgets.")
standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: Qt.quit()
modal: true
}