From c6144131d1f97bcd69682bb733a54f2cd777f127 Mon Sep 17 00:00:00 2001
From: Pierre Rossi <pierre.rossi@digia.com>
Date: Mon, 17 Jun 2013 18:20:39 +0200
Subject: [PATCH] Split out the example into two distinct ones

Cleaner than deciding on startup with an env variable
---
 example/example.pro                           |  18 ------
 examples/common.pri                           |  10 ++++
 examples/examples.pro                         |   4 ++
 .../qtquick}/icons/go-next.png                | Bin
 .../qtquick}/icons/go-previous.png            | Bin
 .../qtquick}/icons/process-stop.png           | Bin
 .../qtquick}/icons/view-refresh.png           | Bin
 {example => examples/qtquick}/main.cpp        |  23 +-------
 examples/qtquick/qtquick.pro                  |  12 ++++
 {example => examples/qtquick}/quickwindow.cpp |   2 +-
 {example => examples/qtquick}/quickwindow.h   |   0
 {example => examples/qtquick}/quickwindow.qml |   0
 examples/widgets/main.cpp                     |  53 ++++++++++++++++++
 examples/widgets/widgets.pro                  |   9 +++
 .../widgets}/widgetwindow.cpp                 |   0
 {example => examples/widgets}/widgetwindow.h  |   0
 qtwebengine.pro                               |   2 +-
 17 files changed, 92 insertions(+), 41 deletions(-)
 delete mode 100644 example/example.pro
 create mode 100644 examples/common.pri
 create mode 100644 examples/examples.pro
 rename {example => examples/qtquick}/icons/go-next.png (100%)
 rename {example => examples/qtquick}/icons/go-previous.png (100%)
 rename {example => examples/qtquick}/icons/process-stop.png (100%)
 rename {example => examples/qtquick}/icons/view-refresh.png (100%)
 rename {example => examples/qtquick}/main.cpp (86%)
 create mode 100644 examples/qtquick/qtquick.pro
 rename {example => examples/qtquick}/quickwindow.cpp (98%)
 rename {example => examples/qtquick}/quickwindow.h (100%)
 rename {example => examples/qtquick}/quickwindow.qml (100%)
 create mode 100644 examples/widgets/main.cpp
 create mode 100644 examples/widgets/widgets.pro
 rename {example => examples/widgets}/widgetwindow.cpp (100%)
 rename {example => examples/widgets}/widgetwindow.h (100%)

diff --git a/example/example.pro b/example/example.pro
deleted file mode 100644
index dda3c5cf4..000000000
--- a/example/example.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TEMPLATE = app
-TARGET = example
-
-HEADERS = quickwindow.h widgetwindow.h
-SOURCES = quickwindow.cpp widgetwindow.cpp main.cpp
-
-OTHER_FILES += quickwindow.qml
-
-INCLUDEPATH += ../lib
-
-LIBPATH = $$getOutDir()/$$getConfigDir()/lib
-
-LIBS += -L$$LIBPATH -lQt5WebEngine
-QMAKE_RPATHDIR += $$LIBPATH
-
-QT += widgets quick
-MOC_DIR=$$PWD
-
diff --git a/examples/common.pri b/examples/common.pri
new file mode 100644
index 000000000..b85159ce8
--- /dev/null
+++ b/examples/common.pri
@@ -0,0 +1,10 @@
+INCLUDEPATH += $$absolute_path(../lib, $$PWD)
+
+LIBPATH = $$getOutDir()/$$getConfigDir()/lib
+
+LIBS += -L$$LIBPATH -lQt5WebEngine
+QMAKE_RPATHDIR += $$LIBPATH
+
+# Quick hack for now as we mess with that for the gyp generation step.
+MOC_DIR=$$PWD/.moc
+
diff --git a/examples/examples.pro b/examples/examples.pro
new file mode 100644
index 000000000..4613dc8d8
--- /dev/null
+++ b/examples/examples.pro
@@ -0,0 +1,4 @@
+TEMPLATE=subdirs
+
+SUBDIRS += qtquick \
+           widgets
diff --git a/example/icons/go-next.png b/examples/qtquick/icons/go-next.png
similarity index 100%
rename from example/icons/go-next.png
rename to examples/qtquick/icons/go-next.png
diff --git a/example/icons/go-previous.png b/examples/qtquick/icons/go-previous.png
similarity index 100%
rename from example/icons/go-previous.png
rename to examples/qtquick/icons/go-previous.png
diff --git a/example/icons/process-stop.png b/examples/qtquick/icons/process-stop.png
similarity index 100%
rename from example/icons/process-stop.png
rename to examples/qtquick/icons/process-stop.png
diff --git a/example/icons/view-refresh.png b/examples/qtquick/icons/view-refresh.png
similarity index 100%
rename from example/icons/view-refresh.png
rename to examples/qtquick/icons/view-refresh.png
diff --git a/example/main.cpp b/examples/qtquick/main.cpp
similarity index 86%
rename from example/main.cpp
rename to examples/qtquick/main.cpp
index 129d8c6c1..ca92eb72c 100644
--- a/example/main.cpp
+++ b/examples/qtquick/main.cpp
@@ -40,21 +40,10 @@
 ****************************************************************************/
 
 #include "quickwindow.h"
