Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/windowTitle into lp:ubuntu-ui-toolkit

Proposed by Cris Dywan
Status: Merged
Merged at revision: 996
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/windowTitle
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 183 lines (+133/-0)
5 files modified
modules/Ubuntu/Components/MainView.qml (+16/-0)
tests/unit/tst_mainview/PageStack.qml (+32/-0)
tests/unit/tst_mainview/PageTitle.qml (+28/-0)
tests/unit/tst_mainview/TabsTitle.qml (+34/-0)
tests/unit/tst_mainview/tst_mainview.cpp (+23/-0)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/windowTitle
Reviewer Review Type Date Requested Status
Zsombor Egri Approve
PS Jenkins bot continuous-integration Approve
Tim Peeters Approve
Review via email: mp+212881@code.launchpad.net

Commit message

Set the window title based on the Header title

To post a comment you must log in.
Revision history for this message
Tim Peeters (tpeeters) wrote :

77 + title: 'Once upon a time'

why single quotes?

Revision history for this message
Tim Peeters (tpeeters) wrote :

Binding {
  target: window
  property: "title"
  value: headerItem.title
}

wouldn't this be enough?

Revision history for this message
Tim Peeters (tpeeters) wrote :

This will not work when we have tabs, but it is ok if we accept that (and there are upcoming changes to the tabs in the header that will make it work).

review: Needs Information
Revision history for this message
Tim Peeters (tpeeters) wrote :

After this gets merged https://code.launchpad.net/~tpeeters/ubuntu-ui-toolkit/tabBarInStyle/+merge/211575 the title will be valid even when using Tabs, so if we merge that one first there won't be a problem.

Code looks good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

I'm missing two more test cases:
1. PageStack: the pushed page changes the title, when the page is popped it sets back to the previous one.
2. Tabs: the current tab title is set as the app title, expect it failing till Tim's MR is landed.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

> I'm missing two more test cases:
> 1. PageStack: the pushed page changes the title, when the page is popped it
> sets back to the previous one.

I still don't see this addressed. I'd like to see a second page push and pop as well. You can invoke the push/pop from C++ or have a property in MainView which drives the second page push/pop.

> 2. Tabs: the current tab title is set as the app title, expect it failing till
> Tim's MR is landed.

Same here, additional test code which changes the tab and checks the title should be added. Of course expect fail for each move.

review: Needs Fixing
Revision history for this message
Zsombor Egri (zsombi) wrote :

