Commit 81d616e8 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/app/App): add a splash screen

parent 038445f3
This diff is collapsed.
......@@ -148,6 +148,7 @@
<file>assets/images/speaker_on_hovered.svg</file>
<file>assets/images/speaker_on_normal.svg</file>
<file>assets/images/speaker_on_pressed.svg</file>
<file>assets/images/splash_screen.svg</file>
<file>assets/images/tooltip_arrow_bottom.svg</file>
<file>assets/images/tooltip_arrow_left.svg</file>
<file>assets/images/tooltip_arrow_right.svg</file>
......@@ -343,6 +344,7 @@
<file>ui/views/App/Settings/SettingsUi.qml</file>
<file>ui/views/App/Settings/SettingsVideo.qml</file>
<file>ui/views/App/Settings/SettingsWindow.qml</file>
<file>ui/views/App/SplashScreen/SplashScreen.qml</file>
<file>ui/views/App/Styles/Calls/CallStyle.qml</file>
<file>ui/views/App/Styles/Calls/CallsWindowStyle.qml</file>
<file>ui/views/App/Styles/Main/Assistant/AssistantAbstractViewStyle.qml</file>
......@@ -360,5 +362,6 @@
<file>ui/views/App/Styles/Main/ManageAccountsStyle.qml</file>
<file>ui/views/App/Styles/qmldir</file>
<file>ui/views/App/Styles/Settings/SettingsWindowStyle.qml</file>
<file>ui/views/App/Styles/SplashScreen/SplashScreenStyle.qml</file>
</qresource>
</RCC>
......@@ -55,6 +55,8 @@
#define QML_VIEW_CALLS_WINDOW "qrc:/ui/views/App/Calls/CallsWindow.qml"
#define QML_VIEW_SETTINGS_WINDOW "qrc:/ui/views/App/Settings/SettingsWindow.qml"
#define QML_VIEW_SPLASH_SCREEN "qrc:/ui/views/App/SplashScreen/SplashScreen.qml"
// =============================================================================
inline bool installLocale (App &app, QTranslator &translator, const QLocale &locale) {
......@@ -92,6 +94,35 @@ App::~App () {
// -----------------------------------------------------------------------------
inline QQuickWindow *createSubWindow (App *app, const char *path) {
QQmlEngine *engine = app->getEngine();
QQmlComponent component(engine, QUrl(path));
if (component.isError()) {
qWarning() << component.errors();
abort();
}
QObject *object = component.create();
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
object->setParent(app->getMainWindow());
return qobject_cast<QQuickWindow *>(object);
}
// -----------------------------------------------------------------------------
inline void activeSplashScreen (App *app) {
QQuickWindow *splash_screen = createSubWindow(app, QML_VIEW_SPLASH_SCREEN);
QObject::connect(
CoreManager::getInstance(), &CoreManager::linphoneCoreCreated, splash_screen, [splash_screen]() {
splash_screen->hide();
splash_screen->deleteLater();
}
);
}
void App::initContentApp () {
// Init core.
CoreManager::init(this, m_parser.value("config"));
......@@ -124,6 +155,9 @@ void App::initContentApp () {
if (m_engine.rootObjects().isEmpty())
qFatal("Unable to open main window.");
// Load splashscreen.
activeSplashScreen(this);
CoreManager *core = CoreManager::getInstance();
if (m_parser.isSet("selftest"))
......@@ -210,24 +244,6 @@ void App::tryToUsePreferredLocale () {
// -----------------------------------------------------------------------------
inline QQuickWindow *createSubWindow (App *app, const char *path) {
QQmlEngine *engine = app->getEngine();
QQmlComponent component(engine, QUrl(path));
if (component.isError()) {
qWarning() << component.errors();
abort();
}
QObject *object = component.create();
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
object->setParent(app->getMainWindow());
return qobject_cast<QQuickWindow *>(object);
}
// -----------------------------------------------------------------------------
QQuickWindow *App::getCallsWindow () {
if (!m_calls_window)
m_calls_window = createSubWindow(this, QML_VIEW_CALLS_WINDOW);
......
import QtQuick 2.7
import QtQuick.Window 2.2
import Common 1.0
import App.Styles 1.0
// =============================================================================
Window {
color: SplashScreenStyle.color
flags: Qt.SplashScreen
modality: Qt.ApplicationModal
visible: image.status === Image.Ready
x: (Screen.width - image.width) / 2
y: (Screen.height - image.height) / 2
height: image.paintedHeight
width: image.paintedWidth
Image {
id: image
anchors.centerIn: parent
height: SplashScreenStyle.height
width: SplashScreenStyle.width
fillMode: Image.PreserveAspectFit
mipmap: true
source: SplashScreenStyle.image
BusyIndicator {
height: SplashScreenStyle.busyIndicator.height
width: SplashScreenStyle.busyIndicator.width
anchors {
bottom: parent.bottom
bottomMargin: SplashScreenStyle.busyIndicator.bottomMargin
horizontalCenter: parent.horizontalCenter
}
}
}
}
pragma Singleton
import QtQuick 2.7
// =============================================================================
QtObject {
property color color: '#444444' // Not a `Common.Color`. Specific case.
property int height: 350
property int width: 620
property url image: 'qrc:/assets/images/splash_screen.svg'
property QtObject busyIndicator: QtObject {
property int bottomMargin: 25
property int height: 24
property int width: 24
}
}
......@@ -23,3 +23,5 @@ singleton MainWindowStyle 1.0 Main/MainWindowStyle.qml
singleton ManageAccountsStyle 1.0 Main/ManageAccountsStyle.qml
singleton SettingsWindowStyle 1.0 Settings/SettingsWindowStyle.qml
singleton SplashScreenStyle 1.0 SplashScreen/SplashScreenStyle.qml
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