Merge lp:~mardy/signon-ui/auth-1610206 into lp:signon-ui

Proposed by Alberto Mardegan on 2016-11-02
Status: Merged
Approved by: Alberto Mardegan on 2016-11-03
Approved revision: 149
Merged at revision: 146
Proposed branch: lp:~mardy/signon-ui/auth-1610206
Merge into: lp:signon-ui
Diff against target: 367 lines (+56/-115)
9 files modified
debian/changelog (+8/-0)
debian/control (+0/-1)
src/debug.cpp (+8/-0)
src/debug.h (+7/-20)
src/qquick-dialog.cpp (+0/-19)
src/qquick-dialog.h (+0/-2)
src/request.cpp (+30/-69)
src/request.h (+1/-0)
src/ubuntu-browser-request.cpp (+2/-4)
To merge this branch: bzr merge lp:~mardy/signon-ui/auth-1610206
Reviewer Review Type Date Requested Status
Alexandre Abreu (community) 2016-11-02 Approve on 2016-11-02
Review via email: mp+309850@code.launchpad.net

Description of the change

Unify QML and QWidget code paths

To post a comment you must log in.
lp:~mardy/signon-ui/auth-1610206 updated on 2016-11-02
149. By Alberto Mardegan on 2016-11-02

Unify QML and QWidget code paths (LP: #1610206)

review: Approve
lp:~mardy/signon-ui/auth-1610206 updated on 2016-11-04
150. By Alberto Mardegan on 2016-11-04

Use QT logging categories

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2016-04-06 09:17:36 +0000
3+++ debian/changelog 2016-11-04 09:26:22 +0000
4@@ -1,3 +1,11 @@
5+signon-ui (0.17+16.04.20160406-0ubuntu2) UNRELEASED; urgency=medium
6+
7+ * debian/control:
8+ - Remove dependency on libgstreamer-plugins-base0.10-dev
9+ * Unify QML and QWidget code paths (LP: #1610206)
10+
11+ -- Alberto Mardegan <alberto.mardegan@canonical.com> Wed, 02 Nov 2016 13:55:35 +0300
12+
13 signon-ui (0.17+16.04.20160406-0ubuntu1) xenial; urgency=medium
14
15 [ Alberto Mardegan ]
16
17=== modified file 'debian/control'
18--- debian/control 2014-09-16 09:27:40 +0000
19+++ debian/control 2016-11-04 09:26:22 +0000
20@@ -8,7 +8,6 @@
21 libaccounts-qt5-dev,
22 libgl1-mesa-dev | libgl-dev,
23 libgles2-mesa-dev | libgles2-dev,
24- libgstreamer-plugins-base0.10-dev,
25 libicu-dev,
26 libnotify-dev,
27 libproxy-dev,
28
29=== modified file 'src/debug.cpp'
30--- src/debug.cpp 2011-11-23 07:57:45 +0000
31+++ src/debug.cpp 2016-11-04 09:26:22 +0000
32@@ -20,10 +20,18 @@
33
34 #include "debug.h"
35
36+Q_LOGGING_CATEGORY(DBG_SIGNON_UI, "signon", QtWarningMsg)
37+
38 int appLoggingLevel = 1; // criticals
39
40 void setLoggingLevel(int level)
41 {
42+ if (level >= 1) {
43+ QLoggingCategory::setFilterRules("signon.warning=true");
44+ if (level >= 2) {
45+ QLoggingCategory::setFilterRules("signon.debug=true");
46+ }
47+ }
48 appLoggingLevel = level;
49 }
50
51
52=== modified file 'src/debug.h'
53--- src/debug.h 2011-11-23 07:57:45 +0000
54+++ src/debug.h 2016-11-04 09:26:22 +0000
55@@ -20,21 +20,13 @@
56 #ifndef SIGNON_UI_DEBUG_H
57 #define SIGNON_UI_DEBUG_H
58
59-#include <QDebug>
60+#include <QLoggingCategory>
61+
62+Q_DECLARE_LOGGING_CATEGORY(DBG_SIGNON_UI)
63
64 /* 0 - fatal, 1 - critical(default), 2 - info/debug */
65 extern int appLoggingLevel;
66
67-static inline bool debugEnabled()
68-{
69- return appLoggingLevel >= 2;
70-}
71-
72-static inline bool criticalsEnabled()
73-{
74- return appLoggingLevel >= 1;
75-}
76-
77 static inline int loggingLevel()
78 {
79 return appLoggingLevel;
80@@ -42,15 +34,10 @@
81
82 void setLoggingLevel(int level);
83
84-#ifdef DEBUG_ENABLED
85- #define TRACE() \
86- if (debugEnabled()) qDebug() << __FILE__ << __LINE__ << __func__
87- #define BLAME() \
88- if (criticalsEnabled()) qCritical() << __FILE__ << __LINE__ << __func__
89-#else
90- #define TRACE() while (0) qDebug()
91- #define BLAME() while (0) qDebug()
92-#endif
93+#define TRACE() \
94+ qCDebug(DBG_SIGNON_UI) << __FILE__ << __LINE__ << __func__
95+#define BLAME() \
96+ qCWarning(DBG_SIGNON_UI) << __FILE__ << __LINE__ << __func__
97
98 #endif // SIGNON_UI_DEBUG_H
99
100
101=== modified file 'src/qquick-dialog.cpp'
102--- src/qquick-dialog.cpp 2016-04-04 11:51:22 +0000
103+++ src/qquick-dialog.cpp 2016-11-04 09:26:22 +0000
104@@ -18,9 +18,6 @@
105 * with this program. If not, see <http://www.gnu.org/licenses/>.
106 */
107
108-#define HAS_FOREIGN_QWINDOW (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) || \
109- defined(FORCE_FOREIGN_QWINDOW))
110-
111 #include "qquick-dialog.h"
112
113 #include "debug.h"
114@@ -39,22 +36,6 @@
115 {
116 }
117
118-void Dialog::show(WId parent, ShowMode mode)
119-{
120- create();
121-#if HAS_FOREIGN_QWINDOW
122- if (mode != TopLevel) {
123- QWindow *parentWindow = QWindow::fromWinId(parent);
124- if (mode == Transient) {
125- setTransientParent(parentWindow);
126- } else if (mode == Embedded) {
127- setParent(parentWindow);
128- }
129- }
130-#endif
131- QQuickView::show();
132-}
133-
134 void Dialog::accept()
135 {
136 done(Dialog::Accepted);
137
138=== modified file 'src/qquick-dialog.h'
139--- src/qquick-dialog.h 2014-04-07 12:39:16 +0000
140+++ src/qquick-dialog.h 2016-11-04 09:26:22 +0000
141@@ -45,8 +45,6 @@
142 explicit Dialog(QWindow *parent = 0);
143 ~Dialog();
144
145- void show(WId parent, ShowMode mode);
146-
147 public Q_SLOTS:
148 void accept();
149 void reject();
150
151=== modified file 'src/request.cpp'
152--- src/request.cpp 2016-04-06 08:00:59 +0000
153+++ src/request.cpp 2016-11-04 09:26:22 +0000
154@@ -18,7 +18,6 @@
155 * with this program. If not, see <http://www.gnu.org/licenses/>.
156 */
157
158-#define HAS_XEMBED (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
159 #define HAS_FOREIGN_QWINDOW (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) || \
160 defined(FORCE_FOREIGN_QWINDOW))
161 #include "request.h"
162@@ -29,9 +28,6 @@
163 #include "browser-request.h"
164 #include "debug.h"
165 #include "dialog-request.h"
166-#if HAS_XEMBED
167-#include "embed-manager.h"
168-#endif
169 #include "errors.h"
170 #include "indicator-service.h"
171 #ifndef UNIT_TESTS
172@@ -81,13 +77,10 @@
173 }
174
175 private Q_SLOTS:
176-#if HAS_XEMBED
177- void onEmbedError();
178-#endif
179 void onIndicatorCallFinished(QDBusPendingCallWatcher *watcher);
180
181 private:
182- void setWidget(QWidget *widget);
183+ bool setWindow(QWindow *window);
184 Accounts::Account *findAccount();
185 bool dispatchToIndicator();
186 void onIndicatorCallSucceeded();
187@@ -100,7 +93,7 @@
188 QVariantMap m_clientData;
189 bool m_inProgress;
190 Accounts::Manager *m_accountManager;
191- QPointer<QWidget> m_widget;
192+ QPointer<QWindow> m_window;
193 };
194
195 } // namespace
196@@ -116,7 +109,7 @@
197 m_parameters(parameters),
198 m_inProgress(false),
199 m_accountManager(0),
200- m_widget(0)
201+ m_window(0)
202 {
203 if (parameters.contains(SSOUI_KEY_CLIENT_DATA)) {
204 QVariant variant = parameters[SSOUI_KEY_CLIENT_DATA];
205@@ -130,82 +123,42 @@
206 {
207 }
208
209-void RequestPrivate::setWidget(QWidget *widget)
210+bool RequestPrivate::setWindow(QWindow *window)
211 {
212- if (m_widget != 0) {
213+ if (m_window != 0) {
214 BLAME() << "Widget already set";
215- return;
216- }
217-
218- m_widget = widget;
219-
220-#if HAS_XEMBED
221- if (embeddedUi() && windowId() != 0) {
222- TRACE() << "Requesting widget embedding";
223- QX11EmbedWidget *embed =
224- EmbedManager::instance()->widgetFor(windowId());
225- QObject::connect(embed, SIGNAL(error(QX11EmbedWidget::Error)),
226- this, SLOT(onEmbedError()),
227- Qt::UniqueConnection);
228- QObject::connect(embed, SIGNAL(containerClosed()),
229- widget, SLOT(close()));
230- QVBoxLayout *layout = new QVBoxLayout;
231- layout->addWidget(widget);
232- widget->show();
233- /* Delete any previous layout */
234- delete embed->layout();
235- embed->setLayout(layout);
236- embed->show();
237- return;
238- }
239-#endif
240+ return false;
241+ }
242+
243+ m_window = window;
244+
245 #if HAS_FOREIGN_QWINDOW
246 if (embeddedUi() && windowId() != 0) {
247 TRACE() << "Requesting window embedding";
248 QWindow *host = QWindow::fromWinId(windowId());
249- widget->show();
250- widget->windowHandle()->setParent(host);
251- return;
252+ window->show();
253+ window->setParent(host);
254+ return true;
255 }
256 #endif
257
258 /* If the window has no parent and the webcredentials indicator service is
259 * up, dispatch the request to it. */
260 if (windowId() == 0 && dispatchToIndicator()) {
261- return;
262+ return false;
263 }
264
265- widget->setWindowModality(Qt::WindowModal);
266- widget->show();
267-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
268- if (windowId() != 0) {
269- TRACE() << "Setting" << widget->effectiveWinId() << "transient for" << windowId();
270- XSetTransientForHint(QX11Info::display(),
271- widget->effectiveWinId(),
272- windowId());
273- }
274-#endif
275+ window->setModality(Qt::WindowModal);
276+ window->show();
277 #if HAS_FOREIGN_QWINDOW
278 if (windowId() != 0) {
279 TRACE() << "Requesting window reparenting";
280 QWindow *parent = QWindow::fromWinId(windowId());
281- widget->windowHandle()->setTransientParent(parent);
282+ window->setTransientParent(parent);
283 }
284 #endif
285-}
286-
287-#if HAS_XEMBED
288-void RequestPrivate::onEmbedError()
289-{
290- Q_Q(Request);
291-
292- QX11EmbedWidget *embed = qobject_cast<QX11EmbedWidget*>(sender());
293- TRACE() << "Embed error:" << embed->error();
294-
295- q->fail(SIGNON_UI_ERROR_EMBEDDING_FAILED,
296- QString("Embedding signon UI failed: %1").arg(embed->error()));
297-}
298-#endif
299+ return true;
300+}
301
302 Accounts::Account *RequestPrivate::findAccount()
303 {
304@@ -285,8 +238,8 @@
305 if (watcher->isError()) {
306 /* if the notification could not be delivered to the indicator, show
307 * the widget. */
308- if (m_widget != 0)
309- m_widget->show();
310+ if (m_window != 0)
311+ m_window->show();
312 } else {
313 onIndicatorCallSucceeded();
314 }
315@@ -352,7 +305,15 @@
316 void Request::setWidget(QWidget *widget)
317 {
318 Q_D(Request);
319- d->setWidget(widget);
320+ if (d->setWindow(widget->windowHandle())) {
321+ widget->show();
322+ }
323+}
324+
325+void Request::setWindow(QWindow *window)
326+{
327+ Q_D(Request);
328+ d->setWindow(window);
329 }
330
331 uint Request::identity() const
332
333=== modified file 'src/request.h'
334--- src/request.h 2013-04-19 11:13:03 +0000
335+++ src/request.h 2016-11-04 09:26:22 +0000
336@@ -70,6 +70,7 @@
337 QObject *parent = 0);
338
339 void setWidget(QWidget *widget);
340+ void setWindow(QWindow *window);
341
342 protected Q_SLOTS:
343 void fail(const QString &name, const QString &message);
344
345=== modified file 'src/ubuntu-browser-request.cpp'
346--- src/ubuntu-browser-request.cpp 2016-04-04 10:26:46 +0000
347+++ src/ubuntu-browser-request.cpp 2016-11-04 09:26:22 +0000
348@@ -190,7 +190,7 @@
349
350 void UbuntuBrowserRequestPrivate::onLoadFinished(bool ok)
351 {
352- Q_Q(const UbuntuBrowserRequest);
353+ Q_Q(UbuntuBrowserRequest);
354
355 TRACE() << "Load finished" << ok;
356
357@@ -201,9 +201,7 @@
358
359 if (!m_dialog->isVisible()) {
360 if (m_responseUrl.isEmpty()) {
361- Dialog::ShowMode mode = (q->windowId() == 0) ? Dialog::TopLevel :
362- q->embeddedUi() ? Dialog::Embedded : Dialog::Transient;
363- m_dialog->show(q->windowId(), mode);
364+ q->setWindow(m_dialog);
365 } else {
366 onFinished();
367 }

Subscribers

People subscribed via source and target branches

to all changes: