From dd5e85df1389039ce14d043e0c9a5099fb4851fc Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Thu, 12 Oct 2023 16:17:13 +0200 Subject: [PATCH] =?UTF-8?q?Add=203=20configs=20:=20-=20show=5Fdefault=5Fpa?= =?UTF-8?q?ge=20:=20at=20start=20:=20open=20the=20page.=20-=20show=5Fforce?= =?UTF-8?q?d=5Fassistant=5Fpage=20:=20on=20'home'=20click=20:=20display=20?= =?UTF-8?q?the=20specified=20page=20of=20assistant.=20-=20show=5Fhome=5Fpa?= =?UTF-8?q?ge:=20if=20false,=20Home=20page=20should=20be=20never=20display?= =?UTF-8?q?ed=C2=B5.=20Assistant=20page=20is=20show=20instead.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/settings/SettingsModel.cpp | 12 ++++++++++++ .../src/components/settings/SettingsModel.hpp | 3 +++ .../Main/Assistant/AssistantAbstractView.qml | 3 ++- .../App/Main/Assistant/AssistantHome.qml | 12 +++++++++--- .../App/Main/Assistant/UseOtherSipAccount.qml | 4 ++-- linphone-app/ui/views/App/Main/MainWindow.js | 19 +------------------ linphone-app/ui/views/App/Main/MainWindow.qml | 18 +++++++++++++++--- 7 files changed, 44 insertions(+), 27 deletions(-) diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index 9e9bc02a7..b316accfb 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -1723,6 +1723,18 @@ bool SettingsModel::getShowStartVideoCallButton ()const{ return !!mConfig->getInt(UiSection, "show_start_video_button", 1); } +int SettingsModel::getShowDefaultPage() const { + return mConfig->getInt(UiSection, "show_default_page", -1); +} + +int SettingsModel::getShowForcedAssistantPage() const { + return mConfig->getInt(UiSection, "show_forced_assistant_page", -1); +} + +bool SettingsModel::getShowHomePage() const { + return !!mConfig->getInt(UiSection, "show_home_page", true); +} + bool SettingsModel::isMipmapEnabled() const{ return !!mConfig->getInt(UiSection, "mipmap_enabled", 0); } diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index e26bb5f47..e38927a4b 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -622,6 +622,9 @@ public: Q_INVOKABLE bool getShowLocalSipAccount () const; Q_INVOKABLE bool getShowStartChatButton () const; Q_INVOKABLE bool getShowStartVideoCallButton () const; + Q_INVOKABLE int getShowDefaultPage() const; // -1 : default + Q_INVOKABLE int getShowForcedAssistantPage() const; // -1 : no force + Q_INVOKABLE bool getShowHomePage() const; bool isMipmapEnabled() const; void setMipmapEnabled(const bool& enabled); diff --git a/linphone-app/ui/views/App/Main/Assistant/AssistantAbstractView.qml b/linphone-app/ui/views/App/Main/Assistant/AssistantAbstractView.qml index 409c3e496..01a02dfee 100644 --- a/linphone-app/ui/views/App/Main/Assistant/AssistantAbstractView.qml +++ b/linphone-app/ui/views/App/Main/Assistant/AssistantAbstractView.qml @@ -2,6 +2,7 @@ import QtQuick 2.7 import QtQuick.Layouts 1.3 import Common 1.0 +import Linphone 1.0 import App.Styles 1.0 @@ -19,7 +20,7 @@ Item { property alias description: description.text property alias title: title.text - property bool backEnabled: true + property bool backEnabled: SettingsModel.getShowForcedAssistantPage() < 0 property bool maximized: false // Used to stretch content to fit all the view (the title will be set to top) default property alias _content: content.data diff --git a/linphone-app/ui/views/App/Main/Assistant/AssistantHome.qml b/linphone-app/ui/views/App/Main/Assistant/AssistantHome.qml index 84a819828..48beb0993 100644 --- a/linphone-app/ui/views/App/Main/Assistant/AssistantHome.qml +++ b/linphone-app/ui/views/App/Main/Assistant/AssistantHome.qml @@ -15,12 +15,12 @@ ColumnLayout { // --------------------------------------------------------------------------- // Info. // --------------------------------------------------------------------------- - + property bool isVisible: SettingsModel.getShowForcedAssistantPage() < 0 Item { id: infoItem Layout.fillHeight: true Layout.fillWidth: true - + visible: parent.isVisible ColumnLayout { anchors.verticalCenter: parent.verticalCenter spacing: 0 @@ -80,7 +80,7 @@ ColumnLayout { Layout.bottomMargin: 10 Layout.maximumWidth: infoItem.width Layout.alignment: Qt.AlignHCenter - visible: applicationVendor != '' && ConstantsCpp.CguUrl != '' && ConstantsCpp.PrivatePolicyUrl != '' + visible: applicationVendor != '' && ConstantsCpp.CguUrl != '' && ConstantsCpp.PrivatePolicyUrl != '' && parent.isVisible checked: SettingsModel.cguAccepted onCheckedChanged: SettingsModel.cguAccepted = checked @@ -101,6 +101,7 @@ ColumnLayout { cellHeight: height / 2 cellWidth: width / 2 enabled: cguCheckBox.checked + visible: parent.isVisible delegate: Item { height: buttons.cellHeight @@ -116,6 +117,11 @@ ColumnLayout { text: $text.replace('%1', Qt.application.name.toUpperCase()) onClicked:{ assistant.pushView($view, $props) } + Component.onCompleted: { + if (SettingsModel.getShowForcedAssistantPage() == index) { + assistant.pushView($view, $props) + } + } } } Connections{ diff --git a/linphone-app/ui/views/App/Main/Assistant/UseOtherSipAccount.qml b/linphone-app/ui/views/App/Main/Assistant/UseOtherSipAccount.qml index 20c876871..9113c9d98 100644 --- a/linphone-app/ui/views/App/Main/Assistant/UseOtherSipAccount.qml +++ b/linphone-app/ui/views/App/Main/Assistant/UseOtherSipAccount.qml @@ -23,14 +23,14 @@ import Common.Styles 1.0 title: qsTr('useOtherSipAccountTitle') - property bool showWarning : true + property bool showWarning : SettingsModel.getShowForcedAssistantPage() < 0 // --------------------------------------------------------------------------- StackView { id: mainStack width: currentItem.implicitWidth>0 ? currentItem.implicitWidth : currentItem.width height: currentItem.implicitHeight>0 ? currentItem.implicitHeight : currentItem.height - initialItem: warningComponent + initialItem: showWarning ? warningComponent : formComponent anchors.horizontalCenter: parent.horizontalCenter } Component{ diff --git a/linphone-app/ui/views/App/Main/MainWindow.js b/linphone-app/ui/views/App/Main/MainWindow.js index 7f7637f53..af0263cc8 100644 --- a/linphone-app/ui/views/App/Main/MainWindow.js +++ b/linphone-app/ui/views/App/Main/MainWindow.js @@ -55,6 +55,7 @@ function unlockView () { } function setView (view, props, callback) { + if(view == 'Home' && !Linphone.SettingsModel.getShowHomePage()) view = 'Assistant'; function apply (view, props, showWindow, callback) { if(showWindow) Linphone.App.smartShowWindow(window) @@ -102,24 +103,6 @@ function manageAccounts () { // ----------------------------------------------------------------------------- function updateSelectedEntry (view, props) { - var item = mainLoader.item - - var mainMenu = item.mainMenu - var timeline = item.timeline - - if (view === 'Home') { - mainMenu.currentMenu = 0 - } else if (view === 'Calls') { - mainMenu.currentMenu = 1 - } else if (view === 'Conversations') { - mainMenu.currentMenu = 2 - } else if (view === 'Contacts') { - mainMenu.currentMenu = 3 - } else if (view === 'Conferences') { - mainMenu.currentMenu = 4 - }else{ - mainMenu.currentMenu = -1 - } } // ----------------------------------------------------------------------------- diff --git a/linphone-app/ui/views/App/Main/MainWindow.qml b/linphone-app/ui/views/App/Main/MainWindow.qml index 7d958b9e4..d80d51168 100644 --- a/linphone-app/ui/views/App/Main/MainWindow.qml +++ b/linphone-app/ui/views/App/Main/MainWindow.qml @@ -70,6 +70,14 @@ ApplicationWindow { active: false anchors.fill: parent + onLoaded: switch(SettingsModel.getShowDefaultPage()) { + case 1 : window.setView('Calls'); break; + case 2 : window.setView('Conversations'); break; + case 3 : ContactsListModel.update(); window.setView('Contacts'); break; + case 4 : window.setView('Conferences'); break; + default:{} + } + sourceComponent: ColumnLayout { // Workaround to get these properties in `MainWindow.js`. readonly property alias contentLoader: contentLoader @@ -266,8 +274,12 @@ ApplicationWindow { // Main menu. Rectangle{ id: mainMenu - property int currentMenu: 0 - + property int currentMenu: contentLoader.source == 'qrc:/ui/views/App/Main/Home.qml' || contentLoader.source == 'qrc:/ui/views/App/Main/Assistant.qml' ? 0 + : contentLoader.source == 'qrc:/ui/views/App/Main/Calls.qml' ? 1 + : contentLoader.source == 'qrc:/ui/views/App/Main/Conversations.qml' ? 2 + : contentLoader.source == 'qrc:/ui/views/App/Main/Contacts.qml' ? 3 + : contentLoader.source == 'qrc:/ui/views/App/Main/Conferences.qml' ? 4 + : -1 Layout.fillHeight: true Layout.preferredWidth: MainWindowStyle.menu.leftMargin + MainWindowStyle.menu.rightMargin + MainWindowStyle.menu.buttonSize color: '#F3F3F3' @@ -382,7 +394,7 @@ ApplicationWindow { anchors.fill: parent - source: 'Home.qml' + source: SettingsModel.getShowHomePage() ? 'Home.qml' : 'Assistant.qml' Component.onCompleted: if(accountStatus.noAccountConfigured) source= 'Assistant.qml' // default proxy = 1. Do not use this set diretly in source because of bindings that will override next setSource } TelKeypad {