Merge lp:~osomon/webbrowser-app/remove-qquickshortcut-source into lp:webbrowser-app/staging

Proposed by Olivier Tilloy on 2017-04-04
Status: Merged
Approved by: Florian Boucault on 2017-04-05
Approved revision: 1644
Merged at revision: 1643
Proposed branch: lp:~osomon/webbrowser-app/remove-qquickshortcut-source
Merge into: lp:webbrowser-app/staging
Diff against target: 535 lines (+9/-406)
9 files modified
README (+1/-1)
debian/control (+2/-3)
src/app/CMakeLists.txt (+1/-3)
src/app/browserapplication.cpp (+1/-3)
src/app/qquickshortcut.cpp (+0/-283)
src/app/qquickshortcut_p.h (+0/-109)
src/app/webbrowser/Browser.qml (+1/-1)
src/app/webbrowser/webbrowser-app.qml (+1/-1)
src/app/webcontainer/WebApp.qml (+2/-2)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/remove-qquickshortcut-source
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team 2017-04-04 Pending
Review via email: mp+321882@code.launchpad.net

Commit message

Use the Shortcut QML type provided by QtQuick 2.5 instead of embedding a source copy.
This is okay now since the lowest target is xenial+overlay, which has Qt 5.6.

To post a comment you must log in.
1644. By Olivier Tilloy on 2017-04-05

Updated README.

Florian Boucault (fboucault) wrote :

Looks good. Only one question, qml-module-qtquick2 in Build-Depends: shouldn't it be bumped also? For the tests perhaps?

Olivier Tilloy (osomon) wrote :

The QML unit tests don't test keyboard shortcuts (they do test key presses, but no Shortcut item is involved). So the build dependency doesn't need to be bumped.

