Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
violethaze74
appstream
Commits
8fd8790a
Commit
8fd8790a
authored
Aug 15, 2019
by
Matthias Klumpp
Browse files
qt: Add support for screenshot videos
CC: #175
parent
2b2e1d4a
Changes
6
Hide whitespace changes
Inline
Side-by-side
qt/image.h
View file @
8fd8790a
...
...
@@ -33,10 +33,10 @@ namespace AppStream {
class
ImageData
;
/**
* A reference to a image that can be accessed via a URL
* A reference to a
n
image that can be accessed via a URL
*
* This class doesn't contain any image data, but only a reference to
* a url and the expected size for the image.
* a
n
url and the expected size for the image.
*
* "expected size" means that the data is read out from the AppStream metadata.
* Discrepancies between the data and the actual data are very rare, but might happen.
...
...
qt/meson.build
View file @
8fd8790a
...
...
@@ -12,6 +12,7 @@ asqt_src = [
'component.cpp',
'pool.cpp',
'image.cpp',
'video.cpp',
'screenshot.cpp',
'icon.cpp',
'provided.cpp',
...
...
@@ -32,6 +33,7 @@ asqt_pub_headers = [
'component.h',
'pool.h',
'image.h',
'video.h',
'screenshot.h',
'icon.h',
'provided.h',
...
...
qt/screenshot.cpp
View file @
8fd8790a
/*
* Copyright (C) 2014 Sune Vuorela <sune@vuorela.dk>
* Copyright (C) 2016 Matthias Klumpp <matthias@tenstral.net>
* Copyright (C) 2016
-2019
Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
...
...
@@ -26,6 +26,7 @@
#include
<QDebug>
#include
"chelpers.h"
#include
"image.h"
#include
"video.h"
using
namespace
AppStream
;
...
...
@@ -90,6 +91,11 @@ bool Screenshot::isDefault() const
return
as_screenshot_get_kind
(
d
->
m_scr
)
==
AS_SCREENSHOT_KIND_DEFAULT
;
}
Screenshot
::
MediaKind
Screenshot
::
mediaKind
()
const
{
return
Screenshot
::
MediaKind
(
as_screenshot_get_media_kind
(
d
->
screenshot
()));
}
QString
Screenshot
::
caption
()
const
{
return
valueWrap
(
as_screenshot_get_caption
(
d
->
m_scr
));
...
...
@@ -113,6 +119,19 @@ QList<Image> Screenshot::images() const
return
res
;
}
QList
<
Video
>
Screenshot
::
videos
()
const
{
QList
<
Video
>
res
;
auto
videos
=
as_screenshot_get_videos
(
d
->
m_scr
);
res
.
reserve
(
videos
->
len
);
for
(
uint
i
=
0
;
i
<
videos
->
len
;
i
++
)
{
auto
vid
=
AS_VIDEO
(
g_ptr_array_index
(
videos
,
i
));
res
.
append
(
Video
(
vid
));
}
return
res
;
}
QDebug
operator
<<
(
QDebug
s
,
const
AppStream
::
Screenshot
&
screenshot
)
{
s
.
nospace
()
<<
"AppStream::Screenshot("
;
if
(
!
screenshot
.
caption
().
isEmpty
())
...
...
qt/screenshot.h
View file @
8fd8790a
/*
* Copyright (C) 2014 Sune Vuorela <sune@vuorela.dk>
* Copyright (C) 2016 Matthias Klumpp <matthias@tenstral.net>
* Copyright (C) 2016
-2019
Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
...
...
@@ -21,6 +21,7 @@
#ifndef APPSTREAMQT_SCREENSHOT_H
#define APPSTREAMQT_SCREENSHOT_H
#include
<QObject>
#include
<QSharedDataPointer>
#include
"appstreamqt_export.h"
...
...
@@ -32,6 +33,7 @@ struct _AsScreenshot;
namespace
AppStream
{
class
Image
;
class
Video
;
class
ScreenshotData
;
/**
...
...
@@ -40,7 +42,15 @@ class ScreenshotData;
*/
class
APPSTREAMQT_EXPORT
Screenshot
{
Q_GADGET
public:
enum
MediaKind
{
MediaKindUnknown
,
MediaKindImage
,
MediaKindVideo
};
Q_ENUM
(
MediaKind
)
Screenshot
();
Screenshot
(
_AsScreenshot
*
scr
);
Screenshot
(
const
Screenshot
&
other
);
...
...
@@ -58,11 +68,21 @@ public:
*/
bool
isDefault
()
const
;
/**
* \return the kind of media (image or video) that this screenshot consists of
*/
MediaKind
mediaKind
()
const
;
/**
* \return the images for this screenshot
*/
QList
<
AppStream
::
Image
>
images
()
const
;
/**
* \return the videos for this screenshot
*/
QList
<
AppStream
::
Video
>
videos
()
const
;
/**
* \return caption for this image or a null QString if no caption
*/
...
...
qt/video.cpp
0 → 100644
View file @
8fd8790a
/*
* Copyright (C) 2019 Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the license, or
* (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include
"appstream.h"
#include
"video.h"
#include
<QSharedData>
#include
<QSize>
#include
<QUrl>
#include
<QDebug>
using
namespace
AppStream
;
class
AppStream
::
VideoData
:
public
QSharedData
{
public:
VideoData
()
{
m_vid
=
as_video_new
();
}
VideoData
(
AsVideo
*
vid
)
:
m_vid
(
vid
)
{
g_object_ref
(
m_vid
);
}
~
VideoData
()
{
g_object_unref
(
m_vid
);
}
bool
operator
==
(
const
VideoData
&
rd
)
const
{
return
rd
.
m_vid
==
m_vid
;
}
AsVideo
*
video
()
const
{
return
m_vid
;
}
AsVideo
*
m_vid
;
};
Video
::
Video
(
const
Video
&
other
)
:
d
(
other
.
d
)
{}
Video
::
Video
()
:
d
(
new
VideoData
)
{}
Video
::
Video
(
_AsVideo
*
vid
)
:
d
(
new
VideoData
(
vid
))
{}
Video
::~
Video
()
{}
Video
&
Video
::
operator
=
(
const
Video
&
other
)
{
this
->
d
=
other
.
d
;
return
*
this
;
}
_AsVideo
*
AppStream
::
Video
::
asVideo
()
const
{
return
d
->
video
();
}
Video
::
CodecKind
Video
::
codec
()
const
{
return
Video
::
CodecKind
(
as_video_get_codec
(
d
->
m_vid
));
}
void
Video
::
setCodec
(
Video
::
CodecKind
codec
)
{
as_video_set_codec
(
d
->
m_vid
,
(
AsVideoCodec
)
codec
);
}
Video
::
ContainerKind
Video
::
container
()
const
{
return
Video
::
ContainerKind
(
as_video_get_container
(
d
->
m_vid
));
}
void
Video
::
setContainer
(
Video
::
ContainerKind
container
)
{
as_video_set_container
(
d
->
m_vid
,
(
AsVideoContainer
)
container
);
}
uint
Video
::
height
()
const
{
return
as_video_get_height
(
d
->
m_vid
);
}
void
Video
::
setHeight
(
uint
height
)
{
as_video_set_height
(
d
->
m_vid
,
height
);
}
uint
Video
::
width
()
const
{
return
as_video_get_width
(
d
->
m_vid
);
}
void
Video
::
setWidth
(
uint
width
)
{
as_video_set_width
(
d
->
m_vid
,
width
);
}
void
Video
::
setUrl
(
const
QUrl
&
url
)
{
as_video_set_url
(
d
->
m_vid
,
qPrintable
(
url
.
toString
()));
}
const
QUrl
Video
::
url
()
const
{
return
QUrl
(
as_video_get_url
(
d
->
m_vid
));
}
QSize
AppStream
::
Video
::
size
()
const
{
return
QSize
(
width
(),
height
());
}
QDebug
operator
<<
(
QDebug
s
,
const
AppStream
::
Video
&
video
)
{
s
.
nospace
()
<<
"AppStream::Video("
<<
video
.
url
()
<<
','
<<
video
.
container
()
<<
':'
<<
video
.
codec
()
<<
"["
<<
video
.
width
()
<<
"x"
<<
video
.
height
()
<<
"])"
;
return
s
.
space
();
}
qt/video.h
0 → 100644
View file @
8fd8790a
/*
* Copyright (C) 2019 Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the license, or
* (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef APPSTREAMQT_VIDEO_H
#define APPSTREAMQT_VIDEO_H
#include
<QSharedDataPointer>
#include
<QObject>
#include
"appstreamqt_export.h"
class
QUrl
;
class
QString
;
struct
_AsVideo
;
namespace
AppStream
{
class
VideoData
;
/**
* A reference to a video that can be accessed via a URL
*
* This class doesn't contain any video data, but only a reference to
* an url and a bit of useful metadata about the video.
*/
class
APPSTREAMQT_EXPORT
Video
{
Q_GADGET
public:
enum
CodecKind
{
CodecKindUnknown
,
CodecKindVP9
,
CodecKindAV1
};
Q_ENUM
(
CodecKind
)
enum
ContainerKind
{
ContainerKindUnknown
,
ContainerKindMKV
,
ContainerKindWebM
};
Q_ENUM
(
ContainerKind
)
Video
();
Video
(
_AsVideo
*
vid
);
Video
(
const
Video
&
other
);
~
Video
();
Video
&
operator
=
(
const
Video
&
other
);
/**
* \returns the internally stored AsVideo
*/
_AsVideo
*
asVideo
()
const
;
/**
* \return the codec of this video, if known
*/
CodecKind
codec
()
const
;
void
setCodec
(
CodecKind
codec
);
/**
* \return the container format of this video, if known
*/
ContainerKind
container
()
const
;
void
setContainer
(
ContainerKind
container
);
/**
* \return the url for this video
*/
const
QUrl
url
()
const
;
void
setUrl
(
const
QUrl
&
url
);
/**
* \return the expected width of this video
*/
uint
width
()
const
;
void
setWidth
(
uint
width
);
/**
* \return the expected height of this video
*/
uint
height
()
const
;
void
setHeight
(
uint
height
);
/**
* \returns the expected size of the video
*/
QSize
size
()
const
;
private:
QSharedDataPointer
<
VideoData
>
d
;
};
}
APPSTREAMQT_EXPORT
QDebug
operator
<<
(
QDebug
s
,
const
AppStream
::
Video
&
video
);
#endif // APPSTREAMQT_VIDEO_H
Write
Preview
Supports
Markdown
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