mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Upgrade avatar icons quality.
Better SVG scaling on icons by using SVG renderer (only available from Qt 5.15.0)
This commit is contained in:
parent
f41e4e74e2
commit
43493de2fd
6 changed files with 52 additions and 18 deletions
|
|
@ -6,7 +6,7 @@
|
|||
version="1.1"
|
||||
id="svg12"
|
||||
sodipodi:docname="contact_custom.svg"
|
||||
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
|
||||
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
|
|
@ -23,15 +23,15 @@
|
|||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
showgrid="false"
|
||||
inkscape:zoom="4.546875"
|
||||
inkscape:cx="5.3883161"
|
||||
inkscape:cy="20.453608"
|
||||
inkscape:zoom="11.313709"
|
||||
inkscape:cx="24.085825"
|
||||
inkscape:cy="50.381358"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1043"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-x="298"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg12" />
|
||||
inkscape:current-layer="contact_selected" />
|
||||
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
|
||||
<title
|
||||
id="title2">contact_selected</title>
|
||||
|
|
@ -50,8 +50,9 @@
|
|||
id="contact_selected"
|
||||
fill="#000000">
|
||||
<path
|
||||
d="m 16.806156,6.8073986 c 0,1.240375 -0.464389,2.4035931 -1.285742,3.2893814 -0.07692,0.0831 -0.08384,0.0916 -0.162964,0.19301 -0.486248,0.417625 -0.438653,1.19712 0.102033,1.565188 l 0.239957,0.163348 0.160318,0.08882 c 2.182907,0.959547 3.728167,2.124062 4.731359,3.438818 1.341204,1.757745 1.617991,3.595246 1.299328,5.213197 -0.03876,0.196802 -0.07457,0.326209 -0.09199,0.376408 l 0.639696,-0.624512 c -2.131541,0.682751 -4.336423,1.109496 -6.515859,1.32744 -1.459858,0.145987 -2.701324,0.180909 -3.626027,0.15426 -0.09097,-0.0026 -0.150694,-0.0051 -0.177303,-0.0066 l -0.183128,-0.0015 v 1 h 1 L 11.910823,21.98497 c -0.04794,0.002 -0.04794,0.002 -0.06847,0.0029 -0.05339,0.0021 -0.05339,0.0021 -0.138837,0.0048 C 10.77693,22.0192 9.5362158,21.98427 8.0764866,21.838261 5.8972563,21.620311 3.6928378,21.193641 1.5618584,20.511036 l 0.6396818,0.624508 C 2.1841174,21.085372 2.148309,20.955972 2.1095499,20.75918 1.7908887,19.141234 2.0676955,17.303731 3.4089596,15.545977 4.4121942,14.231218 5.9575121,13.066699 8.1404944,12.107148 L 8.3008228,12.018328 8.5407796,11.85498 C 9.081466,11.48691 9.1290611,10.707415 8.6371719,10.2763 8.5636892,10.188382 8.5567708,10.179881 8.4804448,10.097423 7.6585929,9.2108448 7.1941071,8.0475319 7.1941071,6.8073986 7.1941071,4.1501811 9.3233001,2 11.944862,2 h 0.110539 c 2.621562,0 4.750755,2.1501811 4.750755,4.8073986 z M 11.944862,0 C 8.2143153,0 5.1941071,3.0499793 5.1941071,6.8073986 c 0,1.7488094 0.6578744,3.3964674 1.8190985,4.6491444 0.024606,0.02658 0.00863,0.007 0.052794,0.06356 0.08033,0.100656 0.147878,0.168201 0.2529297,0.260274 L 7.9780505,11.028336 7.4153214,10.201695 7.1753646,10.365043 7.7380937,11.191685 7.335693,10.276221 c -2.4808032,1.090461 -4.2988965,2.460537 -5.5167142,4.056512 -1.72901696,2.265911 -2.09230889,4.677522 -1.67173122,6.812931 0.05754,0.292149 0.11803058,0.510741 0.16481213,0.645557 0.10312843,0.297197 0.34009473,0.528542 0.63968187,0.624507 2.27434362,0.728528 4.61458782,1.181487 6.92570822,1.412628 1.5502722,0.155046 2.8754682,0.192374 3.8833032,0.163518 0.09881,-0.0031 0.09881,-0.0031 0.164865,-0.0057 -0.989785,-0.449206 0.138812,-0.0015 0.138812,-0.0015 -0.01101,8.89e-4 0.06585,0.0041 0.174221,0.0072 1.006096,0.02899 2.33218,-0.0083 3.882649,-0.163355 2.311327,-0.231134 4.652035,-0.684167 6.926934,-1.412838 0.299593,-0.09596 0.536566,-0.327309 0.639696,-0.624511 0.04678,-0.13482 0.107275,-0.353419 0.164817,-0.645577 0.420577,-2.135401 0.05731,-4.546996 -1.671626,-6.812896 -1.217773,-1.595978 -3.035809,-2.966059 -5.516541,-4.056522 l -0.402411,0.915459 0.562729,-0.826642 -0.239957,-0.163348 -0.562729,0.826641 0.659122,0.752037 c 0.105052,-0.09207 0.1726,-0.159618 0.240001,-0.243902 0.05709,-0.07297 0.04112,-0.05335 0.06622,-0.08047 1.160802,-1.251865 1.8186,-2.899541 1.8186,-4.6486054 C 18.806156,3.0499793 15.785948,0 12.055401,0 Z"
|
||||
id="path8" />
|
||||
d="m 16.806156,6.8073986 c 0,1.240375 -0.464389,2.4035931 -1.285742,3.2893814 -0.07692,0.0831 -0.08384,0.0916 -0.162964,0.19301 -0.486248,0.417625 -0.438653,1.19712 0.102033,1.565188 l 0.239957,0.163348 0.160318,0.08882 c 2.182907,0.959547 3.728167,2.124062 4.731359,3.438818 1.341204,1.757745 1.617991,3.595246 1.299328,5.213197 -0.06743,0.262136 -4.039005,0.897335 -5.968153,1.079336 -2.036172,0.192098 -5.492321,0.198713 -7.7888649,0.06354 C 7.1349766,21.830245 2.2956094,21.216918 2.0971289,20.781233 1.8988401,19.099457 2.0676955,17.303731 3.4089596,15.545977 4.4121942,14.231218 5.9575121,13.066699 8.1404944,12.107148 L 8.3008228,12.018328 8.5407796,11.85498 C 9.081466,11.48691 8.5035876,9.9883807 8.0807376,9.5994819 c -0.1571087,-0.2511322 0,0 0,0 C 7.2588857,8.7129037 7.1941071,8.0475319 7.1941071,6.8073986 7.1941071,4.1501811 9.3233001,2 11.944862,2 h 0.110539 c 2.621562,0 4.750755,2.1501811 4.750755,4.8073986 z M 11.944862,0 C 8.2143153,0 5.1941071,3.0499793 5.1941071,6.8073986 c 0,1.7488094 0.045614,2.6260782 1.2068384,3.8787554 0.024606,0.02658 -0.044164,-0.05656 0,0 0,0 -0.038344,0.278876 0,0 v 0 0 c -2.4808032,1.090461 -3.364149,2.050604 -4.5819667,3.646579 -1.72901696,2.265911 -2.09230889,4.677522 -1.67173122,6.812931 0.05754,0.292149 0.11803058,0.510741 0.16481213,0.645557 0.10312843,0.297197 0.34009473,0.528542 0.63968187,0.624507 2.27434362,0.728528 4.61458782,1.181487 6.92570822,1.412628 2.7609192,0.201216 5.7367432,0.245097 8.2438502,1.63e-4 2.311327,-0.231134 4.652035,-0.684167 6.926934,-1.412838 0.299593,-0.09596 0.536566,-0.327309 0.639696,-0.624511 0.04678,-0.13482 0.107275,-0.353419 0.164817,-0.645577 0.420577,-2.135401 -0.0084,-4.633265 -1.723355,-6.748195 C 21.425651,13.480387 17.597504,10.811464 18.008421,10.35195 18.603951,9.6859906 18.82723,9.0455667 18.806155,6.8073446 18.806156,3.0499793 15.785948,0 12.055401,0 Z"
|
||||
id="path8"
|
||||
sodipodi:nodetypes="sccsccscsccsccsccsssssscccccssssccssscscss" />
|
||||
</g>
|
||||
</g>
|
||||
<metadata
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 3.7 KiB |
|
|
@ -404,6 +404,8 @@ void App::initContentApp () {
|
|||
mEngine->rootContext()->setContextProperty("Colors", mColorListModel->getQmlData());
|
||||
mEngine->rootContext()->setContextProperty("Images", mImageListModel->getQmlData());
|
||||
|
||||
mEngine->rootContext()->setContextProperty("qtIsNewer_5_15_0", QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) );
|
||||
|
||||
registerTypes();
|
||||
registerSharedTypes();
|
||||
registerToolTypes();
|
||||
|
|
|
|||
|
|
@ -286,7 +286,9 @@ QImage ImageProvider::requestImage (const QString &id, QSize *size, const QSize
|
|||
qWarning() << QStringLiteral("Invalid svg file: `%1`.").arg(path);
|
||||
return QImage();
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
renderer.setAspectRatioMode(Qt::KeepAspectRatio);
|
||||
#endif
|
||||
QSize askedSize = !requestedSize.isEmpty()
|
||||
? requestedSize
|
||||
: renderer.defaultSize() * QGuiApplication::primaryScreen()->devicePixelRatio();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <QFile>
|
||||
#include <QImageReader>
|
||||
#include <QDebug>
|
||||
#include <QUrl>
|
||||
|
||||
#include "config.h"
|
||||
#include "Utils.hpp"
|
||||
|
|
@ -545,4 +546,22 @@ bool Utils::isPhoneNumber(const QString& txt){
|
|||
return false;
|
||||
auto account = core->getDefaultAccount();
|
||||
return account && account->isPhoneNumber(Utils::appStringToCoreString(txt));
|
||||
}
|
||||
|
||||
QSize Utils::getImageSize(const QString& url){
|
||||
QString path;
|
||||
QUrl urlDecode(url);
|
||||
if(urlDecode.isLocalFile())
|
||||
path = QDir::toNativeSeparators(urlDecode.toLocalFile());
|
||||
else
|
||||
path = url;
|
||||
QFileInfo info(path);
|
||||
if( !info.exists())
|
||||
return QSize(0,0);
|
||||
QImageReader reader(path);
|
||||
QSize s = reader.size();
|
||||
if( s.isValid())
|
||||
return s;
|
||||
else
|
||||
return QSize(0,0);
|
||||
}
|
||||
|
|
@ -62,6 +62,7 @@ public:
|
|||
Q_INVOKABLE static bool isMe(const QString& address);
|
||||
Q_INVOKABLE static bool isAnimatedImage(const QString& path);
|
||||
Q_INVOKABLE static bool isPhoneNumber(const QString& txt);
|
||||
Q_INVOKABLE QSize getImageSize(const QString& url);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
static inline QString coreStringToAppString (const std::string &str) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import QtGraphicalEffects 1.12
|
|||
import Common 1.0
|
||||
import Linphone 1.0
|
||||
import Utils 1.0
|
||||
import UtilsCpp 1.0
|
||||
|
||||
// =============================================================================
|
||||
// An icon image properly resized.
|
||||
|
|
@ -32,21 +33,29 @@ Item {
|
|||
|
||||
Image {
|
||||
id:image
|
||||
anchors.fill: parent
|
||||
|
||||
property bool colorOverwriteEnabled : false
|
||||
mipmap: SettingsModel.mipmapEnabled
|
||||
cache: Images.areReadOnlyImages
|
||||
asynchronous: true
|
||||
smooth: true
|
||||
//anchors.centerIn: parent
|
||||
anchors.fill: parent
|
||||
antialiasing: false
|
||||
// Better quality is only available from Qt5.15
|
||||
fillMode: !qtIsNewer_5_15_0 ? Image.PreserveAspectFit : Image.Stretch // Stretch is default from Qt's doc
|
||||
// Keep aspect ratio is done by ImagePovider that use directly SVG scalings (=no loss quality).
|
||||
source: width != 0 && height != 0 ? Utils.resolveImageUri(icon) : '' // Do not load image with unknown requested size
|
||||
sourceSize.width: qtIsNewer_5_15_0
|
||||
? fillMode == Image.TileHorizontally
|
||||
? height
|
||||
: width
|
||||
: 0
|
||||
sourceSize.height: qtIsNewer_5_15_0
|
||||
? fillMode == Image.TileVertically
|
||||
? width
|
||||
: height
|
||||
: 0
|
||||
|
||||
//width: iconWidth > 0 ? iconWidth : mainItem.width
|
||||
//height: iconHeight > 0 ? iconHeight : mainItem.height
|
||||
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: Utils.resolveImageUri(icon)
|
||||
sourceSize.width: (iconWidth > 0 ? iconWidth : iconSize)
|
||||
sourceSize.height: ( iconHeight > 0 ? iconHeight : iconSize)
|
||||
layer {
|
||||
enabled: image.colorOverwriteEnabled
|
||||
effect: ColorOverlay {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue