From 7137e95d9d4220bcd6c2a75707eec16de165f153 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 6 Sep 2016 10:36:44 +0200 Subject: [PATCH] feat(app): supports Components --- tests/languages/en.ts | 4 ++-- tests/languages/fr.ts | 4 ++-- tests/linphone.pro | 10 ++++++---- tests/resources.qrc | 3 ++- tests/src/app.cpp | 2 ++ tests/src/main.cpp | 10 +++++----- tests/src/views/main_window.hpp | 10 +++++++--- tests/ui/main_window.qml | 23 ----------------------- 8 files changed, 26 insertions(+), 40 deletions(-) delete mode 100644 tests/ui/main_window.qml diff --git a/tests/languages/en.ts b/tests/languages/en.ts index b87c6bee9..2000ad233 100644 --- a/tests/languages/en.ts +++ b/tests/languages/en.ts @@ -2,10 +2,10 @@ - main_window + SearchBar helloWorld - Hello World! + Hello World diff --git a/tests/languages/fr.ts b/tests/languages/fr.ts index 609e23e2b..f11961a9c 100644 --- a/tests/languages/fr.ts +++ b/tests/languages/fr.ts @@ -2,10 +2,10 @@ - main_window + SearchBar helloWorld - Bonjour le monde ! + Bonjour le monde diff --git a/tests/linphone.pro b/tests/linphone.pro index 71675b9fa..f56b5657d 100644 --- a/tests/linphone.pro +++ b/tests/linphone.pro @@ -1,14 +1,14 @@ -QT += core gui quick widgets +QT = core gui quick widgets TARGET = linphone TEMPLATE = app -SOURCES += \ +SOURCES = \ src/app.cpp \ src/main.cpp \ src/views/main_window.cpp -HEADERS += \ +HEADERS = \ src/app.hpp \ src/views/main_window.hpp @@ -17,8 +17,10 @@ TRANSLATIONS = \ languages/fr.ts lupdate_only{ + # Each component folder must be added explicitly. SOURCES = \ - ui/*.qml + ui/components/SearchBar/*.qml \ + ui/views/*.qml } RESOURCES += \ diff --git a/tests/resources.qrc b/tests/resources.qrc index 6cf86537a..8b6e72210 100644 --- a/tests/resources.qrc +++ b/tests/resources.qrc @@ -5,6 +5,7 @@ languages/fr.qm - ui/main_window.qml + ui/components/SearchBar/SearchBar.qml + ui/views/main_window.qml diff --git a/tests/src/app.cpp b/tests/src/app.cpp index 7661ab156..e05a0ab99 100644 --- a/tests/src/app.cpp +++ b/tests/src/app.cpp @@ -6,6 +6,8 @@ #define LANGUAGES_PATH ":/languages/" +// =================================================================== + App::App(int &argc, char **argv) : QGuiApplication(argc, argv) { // Try to enable system translation by default. (else english) if (m_translator.load(QString(LANGUAGES_PATH) + QLocale::system().name()) || diff --git a/tests/src/main.cpp b/tests/src/main.cpp index 8e3e5dca7..63b24d769 100644 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -4,12 +4,12 @@ #include "app.hpp" -int main (int argc, char *argv[]) { - // Init main window. - App app(argc, argv); - QQmlApplicationEngine engine(QUrl("qrc:/ui/main_window.qml")); +// =================================================================== + +int main (int argc, char *argv[]) { + App app(argc, argv); + QQmlApplicationEngine engine(QUrl("qrc:/ui/views/main_window.qml")); - // File not found. if (engine.rootObjects().isEmpty()) exit(EXIT_FAILURE); diff --git a/tests/src/views/main_window.hpp b/tests/src/views/main_window.hpp index 4d049c8bc..cdbae4e47 100644 --- a/tests/src/views/main_window.hpp +++ b/tests/src/views/main_window.hpp @@ -1,4 +1,8 @@ -#ifndef MAIN_WINDOW_H -#define MAIN_WINDOW_H +#ifndef MAIN_WINDOW_H_ +#define MAIN_WINDOW_H_ -#endif // MAIN_WINDOW +class MainWindow { + // TODO. +}; + +#endif // MAIN_WINDOW_ diff --git a/tests/ui/main_window.qml b/tests/ui/main_window.qml deleted file mode 100644 index 22cd562f8..000000000 --- a/tests/ui/main_window.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Controls 2.0 -import QtQuick.Layouts 1.3 - -ApplicationWindow { - id: mainWindow - visible: true - - header: ToolBar { - RowLayout { - anchors.fill: parent - } - } - - footer: TabBar { - - } - - Text { - anchors.centerIn: parent - text: qsTr("helloWorld"); - } -}