diff options
author | Jeremy Katz <jeremy@panix.com> | 2016-06-22 12:12:06 -0700 |
---|---|---|
committer | Jeremy Katz <jeremy@panix.com> | 2016-07-20 09:49:51 +0000 |
commit | a717da9bb7e7e5e1b84008ba59559ce6d8d5dbcc (patch) | |
tree | ad7739aee13901e37f00b1680ed252c6b544282c | |
parent | bc7d95510fd509535b2bfa3c715937b3c3d56507 (diff) |
Enable loading styles from multiple import paths
Import was previously allowed from two locations:
* qrc:/QtQuick/VirtualKeyboard/content/styles/
* The first import path containing
QtQuick/VirtualKeyboard/Styles/
This prevents an application-supplied style outside of
these locations from being used, even if the style name is unique.
[ChangeLog] Added support for styles in any Qml import path
under the directory QtQuick/VirtualKeyboard/Styles/<style>
Change-Id: Ie6034709182f182efacb0317e49d095d51ced5a6
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf | 2 | ||||
-rw-r--r-- | src/virtualkeyboard/doc/src/technical-guide.qdoc | 4 | ||||
-rw-r--r-- | src/virtualkeyboard/virtualkeyboardsettings.cpp | 5 | ||||
-rw-r--r-- | tests/auto/auto.pro | 1 | ||||
-rw-r--r-- | tests/auto/styles/data/QtQuick/VirtualKeyboard/Styles/test/style.qml | 36 | ||||
-rw-r--r-- | tests/auto/styles/data/tst_styles.qml | 61 | ||||
-rw-r--r-- | tests/auto/styles/styles.pro | 23 | ||||
-rw-r--r-- | tests/auto/styles/tst_styles.cpp | 36 |
8 files changed, 162 insertions, 6 deletions
diff --git a/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf b/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf index 57042810..17bb5ad2 100644 --- a/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf +++ b/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf @@ -15,7 +15,7 @@ exampledirs += ../../../examples/virtualkeyboard \ examplesinstallpath = virtualkeyboard imagedirs += images -depends += qtcore qtgui qtquick +depends += qtcore qtgui qtqml qtquick qhp.projects = QtVirtualKeyboard diff --git a/src/virtualkeyboard/doc/src/technical-guide.qdoc b/src/virtualkeyboard/doc/src/technical-guide.qdoc index 26e95227..7e279bcd 100644 --- a/src/virtualkeyboard/doc/src/technical-guide.qdoc +++ b/src/virtualkeyboard/doc/src/technical-guide.qdoc @@ -577,7 +577,9 @@ style name, the virtual keyboard falls back in the default built-in style. \section2 Adding Custom Styles The process of creating a new style begins by creating a new subdirectory -for the style in the virtual keyboard \e Styles directory. The directory +for the style in a QML import path under the URL-based directory structure +QtQuick/VirtualKeyboard/Styles/. See \l {QML Import Path} +for information about QML import paths. The directory name can not contain spaces or special characters other than underscore. Also, the directory name can not be the same as one of the built-in style, which currently includes "default" and "retro". diff --git a/src/virtualkeyboard/virtualkeyboardsettings.cpp b/src/virtualkeyboard/virtualkeyboardsettings.cpp index 1bc87583..479c8d43 100644 --- a/src/virtualkeyboard/virtualkeyboardsettings.cpp +++ b/src/virtualkeyboard/virtualkeyboardsettings.cpp @@ -71,10 +71,7 @@ public: for (int i = importPathList.size() - 1; i >= 0; --i) { const QString stylesPath = importPathList.at(i) + QStringLiteral("/QtQuick/VirtualKeyboard/Styles/"); - if (QFileInfo(stylesPath).isDir()) { - styleImportPathList += stylesPath; - break; - } + styleImportPathList += stylesPath; } for (const QString &styleImportPath : qAsConst(styleImportPathList)) { diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 47f3c50a..508e6f97 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -2,4 +2,5 @@ TEMPLATE = subdirs SUBDIRS += \ inputpanel \ + styles \ diff --git a/tests/auto/styles/data/QtQuick/VirtualKeyboard/Styles/test/style.qml b/tests/auto/styles/data/QtQuick/VirtualKeyboard/Styles/test/style.qml new file mode 100644 index 00000000..efb8e3bd --- /dev/null +++ b/tests/auto/styles/data/QtQuick/VirtualKeyboard/Styles/test/style.qml @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Jeremy Katz +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard.Styles 2.1 + +KeyboardStyle { + +} diff --git a/tests/auto/styles/data/tst_styles.qml b/tests/auto/styles/data/tst_styles.qml new file mode 100644 index 00000000..0b4d3b37 --- /dev/null +++ b/tests/auto/styles/data/tst_styles.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Jeremy Katz +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtTest 1.0 +import QtQuick 2.0 +import QtQuick.VirtualKeyboard.Settings 2.0 + +Item { + + TestCase { + id: testcase + name: "tst_styles" + + function test_style_data() { + return [ + { tag: "default", result: "default"}, + { tag: "retro", result: "retro"}, // in-source alternate style + { tag: "test", result: "test"} // out-of-source alternate style + ]; + } + + function test_style(data) { + VirtualKeyboardSettings.styleName = data.tag; + compare(VirtualKeyboardSettings.styleName, data.result, + "Failed setting VirtualKeyboardSettings.styleName to " + data.result); + } + + function test_unknownStyle() { + var previous = VirtualKeyboardSettings.styleName; + VirtualKeyboardSettings.styleName = "bogus"; + compare(VirtualKeyboardSettings.styleName, previous, + "Unknown style names should be ignored"); + } + } +} diff --git a/tests/auto/styles/styles.pro b/tests/auto/styles/styles.pro new file mode 100644 index 00000000..eda24717 --- /dev/null +++ b/tests/auto/styles/styles.pro @@ -0,0 +1,23 @@ +TEMPLATE = app +TARGET = tst_styles + +QT += testlib +CONFIG += qmltestcase console + +static { + QT += svg + QTPLUGIN += qtvirtualkeyboardplugin +} + +SOURCES += $$PWD/tst_styles.cpp + +TESTDATA = $$PWD/data/* +DEFINES += TESTDATA_DIR=\\\"$$_PRO_FILE_PWD_/data\\\" + +OTHER_FILES += \ + $$PWD/data/tst_styles.qml \ + +DISTFILES += \ + data/tst_styles.qml \ + data/QtQuick/VirtualKeyboard/Styles/test/style.qml \ + diff --git a/tests/auto/styles/tst_styles.cpp b/tests/auto/styles/tst_styles.cpp new file mode 100644 index 00000000..3d2a329f --- /dev/null +++ b/tests/auto/styles/tst_styles.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Jeremy Katz +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQuickTest/quicktest.h> +#include <QByteArray> + +static bool s_configImport = qputenv("QML2_IMPORT_PATH", TESTDATA_DIR); +static bool s_configIM = qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); + +QUICK_TEST_MAIN(styles) |