From b5a8cdbceb7e931e25d345d5d1c957d8b94b94d5 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Fri, 3 Mar 2023 17:17:08 +0100 Subject: [PATCH] - Some case of unwanted settings folders creation : When calling settings paths from SettingsModel, we checked on default in all cases. That lead to create folders to be writable. => Check for default only if path has not been overwritten in linphonerc. - Replace black thumbnails that contains transparency by white color. Thumbnails are in jpg where there is no transparency. By default, transparency is replaced by black color because not background color has been defined. => Set background image in white. # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 6 ++-- .../src/components/content/ContentModel.cpp | 15 ++++++--- .../src/components/recorder/RecorderModel.cpp | 2 +- .../src/components/settings/SettingsModel.cpp | 32 +++++++++---------- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36b535c87..f138e1f8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,11 +16,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Mute option for each chatrooms. - New Chat Layout. - -## 5.0.12 - undefined +## 5.0.12 - 2023-03-01 ## Fixed +- Some case of unwanted settings folders creation. +- Replace black thumbnails that contains transparency by white color. - Unusable Contact sheet. +- Update SDK to 5.2.28 (cleanup orphan NAT sections and race condition on MSTicker threads). ## 5.0.11 - 2023-02-24 diff --git a/linphone-app/src/components/content/ContentModel.cpp b/linphone-app/src/components/content/ContentModel.cpp index c7765cb5d..e7f6499b1 100644 --- a/linphone-app/src/components/content/ContentModel.cpp +++ b/linphone-app/src/components/content/ContentModel.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "app/App.hpp" #include "app/paths/Paths.hpp" @@ -163,20 +164,26 @@ void ContentModel::createThumbnail (const bool& force) { if(!appdata.mData.contains(path) || !QFileInfo(QString::fromStdString(Paths::getThumbnailsDirPath())+appdata.mData[path]).isFile()){ // File don't exist. Create the thumbnail + QImage originalImage(path); - QImage image(path); - if( image.isNull()){// Try to determine format from headers + if( originalImage.isNull()){// Try to determine format from headers QImageReader reader(path); reader.setDecideFormatFromContent(true); QByteArray format = reader.format(); if(!format.isEmpty()) - image = QImage(path, format); + originalImage = QImage(path, format); } - if (!image.isNull()){ + if (!originalImage.isNull()){ int rotation = 0; QExifImageHeader exifImageHeader; if (exifImageHeader.loadFromJpeg(path)) rotation = int(exifImageHeader.value(QExifImageHeader::ImageTag::Orientation).toShort()); +// Fill with color to replace transparency with white color instead of black (default). + QImage image(originalImage.size(), originalImage.format()); + image.fill(QColor(Qt::white).rgb()); + QPainter painter(&image); + painter.drawImage(0, 0, originalImage); +//-------------------- QImage thumbnail = image.scaled( Constants::ThumbnailImageFileWidth, Constants::ThumbnailImageFileHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation diff --git a/linphone-app/src/components/recorder/RecorderModel.cpp b/linphone-app/src/components/recorder/RecorderModel.cpp index 955875022..78f10e01a 100644 --- a/linphone-app/src/components/recorder/RecorderModel.cpp +++ b/linphone-app/src/components/recorder/RecorderModel.cpp @@ -87,7 +87,7 @@ void RecorderModel::start(){ .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss-zzz")); const QString safeFilePath = Utils::getSafeFilePath( QStringLiteral("%1%2") - .arg(Utils::coreStringToAppString(Paths::getCapturesDirPath())) + .arg(CoreManager::getInstance()->getSettingsModel()->getSavedCallsFolder()) .arg(filename), &soFarSoGood ); diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index d9822ee9e..2a9137319 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -1501,11 +1501,10 @@ void SettingsModel::setEmojiFontSize(const int& size){ } QString SettingsModel::getSavedScreenshotsFolder () const { - return QDir::cleanPath( - Utils::coreStringToAppString( - mConfig->getString(UiSection, "saved_screenshots_folder", Paths::getCapturesDirPath()) - ) - ) + QDir::separator(); + auto path = mConfig->getString(UiSection, "saved_screenshots_folder", ""); + if(path == "") + path = Paths::getCapturesDirPath(); + return QDir::cleanPath(Utils::coreStringToAppString(path)) + QDir::separator(); } void SettingsModel::setSavedScreenshotsFolder (const QString &folder) { @@ -1517,15 +1516,17 @@ void SettingsModel::setSavedScreenshotsFolder (const QString &folder) { // ----------------------------------------------------------------------------- static inline string getLegacySavedCallsFolder (const shared_ptr &config) { - return config->getString(SettingsModel::UiSection, "saved_videos_folder", Paths::getCapturesDirPath()); + auto path = config->getString(SettingsModel::UiSection, "saved_videos_folder", ""); + if(path == "")// Avoid to call default function if exist because calling Path:: will create a folder to be writable. + path = Paths::getCapturesDirPath(); + return path; } QString SettingsModel::getSavedCallsFolder () const { - return QDir::cleanPath( - Utils::coreStringToAppString( - mConfig->getString(UiSection, "saved_calls_folder", getLegacySavedCallsFolder(mConfig)) - ) - ) + QDir::separator(); + auto path = mConfig->getString(UiSection, "saved_calls_folder", "");// Avoid to call default function if exist. + if(path == "") + path = getLegacySavedCallsFolder(mConfig); + return QDir::cleanPath(Utils::coreStringToAppString(path)) + QDir::separator(); } void SettingsModel::setSavedCallsFolder (const QString &folder) { @@ -1537,11 +1538,10 @@ void SettingsModel::setSavedCallsFolder (const QString &folder) { // ----------------------------------------------------------------------------- QString SettingsModel::getDownloadFolder () const { - return QDir::cleanPath( - Utils::coreStringToAppString( - mConfig->getString(UiSection, "download_folder", Paths::getDownloadDirPath()) - ) - ) + QDir::separator(); + auto path = mConfig->getString(UiSection, "download_folder", "");// Avoid to call default function if exist because calling Path:: will create a folder to be writable. + if(path == "" ) + path = Paths::getDownloadDirPath(); + return QDir::cleanPath(Utils::coreStringToAppString(path)) + QDir::separator(); } void SettingsModel::setDownloadFolder (const QString &folder) {