This will change once the qmltests branch lands though.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README'
--- README 2016-03-15 16:03:19 +0000
+++ README 2017-04-05 06:09:00 +0000
@@ -1,6 +1,6 @@
1webbrowser-app is a lightweight web browser tailored for Ubuntu,1webbrowser-app is a lightweight web browser tailored for Ubuntu,
2based on the Oxide web engine and using the Ubuntu UI components.2based on the Oxide web engine and using the Ubuntu UI components.
3It requires Qt 5.4 to build and run.3It requires Qt 5.5 to build and run.
44
55
6= Building =6= Building =
77
=== modified file 'debian/control'
--- debian/control 2017-03-07 20:13:27 +0000
+++ debian/control 2017-04-05 06:09:00 +0000
@@ -25,7 +25,6 @@
25 qt5-default,25 qt5-default,
26 qtbase5-dev (>= 5.4),26 qtbase5-dev (>= 5.4),
27 qtbase5-dev-tools,27 qtbase5-dev-tools,
28 qtbase5-private-dev,
29 qtdeclarative5-dev,28 qtdeclarative5-dev,
30 qtdeclarative5-ubuntu-ui-extras0.2,29 qtdeclarative5-ubuntu-ui-extras0.2,
31 qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.3) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.3),30 qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.3) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.3),
@@ -48,7 +47,7 @@
48 libqt5sql5-sqlite,47 libqt5sql5-sqlite,
49 qml-module-qt-labs-folderlistmodel,48 qml-module-qt-labs-folderlistmodel,
50 qml-module-qt-labs-settings,49 qml-module-qt-labs-settings,
51 qml-module-qtquick2 (>= 5.4),50 qml-module-qtquick2 (>= 5.5),
52 qml-module-qtquick-layouts,51 qml-module-qtquick-layouts,
53 qml-module-qtquick-window2 (>= 5.3),52 qml-module-qtquick-window2 (>= 5.3),
54 qml-module-qtsysteminfo,53 qml-module-qtsysteminfo,
@@ -75,7 +74,7 @@
75 fonts-liberation,74 fonts-liberation,
76 liboxideqt-qmlplugin (>= 1.19),75 liboxideqt-qmlplugin (>= 1.19),
77 libqt5sql5-sqlite,76 libqt5sql5-sqlite,
78 qml-module-qtquick2 (>= 5.4),77 qml-module-qtquick2 (>= 5.5),
79 qml-module-qtquick-window2 (>= 5.3),78 qml-module-qtquick-window2 (>= 5.3),
80 qml-module-ubuntu-onlineaccounts,79 qml-module-ubuntu-onlineaccounts,
81 qml-module-ubuntu-web (= ${binary:Version}),80 qml-module-ubuntu-web (= ${binary:Version}),
8281
=== modified file 'src/app/CMakeLists.txt'
--- src/app/CMakeLists.txt 2016-10-31 10:53:51 +0000
+++ src/app/CMakeLists.txt 2017-04-05 06:09:00 +0000
@@ -24,13 +24,11 @@
24 mime-database.cpp24 mime-database.cpp
25 session-storage.cpp25 session-storage.cpp
26 single-instance-manager.cpp26 single-instance-manager.cpp
27 qquickshortcut.cpp
28)27)
2928
30add_library(${COMMONLIB} STATIC ${COMMONLIB_SRC})29add_library(${COMMONLIB} STATIC ${COMMONLIB_SRC})
3130
32include_directories(${LIBAPPARMOR_INCLUDE_DIRS}31include_directories(${LIBAPPARMOR_INCLUDE_DIRS})
33 ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
34target_link_libraries(${COMMONLIB}32target_link_libraries(${COMMONLIB}
35 Qt5::Core33 Qt5::Core
36 Qt5::Gui34 Qt5::Gui
3735
=== modified file 'src/app/browserapplication.cpp'
--- src/app/browserapplication.cpp 2016-10-31 10:53:51 +0000
+++ src/app/browserapplication.cpp 2017-04-05 06:09:00 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2013-2016 Canonical Ltd.2 * Copyright 2013-2017 Canonical Ltd.
3 *3 *
4 * This file is part of webbrowser-app.4 * This file is part of webbrowser-app.
5 *5 *
@@ -38,7 +38,6 @@
38#include "favicon-fetcher.h"38#include "favicon-fetcher.h"
39#include "meminfo.h"39#include "meminfo.h"
40#include "mime-database.h"40#include "mime-database.h"
41#include "qquickshortcut_p.h"
42#include "session-storage.h"41#include "session-storage.h"
4342
44BrowserApplication::BrowserApplication(int& argc, char** argv)43BrowserApplication::BrowserApplication(int& argc, char** argv)
@@ -176,7 +175,6 @@
176 qmlRegisterSingletonType<MemInfo>(uri, 0, 1, "MemInfo", MemInfo_singleton_factory);175 qmlRegisterSingletonType<MemInfo>(uri, 0, 1, "MemInfo", MemInfo_singleton_factory);
177 qmlRegisterSingletonType<MimeDatabase>(uri, 0, 1, "MimeDatabase", MimeDatabase_singleton_factory);176 qmlRegisterSingletonType<MimeDatabase>(uri, 0, 1, "MimeDatabase", MimeDatabase_singleton_factory);
178 qmlRegisterType<SessionStorage>(uri, 0, 1, "SessionStorage");177 qmlRegisterType<SessionStorage>(uri, 0, 1, "SessionStorage");
179 qmlRegisterType<QQuickShortcut>(uri, 0, 1, "Shortcut");
180178
181 m_engine = new QQmlEngine;179 m_engine = new QQmlEngine;
182 connect(m_engine, SIGNAL(quit()), SLOT(quit()));180 connect(m_engine, SIGNAL(quit()), SLOT(quit()));
183181
=== removed file 'src/app/qquickshortcut.cpp'
--- src/app/qquickshortcut.cpp 2016-03-29 11:01:18 +0000
+++ src/app/qquickshortcut.cpp 1970-01-01 00:00:00 +0000
@@ -1,283 +0,0 @@
1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtQuick module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#include "qquickshortcut_p.h"
35
36#include <QtQuick/qquickitem.h>
37#include <QtQuick/qquickwindow.h>
38#include <QtGui/private/qguiapplication_p.h>
39
40QT_BEGIN_NAMESPACE
41
42/*!
43 \qmltype Shortcut
44 \instantiates QQuickShortcut
45 \inqmlmodule QtQuick
46 \since 5.5
47 \ingroup qtquick-input
48 \brief Provides keyboard shortcuts
49
50 The Shortcut type provides a way of handling keyboard shortcuts. The shortcut can
51 be set to one of the \l{QKeySequence::StandardKey}{standard keyboard shortcuts},
52 or it can be described with a string containing a sequence of up to four key
53 presses that are needed to \l{Shortcut::activated}{activate} the shortcut.
54
55 \qml
56 Item {
57 id: view
58
59 property int currentIndex
60
61 Shortcut {
62 sequence: StandardKey.NextChild
63 onActivated: view.currentIndex++
64 }
65 }
66 \endqml
67
68 \sa Keys
69*/
70
71/*! \qmlsignal QtQuick::Shortcut::activated()
72
73 This signal is emitted when the shortcut is activated.
74
75 The corresponding handler is \c onActivated.
76*/
77
78/*! \qmlsignal QtQuick::Shortcut::activatedAmbiguously()
79
80 This signal is emitted when the shortcut is activated ambigously,
81 meaning that it matches the start of more than one shortcut.
82
83 The corresponding handler is \c onActivatedAmbiguously.
84*/
85
86QQuickShortcut::QQuickShortcut(QObject *parent) : QObject(parent), m_id(0),
87 m_enabled(true), m_completed(false), m_autorepeat(true), m_context(Qt::WindowShortcut)
88{
89}
90
91QQuickShortcut::~QQuickShortcut()
92{
93 ungrabShortcut();
94}
95
96/*!
97 \qmlproperty keysequence QtQuick::Shortcut::sequence
98
99 This property holds the shortcut's key sequence. The key sequence can be set
100 to one of the \l{QKeySequence::StandardKey}{standard keyboard shortcuts}, or
101 it can be described with a string containing a sequence of up to four key
102 presses that are needed to \l{Shortcut::activated}{activate} the shortcut.
103
104 The default value is an empty key sequence.
105
106 \qml
107 Shortcut {
108 sequence: "Ctrl+E,Ctrl+W"
109 onActivated: edit.wrapMode = TextEdit.Wrap
110 }
111 \endqml
112*/
113QVariant QQuickShortcut::sequence() const
114{
115 return m_sequence;
116}
117
118void QQuickShortcut::setSequence(const QVariant &sequence)
119{
120 if (sequence == m_sequence)
121 return;
122
123 QKeySequence shortcut;
124 if (sequence.type() == QVariant::Int)
125 shortcut = QKeySequence(static_cast<QKeySequence::StandardKey>(sequence.toInt()));
126 else
127 shortcut = QKeySequence::fromString(sequence.toString());
128
129 grabShortcut(shortcut, m_context);
130
131 m_sequence = sequence;
132 m_shortcut = shortcut;
133 emit sequenceChanged();
134}
135
136/*!
137 \qmlproperty bool QtQuick::Shortcut::enabled
138
139 This property holds whether the shortcut is enabled.
140
141 The default value is \c true.
142*/
143bool QQuickShortcut::isEnabled() const
144{
145 return m_enabled;
146}
147
148void QQuickShortcut::setEnabled(bool enabled)
149{
150 if (enabled == m_enabled)
151 return;
152
153 if (m_id)
154 QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enabled, m_id, this);
155
156 m_enabled = enabled;
157 emit enabledChanged();
158}
159
160/*!
161 \qmlproperty bool QtQuick::Shortcut::autoRepeat
162
163 This property holds whether the shortcut can auto repeat.
164
165 The default value is \c true.
166*/
167bool QQuickShortcut::autoRepeat() const
168{
169 return m_autorepeat;
170}
171
172void QQuickShortcut::setAutoRepeat(bool repeat)
173{
174 if (repeat == m_autorepeat)
175 return;
176
177 if (m_id)
178 QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(repeat, m_id, this);
179
180 m_autorepeat = repeat;
181 emit autoRepeatChanged();
182}
183
184/*!
185 \qmlproperty enumeration QtQuick::Shortcut::context
186
187 This property holds the \l{Qt::ShortcutContext}{shortcut context}.
188
189 Supported values are:
190 \list
191 \li \c Qt.WindowShortcut (default) - The shortcut is active when its parent item is in an active top-level window.
192 \li \c Qt.ApplicationShortcut - The shortcut is active when one of the application's windows are active.
193 \endlist
194
195 \qml
196 Shortcut {
197 sequence: StandardKey.Quit
198 context: Qt.ApplicationShortcut
199 onActivated: Qt.quit()
200 }
201 \endqml
202*/
203Qt::ShortcutContext QQuickShortcut::context() const
204{
205 return m_context;
206}
207
208void QQuickShortcut::setContext(Qt::ShortcutContext context)
209{
210 if (context == m_context)
211 return;
212
213 grabShortcut(m_shortcut, context);
214
215 m_context = context;
216 emit contextChanged();
217}
218
219void QQuickShortcut::classBegin()
220{
221}
222
223void QQuickShortcut::componentComplete()
224{
225 m_completed = true;
226 grabShortcut(m_shortcut, m_context);
227}
228
229bool QQuickShortcut::event(QEvent *event)
230{
231 if (m_enabled && event->type() == QEvent::Shortcut) {
232 QShortcutEvent *se = static_cast<QShortcutEvent *>(event);
233 if (se->shortcutId() == m_id && se->key() == m_shortcut){
234 if (se->isAmbiguous())
235 emit activatedAmbiguously();
236 else
237 emit activated();
238 return true;
239 }
240 }
241 return false;
242}
243
244static bool qQuickShortcutContextMatcher(QObject *obj, Qt::ShortcutContext context)
245{
246 switch (context) {
247 case Qt::ApplicationShortcut:
248 return true;
249 case Qt::WindowShortcut:
250 while (obj && !obj->isWindowType()) {
251 obj = obj->parent();
252 if (QQuickItem *item = qobject_cast<QQuickItem *>(obj))
253 obj = item->window();
254 }
255 return obj && obj == QGuiApplication::focusWindow();
256 default:
257 return false;
258 }
259}
260
261void QQuickShortcut::grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context)
262{
263 ungrabShortcut();
264
265 if (m_completed && !sequence.isEmpty()) {
266 QGuiApplicationPrivate *pApp = QGuiApplicationPrivate::instance();
267 m_id = pApp->shortcutMap.addShortcut(this, sequence, context, qQuickShortcutContextMatcher);
268 if (!m_enabled)
269 pApp->shortcutMap.setShortcutEnabled(false, m_id, this);
270 if (!m_autorepeat)
271 pApp->shortcutMap.setShortcutAutoRepeat(false, m_id, this);
272 }
273}
274
275void QQuickShortcut::ungrabShortcut()
276{
277 if (m_id) {
278 QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(m_id, this);
279 m_id = 0;
280 }
281}
282
283QT_END_NAMESPACE
2840
=== removed file 'src/app/qquickshortcut_p.h'
--- src/app/qquickshortcut_p.h 2016-03-29 11:01:18 +0000
+++ src/app/qquickshortcut_p.h 1970-01-01 00:00:00 +0000
@@ -1,109 +0,0 @@
1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtQuick module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#ifndef QQUICKSHORTCUT_P_H
35#define QQUICKSHORTCUT_P_H
36
37//
38// W A R N I N G
39// -------------
40//
41// This file is not part of the Qt API. It exists purely as an
42// implementation detail. This header file may change from version to
43// version without notice, or even be removed.
44//
45// We mean it.
46//
47
48#include <QtCore/qobject.h>
49#include <QtCore/qvariant.h>
50#include <QtGui/qkeysequence.h>
51#include <QtQml/qqmlparserstatus.h>
52
53QT_BEGIN_NAMESPACE
54
55class QQuickShortcut : public QObject, public QQmlParserStatus
56{
57 Q_OBJECT
58 Q_INTERFACES(QQmlParserStatus)
59 Q_PROPERTY(QVariant sequence READ sequence WRITE setSequence NOTIFY sequenceChanged FINAL)
60 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL)
61 Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL)
62 Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext NOTIFY contextChanged FINAL)
63
64public:
65 explicit QQuickShortcut(QObject *parent = Q_NULLPTR);
66 ~QQuickShortcut();
67
68 QVariant sequence() const;
69 void setSequence(const QVariant &sequence);
70
71 bool isEnabled() const;
72 void setEnabled(bool enabled);
73
74 bool autoRepeat() const;
75 void setAutoRepeat(bool repeat);
76
77 Qt::ShortcutContext context() const;
78 void setContext(Qt::ShortcutContext context);
79
80Q_SIGNALS:
81 void sequenceChanged();
82 void enabledChanged();
83 void autoRepeatChanged();
84 void contextChanged();
85
86 void activated();
87 void activatedAmbiguously();
88
89protected:
90 void classBegin() Q_DECL_OVERRIDE;
91 void componentComplete() Q_DECL_OVERRIDE;
92 bool event(QEvent *event) Q_DECL_OVERRIDE;
93
94 void grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context);
95 void ungrabShortcut();
96
97private:
98 int m_id;
99 bool m_enabled;
100 bool m_completed;
101 bool m_autorepeat;
102 QKeySequence m_shortcut;
103 Qt::ShortcutContext m_context;
104 QVariant m_sequence;
105};
106
107QT_END_NAMESPACE
108
109#endif // QQUICKSHORTCUT_P_H
1100
=== modified file 'src/app/webbrowser/Browser.qml'
--- src/app/webbrowser/Browser.qml 2017-03-28 11:20:46 +0000
+++ src/app/webbrowser/Browser.qml 2017-04-05 06:09:00 +0000
@@ -16,7 +16,7 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */17 */
1818
19import QtQuick 2.419import QtQuick 2.5
20import QtQuick.Window 2.220import QtQuick.Window 2.2
21import QtSystemInfo 5.521import QtSystemInfo 5.5
22import Qt.labs.settings 1.022import Qt.labs.settings 1.0
2323
=== modified file 'src/app/webbrowser/webbrowser-app.qml'
--- src/app/webbrowser/webbrowser-app.qml 2017-02-23 09:53:09 +0000
+++ src/app/webbrowser/webbrowser-app.qml 2017-04-05 06:09:00 +0000
@@ -16,7 +16,7 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */17 */
1818
19import QtQuick 2.419import QtQuick 2.5
20import QtQuick.Window 2.220import QtQuick.Window 2.2
21import Qt.labs.settings 1.021import Qt.labs.settings 1.0
22import Ubuntu.Components 1.322import Ubuntu.Components 1.3
2323
=== modified file 'src/app/webcontainer/WebApp.qml'
--- src/app/webcontainer/WebApp.qml 2016-12-19 16:44:04 +0000
+++ src/app/webcontainer/WebApp.qml 2017-04-05 06:09:00 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2013-2016 Canonical Ltd.2 * Copyright 2013-2017 Canonical Ltd.
3 *3 *
4 * This file is part of webbrowser-app.4 * This file is part of webbrowser-app.
5 *5 *
@@ -16,7 +16,7 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */17 */
1818
19import QtQuick 2.419import QtQuick 2.5
20import webbrowsercommon.private 0.120import webbrowsercommon.private 0.1
21import com.canonical.Oxide 1.19 as Oxide21import com.canonical.Oxide 1.19 as Oxide
22import Ubuntu.Components 1.322import Ubuntu.Components 1.3

Subscribers

People subscribed via source and target branches