diff --git a/linphone-desktop/assets/images/splash_screen.svg b/linphone-desktop/assets/images/splash_screen.svg new file mode 100644 index 000000000..9bf593611 --- /dev/null +++ b/linphone-desktop/assets/images/splash_screen.svg @@ -0,0 +1,28 @@ + + + + chat liste copy + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/linphone-desktop/resources.qrc b/linphone-desktop/resources.qrc index dab3d93d3..18fac771a 100644 --- a/linphone-desktop/resources.qrc +++ b/linphone-desktop/resources.qrc @@ -148,6 +148,7 @@ assets/images/speaker_on_hovered.svg assets/images/speaker_on_normal.svg assets/images/speaker_on_pressed.svg + assets/images/splash_screen.svg assets/images/tooltip_arrow_bottom.svg assets/images/tooltip_arrow_left.svg assets/images/tooltip_arrow_right.svg @@ -343,6 +344,7 @@ ui/views/App/Settings/SettingsUi.qml ui/views/App/Settings/SettingsVideo.qml ui/views/App/Settings/SettingsWindow.qml + ui/views/App/SplashScreen/SplashScreen.qml ui/views/App/Styles/Calls/CallStyle.qml ui/views/App/Styles/Calls/CallsWindowStyle.qml ui/views/App/Styles/Main/Assistant/AssistantAbstractViewStyle.qml @@ -360,5 +362,6 @@ ui/views/App/Styles/Main/ManageAccountsStyle.qml ui/views/App/Styles/qmldir ui/views/App/Styles/Settings/SettingsWindowStyle.qml + ui/views/App/Styles/SplashScreen/SplashScreenStyle.qml diff --git a/linphone-desktop/src/app/App.cpp b/linphone-desktop/src/app/App.cpp index 2651ef43f..66ea7f135 100644 --- a/linphone-desktop/src/app/App.cpp +++ b/linphone-desktop/src/app/App.cpp @@ -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(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(object); -} - -// ----------------------------------------------------------------------------- - QQuickWindow *App::getCallsWindow () { if (!m_calls_window) m_calls_window = createSubWindow(this, QML_VIEW_CALLS_WINDOW); diff --git a/linphone-desktop/ui/views/App/SplashScreen/SplashScreen.qml b/linphone-desktop/ui/views/App/SplashScreen/SplashScreen.qml index 158b23f5f..4446e91b1 100644 --- a/linphone-desktop/ui/views/App/SplashScreen/SplashScreen.qml +++ b/linphone-desktop/ui/views/App/SplashScreen/SplashScreen.qml @@ -1,8 +1,47 @@ 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 + } + } + } } diff --git a/linphone-desktop/ui/views/App/Styles/SplashScreen/SplashScreenStyle.qml b/linphone-desktop/ui/views/App/Styles/SplashScreen/SplashScreenStyle.qml new file mode 100644 index 000000000..c25094635 --- /dev/null +++ b/linphone-desktop/ui/views/App/Styles/SplashScreen/SplashScreenStyle.qml @@ -0,0 +1,17 @@ +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 + } +} diff --git a/linphone-desktop/ui/views/App/Styles/qmldir b/linphone-desktop/ui/views/App/Styles/qmldir index 0a7ebacbf..0521266f9 100644 --- a/linphone-desktop/ui/views/App/Styles/qmldir +++ b/linphone-desktop/ui/views/App/Styles/qmldir @@ -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