on xenial help sign in
improve previews
d6d0af3Michael Zanetti
qml/Stage/Spread/ScreensAndWorkspaces.qml+2−3
@@ -6,9 +6,7 @@ import ".."
6
6
7Item {
7Item {
8 id: root
8 id: root
9−
9+ property string background
10−
11− Rectangle { anchors.fill: parent; color: "blue"; opacity: .3 }
12
10
13 Row {
11 Row {
14 anchors.bottom: parent.bottom
12 anchors.bottom: parent.bottom
@@ -21,6 +19,7 @@ Item {
21
19
22 delegate: WorkspacePreview {
20 delegate: WorkspacePreview {
23 height: root.height - units.gu(6)
21 height: root.height - units.gu(6)
22+ background: root.background
24 }
23 }
25 }
24 }
26 }
25 }
qml/Stage/Stage.qml+1
@@ -564,6 +564,7 @@ FocusScope {
564 id: screensAndWorkspaces
564 id: screensAndWorkspaces
565 anchors { left: parent.left; top: parent.top; right: parent.right }
565 anchors { left: parent.left; top: parent.top; right: parent.right }
566 height: parent.height / 3
566 height: parent.height / 3
567+ background: root.background
567 }
568 }
568
569
569 Spread {
570 Spread {
qml/Stage/WorkspacePreview.qml+52−10
@@ -1,6 +1,8 @@
1import QtQuick 2.4
1import QtQuick 2.4
2import Ubuntu.Components 1.3
2import Ubuntu.Components 1.3
3+import Unity.Screens 0.1
3import Unity.Application 0.1
4import Unity.Application 0.1
5+import "../Components"
4
6
5UbuntuShape {
7UbuntuShape {
6 id: previewSpace
8 id: previewSpace
@@ -8,35 +10,75 @@ UbuntuShape {
8 // Set the height. this preview will then automatically adjust the width, keeping aspect ratio of the screen
10 // Set the height. this preview will then automatically adjust the width, keeping aspect ratio of the screen
9 width: model.geometry.width * previewScale
11 width: model.geometry.width * previewScale
10 color: "white"
12 color: "white"
13+ property string background
11
14
12 property int screenWidth: model.geometry.width
15 property int screenWidth: model.geometry.width
13 property int screenHeight: model.geometry.height
16 property int screenHeight: model.geometry.height
14− property real previewScale: previewSpace.height / previewSpace.screenHeight
17+ property real previewScale: (previewSpace.height - header.height) / previewSpace.screenHeight
15
18
16− Label {
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 {
17− text: model.name + "," + model.geometry.width
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
18− color: "black"
40+ color: "black"
41+ fontSize: "x-small"
42+ }
43+ }
19 }
44 }
20
45
21− Rectangle {
46+
47+ Wallpaper {
22 anchors.fill: parent
48 anchors.fill: parent
23− anchors.topMargin: units.gu(4)
49+ anchors.topMargin: header.height
50+ source: previewSpace.background
51+ clip: true
24
52
25 Repeater {
53 Repeater {
26 id: topLevelSurfaceRepeater
54 id: topLevelSurfaceRepeater
27 model: topLevelSurfaceList
55 model: topLevelSurfaceList
28 delegate: Rectangle {
56 delegate: Rectangle {
29 width: surfaceItem.width
57 width: surfaceItem.width
30− height: surfaceItem.height
58+ height: surfaceItem.height + decorationHeight * previewScale
31− x: model.window.position.x * previewSpace.previewScale
59+ x: model.window.position.x * previewScale
32− y: model.window.position.y * previewSpace.previewScale
60+ y: (model.window.position.y - decorationHeight) * previewScale
33 color: "blue"
61 color: "blue"
34 z: topLevelSurfaceRepeater.count - index
62 z: topLevelSurfaceRepeater.count - index
35
63
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+ }
36
78
37 MirSurfaceItem {
79 MirSurfaceItem {
38 id: surfaceItem
80 id: surfaceItem
39−
81+ y: parent.decorationHeight * previewScale
40 width: implicitWidth * previewScale
82 width: implicitWidth * previewScale
41 height: implicitHeight * previewScale
83 height: implicitHeight * previewScale
42 surfaceWidth: -1
84 surfaceWidth: -1
tests/mocks/Unity/Application/MirSurfaceItem.cpp+19−5
@@ -185,8 +185,13 @@ void MirSurfaceItem::createQmlContentItem()
185 m_qmlItem = qobject_cast<QQuickItem*>(m_qmlContentComponent->create());
185 m_qmlItem = qobject_cast<QQuickItem*>(m_qmlContentComponent->create());
186 m_qmlItem->setParentItem(this);
186 m_qmlItem->setParentItem(this);
187
187
188+ if (m_fillMode == FillMode::Stretch) {
189+ m_qmlItem->setWidth(width());
190+ m_qmlItem->setHeight(height());
191+ } else {
188− m_qmlItem->setWidth(m_surfaceWidth);
192+ m_qmlItem->setWidth(m_surfaceWidth);
189− m_qmlItem->setHeight(m_surfaceHeight);
193+ m_qmlItem->setHeight(m_surfaceHeight);
194+ }
190
195
191 setImplicitWidth(m_qmlItem->implicitWidth());
196 setImplicitWidth(m_qmlItem->implicitWidth());
192 setImplicitHeight(m_qmlItem->implicitHeight());
197 setImplicitHeight(m_qmlItem->implicitHeight());
@@ -294,7 +299,11 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
294 connect(m_qmlSurface, &MirSurface::liveChanged, this, &MirSurfaceItem::liveChanged);
299 connect(m_qmlSurface, &MirSurface::liveChanged, this, &MirSurfaceItem::liveChanged);
295 connect(m_qmlSurface, &MirSurface::stateChanged, this, &MirSurfaceItem::surfaceStateChanged);
300 connect(m_qmlSurface, &MirSurface::stateChanged, this, &MirSurfaceItem::surfaceStateChanged);
296 connect(m_qmlSurface, &MirSurface::sizeChanged, this, [this] () {
301 connect(m_qmlSurface, &MirSurface::sizeChanged, this, [this] () {
302+ if (m_fillMode == FillMode::Stretch) {
303+ m_qmlItem->setSize(QSize(this->width(), this->height()));
304+ } else {
297− m_qmlItem->setSize(m_qmlSurface->size());
305+ m_qmlItem->setSize(m_qmlSurface->size());
306+ }
298 setImplicitSize(m_qmlSurface->width(), m_qmlSurface->height());
307 setImplicitSize(m_qmlSurface->width(), m_qmlSurface->height());
299 });
308 });
300
309
@@ -388,8 +397,13 @@ void MirSurfaceItem::updateSurfaceSize()
388 if (m_qmlSurface && m_surfaceWidth > 0 && m_surfaceHeight > 0) {
397 if (m_qmlSurface && m_surfaceWidth > 0 && m_surfaceHeight > 0) {
389 m_qmlSurface->resize(m_surfaceWidth, m_surfaceHeight);
398 m_qmlSurface->resize(m_surfaceWidth, m_surfaceHeight);
390 if (m_qmlItem) {
399 if (m_qmlItem) {
400+ if (m_fillMode == FillMode::Stretch) {
401+ m_qmlItem->setWidth(width());
402+ m_qmlItem->setHeight(height());
403+ } else {
391− m_qmlItem->setWidth(m_surfaceWidth);
404+ m_qmlItem->setWidth(m_surfaceWidth);
392− m_qmlItem->setHeight(m_surfaceHeight);
405+ m_qmlItem->setHeight(m_surfaceHeight);
406+ }
393 }
407 }
394 qDebug() << this << "setting implicitsize" << m_surfaceWidth << m_surfaceHeight;
408 qDebug() << this << "setting implicitsize" << m_surfaceWidth << m_surfaceHeight;
395 setImplicitSize(m_surfaceWidth, m_surfaceHeight);
409 setImplicitSize(m_surfaceWidth, m_surfaceHeight);
tests/mocks/Unity/Screens/screens.cpp+5−1
@@ -33,6 +33,11 @@ Screens::Screens(QObject *parent) :
33 for (int i = 0; i < screenCount; ++i) {
33 for (int i = 0; i < screenCount; ++i) {
34 auto screen = new Screen();
34 auto screen = new Screen();
35 screen->enabled = i == 0;
35 screen->enabled = i == 0;
36+ if (i == 0) {
37+ screen->outputTypes = OutputTypes::LVDS;
38+ } else {
39+ screen->outputTypes = OutputTypes::HDMIA;
40+ }
36 screen->name = QString("Monitor %1").arg(i);
41 screen->name = QString("Monitor %1").arg(i);
37 screen->sizes = { QSize(640,480), QSize(1024,748), QSize(1280,1024), QSize(1440,900), QSize(1920,1080) };
42 screen->sizes = { QSize(640,480), QSize(1024,748), QSize(1280,1024), QSize(1440,900), QSize(1920,1080) };
38 screen->geometry = QRect(lastPoint.x(), lastPoint.y(), 1024, 786 );
43 screen->geometry = QRect(lastPoint.x(), lastPoint.y(), 1024, 786 );
@@ -70,7 +75,6 @@ QVariant Screens::data(const QModelIndex &index, int role) const
70
75
71 switch(role) {
76 switch(role) {
72 case ScreenRole:
77 case ScreenRole:
73− qDebug() << "returning" << m_screenList.at(index.row())->qScreen;
74 return QVariant::fromValue(m_screenList.at(index.row())->qScreen);
78 return QVariant::fromValue(m_screenList.at(index.row())->qScreen);
75 case OutputTypeRole:
79 case OutputTypeRole:
76 return m_screenList.at(index.row())->outputTypes;
80 return m_screenList.at(index.row())->outputTypes;