Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
323dcb16
Commit
323dcb16
authored
Jun 19, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(App): use a image provider for qrc images
parent
8572347b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
105 additions
and
1 deletion
+105
-1
CMakeLists.txt
CMakeLists.txt
+2
-0
App.cpp
src/app/App.cpp
+2
-0
ImageProvider.cpp
src/app/providers/ImageProvider.cpp
+58
-0
ImageProvider.hpp
src/app/providers/ImageProvider.hpp
+42
-0
Constants.qml
ui/modules/Common/Constants/Constants.qml
+1
-1
No files found.
CMakeLists.txt
View file @
323dcb16
...
...
@@ -97,6 +97,7 @@ set(SOURCES
src/app/logger/Logger.cpp
src/app/paths/Paths.cpp
src/app/providers/AvatarProvider.cpp
src/app/providers/ImageProvider.cpp
src/app/providers/ThumbnailProvider.cpp
src/app/translator/DefaultTranslator.cpp
src/components/assistant/AssistantModel.cpp
...
...
@@ -149,6 +150,7 @@ set(HEADERS
src/app/logger/Logger.hpp
src/app/paths/Paths.hpp
src/app/providers/AvatarProvider.hpp
src/app/providers/ImageProvider.hpp
src/app/providers/ThumbnailProvider.hpp
src/app/translator/DefaultTranslator.hpp
src/components/assistant/AssistantModel.hpp
...
...
src/app/App.cpp
View file @
323dcb16
...
...
@@ -38,6 +38,7 @@
#include "logger/Logger.hpp"
#include "paths/Paths.hpp"
#include "providers/AvatarProvider.hpp"
#include "providers/ImageProvider.hpp"
#include "providers/ThumbnailProvider.hpp"
#include "translator/DefaultTranslator.hpp"
...
...
@@ -172,6 +173,7 @@ void App::initContentApp () {
// Provide avatars/thumbnails providers.
mEngine
->
addImageProvider
(
AvatarProvider
::
PROVIDER_ID
,
new
AvatarProvider
());
mEngine
->
addImageProvider
(
ImageProvider
::
PROVIDER_ID
,
new
ImageProvider
());
mEngine
->
addImageProvider
(
ThumbnailProvider
::
PROVIDER_ID
,
new
ThumbnailProvider
());
registerTypes
();
...
...
src/app/providers/ImageProvider.cpp
0 → 100644
View file @
323dcb16
/*
* ImageProvider.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: June 19, 2017
* Author: Ronan Abhamon
*/
#include <QImage>
#include <QPainter>
#include <QSvgRenderer>
#include "ImageProvider.hpp"
// =============================================================================
const
QString
ImageProvider
::
PROVIDER_ID
=
"internal"
;
ImageProvider
::
ImageProvider
()
:
QQuickImageProvider
(
QQmlImageProviderBase
::
Image
,
QQmlImageProviderBase
::
ForceAsynchronousImageLoading
)
{}
QImage
ImageProvider
::
requestImage
(
const
QString
&
id
,
QSize
*
,
const
QSize
&
)
{
const
QString
path
=
QStringLiteral
(
":/assets/images/%1"
).
arg
(
id
);
// 1. Build svg renderer.
QSvgRenderer
renderer
(
path
);
if
(
!
renderer
.
isValid
())
return
QImage
(
path
);
// Not a svg file?
// 2. Create en empty image.
const
QRectF
viewBox
=
renderer
.
viewBoxF
();
QImage
image
(
static_cast
<
int
>
(
viewBox
.
width
()),
static_cast
<
int
>
(
viewBox
.
height
()),
QImage
::
Format_ARGB32
);
if
(
image
.
isNull
())
return
QImage
();
// Memory cannot be allocated.
image
.
fill
(
0x00000000
);
// 3. Paint!
QPainter
painter
(
&
image
);
renderer
.
render
(
&
painter
);
return
image
;
}
src/app/providers/ImageProvider.hpp
0 → 100644
View file @
323dcb16
/*
* ImageProvider.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: June 19, 2017
* Author: Ronan Abhamon
*/
#ifndef IMAGE_PROVIDER_H_
#define IMAGE_PROVIDER_H_
#include <QQuickImageProvider>
// =============================================================================
class
ImageProvider
:
public
QQuickImageProvider
{
public:
ImageProvider
();
~
ImageProvider
()
=
default
;
QImage
requestImage
(
const
QString
&
id
,
QSize
*
size
,
const
QSize
&
requestedSize
)
override
;
static
const
QString
PROVIDER_ID
;
private:
};
#endif // IMAGE_PROVIDER_H_
ui/modules/Common/Constants/Constants.qml
View file @
323dcb16
...
...
@@ -9,5 +9,5 @@ QtObject {
property
int
sizeMax
:
999999
property
string
imagesFormat
:
'
.svg
'
property
string
imagesPath
:
'
qrc:/assets/images
/
'
property
string
imagesPath
:
'
image://internal
/
'
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment