From fd8747e4aa10fa6794ba00d3a1982256efece92d Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Thu, 9 Jun 2022 17:02:32 +0200 Subject: [PATCH] Add a simple log viewer inside the application. --- CHANGELOG.md | 2 + linphone-app/assets/languages/da.ts | 4 + linphone-app/assets/languages/de.ts | 4 + linphone-app/assets/languages/en.ts | 4 + linphone-app/assets/languages/es.ts | 4 + linphone-app/assets/languages/fr_FR.ts | 4 + linphone-app/assets/languages/hu.ts | 4 + linphone-app/assets/languages/it.ts | 4 + linphone-app/assets/languages/ja.ts | 4 + linphone-app/assets/languages/lt.ts | 4 + linphone-app/assets/languages/pt_BR.ts | 4 + linphone-app/assets/languages/ru.ts | 4 + linphone-app/assets/languages/sv.ts | 4 + linphone-app/assets/languages/tr.ts | 4 + linphone-app/assets/languages/uk.ts | 4 + linphone-app/assets/languages/zh_CN.ts | 4 + linphone-app/src/app/logger/Logger.cpp | 16 ++ linphone-app/src/app/logger/Logger.hpp | 3 +- .../src/components/settings/SettingsModel.cpp | 4 + .../src/components/settings/SettingsModel.hpp | 2 + .../views/App/Settings/SettingsAdvanced.qml | 10 + .../ui/views/App/Settings/SettingsWindow.qml | 243 +++++++++++------- .../Styles/Settings/SettingsWindowStyle.qml | 28 ++ linphone-sdk | 2 +- 24 files changed, 280 insertions(+), 90 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 892af3ba3..1c77c5169 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Video conference. +- Log viewer. +- Option to set the display name in "using an account" tab of assistant. ### Fixed - Crash on exit. diff --git a/linphone-app/assets/languages/da.ts b/linphone-app/assets/languages/da.ts index 815e398a1..774e805a7 100644 --- a/linphone-app/assets/languages/da.ts +++ b/linphone-app/assets/languages/da.ts @@ -2023,6 +2023,10 @@ Klik her: <a href="%1">%1</a> 'No Plugins to load' : Text in combobox + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/de.ts b/linphone-app/assets/languages/de.ts index 95bc81292..69ce3efc2 100644 --- a/linphone-app/assets/languages/de.ts +++ b/linphone-app/assets/languages/de.ts @@ -2023,6 +2023,10 @@ Klicken Sie hier: <a href="%1">%1</a> 'No Plugins to load' : Text in combobox Keine Plugins zu laden + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/en.ts b/linphone-app/assets/languages/en.ts index 389f78ce6..7c582b2a2 100644 --- a/linphone-app/assets/languages/en.ts +++ b/linphone-app/assets/languages/en.ts @@ -2023,6 +2023,10 @@ Click here: <a href="%1">%1</a> 'No Plugins to load' : Text in combobox No Plugins to load + + viewlogs + VIEW + SettingsAudio diff --git a/linphone-app/assets/languages/es.ts b/linphone-app/assets/languages/es.ts index ab598d284..a97a11223 100644 --- a/linphone-app/assets/languages/es.ts +++ b/linphone-app/assets/languages/es.ts @@ -2023,6 +2023,10 @@ Haga clic aquí: <a href="%1">%1 </a> 'No Plugins to load' : Text in combobox + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/fr_FR.ts b/linphone-app/assets/languages/fr_FR.ts index b823c1f72..954a3c8cd 100644 --- a/linphone-app/assets/languages/fr_FR.ts +++ b/linphone-app/assets/languages/fr_FR.ts @@ -2023,6 +2023,10 @@ Cliquez ici : <a href="%1">%1</a> 'No Plugins to load' : Text in combobox Pas de plugin à charger + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/hu.ts b/linphone-app/assets/languages/hu.ts index 83f427d47..7e77301db 100644 --- a/linphone-app/assets/languages/hu.ts +++ b/linphone-app/assets/languages/hu.ts @@ -2011,6 +2011,10 @@ Kattintson ide: <a href="%1">%1</a> 'No Plugins to load' : Text in combobox Nincsenek betölthető beépülő modulok + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/it.ts b/linphone-app/assets/languages/it.ts index 1cbbdd95f..8fde32e06 100644 --- a/linphone-app/assets/languages/it.ts +++ b/linphone-app/assets/languages/it.ts @@ -2023,6 +2023,10 @@ Clicca: <a href="%1">%1</a> 'No Plugins to load' : Text in combobox + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/ja.ts b/linphone-app/assets/languages/ja.ts index a3b89ab17..0f36ce552 100644 --- a/linphone-app/assets/languages/ja.ts +++ b/linphone-app/assets/languages/ja.ts @@ -2011,6 +2011,10 @@ 'No Plugins to load' : Text in combobox + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/lt.ts b/linphone-app/assets/languages/lt.ts index 1e51fb7d5..d75218fd5 100644 --- a/linphone-app/assets/languages/lt.ts +++ b/linphone-app/assets/languages/lt.ts @@ -2035,6 +2035,10 @@ Spustelėkite čia: <a href="%1">%1</a> 'No Plugins to load' : Text in combobox + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/pt_BR.ts b/linphone-app/assets/languages/pt_BR.ts index ecc63f288..1a16e0c18 100644 --- a/linphone-app/assets/languages/pt_BR.ts +++ b/linphone-app/assets/languages/pt_BR.ts @@ -2023,6 +2023,10 @@ Clique aqui: <a href="%1">%1 </a> 'No Plugins to load' : Text in combobox Nenhum plug-in para carregar + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/ru.ts b/linphone-app/assets/languages/ru.ts index c63b1ff38..f4e348284 100644 --- a/linphone-app/assets/languages/ru.ts +++ b/linphone-app/assets/languages/ru.ts @@ -2035,6 +2035,10 @@ 'No Plugins to load' : Text in combobox Нет плагинов для загрузки + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/sv.ts b/linphone-app/assets/languages/sv.ts index 28a6742bb..614330084 100644 --- a/linphone-app/assets/languages/sv.ts +++ b/linphone-app/assets/languages/sv.ts @@ -2023,6 +2023,10 @@ Klicka här: <a href="%1">%1</a> 'No Plugins to load' : Text in combobox + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/tr.ts b/linphone-app/assets/languages/tr.ts index acab10d69..508904de5 100644 --- a/linphone-app/assets/languages/tr.ts +++ b/linphone-app/assets/languages/tr.ts @@ -2011,6 +2011,10 @@ Buraya tıklayın: <a href="%1">%1</a> 'No Plugins to load' : Text in combobox Yüklenecek eklenti yok + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/uk.ts b/linphone-app/assets/languages/uk.ts index 1b9734695..b6a601919 100644 --- a/linphone-app/assets/languages/uk.ts +++ b/linphone-app/assets/languages/uk.ts @@ -2035,6 +2035,10 @@ 'No Plugins to load' : Text in combobox + + viewlogs + + SettingsAudio diff --git a/linphone-app/assets/languages/zh_CN.ts b/linphone-app/assets/languages/zh_CN.ts index 44cc2787c..530ed1b41 100644 --- a/linphone-app/assets/languages/zh_CN.ts +++ b/linphone-app/assets/languages/zh_CN.ts @@ -2011,6 +2011,10 @@ 'No Plugins to load' : Text in combobox 没有插件可加载 + + viewlogs + + SettingsAudio diff --git a/linphone-app/src/app/logger/Logger.cpp b/linphone-app/src/app/logger/Logger.cpp index 26c2ed58b..1a40395b7 100644 --- a/linphone-app/src/app/logger/Logger.cpp +++ b/linphone-app/src/app/logger/Logger.cpp @@ -209,3 +209,19 @@ void Logger::init (const shared_ptr &config) { mInstance->enable(SettingsModel::getLogsEnabled(config)); } + +QString Logger::getLogText()const{ + QDir path = QString::fromStdString(linphone::Core::getLogCollectionPath()); + QString prefix = QString::fromStdString(linphone::Core::getLogCollectionPrefix()); + auto files = path.entryInfoList(QStringList(prefix+"*.log"), QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Time); + QString result; + for(auto fileInfo : files){ + QFile file(fileInfo.filePath()); + if (file.open(QIODevice::ReadOnly)) { + QByteArray arr = file.readAll(); + result += QString::fromLatin1(arr); + file.close(); + } + } + return result; +} diff --git a/linphone-app/src/app/logger/Logger.hpp b/linphone-app/src/app/logger/Logger.hpp index 36a63cb3a..374b49e52 100644 --- a/linphone-app/src/app/logger/Logger.hpp +++ b/linphone-app/src/app/logger/Logger.hpp @@ -43,8 +43,9 @@ public: } void enable (bool status); + QString getLogText()const; - static void init (const std::shared_ptr &config); + static void init (const std::shared_ptr &config); static Logger *getInstance () { return mInstance; diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index 97ac32d9c..9c1ce7ec9 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -1462,6 +1462,10 @@ void SettingsModel::accessAdvancedSettings() { //------------------------------------------------------------------------------ +QString SettingsModel::getLogText()const{ + return Logger::getInstance()->getLogText(); +} + QString SettingsModel::getLogsFolder () const { return getLogsFolder(mConfig); } diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index 52e3c51d2..eba3242f4 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -543,6 +543,8 @@ public: void accessAdvancedSettings(); + Q_INVOKABLE QString getLogText()const; + QString getLogsFolder () const; void setLogsFolder (const QString &folder); diff --git a/linphone-app/ui/views/App/Settings/SettingsAdvanced.qml b/linphone-app/ui/views/App/Settings/SettingsAdvanced.qml index 0d5031cc0..3892883f5 100644 --- a/linphone-app/ui/views/App/Settings/SettingsAdvanced.qml +++ b/linphone-app/ui/views/App/Settings/SettingsAdvanced.qml @@ -16,7 +16,9 @@ import 'SettingsAdvanced.js' as Logic // ============================================================================= TabContainer { + id: mainItem color: "#00000000" + signal showLogs() Column { id: column spacing: SettingsWindowStyle.forms.spacing @@ -72,6 +74,14 @@ TabContainer { anchors.right: parent.right spacing: SettingsAdvancedStyle.buttons.spacing + TextButtonB { + text: qsTr('viewlogs') + + onClicked: { + mainItem.showLogs() + } + } + TextButtonB { text: qsTr('cleanLogs') diff --git a/linphone-app/ui/views/App/Settings/SettingsWindow.qml b/linphone-app/ui/views/App/Settings/SettingsWindow.qml index 89e95ef6f..6953cb431 100644 --- a/linphone-app/ui/views/App/Settings/SettingsWindow.qml +++ b/linphone-app/ui/views/App/Settings/SettingsWindow.qml @@ -2,6 +2,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 +import Clipboard 1.0 import Common 1.0 import Common.Styles 1.0 import Konami 1.0 @@ -45,107 +46,173 @@ ApplicationWindow { // ------------------------------------------------------------------------- // Navigation bar. // ------------------------------------------------------------------------- - - RowLayout { + Item{ Layout.fillWidth: true - spacing: 0 - - TabBar { - id: tabBar - - onCurrentIndexChanged: SettingsModel.onSettingsTabChanged(currentIndex) - - TabButton { - iconName: TabButtonStyle.icon.sipAccountsIcon - text: qsTr('sipAccountsTab') - width: implicitWidth - } - - TabButton { - iconName: TabButtonStyle.icon.audioIcon - text: qsTr('audioTab') - width: implicitWidth - } - - TabButton { - enabled: SettingsModel.videoSupported - iconName: TabButtonStyle.icon.videoIcon - text: qsTr('videoTab') - width: implicitWidth - } - - TabButton { - iconName: TabButtonStyle.icon.callIcon - text: qsTr('callsAndChatTab') - width: implicitWidth - } - - TabButton { - enabled: SettingsModel.showNetworkSettings || SettingsModel.developerSettingsEnabled - iconName: TabButtonStyle.icon.networkIcon - text: qsTr('networkTab') - width: implicitWidth - } - - TabButton { - visible: SettingsModel.tunnelAvailable() - enabled: visible - iconName: TabButtonStyle.icon.sipAccountsIcon - //: 'Tunnel' : Tab title for tunnel section in settings. - text: qsTr('tunnelTab') - width: visible ? implicitWidth : 0 - } - - TabButton { - iconName: TabButtonStyle.icon.advancedIcon - text: qsTr('uiTab') - width: implicitWidth - } - - TabButton { - iconName: TabButtonStyle.icon.advancedIcon - text: qsTr('uiAdvanced') - width: implicitWidth - } - } - - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: TabButtonStyle.text.height - - color: TabButtonStyle.backgroundColor.normal - - MouseArea { - anchors.fill: parent + Layout.preferredHeight: TabButtonStyle.text.height + RowLayout { + anchors.fill: parent + spacing: 0 + TabBar { + id: tabBar - onClicked: konami.forceActiveFocus() - cursorShape: Qt.ArrowCursor + onCurrentIndexChanged: SettingsModel.onSettingsTabChanged(currentIndex) - Konami { - id: konami - onTriggered: SettingsModel.developerSettingsEnabled = true + TabButton { + iconName: TabButtonStyle.icon.sipAccountsIcon + text: qsTr('sipAccountsTab') + width: implicitWidth + } + + TabButton { + iconName: TabButtonStyle.icon.audioIcon + text: qsTr('audioTab') + width: implicitWidth + } + + TabButton { + enabled: SettingsModel.videoSupported + iconName: TabButtonStyle.icon.videoIcon + text: qsTr('videoTab') + width: implicitWidth + } + + TabButton { + iconName: TabButtonStyle.icon.callIcon + text: qsTr('callsAndChatTab') + width: implicitWidth + } + + TabButton { + enabled: SettingsModel.showNetworkSettings || SettingsModel.developerSettingsEnabled + iconName: TabButtonStyle.icon.networkIcon + text: qsTr('networkTab') + width: implicitWidth + } + + TabButton { + visible: SettingsModel.tunnelAvailable() + enabled: visible + iconName: TabButtonStyle.icon.sipAccountsIcon + //: 'Tunnel' : Tab title for tunnel section in settings. + text: qsTr('tunnelTab') + width: visible ? implicitWidth : 0 + } + + TabButton { + iconName: TabButtonStyle.icon.advancedIcon + text: qsTr('uiTab') + width: implicitWidth + } + + TabButton { + iconName: TabButtonStyle.icon.advancedIcon + text: qsTr('uiAdvanced') + width: implicitWidth } } + + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: TabButtonStyle.text.height + + color: TabButtonStyle.backgroundColor.normal + + MouseArea { + anchors.fill: parent + + onClicked: konami.forceActiveFocus() + cursorShape: Qt.ArrowCursor + + Konami { + id: konami + onTriggered: SettingsModel.developerSettingsEnabled = true + } + } + } + } + Rectangle{ + id: hideBar + anchors.fill: parent + color: TabButtonStyle.backgroundColor.normal + visible: logViewer.active } } // ------------------------------------------------------------------------- // Content. // ------------------------------------------------------------------------- - - StackLayout { + Item{ Layout.fillHeight: true Layout.fillWidth: true - - currentIndex: tabBar.currentIndex - SettingsSipAccounts {} - SettingsAudio {} - SettingsVideo {} - SettingsCallsChat {} - SettingsNetwork {} - SettingsTunnel {} - SettingsUi {} - SettingsAdvanced {} + StackLayout { + anchors.fill: parent + + currentIndex: tabBar.currentIndex + SettingsSipAccounts {} + SettingsAudio {} + SettingsVideo {} + SettingsCallsChat {} + SettingsNetwork {} + SettingsTunnel {} + SettingsUi {} + SettingsAdvanced {onShowLogs: logViewer.active=true } + } + Loader{ + id: logViewer + anchors.fill: parent + active: false + sourceComponent: Component{ + Rectangle{ + id: logBackground + anchors.fill: parent + property variant stringList: null + function updateText() { + stringList = SettingsModel.getLogText().split('\n') + idContentListView.positionViewAtEnd() + } + Component.onCompleted: updateText() + ColumnLayout{ + anchors.fill: parent + RowLayout{// Prepare for other actions + ActionButton{ + Layout.topMargin: 5 + Layout.leftMargin: 5 + backgroundRadius: width/2 + isCustom: true + colorSet: SettingsWindowStyle.buttons.back + onClicked: logViewer.active = false + } + ActionButton{ + Layout.topMargin: 5 + Layout.leftMargin: 5 + backgroundRadius: width/2 + isCustom: true + colorSet: SettingsWindowStyle.buttons.copy + onClicked: {updating = true ; Clipboard.text = SettingsModel.getLogText();updating=false} + } + } + ListView { + id: idContentListView + model: logBackground.stringList + Layout.fillHeight: true + Layout.fillWidth: true + Layout.topMargin: 20 + Layout.leftMargin: 10 + Layout.rightMargin: 10 + + delegate: Text { + width: idContentListView.width + text: model.modelData + font.pointSize: FormTableStyle.entry.text.pointSize + textFormat: Text.PlainText + wrapMode: Text.Wrap + } + ScrollBar.vertical: ScrollBar {} + } + } + } + } + } } // ------------------------------------------------------------------------- diff --git a/linphone-app/ui/views/App/Styles/Settings/SettingsWindowStyle.qml b/linphone-app/ui/views/App/Styles/Settings/SettingsWindowStyle.qml index 1d463f6c3..4cf432aec 100644 --- a/linphone-app/ui/views/App/Styles/Settings/SettingsWindowStyle.qml +++ b/linphone-app/ui/views/App/Styles/Settings/SettingsWindowStyle.qml @@ -54,5 +54,33 @@ QtObject { property color foregroundHoveredColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_h', icon, 'me_h_b_fg').color property color foregroundPressedColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_p', icon, 'me_p_b_fg').color } + property QtObject back: QtObject { + property int iconSize: 35 + property string icon : 'back_custom' + property string name : 'back' + property color backgroundNormalColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_n', icon, 's_n_b_bg').color + property color backgroundDisabledColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_d', icon, 's_d_b_bg').color + property color backgroundHoveredColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_h', icon, 's_h_b_bg').color + property color backgroundPressedColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_p', icon, 's_p_b_bg').color + property color foregroundNormalColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_n', icon, 's_n_b_fg').color + property color foregroundDisabledColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_d', icon, 's_d_b_fg').color + property color foregroundHoveredColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_h', icon, 's_h_b_fg').color + property color foregroundPressedColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_p', icon, 's_p_b_fg').color + } + property QtObject copy: QtObject { + property int iconSize: 30 + property string icon : 'copy_custom' + property string name : 'copy' + property color backgroundNormalColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_n', icon, 'l_n_b_bg').color + property color backgroundDisabledColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_d', icon, 'l_d_b_bg').color + property color backgroundHoveredColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_h', icon, 'l_h_b_bg').color + property color backgroundPressedColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_p', icon, 'l_p_b_bg').color + property color backgroundUpdatingColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_u', icon, 'l_p_b_bg').color + property color foregroundNormalColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_n', icon, 'l_n_b_fg').color + property color foregroundDisabledColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_d', icon, 'l_d_b_fg').color + property color foregroundHoveredColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_h', icon, 'l_h_b_fg').color + property color foregroundPressedColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_p', icon, 'l_p_b_fg').color + property color foregroundUpdatingColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_u', icon, 'l_p_b_fg').color + } } } diff --git a/linphone-sdk b/linphone-sdk index 9542d335e..1355eaf8e 160000 --- a/linphone-sdk +++ b/linphone-sdk @@ -1 +1 @@ -Subproject commit 9542d335ea525de66d7b5519bac4e1ba808caa3a +Subproject commit 1355eaf8e34f3505f3812743bd2232e01558fde2