aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/src-qml')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/NativeWindow.qml231
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml8
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml10
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml14
4 files changed, 157 insertions, 106 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/NativeWindow.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/NativeWindow.qml
index 92263689..2150e37c 100644
--- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/NativeWindow.qml
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/NativeWindow.qml
@@ -5,6 +5,7 @@ import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import Lumina.Backend.NativeWindowObject 2.0
+import Lumina.Backend.RootDesktopObject 2.0
Rectangle {
property NativeWindowObject object
@@ -14,94 +15,119 @@ Rectangle {
id: windowFrame
border.width: 5
- //border.color: palette.window
- color: palette.window
+ border.color: palette.highlight
+ radius: 5
+ color: "transparent" //palette.window
x: object.frameGeometry.x
y: object.frameGeometry.y
width: object.frameGeometry.width
height: object.frameGeometry.height
+ onXChanged: {
+ windowFrame.object.updateGeometry(windowFrame.x, windowFrame.y, windowFrame.width, windowFrame.height)
+ }
+ onYChanged: {
+ windowFrame.object.updateGeometry(windowFrame.x, windowFrame.y, windowFrame.width, windowFrame.height)
+ }
+
MouseArea {
id: resizeArea
anchors.fill: parent
- property int positionX: 0
- property int positionY: 0
- property int newWidth: 0
- property int newHeight: 0
-
- onPositionChanged: {
- var globalP = windowFrame.mapToGlobal(mouse.x, mouse.y)
- if(positionY < windowFrame.y + 15 ) {
- /*if(positionX < windowFrame.x + 15) {
- console.log("Top Left");
- //Top Left
- newWidth = windowFrame.width + (windowFrame.x - mouse.x)
- newHeight = windowFrame.height + (windowFrame.y - mouse.y)
- windowFrame.x = mouse.x
- windowFrame.y = mouse.y
- }else if(positionX > windowFrame.x + windowFrame.width - 15) {
- console.log("Top Right");
- //Top Right
- newX = positionX - mouse.x
- newY = positionY - mouse.y
- newWidth = windowFrame.width - (positionX - mouse.x)
- newHeight = windowFrame.height + (windowFrame.y - mouse.y)
- windowFrame.y = mouse.y
- }else{*/
- //Top
- windowFrame.height -= 1
- windowFrame.y = globalP.y
- // }
+ drag.target: undefined
+ property int resizeDirection: NativeWindowObject.TOP_LEFT
+ property int positionX: -1
+ property int positionY: -1
+
+ onPressed: {
+ //NOTE: This is only triggered for resize events
+ var globalP = windowFrame.mapToItem(rootCanvas, mouse.x, mouse.y)
+ positionX = globalP.x
+ positionY = globalP.y
+ if(positionY <= windowFrame.y + 10 ) {
+ if(positionX <= windowFrame.x + 10)
+ resizeDirection = NativeWindowObject.TOP_LEFT
+ else if(positionX >= windowFrame.x + windowFrame.width - 10)
+ resizeDirection = NativeWindowObject.TOP_RIGHT
+ else
+ resizeDirection = NativeWindowObject.TOP
+ }else if(positionY >= windowFrame.y + windowFrame.height - 10) {
+ if(positionX <= windowFrame.x + 10)
+ resizeDirection = NativeWindowObject.BOTTOM_LEFT
+ else if(positionX >= windowFrame.x + windowFrame.width - 10)
+ resizeDirection = NativeWindowObject.BOTTOM_RIGHT
+ else
+ resizeDirection = NativeWindowObject.BOTTOM
+ }else if(positionX <= windowFrame.x + 10) {
+ resizeDirection = NativeWindowObject.LEFT
+ }else if(positionX >= windowFrame.x + windowFrame.width - 10) {
+ resizeDirection = NativeWindowObject.RIGHT
}
-/*else if(mouse.x < windowFrame.x + 15) {
- if(mouse.y > windowFrame.y + windowFrame.height - 15) {
- //Bottom Left
- newX = positionX - mouse.x
- newWidth = windowFrame.width - newX
- newHeight = windowFrame.height - newY
- }else{
- //Left
- }
- }else if(mouse.y > windowFrame.y + windowFrame.height - 15) {
- if(mouse.x > windowFrame.x + windowFrame.width - 15) {
- //Bottom Right
- }else{
- //Bottom
- }
- }else if(mouse.x > windowFrame.x + windowFrame.width - 15) {
- //Right
- } else {
- console.log("Cursor error");
- }*/
+ //console.log("Initial X: ", positionX, "Initial Y: ", positionY);
+ //console.log("Initial X Frame: ", windowFrame.x, "Initial Y Frame: ", windowFrame.y);
}
- }
-
- MouseArea {
- id: dragArea
- anchors.fill: titleBar
- drag.target: windowFrame
- drag.axis: Drag.XAndYAxis
- onClicked: { console.log("dragArea"); }
- //released: { function(); }
- }
- states: [
- State {
- when: resizeArea.drag.held
- PropertyChanges { target: Window; color:"red" }
- },
- State {
- when: dragArea.drag.held
- AnchorChanges { target: windowFrame; anchors.verticalCenter: undefined; anchors.horizontalCenter: undefined }
+ onReleased: {
+ positionX = -1
+ positionY = -1
+ //windowFrame.object.updateGeometry(windowFrame.x, windowFrame.y, windowFrame.width, windowFrame.height)
}
- ]
-
+ onPositionChanged: {
+ //NOTE: This is only triggered for resize events
+ if(positionX != -1 && positionY != -1) {
+ var globalP = windowFrame.mapToItem(rootCanvas, mouse.x, mouse.y)
+ /*console.log("Global P: ", globalP);
+ console.log("Position X: ", positionX, "Position Y: ", positionY)
+ console.log("Old Position : ", windowFrame.x, " , ", windowFrame.y)
+ console.log(resizeDirection);*/
+ if(resizeDirection == NativeWindowObject.TOP_LEFT) {
+ windowFrame.height -= globalP.y - positionY
+ windowFrame.width -= globalP.x - positionX
+ windowFrame.y = globalP.y
+ windowFrame.x = globalP.x
+ }else if(resizeDirection == NativeWindowObject.TOP_RIGHT) {
+ //console.log("TOP RIGHT Old Height: ", windowFrame.height, "Old Width: ", windowFrame.width)
+ windowFrame.height -= globalP.y - positionY
+ windowFrame.width += globalP.x - positionX
+ //console.log("New Height: ", windowFrame.height, "New Width: ", windowFrame.width)
+ windowFrame.y = globalP.y
+ //console.log("New Position : ", windowFrame.x, " , ", windowFrame.y)
+ }else if(resizeDirection == NativeWindowObject.TOP) {
+ windowFrame.height -= globalP.y - positionY
+ windowFrame.y = globalP.y
+ } else if(resizeDirection == NativeWindowObject.RIGHT) {
+ windowFrame.width += globalP.x - positionX
+ } else if(resizeDirection == NativeWindowObject.BOTTOM_RIGHT) {
+ windowFrame.height += globalP.y - positionY
+ windowFrame.width += globalP.x - positionX
+ } else if(resizeDirection == NativeWindowObject.BOTTOM) {
+ windowFrame.height += globalP.y - positionY
+ } else if(resizeDirection == NativeWindowObject.BOTTOM_LEFT) {
+ windowFrame.width -= globalP.x - positionX
+ windowFrame.height += globalP.y - positionY
+ windowFrame.x = globalP.x
+ } else if(resizeDirection == NativeWindowObject.LEFT) {
+ windowFrame.width -= globalP.x - positionX
+ windowFrame.x = globalP.x
+ }
+ //Set a miniumum width and height as 80x50
+ if(windowFrame.width < 80) {
+ windowFrame.width = 80
+ }
+ if(windowFrame.height < 50) {
+ windowFrame.height = 50
+ }
+ positionY = globalP.y
+ positionX = globalP.x
+ }
+ windowFrame.object.updateGeometry(windowFrame.x, windowFrame.y, windowFrame.width, windowFrame.height)
+ }
+ }
Rectangle {
id: titleBar
- border.width: 2
- color: palette.window
+ border.width: 0
+ color: palette.window
height: 25
anchors.top: windowFrame.top
anchors.right: windowFrame.right
@@ -109,48 +135,51 @@ Rectangle {
anchors.margins: windowFrame.border.width
width: parent.width
- RowLayout {
- anchors.fill: titleBar
- spacing: 0
+ MouseArea {
+ id: dragArea
+ anchors.fill: parent
+ drag.target: windowFrame
+ drag.axis: Drag.XAndYAxis
+ //acceptedButtons: Qt.RightButton
+ //onClicked: contextMenu.open()
+ //released: { function(); }
+ }
- Button {
- id: otherButton
- anchors.left: parent.left
- Layout.fillHeight: true
- iconSource: windowFrame.object.icon
- }
+ ToolButton {
+ id: otherButton
+ anchors.left: parent.left
+ height: parent.height
+ iconSource: windowFrame.object.icon
+ }
- Text {
- Layout.fillWidth: true
- Layout.fillHeight: true
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.verticalCenter: parent.verticalCenter
- color: palette.windowText
- text: windowFrame.object.shortTitle
-
- MouseArea {
- acceptedButtons: Qt.RightButton
- anchors.fill: parent
- //onClicked: contextMenu.open()
- }
- }
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ color: palette.windowText
+ text: windowFrame.object.shortTitle
+ fontSizeMode: Text.Fit
+ }
- Button {
+ RowLayout {
+ spacing: 0
+ anchors.right: parent.right
+ height: parent.height
+
+ ToolButton {
id: minButton
Layout.fillHeight: true
iconName: "window-minimize"
onClicked: { windowFrame.object.toggleVisibility() }
}
- Button {
+ ToolButton {
id: maxButton
Layout.fillHeight: true
iconName: "window-maximize"
//onClicked: { windowFrame.object.toggleMaximize() }
}
- Button {
+ ToolButton {
id: closeButton
Layout.fillHeight: true
iconName: "document-close"
@@ -161,6 +190,7 @@ Rectangle {
Image {
id: frameContents
+ cache: false
source: windowFrame.object.winImage
anchors.top: titleBar.bottom
anchors.bottom: parent.bottom
@@ -173,11 +203,10 @@ Rectangle {
height: parent.height
MouseArea {
- width: parent.width;
+ width: parent.width
height: parent.height
anchors.fill: frameContents
onClicked: { console.log(parent.mapToGlobal(mouse.x, mouse.y)); }
-
}
}
}
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml
index 846b5b55..556da5ec 100644
--- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml
@@ -10,15 +10,13 @@ import QtQuick.Controls 1
import Lumina.Backend.PanelObject 2.0
-AnimatedImage {
+Rectangle {
//C++ backend object
- property string screen_id
+ property string panel_id
property PanelObject object
//Normal geometries/placements
- asynchronous: true
- clip: true
- source: object.background
+ color: object.background
x: object.x
y: object.y
width: object.width
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml
index 9122ce5b..f48f7751 100644
--- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml
@@ -66,4 +66,14 @@ Rectangle {
z: 100+index
}
}
+
+ //Setup the Panels
+ Repeater{
+ model: RootObject.panels
+ QML.Panel{
+ panel_id: modelData
+ object: RootObject.panel(panel_id)
+ z: 10100+index
+ }
+ }
}
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml
index 3b83653a..82e7c89d 100644
--- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml
@@ -9,6 +9,9 @@ import QtQuick.Window 2.2
import QtQuick.Controls 1
import Lumina.Backend.ScreenObject 2.0
+import Lumina.Backend.PanelObject 2.0
+
+import "." as QML
AnimatedImage {
//C++ backend object
@@ -23,4 +26,15 @@ AnimatedImage {
y: object.y
width: object.width
height: object.height
+
+ //Setup the Panels
+ Repeater{
+ model: object.panels
+ QML.Panel{
+ panel_id: modelData
+ object: parent.object.panel(panel_id)
+ z: 10000+index
+ }
+ }
+
}
bgstack15