-#include "widgetwindow.h"
-
 #include "qquickwebcontentsview.h"
+#include <QApplication>
 
-int mainWidget(int argc, char **argv)
-{
-    QApplication app(argc, argv);
-
-    WidgetWindow window;
-    window.show();
-
-    return app.exec();
-}
-
-int mainQuick(int argc, char **argv)
+int main(int argc, char **argv)
 {
     QApplication app(argc, argv);
 
@@ -64,11 +53,3 @@ int mainQuick(int argc, char **argv)
 
     return app.exec();
 }
-
-int main(int argc, char **argv)
-{
-    if (qgetenv("QQUICKWEBENGINE").isNull())
-        return mainWidget(argc, argv);
-    else
-        return mainQuick(argc, argv);
-}
diff --git a/examples/qtquick/qtquick.pro b/examples/qtquick/qtquick.pro
new file mode 100644
index 000000000..6d3e8a62e
--- /dev/null
+++ b/examples/qtquick/qtquick.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+TARGET = qtquick-nano-browser
+
+include(../common.pri)
+
+HEADERS = quickwindow.h
+SOURCES = quickwindow.cpp main.cpp
+
+OTHER_FILES += quickwindow.qml
+
+QT += quick \
+      widgets # QApplication is required to get native styling with QtQuickControls
diff --git a/example/quickwindow.cpp b/examples/qtquick/quickwindow.cpp
similarity index 98%
rename from example/quickwindow.cpp
rename to examples/qtquick/quickwindow.cpp
index 018f1c937..fed881fc0 100644
--- a/example/quickwindow.cpp
+++ b/examples/qtquick/quickwindow.cpp
@@ -65,5 +65,5 @@ public:
 ApplicationEngine::ApplicationEngine()
 {
     rootContext()->setContextProperty("utils", new Utils(this));
-    load(QUrl("example/quickwindow.qml"));
+    load(QUrl("quickwindow.qml"));
 }
diff --git a/example/quickwindow.h b/examples/qtquick/quickwindow.h
similarity index 100%
rename from example/quickwindow.h
rename to examples/qtquick/quickwindow.h
diff --git a/example/quickwindow.qml b/examples/qtquick/quickwindow.qml
similarity index 100%
rename from example/quickwindow.qml
rename to examples/qtquick/quickwindow.qml
diff --git a/examples/widgets/main.cpp b/examples/widgets/main.cpp
new file mode 100644
index 000000000..f6c9a37b0
--- /dev/null
+++ b/examples/widgets/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** 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 "widgetwindow.h"
+#include <QApplication>
+
+int main(int argc, char **argv)
+{
+    QApplication app(argc, argv);
+
+    WidgetWindow window;
+    window.show();
+
+    return app.exec();
+}
diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro
new file mode 100644
index 000000000..3d0d17d7f
--- /dev/null
+++ b/examples/widgets/widgets.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+TARGET = widget-nano-browser
+
+include(../common.pri)
+
+HEADERS = widgetwindow.h
+SOURCES = widgetwindow.cpp main.cpp
+
+QT += widgets
diff --git a/example/widgetwindow.cpp b/examples/widgets/widgetwindow.cpp
similarity index 100%
rename from example/widgetwindow.cpp
rename to examples/widgets/widgetwindow.cpp
diff --git a/example/widgetwindow.h b/examples/widgets/widgetwindow.h
similarity index 100%
rename from example/widgetwindow.h
rename to examples/widgets/widgetwindow.h
diff --git a/qtwebengine.pro b/qtwebengine.pro
index c08945a44..ddf013d55 100644
--- a/qtwebengine.pro
+++ b/qtwebengine.pro
@@ -8,7 +8,7 @@ SUBDIRS = shared \
           lib \
           process \
           build \ # This is where we use the generated qt_generated.gypi and run gyp
-          example \
+          examples \
 
 # Ninja executable location needs to be determined early for extra targets. Should be fetched from cache most of the time anyway.
 NINJA_EXECUTABLE = $$findNinja()
-- 
GitLab