Ok, so the PageStack and Tabs test (will test) the title change, so there's no reason to have these tests duplicated. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/MainView.qml'
2--- modules/Ubuntu/Components/MainView.qml 2014-02-12 17:38:57 +0000
3+++ modules/Ubuntu/Components/MainView.qml 2014-03-27 15:54:22 +0000
4@@ -17,6 +17,7 @@
5 import QtQuick 2.0
6 import Ubuntu.Unity.Action 1.1 as UnityActions
7 import Ubuntu.PerformanceMetrics 0.1
8+import QtQuick.Window 2.0
9
10 /*!
11 \qmltype MainView
12@@ -343,6 +344,21 @@
13 }
14 }
15 }
16+
17+ // 'window' is defined by QML between startup and showing on the screen.
18+ // There is no signal for when it becomes available and re-declaring it is not safe.
19+ property bool windowActive: typeof window != 'undefined'
20+ onWindowActiveChanged: {
21+ window.title = headerItem.title
22+ }
23+
24+ Connections {
25+ target: headerItem
26+ onTitleChanged: {
27+ if (headerItem.windowActive)
28+ window.title = headerItem.title
29+ }
30+ }
31 }
32
33 Connections {
34
35=== added file 'tests/unit/tst_mainview/PageStack.qml'
36--- tests/unit/tst_mainview/PageStack.qml 1970-01-01 00:00:00 +0000
37+++ tests/unit/tst_mainview/PageStack.qml 2014-03-27 15:54:22 +0000
38@@ -0,0 +1,32 @@
39+/*
40+ * Copyright 2014 Canonical Ltd.
41+ *
42+ * This program is free software; you can redistribute it and/or modify
43+ * it under the terms of the GNU Lesser General Public License as published by
44+ * the Free Software Foundation; version 3.
45+ *
46+ * This program is distributed in the hope that it will be useful,
47+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
48+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49+ * GNU Lesser General Public License for more details.
50+ *
51+ * You should have received a copy of the GNU Lesser General Public License
52+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
53+ */
54+
55+import QtQuick 2.0
56+import Ubuntu.Components 0.1
57+
58+MainView {
59+ objectName: "pageStack"
60+ applicationName: "once.upon.a.time"
61+
62+ PageStack {
63+ objectName: "stack"
64+
65+ Page {
66+ objectName: "page"
67+ title: 'Far far away'
68+ }
69+ }
70+}
71
72=== added file 'tests/unit/tst_mainview/PageTitle.qml'
73--- tests/unit/tst_mainview/PageTitle.qml 1970-01-01 00:00:00 +0000
74+++ tests/unit/tst_mainview/PageTitle.qml 2014-03-27 15:54:22 +0000
75@@ -0,0 +1,28 @@
76+/*
77+ * Copyright 2014 Canonical Ltd.
78+ *
79+ * This program is free software; you can redistribute it and/or modify
80+ * it under the terms of the GNU Lesser General Public License as published by
81+ * the Free Software Foundation; version 3.
82+ *
83+ * This program is distributed in the hope that it will be useful,
84+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
85+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86+ * GNU Lesser General Public License for more details.
87+ *
88+ * You should have received a copy of the GNU Lesser General Public License
89+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
90+ */
91+
92+import QtQuick 2.0
93+import Ubuntu.Components 0.1
94+
95+MainView {
96+ objectName: "pageTitle"
97+ applicationName: "once.upon.a.time"
98+
99+ Page {
100+ objectName: "page"
101+ title: 'Once upon a time'
102+ }
103+}
104
105=== added file 'tests/unit/tst_mainview/TabsTitle.qml'
106--- tests/unit/tst_mainview/TabsTitle.qml 1970-01-01 00:00:00 +0000
107+++ tests/unit/tst_mainview/TabsTitle.qml 2014-03-27 15:54:22 +0000
108@@ -0,0 +1,34 @@
109+/*
110+ * Copyright 2014 Canonical Ltd.
111+ *
112+ * This program is free software; you can redistribute it and/or modify
113+ * it under the terms of the GNU Lesser General Public License as published by
114+ * the Free Software Foundation; version 3.
115+ *
116+ * This program is distributed in the hope that it will be useful,
117+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
118+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
119+ * GNU Lesser General Public License for more details.
120+ *
121+ * You should have received a copy of the GNU Lesser General Public License
122+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
123+ */
124+
125+import QtQuick 2.0
126+import Ubuntu.Components 0.1
127+
128+MainView {
129+ objectName: "tabsTitle"
130+ applicationName: "once.upon.a.time"
131+
132+ Tabs {
133+ objectName: "tabs"
134+ Tab {
135+ title: 'Long long ago'
136+ page: Page {
137+ objectName: "page"
138+ title: 'Not the title you are looking for'
139+ }
140+ }
141+ }
142+}
143
144=== modified file 'tests/unit/tst_mainview/tst_mainview.cpp'
145--- tests/unit/tst_mainview/tst_mainview.cpp 2013-11-05 13:52:05 +0000
146+++ tests/unit/tst_mainview/tst_mainview.cpp 2014-03-27 15:54:22 +0000
147@@ -34,6 +34,7 @@
148
149 #include "ucapplication.h"
150 #include "ucunits.h"
151+#include "uctestcase.h"
152
153 class tst_MainView : public QObject
154 {
155@@ -153,6 +154,28 @@
156 // No warnings from QML
157 QCOMPARE(spy.count(), 0);
158 }
159+
160+ void testWindowTitleFromPage() {
161+ QScopedPointer<UbuntuTestCase> testCase(new UbuntuTestCase("PageTitle.qml"));
162+ QQuickItem *page = testCase->findItem<QQuickItem*>("page");
163+ QCOMPARE(QString("Once upon a time"), page->property("title").toString());
164+ QCOMPARE(testCase->title(), page->property("title").toString());
165+ }
166+
167+ void testWindowTitleFromStack() {
168+ QScopedPointer<UbuntuTestCase> testCase(new UbuntuTestCase("PageStack.qml"));
169+ QQuickItem *page = testCase->findItem<QQuickItem*>("page");
170+ QCOMPARE(QString("Far far away"), page->property("title").toString());
171+ QCOMPARE(testCase->title(), page->property("title").toString());
172+ }
173+
174+ void testWindowTitleFromTabs() {
175+ QScopedPointer<UbuntuTestCase> testCase(new UbuntuTestCase("TabsTitle.qml"));
176+ QQuickItem *page = testCase->findItem<QQuickItem*>("page");
177+ QEXPECT_FAIL(0, "Tabs don't correctly propagate the title yet", Continue);
178+ QCOMPARE(QString("Long long ago"), page->property("title").toString());
179+ QCOMPARE(testCase->title(), page->property("title").toString());
180+ }
181 };
182
183 QTEST_MAIN(tst_MainView)

Subscribers

People subscribed via source and target branches

to status/vote changes: