Skip to content

Commit

Permalink
Moved the cluster detection into the AutoConfig.qml
Browse files Browse the repository at this point in the history
This is needed as also the multi-process applications need to know
whether to display the cluster widget and how big it can be rendered

Change-Id: I589439f50fa3aa60630dd7b1fb6e4008a3d1b8c2
Reviewed-by: Nedim Hadzic <[email protected]>
  • Loading branch information
Gagi2k committed Sep 1, 2016
1 parent dc7f8ff commit dae966c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
9 changes: 0 additions & 9 deletions Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,11 @@ Rectangle {
id: clusterItem
}

function calculateSize() {
print (Screen.width, Screen.height)
Style.clusterWidth = Screen.width
Style.clusterHeight = Screen.width * 0.375
}

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

}
}

Expand Down
5 changes: 3 additions & 2 deletions apps/com.pelagicore.music/ClusterWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ import controls 1.0
import "."

Item {
width: 1300
width: Style.clusterWidth * 0.677
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter

ListView {
id: playListView
width: 400
width: parent.width * 0.3
height: parent.height
anchors.centerIn: parent
clip: true
Expand Down
14 changes: 14 additions & 0 deletions imports/shared/utils/AutoConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@

import QtQuick 2.0
import QtQuick.Window 2.2
import com.pelagicore.ScreenManager 1.0

QtObject {
property bool withCluster: false
property int cellWidth: 53 // 1280/24
property int cellHeight: 33 // 800/24
property var fontWeight: Font.Light
Expand All @@ -52,12 +54,15 @@ QtObject {
property int symbolSizeL: 96
property int symbolSizeXL: 114
property int symbolSizeXXL: 192
property bool showClusterIfPossible: false

property string displayBackground: "background_1920x1080"


property int screenWidth: Screen.width
property int screenHeight: Math.min(screenWidth * 0.62, Screen.height)
property int clusterWidth: 1920
property int clusterHeight: 720

onScreenWidthChanged: cellWidth = Math.floor(screenWidth/24)
onScreenHeightChanged: cellHeight = Math.floor(screenHeight/24)
Expand Down Expand Up @@ -103,5 +108,14 @@ QtObject {
fontSizeXXL = scalFactor * 48

fontWeight = Font.Light

var canDisplayCluster = Screen.desktopAvailableWidth > Screen.width || ScreenManager.screenCount() > 1
if (canDisplayCluster) {
print("Instrument Cluster enabled")
withCluster = true
clusterWidth = ScreenManager.availableScreens[1].size.width
clusterHeight = Math.min(ScreenManager.availableScreens[1].size.width * 0.375, ScreenManager.availableScreens[1].size.height)
print("cluster resolution: " + clusterWidth + "x" + clusterHeight)
}
}
}
3 changes: 3 additions & 0 deletions imports/shared/utils/Style.qml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ QtObject {

property bool isClient: typeof ApplicationInterface !== 'undefined'
property string styleConfig: isClient ? ApplicationInterface.additionalConfiguration.styleConfig : ApplicationManager.additionalConfiguration.styleConfig
property bool showClusterIfPossible: isClient ? ApplicationInterface.additionalConfiguration.showCluster :ApplicationManager.additionalConfiguration.showCluster

property Loader styleLoader: Loader {
source: styleConfig === "auto" ? Qt.resolvedUrl("AutoConfig.qml") : styleConfig

onLoaded: {
print("StyleConfig loaded: ", source)
if (item.showClusterIfPossible)
item.showClusterIfPossible = root.showClusterIfPossible
}
}

Expand Down
8 changes: 6 additions & 2 deletions plugins/screenManager/screenmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ void ScreenManager::setScreen(QWindow *window, int screen)
}
}

QList<QScreen *> ScreenManager::availableScreens() const
QList<QObject *> ScreenManager::availableScreens() const
{
return QGuiApplication::screens();
QList<QObject *> list;
for (QScreen *screen : QGuiApplication::screens())
list.append(screen);

return list;
}
4 changes: 2 additions & 2 deletions plugins/screenManager/screenmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class ScreenManager : public QObject
{
Q_OBJECT

Q_PROPERTY(QList<QScreen*> availableScreens READ availableScreens NOTIFY availableScreensChanged)
Q_PROPERTY(QList<QObject*> availableScreens READ availableScreens NOTIFY availableScreensChanged)

public:
explicit ScreenManager(QObject *parent = 0);

Q_INVOKABLE int screenCount() const;
Q_INVOKABLE void setScreen(QWindow * window, int screen);
QList<QScreen*> availableScreens() const;
QList<QObject*> availableScreens() const;

signals:
void availableScreensChanged();
Expand Down

0 comments on commit dae966c

Please sign in to comment.