1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-13 22:42:51 +01:00
ScreenPlay/main.qml

260 lines
6.9 KiB
QML
Raw Normal View History

import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
import Qt.labs.platform 1.0
2017-12-19 15:43:31 +01:00
import "qml/"
import "qml/Installed"
2017-06-06 12:51:53 +02:00
ApplicationWindow {
2017-04-04 17:40:21 +02:00
id: window
color: "#eeeeee"
// Set visible if the -silent parameter was not set
visible: false
width: 1400
2017-04-23 11:31:05 +02:00
minimumHeight: 768
minimumWidth: 1050
Connections {
target: screenPlaySettings
onSetMainWindowVisible: {
window.visible = visible
setX(Screen.width / 2 - width / 2)
setY(Screen.height / 2 - height / 2)
}
}
2017-11-02 18:54:32 +01:00
LinearGradient {
id: tabShadow
height: 6
z: 500
cached: true
2017-11-02 18:54:32 +01:00
anchors {
2017-11-02 18:54:32 +01:00
top: nav.bottom
right: parent.right
left: parent.left
}
start: Qt.point(0, 0)
end: Qt.point(0, 6)
2017-11-02 18:54:32 +01:00
gradient: Gradient {
GradientStop {
position: 0.0
color: "#33000000"
}
GradientStop {
position: 1.0
color: "#00000000"
}
2017-11-02 18:54:32 +01:00
}
}
SystemTrayIcon {
id: sti
visible: true
iconSource: "qrc:/assets/icons/favicon.ico"
menu: Menu {
MenuItem {
text: qsTr("Open ScreenPlay")
onTriggered: {
window.show()
}
}
MenuItem {
id: miMuteAll
property bool isMuted: false
text: qsTr("Mute all")
onTriggered: {
if (miMuteAll.isMuted) {
isMuted = false
miMuteAll.text = qsTr("Mute all")
screenPlaySettings.setMuteAll(false)
} else {
isMuted = true
miMuteAll.text = qsTr("Unmute all")
screenPlaySettings.setMuteAll(true)
}
}
}
MenuItem {
id: miStopAll
property bool isPlaying: false
2018-01-16 15:57:11 +01:00
text: qsTr("Pause all")
onTriggered: {
if (miStopAll.isPlaying) {
isPlaying = false
miStopAll.text = qsTr("Pause all")
screenPlaySettings.setPlayAll(true)
} else {
isPlaying = true
miStopAll.text = qsTr("Play all")
screenPlaySettings.setPlayAll(false)
}
}
}
MenuItem {
text: qsTr("Quit")
onTriggered: Qt.quit()
}
}
}
Loader {
id: pageLoader
asynchronous: true
2017-12-19 15:43:31 +01:00
source: "qrc:/qml/Installed/Installed.qml"
anchors {
top: nav.bottom
right: parent.right
bottom: parent.bottom
left: parent.left
}
onStatusChanged: {
if (status == Loader.Ready) {
if (pageLoaderCreate.source != "qrc:/qml/Create/Create.qml")
timerLoader.start()
}
}
}
Timer {
id: timerLoader
interval: 500
onTriggered: {
pageLoaderCreate.source = "qrc:/qml/Create/Create.qml"
}
}
Loader {
id: pageLoaderCreate
visible: false
asynchronous: true
anchors {
top: nav.bottom
right: parent.right
bottom: parent.bottom
left: parent.left
}
}
Loader {
id: pageLoaderWorkshop
visible: false
asynchronous: true
anchors {
top: nav.bottom
right: parent.right
bottom: parent.bottom
left: parent.left
}
2017-12-30 14:16:37 +01:00
onStatusChanged: {
if (status == Loader.Ready) {
2017-12-30 14:16:37 +01:00
connectionsPageLoaderWorkshop.target = pageLoaderWorkshop
}
}
}
Connections {
id: connectionsPageLoaderWorkshop
2017-12-30 14:16:37 +01:00
ignoreUnknownSignals: true
onOpenCreate: {
print("lellele")
if (!ignoreWorkshopBanner) {
switchPage("Workshop")
ignoreWorkshopBanner = true
}
}
}
Connections {
target: pageLoader.item
ignoreUnknownSignals: true
property bool ignoreWorkshopBanner: false
onSetSidebaractiveItem: {
if (type === "video") {
if (sidebar.activeScreen == screenId
&& sidebar.state == "active") {
sidebar.state = "inactive"
} else {
sidebar.state = "active"
}
} else if (type === "widget") {
if (sidebar.activeScreen == screenId
&& sidebar.state == "activeWidget") {
sidebar.state = "inactive"
} else {
sidebar.state = "activeWidget"
}
}
sidebar.activeScreen = screenId
sidebar.type = type
}
onSetNavigationItem: {
if (pos === 0) {
nav.onPageChanged("Create")
} else {
nav.onPageChanged("Workshop")
}
}
}
Sidebar {
id: sidebar
width: 400
navHeight: nav.height
anchors {
top: parent.top
right: parent.right
bottom: parent.bottom
}
}
Navigation {
id: nav
anchors {
top: parent.top
right: parent.right
left: parent.left
}
onChangePage: {
2017-12-30 14:16:37 +01:00
switchPage(name)
}
2017-04-13 08:24:11 +02:00
onToggleMonitors: {
monitors.state = monitors.state == "active" ? "inactive" : "active"
}
}
function switchPage(name) {
if (name === "Create") {
2017-12-30 14:16:37 +01:00
pageLoader.visible = false
pageLoaderCreate.setSource("qrc:/qml/Create/Create.qml")
pageLoaderCreate.visible = true
pageLoaderWorkshop.visible = false
sidebar.state = "inactive"
} else if (name === "Workshop") {
2017-12-30 14:16:37 +01:00
pageLoader.visible = false
pageLoaderCreate.visible = false
pageLoaderWorkshop.setSource("qrc:/qml/Workshop/Workshop.qml")
pageLoaderWorkshop.visible = true
sidebar.state = "inactive"
} else {
pageLoader.visible = true
pageLoaderCreate.visible = false
pageLoaderWorkshop.visible = false
pageLoader.setSource("qrc:/qml/" + name + "/" + name + ".qml")
sidebar.state = "inactive"
}
}
2017-04-13 08:24:11 +02:00
Monitors {
id: monitors
state: "inactive"
anchors.fill: pageLoader
z: 98
}
}