Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Qt UI Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Design Studio
QML Viewer Projects
Qt UI Viewer
Commits
d7f6151c
Verified
Commit
d7f6151c
authored
1 year ago
by
Burak Hançerli
Browse files
Options
Downloads
Patches
Plain Diff
fix:
QDS-11873
laggy QR scanner
parent
a8187df3
No related branches found
No related tags found
1 merge request
!33
Spyrosoft Feedbacks
Pipeline
#66985
passed
1 year ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+7
-5
7 additions, 5 deletions
CMakeLists.txt
src/backend.cpp
+36
-7
36 additions, 7 deletions
src/backend.cpp
src/serviceConnector.cpp
+6
-5
6 additions, 5 deletions
src/serviceConnector.cpp
with
49 additions
and
17 deletions
CMakeLists.txt
+
7
−
5
View file @
d7f6151c
...
...
@@ -13,13 +13,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package
(
QT NAMES Qt6
COMPONENTS Core
COMPONENTS Core
Widgets Quick Gui Qml Multimedia MultimediaWidgets Concurrent
REQUIRED
)
find_package
(
Qt6
COMPONENTS Core Widgets Quick Gui Qml Multimedia MultimediaWidgets
COMPONENTS Core Widgets Quick Gui Qml Multimedia MultimediaWidgets
Concurrent
REQUIRED
)
...
...
@@ -44,9 +44,11 @@ qt_add_executable(${PROJECT_NAME}
)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE
Qt::Core Qt::Widgets
Qt::Quick Qt::Gui
Qt::Qml Qt::GuiPrivate Qt::Multimedia Qt::MultimediaWidgets
Qt6::Core Qt6::Widgets
Qt6::Quick Qt6::Gui
Qt6::Qml Qt6::GuiPrivate
Qt6::Multimedia Qt6::MultimediaWidgets
Qt6::Concurrent
ZXing::ZXing
)
...
...
This diff is collapsed.
Click to expand it.
src/backend.cpp
+
36
−
7
View file @
d7f6151c
...
...
@@ -28,6 +28,7 @@
#include
<QCameraDevice>
#include
<QDesktopServices>
#include
<QElapsedTimer>
#include
<QFileInfo>
#include
<QJsonArray>
#include
<QJsonObject>
...
...
@@ -37,6 +38,7 @@
#include
<QSettings>
#include
<QSslSocket>
#include
<QVideoSink>
#include
<QtConcurrent>
#include
"../3rdparty/zxing-cpp/example/ZXingQtReader.h"
...
...
@@ -217,20 +219,47 @@ void Backend::openCamera()
this
,
[
&
](
const
QVideoFrame
&
frame
)
{
static
int
i
=
0
;
if
(
i
++
<
30
)
{
static
QAtomicInt
running
=
0
;
if
(
i
++
<
20
||
running
>
0
)
{
return
;
}
i
=
0
;
auto
results
=
ReadBarcodes
(
frame
.
toImage
());
for
(
auto
&
result
:
results
)
{
QtConcurrent
::
run
([
=
]
{
// lock the thread so that only one barcode can be read at a time
running
++
;
QElapsedTimer
timer
;
timer
.
start
();
QList
<
Result
>
results
=
ReadBarcodes
(
frame
.
toImage
());
qDebug
()
<<
"Barcode detection took"
<<
timer
.
elapsed
()
<<
"ms"
;
// release the lock so that another barcode can be read
running
--
;
return
results
;
}).
then
([
=
](
const
QList
<
Result
>
&
results
)
{
if
(
results
.
isEmpty
()
||
!
m_captureSession
)
return
;
qDebug
()
<<
"Stopping camera"
;
qobject_cast
<
CustomVideoWidget
*>
(
m_captureSession
->
videoOutput
())
->
close
();
qDebug
()
<<
"Camera stopped"
;
Result
result
=
results
.
first
();
qDebug
()
<<
"Text: "
<<
result
.
text
();
qDebug
()
<<
"Format: "
<<
result
.
format
();
qDebug
()
<<
"Content:"
<<
result
.
contentType
();
parseDesignViewerUrl
(
result
.
text
());
qobject_cast
<
CustomVideoWidget
*>
(
m_captureSession
->
videoOutput
())
->
close
();
}
// we have to use invokeMethod because we are in a different thread
// then where the serviceConnector is created
QMetaObject
::
invokeMethod
(
this
,
"parseDesignViewerUrl"
,
Qt
::
QueuedConnection
,
Q_ARG
(
QUrl
,
result
.
text
()));
});
});
// stop camera when app is not active.
...
...
@@ -469,7 +498,7 @@ void Backend::updateUserProjectList()
return
;
}
qDebug
()
<<
"Fetching available project list for user:
"
<<
userHash
;
qDebug
()
<<
"Fetching available project list for user:"
<<
userHash
;
QJsonArray
projectList
=
m_serviceConnector
.
fetchUserProjectList
(
userHash
);
if
(
projectList
.
isEmpty
())
{
...
...
This diff is collapsed.
Click to expand it.
src/serviceConnector.cpp
+
6
−
5
View file @
d7f6151c
...
...
@@ -53,13 +53,13 @@ QByteArray ServiceConnector::fetchResource(const QString &url, const bool quite)
QObject
::
connect
(
reply
.
data
(),
&
QNetworkReply
::
downloadProgress
,
this
,
[
&
](
qint64
bytesReceived
,
qint64
bytesTotal
)
{
float
percentage
=
roundf
((
float
)
bytesReceived
/
(
float
)
bytesTotal
*
100
);
qDebug
()
<<
"Download progress"
<<
QString
::
number
(
percentage
)
<<
"% -"
<<
QString
::
number
(
bytesReceived
)
<<
"/"
<<
QString
::
number
(
bytesTotal
);
[
&
](
qint64
bytesReceived
,
qint64
bytesTotal
)
{
float
percentage
=
roundf
((
float
)
bytesReceived
/
(
float
)
bytesTotal
*
100
);
qDebug
()
<<
"Download progress"
<<
QString
::
number
(
percentage
)
<<
"% -"
<<
QString
::
number
(
bytesReceived
)
<<
"/"
<<
QString
::
number
(
bytesTotal
);
emit
downloadProgress
(
percentage
);
});
loop
.
exec
();
if
(
reply
->
error
()
!=
QNetworkReply
::
NoError
)
{
...
...
@@ -98,6 +98,7 @@ QJsonArray ServiceConnector::fetchUserProjectList(const QString &userHash)
auto
reply
=
fetchResource
(
"https://designviewer.qt.io/api/v1/qmlrc/list/"
+
userHash
+
"?key=818815"
,
true
);
if
(
reply
.
size
()
==
0
)
{
return
QJsonArray
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment