From 768ea9d60156b3f4e8b28aa4cde9532c9be906e9 Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Wed, 4 Nov 2020 15:24:46 -0500 Subject: [PATCH] refactor: use ApplicationWindow as the main entry point Change-Id: I5e298e51fdc4099f0380d8a2ce2176cd66070eed --- src/MainApplicationWindow.qml | 203 +++++++++--------- src/calladapter.cpp | 4 - src/constant/JamiQmlUtils.qml | 3 + src/constant/JamiTheme.qml | 10 + src/conversationsadapter.cpp | 4 - src/lrcinstance.h | 2 +- src/mainapplication.cpp | 23 -- src/mainapplication.h | 1 - src/mainview/MainView.qml | 91 ++++---- src/mainview/components/AccountComboBox.qml | 4 +- .../components/AccountComboBoxPopup.qml | 2 +- src/mainview/components/CallOverlay.qml | 2 +- src/mainview/components/CallStackView.qml | 2 + .../components/ConversationSmartListView.qml | 2 +- .../ConversationSmartListViewItemDelegate.qml | 2 +- src/mainview/components/MessageWebView.qml | 2 +- src/mainview/components/UserInfoCallPage.qml | 4 +- src/mainview/components/WelcomePage.qml | 62 +++--- src/settingsview/SettingsView.qml | 8 +- .../components/KeyBoardShortcutTable.qml | 6 +- .../components/SettingsHeader.qml | 2 +- src/wizardview/WizardView.qml | 13 +- 22 files changed, 215 insertions(+), 237 deletions(-) diff --git a/src/MainApplicationWindow.qml b/src/MainApplicationWindow.qml index 821dc8665..d61215fdc 100644 --- a/src/MainApplicationWindow.qml +++ b/src/MainApplicationWindow.qml @@ -1,3 +1,25 @@ +/* + * Copyright (C) 2020 by Savoir-faire Linux + * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> + * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> + * Author: Albert Babà <albert.babi@savoirfairelinux.com> + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> + * Author: Yang Wang <yang.wang@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + import QtQuick 2.14 import QtQuick.Window 2.14 import QtQuick.Controls 2.14 @@ -16,111 +38,104 @@ import "commoncomponents" ApplicationWindow { id: root - property ApplicationWindow appWindow: root + enum LoadedSource { + WizardView = 0, + MainView, + None + } - AccountMigrationDialog{ - id: accountMigrationDialog + Universal.theme: Universal.Light - visible: false + title: JamiStrings.appTitle - onAccountMigrationFinished:{ - startClientByMainview() - } + width: { + if (checkLoadedSource() === MainApplicationWindow.LoadedSource.WizardView) + return JamiTheme.wizardViewMinWidth + return JamiTheme.mainViewPreferredWidth + } + height: { + if (checkLoadedSource() === MainApplicationWindow.LoadedSource.WizardView) + return JamiTheme.wizardViewMinHeight + return JamiTheme.mainViewPreferredHeight + } + minimumWidth: { + if (checkLoadedSource() === MainApplicationWindow.LoadedSource.WizardView) + return JamiTheme.wizardViewMinWidth + return JamiTheme.mainViewMinWidth + } + minimumHeight: { + if (checkLoadedSource() === MainApplicationWindow.LoadedSource.WizardView) + return JamiTheme.wizardViewMinHeight + return JamiTheme.mainViewMinHeight } - function close(force = false) { - // If we're in the onboarding wizard or 'MinimizeOnClose' - // is set, then we can quit - if (force || !SettingsAdapter.getAppValue(Settings.MinimizeOnClose) || - !UtilsAdapter.getAccountListSize()) { - Qt.quit() - } else { - // hide to the systray - if (mainViewLoader.item) - mainViewLoader.item.hide() - else - Qt.quit() - } + visible: mainApplicationLoader.status === Loader.Ready + + function checkLoadedSource() { + var sourceString = mainApplicationLoader.source.toString() + + if (sourceString === JamiQmlUtils.wizardViewLoadPath) + return MainApplicationWindow.LoadedSource.WizardView + else if (sourceString === JamiQmlUtils.mainViewLoadPath) + return MainApplicationWindow.LoadedSource.MainView + + return MainApplicationWindow.LoadedSource.None } function startAccountMigration(){ return accountMigrationDialog.startAccountMigrationOfTopStack() } - function startClientByMainview(){ + function startClient(){ setX(Screen.width / 2 - width / 2) setY(Screen.height / 2 - height / 2) - if (!UtilsAdapter.getAccountListSize()) { - wizardView.show() + if (UtilsAdapter.getAccountListSize() !== 0) { + mainApplicationLoader.setSource(JamiQmlUtils.mainViewLoadPath, + {"containerWindow": root}) } else { - mainViewLoader.setSource("qrc:/src/mainview/MainView.qml") + mainApplicationLoader.setSource(JamiQmlUtils.wizardViewLoadPath) } } - Universal.theme: Universal.Light + function close(force = false) { + // If we're in the onboarding wizard or 'MinimizeOnClose' + // is set, then we can quit + if (force || !SettingsAdapter.getAppValue(Settings.MinimizeOnClose) || + !UtilsAdapter.getAccountListSize()) { + Qt.quit() + } else + hide() + } + + AccountMigrationDialog{ + id: accountMigrationDialog + + visible: false + + onAccountMigrationFinished: startClient() + } - visible: false Loader { - id: mainViewLoader + id: mainApplicationLoader - property int newAddedAccountIndex: -1 + anchors.fill: parent asynchronous: true visible: status == Loader.Ready source: "" Connections { - target: mainViewLoader.item - - function onCloseApp() { - root.close() - } - - function onNoAccountIsAvailable() { - mainViewLoader.setSource("") - wizardViewForApplicationStart.changePageQML(0) - wizardView.show() - } - } - } - - Window { - id: wizardView - - title: "Jami" - - minimumWidth: 500 - minimumHeight: 600 - - WizardView { - id: wizardViewForApplicationStart - - anchors.fill: parent - - onNeedToShowMainViewWindow: { - mainViewLoader.newAddedAccountIndex = accountIndex - if (mainViewLoader.source.toString() !== "qrc:/src/mainview/MainView.qml") - mainViewLoader.setSource("qrc:/src/mainview/MainView.qml") - wizardView.close() + target: mainApplicationLoader.item + + function onLoaderSourceChangeRequested(sourceToLoad) { + if (sourceToLoad === MainApplicationWindow.LoadedSource.WizardView) + mainApplicationLoader.setSource(JamiQmlUtils.wizardViewLoadPath) + else + mainApplicationLoader.setSource(JamiQmlUtils.mainViewLoadPath, + {"containerWindow": root}) } - - onWizardViewIsClosed: parent.close() - } - - // @disable-check M16 - onClosing: { - if (mainViewLoader.source.toString() !== "qrc:/src/mainview/MainView.qml") { - root.close() - } - } - // @enable-check M16 - } - - Component.onCompleted: { - if(!startAccountMigration()){ - startClientByMainview() } } @@ -138,31 +153,25 @@ ApplicationWindow { Connections { target: LRCInstance - function restore(window) { - window.show() - window.raise(); - window.requestActivate() + function onRestoreAppRequested() { + requestActivate() + showNormal() } - function onRestoreAppRequested() { - if (mainViewLoader.item) - restore(mainViewLoader.item) + function onNotificationClicked() { + requestActivate() + raise() + if (visibility === Window.Hidden || + visibility === Window.Minimized) + showNormal() } + } - function onNotificationClicked(forceToTop) { - var window = mainViewLoader.item ? mainViewLoader.item : wizardView - // This is a hack to bring the window to the front which is normally done - // with QWindow::requestActivate but is thwarted for qml windows by the - // notification being clicked. Native solutions are preferable. - if (forceToTop && (!window.visible - || window.visibility & Qt.WindowMinimized - || window.visibility === Qt.WindowNoState)) { - var tmpFlags = window.flags - window.hide() - window.flags = Qt.WindowStaysOnTopHint - window.flags = tmpFlags - } - restore(window) + onClosing: root.close() + + Component.onCompleted: { + if(!startAccountMigration()){ + startClient() } } } diff --git a/src/calladapter.cpp b/src/calladapter.cpp index 385a211b9..de21e85f8 100644 --- a/src/calladapter.cpp +++ b/src/calladapter.cpp @@ -307,11 +307,7 @@ CallAdapter::showNotification(const QString& accountId, const QString& convUid) } auto onClicked = [this, convInfo]() { -#ifdef Q_OS_WINDOWS emit LRCInstance::instance().notificationClicked(); -#else - emit LRCInstance::instance().notificationClicked(true); -#endif if (!convInfo.uid.isEmpty()) { emit callSetupMainViewRequired(convInfo.accountId, convInfo.uid); } diff --git a/src/constant/JamiQmlUtils.qml b/src/constant/JamiQmlUtils.qml index fcbed2a00..6a75fce9e 100644 --- a/src/constant/JamiQmlUtils.qml +++ b/src/constant/JamiQmlUtils.qml @@ -22,6 +22,9 @@ pragma Singleton import QtQuick 2.14 Item { + readonly property string mainViewLoadPath: "qrc:/src/mainview/MainView.qml" + readonly property string wizardViewLoadPath: "qrc:/src/wizardview/WizardView.qml" + property bool callIsFullscreen: false TextMetrics { diff --git a/src/constant/JamiTheme.qml b/src/constant/JamiTheme.qml index ae2061e93..f08d6852d 100644 --- a/src/constant/JamiTheme.qml +++ b/src/constant/JamiTheme.qml @@ -171,6 +171,16 @@ Item { property int preferredDialogHeight: 300 property int minimumPreviewWidth: 120 + // main application spec + property int mainViewMinWidth: 460 + property int mainViewMinHeight: 400 + + property int wizardViewMinWidth: 500 + property int wizardViewMinHeight: 600 + + property int mainViewPreferredWidth: 650 + property int mainViewPreferredHeight: 600 + function setTheme(dark) { darkTheme = dark } diff --git a/src/conversationsadapter.cpp b/src/conversationsadapter.cpp index 6ab90f462..94abfca3e 100644 --- a/src/conversationsadapter.cpp +++ b/src/conversationsadapter.cpp @@ -146,11 +146,7 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId, auto& contact = accInfo.contactModel->getContact(interaction.authorUri); auto from = accInfo.contactModel->bestNameForContact(interaction.authorUri); auto onClicked = [this, accountId, convUid, uri = interaction.authorUri] { -#ifdef Q_OS_WINDOWS emit LRCInstance::instance().notificationClicked(); -#else - emit LRCInstance::instance().notificationClicked(true); -#endif auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId); if (!convInfo.uid.isEmpty()) { selectConversation(accountId, convInfo.uid); diff --git a/src/lrcinstance.h b/src/lrcinstance.h index 69bcef266..fc0efe96c 100644 --- a/src/lrcinstance.h +++ b/src/lrcinstance.h @@ -446,7 +446,7 @@ signals: void accountListChanged(); void currentAccountChanged(); void restoreAppRequested(); - void notificationClicked(bool forceToTop = false); + void notificationClicked(); void updateSmartList(); void quitEngineRequested(); diff --git a/src/mainapplication.cpp b/src/mainapplication.cpp index 33b3f2d4c..9739c606d 100644 --- a/src/mainapplication.cpp +++ b/src/mainapplication.cpp @@ -172,7 +172,6 @@ MainApplication::init() vsConsoleDebug(); } - connectForceWindowToTop(); initSettings(); initSystray(); initQmlEngine(); @@ -364,25 +363,3 @@ MainApplication::cleanup() #endif QApplication::exit(0); } - -void -MainApplication::connectForceWindowToTop() -{ -#ifdef Q_OS_WINDOWS - QObject::connect(&LRCInstance::instance(), &LRCInstance::notificationClicked, [] { - for (QWindow* appWindow : qApp->allWindows()) { - if (appWindow->objectName().compare("mainViewWindow")) - continue; - // clang-format off - ::SetWindowPos((HWND) appWindow->winId(), - HWND_TOPMOST, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); - ::SetWindowPos((HWND) appWindow->winId(), - HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); - // clang-format on - return; - } - }); -#endif -} diff --git a/src/mainapplication.h b/src/mainapplication.h index 5c3585e96..4343ec6b3 100644 --- a/src/mainapplication.h +++ b/src/mainapplication.h @@ -48,7 +48,6 @@ private: void initSettings(); void initSystray(); void cleanup(); - void connectForceWindowToTop(); private: QScopedPointer<QFile> debugFile_; diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml index 6fbe9d42a..48efbf647 100644 --- a/src/mainview/MainView.qml +++ b/src/mainview/MainView.qml @@ -28,29 +28,24 @@ import net.jami.Constants 1.0 // Import qml component files. import "components" +import "../" import "../wizardview" import "../settingsview" import "../settingsview/components" -Window { - id: mainViewWindow - objectName: "mainViewWindow" +Rectangle { + id: mainView - property int minWidth: settingsViewPreferredWidth - property int minHeight: 400 + objectName: "mainView" + + property var containerWindow: "" - property int mainViewWindowPreferredWidth: 650 - property int mainViewWindowPreferredHeight: 600 property int sidePanelViewStackPreferredWidth: 250 property int mainViewStackPreferredWidth: 250 - property int settingsViewPreferredWidth: 445 + property int settingsViewPreferredWidth: 460 property int onWidthChangedTriggerDistance: 5 - property int savedSidePanelViewMinWidth: 0 - property int savedSidePanelViewMaxWidth: 0 - property int savedWelcomeViewMinWidth: 0 - property int savedWelcomeViewMaxWidth: 0 - property bool sidePanelOnly: !mainViewStack.visible + property bool sidePanelOnly: (!mainViewStack.visible) && sidePanelViewStack.visible // To calculate tab bar bottom border hidden rect left margin. property int tabBarLeftMargin: 8 @@ -60,13 +55,12 @@ Window { // For updating msgWebView property string currentConvUID: "" - signal closeApp - signal noAccountIsAvailable + signal loaderSourceChangeRequested(int sourceToLoad) property string currentAccountId: AccountAdapter.currentAccountId onCurrentAccountIdChanged: { var index = UtilsAdapter.getCurrAccList().indexOf(currentAccountId) - mainViewWindowSidePanel.refreshAccountComboBox(index) + mainViewSidePanel.refreshAccountComboBox(index) if (inSettingsView) { settingsView.accountListChanged() settingsView.setSelected(settingsView.selectedMenu, true) @@ -86,7 +80,7 @@ Window { function showWelcomeView() { currentConvUID = "" callStackView.needToCloseInCallConversationAndPotentialWindow() - mainViewWindowSidePanel.deselectConversationSmartList() + mainViewSidePanel.deselectConversationSmartList() if (isPageInStack("callStackViewObject", sidePanelViewStack) || isPageInStack("communicationPageMessageWebView", sidePanelViewStack) || isPageInStack("communicationPageMessageWebView", mainViewStack) || @@ -167,8 +161,8 @@ Window { var windowCurrentMinimizedSize = settingsViewPreferredWidth + sidePanelViewStackPreferredWidth + onWidthChangedTriggerDistance - if (mainViewWindow.width < windowCurrentMinimizedSize) - mainViewWindow.width = windowCurrentMinimizedSize + if (containerWindow.width < windowCurrentMinimizedSize) + containerWindow.width = windowCurrentMinimizedSize } } else { sidePanelViewStack.pop(StackView.Immediate) @@ -235,12 +229,6 @@ Window { } } - title: JamiStrings.appTitle - visible: true - width: mainViewWindowPreferredWidth - height: mainViewWindowPreferredHeight - minimumWidth: minWidth - minimumHeight: minHeight color: JamiTheme.backgroundColor Connections { @@ -255,13 +243,14 @@ Window { Connections { target: JamiQmlUtils + // TODO: call in fullscreen inside containerWindow function onCallIsFullscreenChanged() { if (JamiQmlUtils.callIsFullscreen) { UtilsAdapter.setSystemTrayIconVisible(false) - mainViewWindow.hide() + containerWindow.hide() } else { UtilsAdapter.setSystemTrayIconVisible(true) - mainViewWindow.show() + containerWindow.show() } } } @@ -279,8 +268,8 @@ Window { Layout.fillWidth: true Layout.fillHeight: true - width: mainViewWindow.width - height: mainViewWindow.height + width: mainView.width + height: mainView.height handle: Rectangle { implicitWidth: JamiTheme.splitViewHandlePreferredWidth @@ -312,7 +301,7 @@ Window { width: mainViewSidePanelRect.width height: 64 - visible: (mainViewWindowSidePanel.visible || settingsMenu.visible) + visible: (mainViewSidePanel.visible || settingsMenu.visible) currentIndex: 0 @@ -321,8 +310,8 @@ Window { function onUpdateConversationForAddedContact() { MessagesAdapter.updateConversationForAddedContact() - mainViewWindowSidePanel.clearContactSearchBar() - mainViewWindowSidePanel.forceReselectConversationSmartListCurrentIndex() + mainViewSidePanel.clearContactSearchBar() + mainViewSidePanel.forceReselectConversationSmartListCurrentIndex() } function onAccountStatusChanged(accountId) { @@ -342,7 +331,7 @@ Window { StackView { id: sidePanelViewStack - initialItem: mainViewWindowSidePanel + initialItem: mainViewSidePanel anchors.top: accountComboBox.visible ? accountComboBox.bottom : mainViewSidePanelRect.top @@ -375,7 +364,7 @@ Window { Layout.fillWidth: true Layout.fillHeight: true - onNeedToShowMainViewWindow: { + onLoaderSourceChangeRequested: { mainViewStackLayout.currentIndex = 0 backToMainView() } @@ -409,7 +398,7 @@ Window { } SidePanel { - id: mainViewWindowSidePanel + id: mainViewSidePanel Connections { target: ConversationsAdapter @@ -429,6 +418,7 @@ Window { WelcomePage { id: welcomePage + visible: false } @@ -437,14 +427,13 @@ Window { visible: false - onSettingsViewWindowNeedToShowMainViewWindow: { + onSettingsViewNeedToShowMainView: { AccountAdapter.accountChanged(0) toggleSettingsView() } - onSettingsViewWindowNeedToShowNewWizardWindow: { - mainViewWindow.noAccountIsAvailable() - } + onSettingsViewNeedToShowNewWizardWindow: loaderSourceChangeRequested( + MainApplicationWindow.LoadedSource.WizardView) onSettingsBackArrowClicked: sidePanelViewStack.pop(StackView.Immediate) } @@ -464,7 +453,7 @@ Window { target: MessagesAdapter function onNeedToUpdateSmartList() { - mainViewWindowSidePanel.forceUpdateConversationSmartListView() + mainViewSidePanel.forceUpdateConversationSmartListView() } function onNavigateToWelcomePageRequested() { @@ -498,7 +487,7 @@ Window { var widthToCompare = sidePanelViewStackPreferredWidth + (inSettingsView ? settingsViewPreferredWidth : mainViewStackPreferredWidth) - if (mainViewWindow.width < widthToCompare - onWidthChangedTriggerDistance + if (mainView.width < widthToCompare - onWidthChangedTriggerDistance && mainViewStack.visible) { mainViewStack.visible = false @@ -515,8 +504,8 @@ Window { else if (inWelcomeViewStack) recursionStackViewItemMove(mainViewStack, sidePanelViewStack) - mainViewWindow.update() - } else if (mainViewWindow.width >= widthToCompare + onWidthChangedTriggerDistance + mainView.update() + } else if (mainView.width >= widthToCompare + onWidthChangedTriggerDistance && !mainViewStack.visible) { mainViewStack.visible = true @@ -535,7 +524,7 @@ Window { pushCallStackView() } - mainViewWindow.update() + mainView.update() } } @@ -543,7 +532,7 @@ Window { id: aboutPopUpDialog height: Math.min(preferredHeight, - mainViewWindow.height - JamiTheme.preferredMarginSize * 2) + mainView.height - JamiTheme.preferredMarginSize * 2) } WelcomePageQrDialog { @@ -559,12 +548,6 @@ Window { id: userProfile } - onClosing: { - close.accepted = false - mainViewWindow.hide() - mainViewWindow.closeApp() - } - Shortcut { sequence: "Ctrl+M" context: Qt.ApplicationShortcut @@ -621,10 +604,10 @@ Window { sequence: "F11" context: Qt.ApplicationShortcut onActivated: { - if (mainViewWindow.visibility !== 5) // 5 = FullScreen - mainViewWindow.visibility = "FullScreen" + if (containerWindow.visibility !== Window.FullScreen) + containerWindow.visibility = Window.FullScreen else - mainViewWindow.visibility = "Windowed" + containerWindow.visibility = Window.Windowed } } diff --git a/src/mainview/components/AccountComboBox.qml b/src/mainview/components/AccountComboBox.qml index 28dfbcbf4..09994b88e 100644 --- a/src/mainview/components/AccountComboBox.qml +++ b/src/mainview/components/AccountComboBox.qml @@ -250,13 +250,13 @@ ComboBox { PushButton { id: settingsButton - source: !mainViewWindow.inSettingsView ? + source: !mainView.inSettingsView ? "qrc:/images/icons/round-settings-24px.svg" : "qrc:/images/icons/round-close-24px.svg" normalColor: JamiTheme.backgroundColor imageColor: JamiTheme.textColor - toolTipText: !mainViewWindow.inSettingsView ? + toolTipText: !mainView.inSettingsView ? JamiStrings.openSettings : JamiStrings.closeSettings diff --git a/src/mainview/components/AccountComboBoxPopup.qml b/src/mainview/components/AccountComboBoxPopup.qml index 257b33d06..31c3d080a 100644 --- a/src/mainview/components/AccountComboBoxPopup.qml +++ b/src/mainview/components/AccountComboBoxPopup.qml @@ -173,7 +173,7 @@ Popup { onClicked: { root.close() - mainViewWindow.startWizard() + mainView.startWizard() } } diff --git a/src/mainview/components/CallOverlay.qml b/src/mainview/components/CallOverlay.qml index 621d0f283..507402070 100644 --- a/src/mainview/components/CallOverlay.qml +++ b/src/mainview/components/CallOverlay.qml @@ -262,7 +262,7 @@ Rectangle { if (JamiQmlUtils.callIsFullscreen) { callStackView.toggleFullScreen() } else { - mainViewWindow.showWelcomeView() + mainView.showWelcomeView() } } } diff --git a/src/mainview/components/CallStackView.qml b/src/mainview/components/CallStackView.qml index 2153a5e1e..990ad35bc 100644 --- a/src/mainview/components/CallStackView.qml +++ b/src/mainview/components/CallStackView.qml @@ -52,6 +52,8 @@ Rectangle { function needToCloseInCallConversationAndPotentialWindow() { // Close potential window, context menu releated windows. + if (!callStackMainView.currentItem) + return if (callStackMainView.currentItem.stackNumber === CallStackView.AudioPageStack) { audioCallPage.closeInCallConversation() CallFullScreenWindowContainerCreation.closeVideoCallFullScreenWindowContainer() diff --git a/src/mainview/components/ConversationSmartListView.qml b/src/mainview/components/ConversationSmartListView.qml index 4c362da84..d6a9a472c 100644 --- a/src/mainview/components/ConversationSmartListView.qml +++ b/src/mainview/components/ConversationSmartListView.qml @@ -42,7 +42,7 @@ ListView { function repositionIndex(uid = "") { if (uid === "") - uid = mainViewWindow.currentConvUID + uid = mainView.currentConvUID root.currentIndex = -1 updateListView() for (var i = 0; i < count; i++) { diff --git a/src/mainview/components/ConversationSmartListViewItemDelegate.qml b/src/mainview/components/ConversationSmartListViewItemDelegate.qml index 0cd9eb97c..226da609c 100644 --- a/src/mainview/components/ConversationSmartListViewItemDelegate.qml +++ b/src/mainview/components/ConversationSmartListViewItemDelegate.qml @@ -73,7 +73,7 @@ ItemDelegate { function onShowConversation(accountId, convUid) { if (convUid === UID) { - mainViewWindow.setMainView(DisplayID == DisplayName ? "" : DisplayID, + mainView.setMainView(DisplayID == DisplayName ? "" : DisplayID, DisplayName, UID, CallStackViewShouldShow, IsAudioOnly, CallState) } } diff --git a/src/mainview/components/MessageWebView.qml b/src/mainview/components/MessageWebView.qml index f29742602..08d092ecf 100644 --- a/src/mainview/components/MessageWebView.qml +++ b/src/mainview/components/MessageWebView.qml @@ -128,7 +128,7 @@ Rectangle { onBackClicked: { MessagesAdapter.updateDraft() - mainViewWindow.showWelcomeView() + mainView.showWelcomeView() } onNeedToHideConversationInCall: { diff --git a/src/mainview/components/UserInfoCallPage.qml b/src/mainview/components/UserInfoCallPage.qml index 80460bcc2..8cd9cebf5 100644 --- a/src/mainview/components/UserInfoCallPage.qml +++ b/src/mainview/components/UserInfoCallPage.qml @@ -68,9 +68,9 @@ Rectangle { toolTipText: qsTr("Toggle to display side panel") - visible: mainViewWindow.sidePanelOnly + visible: mainView.sidePanelOnly - onClicked: mainViewWindow.showWelcomeView() + onClicked: mainView.showWelcomeView() } AvatarImage { diff --git a/src/mainview/components/WelcomePage.qml b/src/mainview/components/WelcomePage.qml index 9fbf71ec4..1ba14f660 100644 --- a/src/mainview/components/WelcomePage.qml +++ b/src/mainview/components/WelcomePage.qml @@ -26,30 +26,31 @@ import net.jami.Constants 1.0 import "../../commoncomponents" Rectangle { - id: welcomeRect + id: root anchors.fill: parent color: JamiTheme.secondaryBackgroundColor - Rectangle { - id: welcomeRectComponentsGroup + ColumnLayout { + id: welcomePageColumnLayout anchors.centerIn: parent - width: Math.max(mainViewStackPreferredWidth, welcomeRect.width - 100) - height: mainViewWindow.minimumHeight - color: JamiTheme.secondaryBackgroundColor + width: Math.max(mainViewStackPreferredWidth, root.width - 100) + height: parent.height ColumnLayout { - id: welcomeRectComponentsGroupColumnLayout + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: welcomePageColumnLayout.width + Layout.preferredHeight: implicitHeight + Layout.topMargin: JamiTheme.preferredMarginSize ResponsiveImage { id: jamiLogoImage Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: welcomeRectComponentsGroup.width + Layout.preferredWidth: welcomePageColumnLayout.width Layout.preferredHeight: 100 - Layout.topMargin: JamiTheme.preferredMarginSize Layout.bottomMargin: 10 smooth: true @@ -62,7 +63,7 @@ Rectangle { id: jamiIntroText Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: welcomeRectComponentsGroup.width + Layout.preferredWidth: welcomePageColumnLayout.width Layout.preferredHeight: 80 Layout.bottomMargin: 5 @@ -80,7 +81,7 @@ Rectangle { id: jamiShareWithFriendText Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: welcomeRectComponentsGroup.width + Layout.preferredWidth: welcomePageColumnLayout.width Layout.preferredHeight: 50 wrapMode: Text.WordWrap @@ -99,9 +100,9 @@ Rectangle { id: jamiRegisteredNameRect Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: welcomeRectComponentsGroup.width + Layout.preferredWidth: welcomePageColumnLayout.width Layout.preferredHeight: 65 - Layout.bottomMargin: JamiTheme.preferredMarginSize + color: JamiTheme.secondaryBackgroundColor visible: AccountAdapter.currentAccountType === Profile.Type.RING @@ -113,9 +114,11 @@ Rectangle { Text { id: jamiRegisteredNameText + Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: welcomeRectComponentsGroup.width + Layout.preferredWidth: welcomePageColumnLayout.width Layout.preferredHeight: 30 + font.pointSize: JamiTheme.textFontSize + 1 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -125,7 +128,7 @@ Rectangle { id: textMetricsjamiRegisteredNameText font: jamiRegisteredNameText.font text: UtilsAdapter.getBestId(AccountAdapter.currentAccountId) - elideWidth: welcomeRectComponentsGroup.width + elideWidth: welcomePageColumnLayout.width elide: Qt.ElideMiddle } } @@ -148,27 +151,26 @@ Rectangle { } } } - } - } - MaterialButton { - id: btnClose + } - anchors.bottom: parent.bottom - anchors.bottomMargin: JamiTheme.preferredMarginSize - anchors.horizontalCenter: parent.horizontalCenter + MaterialButton { + id: btnAboutPopUp - width: 150 - height: 30 + Layout.alignment: Qt.AlignBottom | Qt.AlignHCenter + Layout.bottomMargin: JamiTheme.preferredMarginSize + Layout.preferredWidth: 150 + Layout.preferredHeight: 30 - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true - text: JamiStrings.aboutJami + text: JamiStrings.aboutJami - onClicked: aboutPopUpDialog.open() + onClicked: aboutPopUpDialog.open() + } } CustomBorder { diff --git a/src/settingsview/SettingsView.qml b/src/settingsview/SettingsView.qml index e013f27b5..3369d5a4a 100644 --- a/src/settingsview/SettingsView.qml +++ b/src/settingsview/SettingsView.qml @@ -87,9 +87,9 @@ Rectangle { AccountAdapter.stopPreviewing() settingsViewRect.stopBooth() if (showMainView) - settingsViewWindowNeedToShowMainViewWindow() + settingsViewNeedToShowMainView() else - settingsViewWindowNeedToShowNewWizardWindow() + settingsViewNeedToShowNewWizardWindow() } function accountListChanged() { @@ -106,8 +106,8 @@ Rectangle { property int profileType: SettingsAdapter.getCurrentAccount_Profile_Info_Type() property int selectedMenu: SettingsView.Account // signal to redirect the page to main view - signal settingsViewWindowNeedToShowMainViewWindow() - signal settingsViewWindowNeedToShowNewWizardWindow + signal settingsViewNeedToShowMainView() + signal settingsViewNeedToShowNewWizardWindow signal settingsBackArrowClicked diff --git a/src/settingsview/components/KeyBoardShortcutTable.qml b/src/settingsview/components/KeyBoardShortcutTable.qml index 1f38c8cc0..240d21914 100644 --- a/src/settingsview/components/KeyBoardShortcutTable.qml +++ b/src/settingsview/components/KeyBoardShortcutTable.qml @@ -157,7 +157,7 @@ BaseDialog { Rectangle { id: cellRectWithThreeKeys - implicitWidth: minWidth / 2 + implicitWidth: JamiTheme.mainViewMinWidth / 2 implicitHeight: 50 anchors.left: parent.left anchors.leftMargin: 20 @@ -257,8 +257,8 @@ BaseDialog { anchors.bottomMargin: 20 anchors.topMargin: 50 - width: minWidth - height: minHeight - 100 + width: JamiTheme.mainViewMinWidth + height: JamiTheme.mainViewMinHeight - 100 anchors.fill: parent StackLayout { diff --git a/src/settingsview/components/SettingsHeader.qml b/src/settingsview/components/SettingsHeader.qml index c6dd4b8e3..430b0dd37 100644 --- a/src/settingsview/components/SettingsHeader.qml +++ b/src/settingsview/components/SettingsHeader.qml @@ -47,7 +47,7 @@ RowLayout { toolTipText: JamiStrings.back hoverEnabled: true - visible: mainViewWindow.sidePanelOnly + visible: mainView.sidePanelOnly onClicked: { backArrowClicked() diff --git a/src/wizardview/WizardView.qml b/src/wizardview/WizardView.qml index b3d80c587..655fd6525 100644 --- a/src/wizardview/WizardView.qml +++ b/src/wizardview/WizardView.qml @@ -25,6 +25,7 @@ import net.jami.Models 1.0 import net.jami.Adapters 1.0 import net.jami.Constants 1.0 +import "../" import "../commoncomponents" import "components" @@ -67,7 +68,7 @@ Rectangle { property var inputParaObject: ({}) // signal to redirect the page to main view - signal needToShowMainViewWindow(int accountIndex) + signal loaderSourceChangeRequested(int sourceToLoad) signal wizardViewIsClosed visible: true @@ -98,7 +99,7 @@ Rectangle { changePageQML(WizardView.WizardViewPageIndex.BACKUPKEYSPAGE) } else { changePageQML(WizardView.WizardViewPageIndex.WELCOMEPAGE) - needToShowMainViewWindow(addedAccountIndex) + loaderSourceChangeRequested(MainApplicationWindow.LoadedSource.MainView) } } @@ -162,7 +163,7 @@ Rectangle { title, info) if (success) { console.log("Account Export Succeed") - needToShowMainViewWindow(addedAccountIndex) + loaderSourceChangeRequested(MainApplicationWindow.LoadedSource.MainView) } } } @@ -321,12 +322,12 @@ Rectangle { } changePageQML(WizardView.WizardViewPageIndex.WELCOMEPAGE) - needToShowMainViewWindow(addedAccountIndex) + loaderSourceChangeRequested(MainApplicationWindow.LoadedSource.MainView) } onLeavePage: { changePageQML(WizardView.WizardViewPageIndex.WELCOMEPAGE) - needToShowMainViewWindow(addedAccountIndex) + loaderSourceChangeRequested(MainApplicationWindow.LoadedSource.MainView) } } @@ -383,7 +384,7 @@ Rectangle { changePageQML(WizardView.WizardViewPageIndex.BACKUPKEYSPAGE) else { changePageQML(WizardView.WizardViewPageIndex.WELCOMEPAGE) - needToShowMainViewWindow(addedAccountIndex) + loaderSourceChangeRequested(MainApplicationWindow.LoadedSource.MainView) } profilePage.initializeOnShowUp() -- GitLab