diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2013-08-13 11:54:26 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2013-08-19 18:55:35 +0200 |
commit | 6713e9266b5df317109f1645ac516346a6f9a44c (patch) | |
tree | 1bc81fa70dc67f7c5df5551fdb2813d3400bf04d /examples/quick | |
parent | 1c7cfb2c890243a59aff8583d3fc5cbdf476ca7f (diff) |
Prepare the directories to have more examples included.
This also ajust the name to be consistent with other Qt examples.
- Move nano browser one directory level down,
also renaming them to match their target name
- Remove the dashes from the target names
- Rename the qtquick example directory to quick, matching the style in lib
Change-Id: I4a5e31be0b919ae596eadbf731be52372ae61151
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'examples/quick')
-rw-r--r-- | examples/quick/quicknanobrowser/main.cpp | 58 | ||||
-rw-r--r-- | examples/quick/quicknanobrowser/quicknanobrowser.pro | 16 | ||||
-rw-r--r-- | examples/quick/quicknanobrowser/quickwindow.cpp | 66 | ||||
-rw-r--r-- | examples/quick/quicknanobrowser/quickwindow.h | 55 | ||||
-rw-r--r-- | examples/quick/quicknanobrowser/quickwindow.qml | 103 | ||||
-rw-r--r-- | examples/quick/quicknanobrowser/resources.qrc | 5 |
6 files changed, 303 insertions, 0 deletions
diff --git a/examples/quick/quicknanobrowser/main.cpp b/examples/quick/quicknanobrowser/main.cpp new file mode 100644 index 000000000..982c1eb7a --- /dev/null +++ b/examples/quick/quicknanobrowser/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quickwindow.h" +#ifndef QT_NO_WIDGETS +#include <QtWidgets/QApplication> +typedef QApplication Application; +#else +#include <QtGui/QGuiApplication> +typedef QGuiApplication Application; +#endif + +int main(int argc, char **argv) +{ + Application app(argc, argv); + + ApplicationEngine appEngine; + + return app.exec(); +} diff --git a/examples/quick/quicknanobrowser/quicknanobrowser.pro b/examples/quick/quicknanobrowser/quicknanobrowser.pro new file mode 100644 index 000000000..da71b034c --- /dev/null +++ b/examples/quick/quicknanobrowser/quicknanobrowser.pro @@ -0,0 +1,16 @@ +TEMPLATE = app +TARGET = quicknanobrowser + +include(../../common.pri) + +HEADERS = quickwindow.h +SOURCES = quickwindow.cpp main.cpp + +OTHER_FILES += quickwindow.qml +RESOURCES += resources.qrc + + +QT += qml quick +qtHaveModule(widgets) { + QT += widgets # QApplication is required to get native styling with QtQuickControls +} diff --git a/examples/quick/quicknanobrowser/quickwindow.cpp b/examples/quick/quicknanobrowser/quickwindow.cpp new file mode 100644 index 000000000..1f753c691 --- /dev/null +++ b/examples/quick/quicknanobrowser/quickwindow.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quickwindow.h" + +#include "util.h" + +#include <QFileInfo> +#include <QObject> +#include <QQmlContext> +#include <QQmlEngine> +#include <QUrl> + +class Utils : public QObject { + Q_OBJECT +public: + Utils(QObject* parent = 0) : QObject(parent) { } + Q_INVOKABLE static QUrl fromUserInput(const QString& userInput) { return urlFromUserInput(userInput); } + Q_INVOKABLE static QUrl initialUrl() { return startupUrl(); } +}; + +#include "quickwindow.moc" + +ApplicationEngine::ApplicationEngine() +{ + rootContext()->setContextProperty("utils", new Utils(this)); + load(QUrl("qrc:/quickwindow.qml")); +} diff --git a/examples/quick/quicknanobrowser/quickwindow.h b/examples/quick/quicknanobrowser/quickwindow.h new file mode 100644 index 000000000..3f1f944ca --- /dev/null +++ b/examples/quick/quicknanobrowser/quickwindow.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QUICKWINDOW_H +#define QUICKWINDOW_H + +#include <QQmlApplicationEngine> + +class QWebContentsView; + +class ApplicationEngine : public QQmlApplicationEngine { + Q_OBJECT +public: + ApplicationEngine(); +}; + +#endif // QUICKWINDOW_H diff --git a/examples/quick/quicknanobrowser/quickwindow.qml b/examples/quick/quicknanobrowser/quickwindow.qml new file mode 100644 index 000000000..9086d26fa --- /dev/null +++ b/examples/quick/quicknanobrowser/quickwindow.qml @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtWebEngine 1.0 +import QtQuick.Controls 1.0 +import QtQuick.Layouts 1.0 + +ApplicationWindow { + id: browserWindow + height: 600 + width: 800 + visible: true + title: webContentsView.title + + // Focus and select text in URL bar + Action { + id: focus + shortcut: "Ctrl+L" // How to have Cmd + L on Mac ? + onTriggered: { + addressBar.forceActiveFocus(); + addressBar.selectAll(); + } + } + + toolBar: ToolBar { + id: navigationBar + RowLayout { + anchors.fill: parent + + ToolButton { + id: backButton + iconSource: "icons/go-previous.png" + onClicked: webContentsView.goBack() + enabled: webContentsView.canGoBack + } + ToolButton { + id: forwardButton + iconSource: "icons/go-next.png" + onClicked: webContentsView.goForward() + enabled: webContentsView.canGoForward + } + ToolButton { + id: reloadButton + iconSource: webContentsView.loading ? "icons/process-stop.png" : "icons/view-refresh.png" + onClicked: webContentsView.reload() + } + TextField { + id: addressBar + focus: true + Layout.fillWidth: true + + onAccepted: webContentsView.url = utils.fromUserInput(text) + } + } + } + + WebContentsView { + id: webContentsView + focus: true + anchors.fill: parent + url: utils.initialUrl() + + onUrlChanged: addressBar.text = url + } +} diff --git a/examples/quick/quicknanobrowser/resources.qrc b/examples/quick/quicknanobrowser/resources.qrc new file mode 100644 index 000000000..de8232440 --- /dev/null +++ b/examples/quick/quicknanobrowser/resources.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>quickwindow.qml</file> +</qresource> +</RCC> |