on xenial help sign in
Moar changes
5b2c442Andrea Cimitan
qml/Dash/Dash.qml+2−21
@@ -210,7 +210,6 @@ Showable {
210 objectName: "dashTempScopeItem"
210 objectName: "dashTempScopeItem"
211
211
212 property var scopeThatOpenedScope: null
212 property var scopeThatOpenedScope: null
213− property var oldScope: null
214
213
215 x: dashContent.x + width
214 x: dashContent.x + width
216 y: dashContent.y
215 y: dashContent.y
@@ -224,25 +223,6 @@ Showable {
224 closePreview();
223 closePreview();
225 }
224 }
226
225
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−
246 Connections {
226 Connections {
247 target: scopeItem.scope
227 target: scopeItem.scope
248 onGotoScope: {
228 onGotoScope: {
@@ -250,8 +230,9 @@ Showable {
250 }
230 }
251 onOpenScope: {
231 onOpenScope: {
252 scopeItem.closePreview();
232 scopeItem.closePreview();
253− scopeItem.oldScope = scopeItem.scope;
233+ var oldScope = scopeItem.scope;
254 scopeItem.scope = scope;
234 scopeItem.scope = scope;
235+ scopeItem.scopeThatOpenedScope.closeScope(oldScope);
255 }
236 }
256 }
237 }
257 }
238 }
tests/mocks/Unity/fake_scope.cpp−5
@@ -208,11 +208,6 @@ void Scope::cancelActivation()
208
208
209void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
209void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
210{
210{
211− if (scope != m_openScope) {
212− qDebug() << scope << m_openScope;
213− qFatal("Scope::closeScope got wrong scope in closeScope");
214− }
215− m_openScope = nullptr;
216}
211}
217
212
218QString Scope::currentNavigationId() const
213QString Scope::currentNavigationId() const
tests/mocks/Unity/fake_scopes.cpp+24
@@ -177,6 +177,30 @@ unity::shell::scopes::ScopeInterface* Scopes::overviewScope() const
177 return m_scopesOverview;
177 return m_scopesOverview;
178}
178}
179
179
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+
180void Scopes::setFavorite(const QString& scopeId, bool favorite)
204void Scopes::setFavorite(const QString& scopeId, bool favorite)
181{
205{
182 if (favorite) {
206 if (favorite) {
tests/mocks/Unity/fake_scopes.h+6
@@ -26,6 +26,7 @@
26
26
27// Qt
27// Qt
28#include <QList>
28#include <QList>
29+#include <QSet>
29#include <QTimer>
30#include <QTimer>
30
31
31class ScopesOverview;
32class ScopesOverview;
@@ -59,6 +60,10 @@ public:
59 Q_INVOKABLE void setFavorite(const QString& scopeId, bool favorite) override;
60 Q_INVOKABLE void setFavorite(const QString& scopeId, bool favorite) override;
60 Q_INVOKABLE void moveFavoriteTo(const QString& scopeId, int index) override;
61 Q_INVOKABLE void moveFavoriteTo(const QString& scopeId, int index) override;
61
62
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+
62 // This is used as part of implementation of the other C++ code, not API
67 // This is used as part of implementation of the other C++ code, not API
63 QList<Scope*> favScopes() const;
68 QList<Scope*> favScopes() const;
64 QList<Scope*> nonFavScopes() const;
69 QList<Scope*> nonFavScopes() const;
@@ -70,6 +75,7 @@ private Q_SLOTS:
70private:
75private:
71 QList<Scope*> m_scopes; // the favorite ones
76 QList<Scope*> m_scopes; // the favorite ones
72 QList<Scope*> m_allScopes;
77 QList<Scope*> m_allScopes;
78+ QSet<unity::shell::scopes::ScopeInterface*> m_tempScopes;
73 ScopesOverview *m_scopesOverview;
79 ScopesOverview *m_scopesOverview;
74 bool m_loaded;
80 bool m_loaded;
75 QTimer timer;
81 QTimer timer;
tests/qmltests/Dash/tst_Dash.qml−1
@@ -476,7 +476,6 @@ Item {
476 tryCompare(findChild(dashTempScopeItem, "categoryListView"), "visible", false);
476 tryCompare(findChild(dashTempScopeItem, "categoryListView"), "visible", false);
477
477
478 dashTempScopeItem.scope.openScope(scopes.getScopeFromAll("MockScope9"));
478 dashTempScopeItem.scope.openScope(scopes.getScopeFromAll("MockScope9"));
479− dashTempScopeItem.scope.activate();
480 tryCompare(subPageLoader, "open", false);
479 tryCompare(subPageLoader, "open", false);
481
480
482 // Go back
481 // Go back