on xenial help sign in
improve previews
commitd6d0af35533de6594c30ac38445b720b621bc6a4 authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 16 Jan 2017, 15:08 (10 years ago) parent6791285
5 files changed+79−19
qml/Stage/Spread/ScreensAndWorkspaces.qml+2−3 qml/Stage/Stage.qml+1 qml/Stage/WorkspacePreview.qml+52−10 tests/mocks/Unity/Application/MirSurfaceItem.cpp+19−5 tests/mocks/Unity/Screens/screens.cpp+5−1
qml/Stage/Spread/ScreensAndWorkspaces.qml+2−3
@@ -6,9 +6,7 @@ import ".."
66
77Item {
88 id: root
9−
10−
11− Rectangle { anchors.fill: parent; color: "blue"; opacity: .3 }
9+ property string background
1210
1311 Row {
1412 anchors.bottom: parent.bottom
@@ -21,6 +19,7 @@ Item {
2119
2220 delegate: WorkspacePreview {
2321 height: root.height - units.gu(6)
22+ background: root.background
2423 }
2524 }
2625 }
qml/Stage/Stage.qml+1
@@ -564,6 +564,7 @@ FocusScope {
564564 id: screensAndWorkspaces
565565 anchors { left: parent.left; top: parent.top; right: parent.right }
566566 height: parent.height / 3
567+ background: root.background
567568 }
568569
569570 Spread {
qml/Stage/WorkspacePreview.qml+52−10
@@ -1,6 +1,8 @@
11import QtQuick 2.4
22import Ubuntu.Components 1.3
3+import Unity.Screens 0.1
34import Unity.Application 0.1
5+import "../Components"
46
57UbuntuShape {
68 id: previewSpace
@@ -8,35 +10,75 @@ UbuntuShape {
810 // Set the height. this preview will then automatically adjust the width, keeping aspect ratio of the screen
911 width: model.geometry.width * previewScale
1012 color: "white"
13+ property string background
1114
1215 property int screenWidth: model.geometry.width
1316 property int screenHeight: model.geometry.height
14− property real previewScale: previewSpace.height / previewSpace.screenHeight
17+ property real previewScale: (previewSpace.height - header.height) / previewSpace.screenHeight
1518
16− Label {
17− text: model.name + "," + model.geometry.width
18− color: "black"
19+ Item {
20+ id: header
21+ anchors { left: parent.left; top: parent.top; right: parent.right }
22+ height: units.gu(7)
23+ Column {
24+ anchors.fill: parent
25+ anchors.margins: units.gu(1)
26+
27+ Label {
28+ text: model.name
29+ color: "black"
30+ }
31+
32+ Label {
33+ text: model.outputType === Screens.LVDS ? "Built-in" : "Clone"
34+ color: "black"
35+ fontSize: "x-small"
36+ }
37+
38+ Label {
39+ text: model.geometry.width + "x" + model.geometry.height
40+ color: "black"
41+ fontSize: "x-small"
42+ }
43+ }
1944 }
2045
21− Rectangle {
46+
47+ Wallpaper {
2248 anchors.fill: parent
23− anchors.topMargin: units.gu(4)
49+ anchors.topMargin: header.height
50+ source: previewSpace.background
51+ clip: true
2452
2553 Repeater {
2654 id: topLevelSurfaceRepeater
2755 model: topLevelSurfaceList
2856 delegate: Rectangle {
2957 width: surfaceItem.width
30− height: surfaceItem.height
31− x: model.window.position.x * previewSpace.previewScale
32− y: model.window.position.y * previewSpace.previewScale
58+ height: surfaceItem.height + decorationHeight * previewScale
59+ x: model.window.position.x * previewScale
60+ y: (model.window.position.y - decorationHeight) * previewScale
3361 color: "blue"
3462 z: topLevelSurfaceRepeater.count - index
3563
64+ property int decorationHeight: units.gu(3)
65+
66+ WindowDecoration {
67+ width: surfaceItem.implicitWidth
68+ height: parent.decorationHeight
69+ transform: Scale {
70+ origin.x: 0
71+ origin.y: 0
72+ xScale: previewScale
73+ yScale: previewScale
74+ }
75+ title: model.window && model.window.surface ? model.window.surface.name : ""
76+ z: 3
77+ }
3678
3779 MirSurfaceItem {
3880 id: surfaceItem
39−
81+ y: parent.decorationHeight * previewScale
4082 width: implicitWidth * previewScale
4183 height: implicitHeight * previewScale
4284 surfaceWidth: -1
tests/mocks/Unity/Application/MirSurfaceItem.cpp+19−5
@@ -185,8 +185,13 @@ void MirSurfaceItem::createQmlContentItem()
185185 m_qmlItem = qobject_cast<QQuickItem*>(m_qmlContentComponent->create());
186186 m_qmlItem->setParentItem(this);
187187
188− m_qmlItem->setWidth(m_surfaceWidth);
189− m_qmlItem->setHeight(m_surfaceHeight);
188+ if (m_fillMode == FillMode::Stretch) {
189+ m_qmlItem->setWidth(width());
190+ m_qmlItem->setHeight(height());
191+ } else {
192+ m_qmlItem->setWidth(m_surfaceWidth);
193+ m_qmlItem->setHeight(m_surfaceHeight);
194+ }
190195
191196 setImplicitWidth(m_qmlItem->implicitWidth());
192197 setImplicitHeight(m_qmlItem->implicitHeight());
@@ -294,7 +299,11 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
294299 connect(m_qmlSurface, &MirSurface::liveChanged, this, &MirSurfaceItem::liveChanged);
295300 connect(m_qmlSurface, &MirSurface::stateChanged, this, &MirSurfaceItem::surfaceStateChanged);
296301 connect(m_qmlSurface, &MirSurface::sizeChanged, this, [this] () {
297− m_qmlItem->setSize(m_qmlSurface->size());
302+ if (m_fillMode == FillMode::Stretch) {
303+ m_qmlItem->setSize(QSize(this->width(), this->height()));
304+ } else {
305+ m_qmlItem->setSize(m_qmlSurface->size());
306+ }
298307 setImplicitSize(m_qmlSurface->width(), m_qmlSurface->height());
299308 });
300309
@@ -388,8 +397,13 @@ void MirSurfaceItem::updateSurfaceSize()
388397 if (m_qmlSurface && m_surfaceWidth > 0 && m_surfaceHeight > 0) {
389398 m_qmlSurface->resize(m_surfaceWidth, m_surfaceHeight);
390399 if (m_qmlItem) {
391− m_qmlItem->setWidth(m_surfaceWidth);
392− m_qmlItem->setHeight(m_surfaceHeight);
400+ if (m_fillMode == FillMode::Stretch) {
401+ m_qmlItem->setWidth(width());
402+ m_qmlItem->setHeight(height());
403+ } else {
404+ m_qmlItem->setWidth(m_surfaceWidth);
405+ m_qmlItem->setHeight(m_surfaceHeight);
406+ }
393407 }
394408 qDebug() << this << "setting implicitsize" << m_surfaceWidth << m_surfaceHeight;
395409 setImplicitSize(m_surfaceWidth, m_surfaceHeight);
tests/mocks/Unity/Screens/screens.cpp+5−1
@@ -33,6 +33,11 @@ Screens::Screens(QObject *parent) :
3333 for (int i = 0; i < screenCount; ++i) {
3434 auto screen = new Screen();
3535 screen->enabled = i == 0;
36+ if (i == 0) {
37+ screen->outputTypes = OutputTypes::LVDS;
38+ } else {
39+ screen->outputTypes = OutputTypes::HDMIA;
40+ }
3641 screen->name = QString("Monitor %1").arg(i);
3742 screen->sizes = { QSize(640,480), QSize(1024,748), QSize(1280,1024), QSize(1440,900), QSize(1920,1080) };
3843 screen->geometry = QRect(lastPoint.x(), lastPoint.y(), 1024, 786 );
@@ -70,7 +75,6 @@ QVariant Screens::data(const QModelIndex &index, int role) const
7075
7176 switch(role) {
7277 case ScreenRole:
73− qDebug() << "returning" << m_screenList.at(index.row())->qScreen;
7478 return QVariant::fromValue(m_screenList.at(index.row())->qScreen);
7579 case OutputTypeRole:
7680 return m_screenList.at(index.row())->outputTypes;