Skip to content

Commit

Permalink
Added an autodetection for showing the Instrument Cluster
Browse files Browse the repository at this point in the history
Instead of changing the main file manually, the Main file is more smart
now and tries to detect whether showing the InstrumentCluster is possible.

Using am-config.yaml the Cluster can still be disabled if it's not
wanted, e.g. for development on the Desktop

Change-Id: If2ff186cf1317fc309050e1f4b3a479e25342249
Reviewed-by: Nedim Hadzic <[email protected]>
  • Loading branch information
Gagi2k committed Aug 30, 2016
1 parent ada06ff commit 2f6d87c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 65 deletions.
49 changes: 49 additions & 0 deletions Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@

import QtQuick 2.5
import QtQuick.Window 2.2
import QtApplicationManager 1.0
import com.pelagicore.ScreenManager 1.0
import "sysui/Cluster"
import "sysui"
import controls 1.0
import utils 1.0

Rectangle {
id: root

property bool showClusterIfPossible: ApplicationManager.additionalConfiguration.showCluster
property var cluster

color: "black"
width: Style.screenWidth
height: Style.screenHeight
Expand Down Expand Up @@ -71,4 +77,47 @@ Rectangle {
anchors.fill: display
}
}

Component {
id: clusterComponent
Window {
id: cluster
title: "Neptune Cluster Display"
height: 720
width: 1920
visible: false

color: "black"

Cluster {}

Component.onCompleted: {
WindowManager.registerCompositorView(cluster)
Style.withCluster = true
ScreenManager.setScreen(cluster, 1)
cluster.show()
}
}
}

Window.onActiveChanged: {
if (Window.active && !WindowManager.runningOnDesktop)
cluster.requestActivate()
}

Component.onCompleted: {
var canDisplayCluster = Screen.desktopAvailableWidth > Screen.width || WindowManager.runningOnDesktop || ScreenManager.screenCount() > 1

if (!showClusterIfPossible) {
console.log("Showing Instrument Cluster was disabled");
return
}

if (canDisplayCluster) {
console.log("Showing Instrument Cluster");
cluster = clusterComponent.createObject(root);
} else {
console.log("Showing the Instrument Cluster is not possible on this platform");
}
}
}
65 changes: 0 additions & 65 deletions MainWithCluster.qml

This file was deleted.

1 change: 1 addition & 0 deletions am-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ui:
additionalConfiguration:
appStoreServerUrl: 'http://chaos.pelagicore.net:8080'
styleConfig: "auto"
showCluster: yes
windowIcon: "imports/shared/assets/icons/active/[email protected]"

# development setup: no security
Expand Down
5 changes: 5 additions & 0 deletions plugins/screenManager/screenmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ ScreenManager::ScreenManager(QObject *parent)
connect(qApp, &QGuiApplication::screenAdded, this, &ScreenManager::availableScreensChanged);
}

int ScreenManager::screenCount() const
{
return QGuiApplication::screens().count();
}

void ScreenManager::setScreen(QWindow *window, int screen)
{
if (screen >= 0 && screen < QGuiApplication::screens().count()) {
Expand Down

0 comments on commit 2f6d87c

Please sign in to comment.