on xenial help sign in
New tabbar from sdk
8189f0aAlbert Astals
Dash/DashContent.qml+12−39
@@ -163,51 +163,24 @@ Item {
163 objectName: "tabbar"
163 objectName: "tabbar"
164 height: units.gu(7)
164 height: units.gu(7)
165 width: parent.width
165 width: parent.width
166− implicitWidth: currentButtonWidth
166+ implicitWidth: 400
167
167
168− property alias selectedTabIndex: tabs.selectedTabIndex
168+ model: dashContentList.model
169
169
170− Component.onCompleted: {
170+ onSelectedIndexChanged: {
171− __styleInstance.headerTextStyle = Text.Raised
171+ dashContentList.currentIndex = selectedIndex;
172− __styleInstance.headerTextStyleColor = "black"
173 }
172 }
174
173
175− tabsItem: TabsBase {
174+ Connections {
176− id: tabs
177−
178− Repeater {
179− model: dashContentList.model
175+ target: dashContentList
180− Tab {
176+ onCurrentIndexChanged: {
181− id: tab
182− title: scope.name
183− Component.onCompleted: {
184− var aux = tabs.tabList;
185− aux.push(tab)
186− tabs.tabList = aux;
187− tabs.modelChanged();
188− if (tabs.selectedTabIndex == -1) {
189− tabs.selectedTabIndex = 0;
190− }
191− }
192− Component.onDestruction: {
193− var aux = tabs.tabList;
194− aux.splice(aux.indexOf(tab), 1)
195− tabs.tabList = aux;
196− tabs.modelChanged();
197− }
198− }
199− }
200−
201− onSelectedTabIndexChanged: {
202− dashContentList.currentIndex = selectedTabIndex;
177+ tabbar.selectedIndex = dashContentList.currentIndex
203 }
178 }
179+ }
204
180
205− Connections {
181+ Component.onCompleted: {
206− target: dashContentList
182+ __styleInstance.headerTextStyle = Text.Raised
207− onCurrentIndexChanged: {
183+ __styleInstance.headerTextStyleColor = "black"
208− tabs.selectedTabIndex = dashContentList.currentIndex
209− }
210− }
211 }
184 }
212 }
185 }
213 }
186 }
plugins/Unity/scopes.cpp+3
@@ -36,6 +36,7 @@ Scopes::Scopes(QObject *parent)
36 m_roles[Scopes::RoleScope] = "scope";
36 m_roles[Scopes::RoleScope] = "scope";
37 m_roles[Scopes::RoleId] = "id";
37 m_roles[Scopes::RoleId] = "id";
38 m_roles[Scopes::RoleVisible] = "visible";
38 m_roles[Scopes::RoleVisible] = "visible";
39+ m_roles[Scopes::RoleTitle] = "title";
39
40
40 m_unityScopes->scope_added.connect(sigc::mem_fun(this, &Scopes::onScopeAdded));
41 m_unityScopes->scope_added.connect(sigc::mem_fun(this, &Scopes::onScopeAdded));
41 m_unityScopes->scope_removed.connect(sigc::mem_fun(this, &Scopes::onScopeRemoved));
42 m_unityScopes->scope_removed.connect(sigc::mem_fun(this, &Scopes::onScopeRemoved));
@@ -71,6 +72,8 @@ QVariant Scopes::data(const QModelIndex& index, int role) const
71 return QVariant::fromValue(scope->id());
72 return QVariant::fromValue(scope->id());
72 } else if (role == Scopes::RoleVisible) {
73 } else if (role == Scopes::RoleVisible) {
73 return QVariant::fromValue(scope->visible());
74 return QVariant::fromValue(scope->visible());
75+ } else if (role == Scopes::RoleTitle) {
76+ return scope->name();
74 } else {
77 } else {
75 return QVariant();
78 return QVariant();
76 }
79 }
plugins/Unity/scopes.h+2−1
@@ -54,7 +54,8 @@ public:
54 enum Roles {
54 enum Roles {
55 RoleScope,
55 RoleScope,
56 RoleId,
56 RoleId,
57− RoleVisible
57+ RoleVisible,
58+ RoleTitle
58 };
59 };
59
60
60 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
61 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
tests/qmltests/Dash/tst_Dash.qml+2−2
@@ -88,7 +88,7 @@ Item {
88
88
89 dash.setCurrentScope(data.tag, true /* animate */, false /* reset */);
89 dash.setCurrentScope(data.tag, true /* animate */, false /* reset */);
90 compare(dashContent.currentIndex, data.shouldBeVisible ? data.visualIndex : current_index);
90 compare(dashContent.currentIndex, data.shouldBeVisible ? data.visualIndex : current_index);
91− compare(tabbar.selectedTabIndex, data.shouldBeVisible ? data.visualIndex : current_index);
91+ compare(tabbar.selectedIndex, data.shouldBeVisible ? data.visualIndex : current_index);
92 }
92 }
93
93
94 function test_show_scope_on_load_data() {
94 function test_show_scope_on_load_data() {
@@ -124,7 +124,7 @@ Item {
124 var dashContent = findChild(dash, "dashContent");
124 var dashContent = findChild(dash, "dashContent");
125 var current_index = dashContent.currentIndex;
125 var current_index = dashContent.currentIndex;
126
126
127− tabbar.selectedTabIndex = data.visualIndex;
127+ tabbar.selectedIndex = data.visualIndex;
128 compare(dashContent.currentIndex, data.shouldBeVisible ? data.visualIndex : current_index);
128 compare(dashContent.currentIndex, data.shouldBeVisible ? data.visualIndex : current_index);
129 }
129 }
130 }
130 }
tests/qmltests/Dash/tst_DashContent.qml+2−2
@@ -240,9 +240,9 @@ Item {
240 function test_tabBar_listens_to_index_change() {
240 function test_tabBar_listens_to_index_change() {
241 var tabbar = findChild(dashContent, "tabbar");
241 var tabbar = findChild(dashContent, "tabbar");
242 tryCompare(dashContent, "currentIndex", 0);
242 tryCompare(dashContent, "currentIndex", 0);
243− compare(tabbar.selectedTabIndex, 0);
243+ compare(tabbar.selectedIndex, 0);
244 dashContent.currentIndex = 1;
244 dashContent.currentIndex = 1;
245− compare(tabbar.selectedTabIndex, 1);
245+ compare(tabbar.selectedIndex, 1);
246 }
246 }
247 }
247 }
248}
248}