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

Proposed by Alberto Mardegan
Status: Merged
Approved by: Alberto Mardegan
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) Approve
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
149. By Alberto Mardegan

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

Revision history for this message
Alexandre Abreu (abreu-alexandre) :
review: Approve
lp:~mardy/signon-ui/auth-1610206 updated
150. By Alberto Mardegan

Use QT logging categories

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2016-04-06 09:17:36 +0000
+++ debian/changelog 2016-11-04 09:26:22 +0000
@@ -1,3 +1,11 @@
1signon-ui (0.17+16.04.20160406-0ubuntu2) UNRELEASED; urgency=medium
2
3 * debian/control:
4 - Remove dependency on libgstreamer-plugins-base0.10-dev
5 * Unify QML and QWidget code paths (LP: #1610206)
6
7 -- Alberto Mardegan <alberto.mardegan@canonical.com> Wed, 02 Nov 2016 13:55:35 +0300
8
1signon-ui (0.17+16.04.20160406-0ubuntu1) xenial; urgency=medium9signon-ui (0.17+16.04.20160406-0ubuntu1) xenial; urgency=medium
210
3 [ Alberto Mardegan ]11 [ Alberto Mardegan ]
412
=== modified file 'debian/control'
--- debian/control 2014-09-16 09:27:40 +0000
+++ debian/control 2016-11-04 09:26:22 +0000
@@ -8,7 +8,6 @@
8 libaccounts-qt5-dev,8 libaccounts-qt5-dev,
9 libgl1-mesa-dev | libgl-dev,9 libgl1-mesa-dev | libgl-dev,
10 libgles2-mesa-dev | libgles2-dev,10 libgles2-mesa-dev | libgles2-dev,
11 libgstreamer-plugins-base0.10-dev,
12 libicu-dev,11 libicu-dev,
13 libnotify-dev,12 libnotify-dev,
14 libproxy-dev,13 libproxy-dev,
1514
=== modified file 'src/debug.cpp'
--- src/debug.cpp 2011-11-23 07:57:45 +0000
+++ src/debug.cpp 2016-11-04 09:26:22 +0000
@@ -20,10 +20,18 @@
2020
21#include "debug.h"21#include "debug.h"
2222
23Q_LOGGING_CATEGORY(DBG_SIGNON_UI, "signon", QtWarningMsg)
24
23int appLoggingLevel = 1; // criticals25int appLoggingLevel = 1; // criticals
2426
25void setLoggingLevel(int level)27void setLoggingLevel(int level)
26{28{
29 if (level >= 1) {
30 QLoggingCategory::setFilterRules("signon.warning=true");
31 if (level >= 2) {
32 QLoggingCategory::setFilterRules("signon.debug=true");
33 }
34 }
27 appLoggingLevel = level;35 appLoggingLevel = level;
28}36}
2937
3038
=== modified file 'src/debug.h'
--- src/debug.h 2011-11-23 07:57:45 +0000
+++ src/debug.h 2016-11-04 09:26:22 +0000
@@ -20,21 +20,13 @@
20#ifndef SIGNON_UI_DEBUG_H20#ifndef SIGNON_UI_DEBUG_H
21#define SIGNON_UI_DEBUG_H21#define SIGNON_UI_DEBUG_H
2222
23#include <QDebug>23#include <QLoggingCategory>
24
25Q_DECLARE_LOGGING_CATEGORY(DBG_SIGNON_UI)
2426
25/* 0 - fatal, 1 - critical(default), 2 - info/debug */27/* 0 - fatal, 1 - critical(default), 2 - info/debug */
26extern int appLoggingLevel;28extern int appLoggingLevel;
2729
28static inline bool debugEnabled()
29{
30 return appLoggingLevel >= 2;
31}
32
33static inline bool criticalsEnabled()
34{
35 return appLoggingLevel >= 1;
36}
37
38static inline int loggingLevel()30static inline int loggingLevel()
39{31{
40 return appLoggingLevel;32 return appLoggingLevel;
@@ -42,15 +34,10 @@
4234
43void setLoggingLevel(int level);35void setLoggingLevel(int level);
4436
45#ifdef DEBUG_ENABLED37#define TRACE() \
46 #define TRACE() \38 qCDebug(DBG_SIGNON_UI) << __FILE__ << __LINE__ << __func__
47 if (debugEnabled()) qDebug() << __FILE__ << __LINE__ << __func__39#define BLAME() \
48 #define BLAME() \40 qCWarning(DBG_SIGNON_UI) << __FILE__ << __LINE__ << __func__
49 if (criticalsEnabled()) qCritical() << __FILE__ << __LINE__ << __func__
50#else
51 #define TRACE() while (0) qDebug()
52 #define BLAME() while (0) qDebug()
53#endif
5441
55#endif // SIGNON_UI_DEBUG_H42#endif // SIGNON_UI_DEBUG_H
5643
5744
=== modified file 'src/qquick-dialog.cpp'
--- src/qquick-dialog.cpp 2016-04-04 11:51:22 +0000
+++ src/qquick-dialog.cpp 2016-11-04 09:26:22 +0000
@@ -18,9 +18,6 @@
18 * with this program. If not, see <http://www.gnu.org/licenses/>.18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */19 */
2020
21#define HAS_FOREIGN_QWINDOW (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) || \
22 defined(FORCE_FOREIGN_QWINDOW))
23
24#include "qquick-dialog.h"21#include "qquick-dialog.h"
2522
26#include "debug.h"23#include "debug.h"
@@ -39,22 +36,6 @@
39{36{
40}37}
4138
42void Dialog::show(WId parent, ShowMode mode)
43{
44 create();
45#if HAS_FOREIGN_QWINDOW
46 if (mode != TopLevel) {
47 QWindow *parentWindow = QWindow::fromWinId(parent);
48 if (mode == Transient) {
49 setTransientParent(parentWindow);
50 } else if (mode == Embedded) {
51 setParent(parentWindow);
52 }
53 }
54#endif
55 QQuickView::show();
56}
57
58void Dialog::accept()39void Dialog::accept()
59{40{
60 done(Dialog::Accepted);41 done(Dialog::Accepted);
6142
=== modified file 'src/qquick-dialog.h'
--- src/qquick-dialog.h 2014-04-07 12:39:16 +0000
+++ src/qquick-dialog.h 2016-11-04 09:26:22 +0000
@@ -45,8 +45,6 @@
45 explicit Dialog(QWindow *parent = 0);45 explicit Dialog(QWindow *parent = 0);
46 ~Dialog();46 ~Dialog();
4747
48 void show(WId parent, ShowMode mode);
49
50public Q_SLOTS:48public Q_SLOTS:
51 void accept();49 void accept();
52 void reject();50 void reject();
5351
=== modified file 'src/request.cpp'
--- src/request.cpp 2016-04-06 08:00:59 +0000
+++ src/request.cpp 2016-11-04 09:26:22 +0000
@@ -18,7 +18,6 @@
18 * with this program. If not, see <http://www.gnu.org/licenses/>.18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */19 */
2020
21#define HAS_XEMBED (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
22#define HAS_FOREIGN_QWINDOW (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) || \21#define HAS_FOREIGN_QWINDOW (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) || \
23 defined(FORCE_FOREIGN_QWINDOW))22 defined(FORCE_FOREIGN_QWINDOW))
24#include "request.h"23#include "request.h"
@@ -29,9 +28,6 @@
29#include "browser-request.h"28#include "browser-request.h"
30#include "debug.h"29#include "debug.h"
31#include "dialog-request.h"30#include "dialog-request.h"
32#if HAS_XEMBED
33#include "embed-manager.h"
34#endif
35#include "errors.h"31#include "errors.h"
36#include "indicator-service.h"32#include "indicator-service.h"
37#ifndef UNIT_TESTS33#ifndef UNIT_TESTS
@@ -81,13 +77,10 @@
81 }77 }
8278
83private Q_SLOTS:79private Q_SLOTS:
84#if HAS_XEMBED
85 void onEmbedError();
86#endif
87 void onIndicatorCallFinished(QDBusPendingCallWatcher *watcher);80 void onIndicatorCallFinished(QDBusPendingCallWatcher *watcher);
8881
89private:82private:
90 void setWidget(QWidget *widget);83 bool setWindow(QWindow *window);
91 Accounts::Account *findAccount();84 Accounts::Account *findAccount();
92 bool dispatchToIndicator();85 bool dispatchToIndicator();
93 void onIndicatorCallSucceeded();86 void onIndicatorCallSucceeded();
@@ -100,7 +93,7 @@
100 QVariantMap m_clientData;93 QVariantMap m_clientData;
101 bool m_inProgress;94 bool m_inProgress;
102 Accounts::Manager *m_accountManager;95 Accounts::Manager *m_accountManager;
103 QPointer<QWidget> m_widget;96 QPointer<QWindow> m_window;
104};97};
10598
106} // namespace99} // namespace
@@ -116,7 +109,7 @@
116 m_parameters(parameters),109 m_parameters(parameters),
117 m_inProgress(false),110 m_inProgress(false),
118 m_accountManager(0),111 m_accountManager(0),
119 m_widget(0)112 m_window(0)
120{113{
121 if (parameters.contains(SSOUI_KEY_CLIENT_DATA)) {114 if (parameters.contains(SSOUI_KEY_CLIENT_DATA)) {
122 QVariant variant = parameters[SSOUI_KEY_CLIENT_DATA];115 QVariant variant = parameters[SSOUI_KEY_CLIENT_DATA];
@@ -130,82 +123,42 @@
130{123{
131}124}
132125
133void RequestPrivate::setWidget(QWidget *widget)126bool RequestPrivate::setWindow(QWindow *window)
134{127{
135 if (m_widget != 0) {128 if (m_window != 0) {
136 BLAME() << "Widget already set";129 BLAME() << "Widget already set";
137 return;130 return false;
138 }131 }
139132
140 m_widget = widget;133 m_window = window;
141134
142#if HAS_XEMBED
143 if (embeddedUi() && windowId() != 0) {
144 TRACE() << "Requesting widget embedding";
145 QX11EmbedWidget *embed =
146 EmbedManager::instance()->widgetFor(windowId());
147 QObject::connect(embed, SIGNAL(error(QX11EmbedWidget::Error)),
148 this, SLOT(onEmbedError()),
149 Qt::UniqueConnection);
150 QObject::connect(embed, SIGNAL(containerClosed()),
151 widget, SLOT(close()));
152 QVBoxLayout *layout = new QVBoxLayout;
153 layout->addWidget(widget);
154 widget->show();
155 /* Delete any previous layout */
156 delete embed->layout();
157 embed->setLayout(layout);
158 embed->show();
159 return;
160 }
161#endif
162#if HAS_FOREIGN_QWINDOW135#if HAS_FOREIGN_QWINDOW
163 if (embeddedUi() && windowId() != 0) {136 if (embeddedUi() && windowId() != 0) {
164 TRACE() << "Requesting window embedding";137 TRACE() << "Requesting window embedding";
165 QWindow *host = QWindow::fromWinId(windowId());138 QWindow *host = QWindow::fromWinId(windowId());
166 widget->show();139 window->show();
167 widget->windowHandle()->setParent(host);140 window->setParent(host);
168 return;141 return true;
169 }142 }
170#endif143#endif
171144
172 /* If the window has no parent and the webcredentials indicator service is145 /* If the window has no parent and the webcredentials indicator service is
173 * up, dispatch the request to it. */146 * up, dispatch the request to it. */
174 if (windowId() == 0 && dispatchToIndicator()) {147 if (windowId() == 0 && dispatchToIndicator()) {
175 return;148 return false;
176 }149 }
177150
178 widget->setWindowModality(Qt::WindowModal);151 window->setModality(Qt::WindowModal);
179 widget->show();152 window->show();
180#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
181 if (windowId() != 0) {
182 TRACE() << "Setting" << widget->effectiveWinId() << "transient for" << windowId();
183 XSetTransientForHint(QX11Info::display(),
184 widget->effectiveWinId(),
185 windowId());
186 }
187#endif
188#if HAS_FOREIGN_QWINDOW153#if HAS_FOREIGN_QWINDOW
189 if (windowId() != 0) {154 if (windowId() != 0) {
190 TRACE() << "Requesting window reparenting";155 TRACE() << "Requesting window reparenting";
191 QWindow *parent = QWindow::fromWinId(windowId());156 QWindow *parent = QWindow::fromWinId(windowId());
192 widget->windowHandle()->setTransientParent(parent);157 window->setTransientParent(parent);
193 }158 }
194#endif159#endif
195}160 return true;
196161}
197#if HAS_XEMBED
198void RequestPrivate::onEmbedError()
199{
200 Q_Q(Request);
201
202 QX11EmbedWidget *embed = qobject_cast<QX11EmbedWidget*>(sender());
203 TRACE() << "Embed error:" << embed->error();
204
205 q->fail(SIGNON_UI_ERROR_EMBEDDING_FAILED,
206 QString("Embedding signon UI failed: %1").arg(embed->error()));
207}
208#endif
209162
210Accounts::Account *RequestPrivate::findAccount()163Accounts::Account *RequestPrivate::findAccount()
211{164{
@@ -285,8 +238,8 @@
285 if (watcher->isError()) {238 if (watcher->isError()) {
286 /* if the notification could not be delivered to the indicator, show239 /* if the notification could not be delivered to the indicator, show
287 * the widget. */240 * the widget. */
288 if (m_widget != 0)241 if (m_window != 0)
289 m_widget->show();242 m_window->show();
290 } else {243 } else {
291 onIndicatorCallSucceeded();244 onIndicatorCallSucceeded();
292 }245 }
@@ -352,7 +305,15 @@
352void Request::setWidget(QWidget *widget)305void Request::setWidget(QWidget *widget)
353{306{
354 Q_D(Request);307 Q_D(Request);
355 d->setWidget(widget);308 if (d->setWindow(widget->windowHandle())) {
309 widget->show();
310 }
311}
312
313void Request::setWindow(QWindow *window)
314{
315 Q_D(Request);
316 d->setWindow(window);
356}317}
357318
358uint Request::identity() const319uint Request::identity() const
359320
=== modified file 'src/request.h'
--- src/request.h 2013-04-19 11:13:03 +0000
+++ src/request.h 2016-11-04 09:26:22 +0000
@@ -70,6 +70,7 @@
70 QObject *parent = 0);70 QObject *parent = 0);
7171
72 void setWidget(QWidget *widget);72 void setWidget(QWidget *widget);
73 void setWindow(QWindow *window);
7374
74protected Q_SLOTS:75protected Q_SLOTS:
75 void fail(const QString &name, const QString &message);76 void fail(const QString &name, const QString &message);
7677
=== modified file 'src/ubuntu-browser-request.cpp'
--- src/ubuntu-browser-request.cpp 2016-04-04 10:26:46 +0000
+++ src/ubuntu-browser-request.cpp 2016-11-04 09:26:22 +0000
@@ -190,7 +190,7 @@
190190
191void UbuntuBrowserRequestPrivate::onLoadFinished(bool ok)191void UbuntuBrowserRequestPrivate::onLoadFinished(bool ok)
192{192{
193 Q_Q(const UbuntuBrowserRequest);193 Q_Q(UbuntuBrowserRequest);
194194
195 TRACE() << "Load finished" << ok;195 TRACE() << "Load finished" << ok;
196196
@@ -201,9 +201,7 @@
201201
202 if (!m_dialog->isVisible()) {202 if (!m_dialog->isVisible()) {
203 if (m_responseUrl.isEmpty()) {203 if (m_responseUrl.isEmpty()) {
204 Dialog::ShowMode mode = (q->windowId() == 0) ? Dialog::TopLevel :204 q->setWindow(m_dialog);
205 q->embeddedUi() ? Dialog::Embedded : Dialog::Transient;
206 m_dialog->show(q->windowId(), mode);
207 } else {205 } else {
208 onFinished();206 onFinished();
209 }207 }

Subscribers

People subscribed via source and target branches

to all changes: