on xenial help sign in
Moar changes
commit5b2c4427c3c883050f6d5a432dcf22d2ea915376 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateWed 4 Feb 2015, 11:04 (12 years ago) parent4547552
5 files changed+32−27
qml/Dash/Dash.qml+2−21 tests/mocks/Unity/fake_scope.cpp−5 tests/mocks/Unity/fake_scopes.cpp+24 tests/mocks/Unity/fake_scopes.h+6 tests/qmltests/Dash/tst_Dash.qml−1
qml/Dash/Dash.qml+2−21
@@ -210,7 +210,6 @@ Showable {
210210 objectName: "dashTempScopeItem"
211211
212212 property var scopeThatOpenedScope: null
213− property var oldScope: null
214213
215214 x: dashContent.x + width
216215 y: dashContent.y
@@ -224,25 +223,6 @@ Showable {
224223 closePreview();
225224 }
226225
227− Timer {
228− id: timer
229− interval: 1000
230− onTriggered: scopeItem.closeScope()
231− }
232−
233− onScopeChanged: {
234− console.log("scope changed", scope)
235− timer.start()
236− }
237−
238− function closeScope() {
239− if (oldScope) {
240− console.log("closing scope, oldscope - current scope", oldScope, scopeItem.scope)
241− scopeThatOpenedScope.closeScope(oldScope);
242− oldScope = null;
243− }
244− }
245−
246226 Connections {
247227 target: scopeItem.scope
248228 onGotoScope: {
@@ -250,8 +230,9 @@ Showable {
250230 }
251231 onOpenScope: {
252232 scopeItem.closePreview();
253− scopeItem.oldScope = scopeItem.scope;
233+ var oldScope = scopeItem.scope;
254234 scopeItem.scope = scope;
235+ scopeItem.scopeThatOpenedScope.closeScope(oldScope);
255236 }
256237 }
257238 }
tests/mocks/Unity/fake_scope.cpp−5
@@ -208,11 +208,6 @@ void Scope::cancelActivation()
208208
209209void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
210210{
211− if (scope != m_openScope) {
212− qDebug() << scope << m_openScope;
213− qFatal("Scope::closeScope got wrong scope in closeScope");
214− }
215− m_openScope = nullptr;
216211}
217212
218213QString Scope::currentNavigationId() const
tests/mocks/Unity/fake_scopes.cpp+24
@@ -177,6 +177,30 @@ unity::shell::scopes::ScopeInterface* Scopes::overviewScope() const
177177 return m_scopesOverview;
178178}
179179
180+void Scopes::addTempScope(unity::shell::scopes::ScopeInterface* scope)
181+{
182+ if (!m_tempScopes.contains(scope)) {
183+ m_tempScopes.insert(scope);
184+ }
185+}
186+
187+void Scopes::closeScope(unity::shell::scopes::ScopeInterface* scope)
188+{
189+ if (m_tempScopes.remove(scope)) {
190+ scope->deleteLater();
191+ }
192+}
193+
194+unity::shell::scopes::ScopeInterface* Scopes::findTempScope(QString const& id) const
195+{
196+ for (auto s: m_tempScopes) {
197+ if (s->id() == id) {
198+ return s;
199+ }
200+ }
201+ return nullptr;
202+}
203+
180204void Scopes::setFavorite(const QString& scopeId, bool favorite)
181205{
182206 if (favorite) {
tests/mocks/Unity/fake_scopes.h+6
@@ -26,6 +26,7 @@
2626
2727// Qt
2828#include <QList>
29+#include <QSet>
2930#include <QTimer>
3031
3132class ScopesOverview;
@@ -59,6 +60,10 @@ public:
5960 Q_INVOKABLE void setFavorite(const QString& scopeId, bool favorite) override;
6061 Q_INVOKABLE void moveFavoriteTo(const QString& scopeId, int index) override;
6162
63+ unity::shell::scopes::ScopeInterface* findTempScope(QString const& id) const;
64+ void addTempScope(unity::shell::scopes::ScopeInterface* scope);
65+ Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope);
66+
6267 // This is used as part of implementation of the other C++ code, not API
6368 QList<Scope*> favScopes() const;
6469 QList<Scope*> nonFavScopes() const;
@@ -70,6 +75,7 @@ private Q_SLOTS:
7075private:
7176 QList<Scope*> m_scopes; // the favorite ones
7277 QList<Scope*> m_allScopes;
78+ QSet<unity::shell::scopes::ScopeInterface*> m_tempScopes;
7379 ScopesOverview *m_scopesOverview;
7480 bool m_loaded;
7581 QTimer timer;
tests/qmltests/Dash/tst_Dash.qml−1
@@ -476,7 +476,6 @@ Item {
476476 tryCompare(findChild(dashTempScopeItem, "categoryListView"), "visible", false);
477477
478478 dashTempScopeItem.scope.openScope(scopes.getScopeFromAll("MockScope9"));
479− dashTempScopeItem.scope.activate();
480479 tryCompare(subPageLoader, "open", false);
481480
482481 // Go back