Commit 7137e95d authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): supports Components

parent 51c5694d
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1"> <TS version="2.1">
<context> <context>
<name>main_window</name> <name>SearchBar</name>
<message> <message>
<source>helloWorld</source> <source>helloWorld</source>
<translation>Hello World!</translation> <translation>Hello World</translation>
</message> </message>
</context> </context>
</TS> </TS>
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1"> <TS version="2.1">
<context> <context>
<name>main_window</name> <name>SearchBar</name>
<message> <message>
<source>helloWorld</source> <source>helloWorld</source>
<translation>Bonjour le monde !</translation> <translation>Bonjour le monde</translation>
</message> </message>
</context> </context>
</TS> </TS>
QT += core gui quick widgets QT = core gui quick widgets
TARGET = linphone TARGET = linphone
TEMPLATE = app TEMPLATE = app
SOURCES += \ SOURCES = \
src/app.cpp \ src/app.cpp \
src/main.cpp \ src/main.cpp \
src/views/main_window.cpp src/views/main_window.cpp
HEADERS += \ HEADERS = \
src/app.hpp \ src/app.hpp \
src/views/main_window.hpp src/views/main_window.hpp
...@@ -17,8 +17,10 @@ TRANSLATIONS = \ ...@@ -17,8 +17,10 @@ TRANSLATIONS = \
languages/fr.ts languages/fr.ts
lupdate_only{ lupdate_only{
# Each component folder must be added explicitly.
SOURCES = \ SOURCES = \
ui/*.qml ui/components/SearchBar/*.qml \
ui/views/*.qml
} }
RESOURCES += \ RESOURCES += \
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<file>languages/fr.qm</file> <file>languages/fr.qm</file>
<!-- UI. --> <!-- UI. -->
<file>ui/main_window.qml</file> <file>ui/components/SearchBar/SearchBar.qml</file>
<file>ui/views/main_window.qml</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#define LANGUAGES_PATH ":/languages/" #define LANGUAGES_PATH ":/languages/"
// ===================================================================
App::App(int &argc, char **argv) : QGuiApplication(argc, argv) { App::App(int &argc, char **argv) : QGuiApplication(argc, argv) {
// Try to enable system translation by default. (else english) // Try to enable system translation by default. (else english)
if (m_translator.load(QString(LANGUAGES_PATH) + QLocale::system().name()) || if (m_translator.load(QString(LANGUAGES_PATH) + QLocale::system().name()) ||
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
#include "app.hpp" #include "app.hpp"
// ===================================================================
int main (int argc, char *argv[]) { int main (int argc, char *argv[]) {
// Init main window.
App app(argc, argv); App app(argc, argv);
QQmlApplicationEngine engine(QUrl("qrc:/ui/main_window.qml")); QQmlApplicationEngine engine(QUrl("qrc:/ui/views/main_window.qml"));
// File not found.
if (engine.rootObjects().isEmpty()) if (engine.rootObjects().isEmpty())
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
#ifndef MAIN_WINDOW_H #ifndef MAIN_WINDOW_H_
#define MAIN_WINDOW_H #define MAIN_WINDOW_H_
#endif // MAIN_WINDOW class MainWindow {
// TODO.
};
#endif // MAIN_WINDOW_
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");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment