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
bbd837c0
Verified
Commit
bbd837c0
authored
1 year ago
by
Burak Hançerli
Browse files
Options
Downloads
Patches
Plain Diff
enh: show only one error when there's a network issue
parent
0d368734
No related branches found
No related tags found
1 merge request
!38
QDS-11878 Reduce the numbers of user notification
Pipeline
#67247
passed
1 year ago
Stage: build
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
android/AndroidManifest.xml
+1
-1
1 addition, 1 deletion
android/AndroidManifest.xml
src/backend.cpp
+10
-10
10 additions, 10 deletions
src/backend.cpp
src/serviceConnector.cpp
+23
-35
23 additions, 35 deletions
src/serviceConnector.cpp
src/serviceConnector.h
+5
-2
5 additions, 2 deletions
src/serviceConnector.h
with
39 additions
and
48 deletions
android/AndroidManifest.xml
+
1
−
1
View file @
bbd837c0
<?xml version="1.0"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"io.qt.qtdesignviewer"
android:installLocation=
"auto"
android:versionCode=
"2
5
"
android:versionName=
"1.2"
>
android:installLocation=
"auto"
android:versionCode=
"2
6
"
android:versionName=
"1.2"
>
<!-- %%INSERT_PERMISSIONS -->
<!-- %%INSERT_FEATURES -->
<supports-screens
android:anyDensity=
"true"
android:largeScreens=
"true"
...
...
This diff is collapsed.
Click to expand it.
src/backend.cpp
+
10
−
10
View file @
bbd837c0
...
...
@@ -336,10 +336,12 @@ void Backend::runDemoProject(const QString &projectName)
// sample project info
// [{"lastUpdate":1701947766739.9812,"name":"ClusterTutorial.qmlrc"}]
const
std
::
optional
<
QJsonArray
>
projectList
=
m_serviceConnector
.
fetch
User
DemoList
();
const
std
::
optional
<
QJsonArray
>
projectList
=
m_serviceConnector
.
fetchDemoList
();
if
(
projectList
==
std
::
nullopt
)
{
qCritical
(
"Please check your internet connection and try again"
);
qCritical
(
"Could not fetch demo project list. Please check your internet connection and try "
"again."
);
emit
popupClose
();
return
;
}
...
...
@@ -357,9 +359,8 @@ void Backend::runDemoProject(const QString &projectName)
if
(
!
cached
)
{
updatePopup
(
"Downloading demo project..."
,
false
);
const
QString
url
=
"https://designviewer.qt.io/qmlprojects/demos/"
+
projectName
+
".qmlrc"
;
const
std
::
optional
<
QByteArray
>
project
=
m_serviceConnector
.
fetchProject
(
url
);
const
std
::
optional
<
QByteArray
>
project
=
m_serviceConnector
.
fetchDemo
(
projectName
+
".qmlrc"
);
if
(
project
==
std
::
nullopt
)
{
qCritical
()
<<
"Could not download demo project. Please check the logs for more "
...
...
@@ -368,8 +369,6 @@ void Backend::runDemoProject(const QString &projectName)
return
;
}
qDebug
()
<<
"Demo project is not cached. Trying to download from "
<<
url
<<
" ..."
;
updatePopup
(
"Caching demo project..."
);
if
(
!
m_projectManager
->
cacheDemoProject
(
project
.
value
(),
projectInfo
))
{
qCritical
()
...
...
@@ -416,7 +415,8 @@ void Backend::runUserProject(const QString &projectName)
const
std
::
optional
<
QJsonArray
>
projectList
=
m_serviceConnector
.
fetchUserProjectList
(
userHash
);
if
(
projectList
==
std
::
nullopt
)
{
qCritical
(
"Please check your internet connection and try again"
);
qCritical
(
"Could not fetch up-to-date project information. Please check your internet "
"connection and try again."
);
emit
popupClose
();
return
;
}
...
...
@@ -505,8 +505,8 @@ void Backend::updateUserProjectList()
const
std
::
optional
<
QJsonArray
>
projectList
=
m_serviceConnector
.
fetchUserProjectList
(
userHash
);
if
(
projectList
==
std
::
nullopt
)
{
qWarning
(
"Could not fetch project list. Either there are no projects or there is a "
"network issue
"
);
qWarning
(
"Could not fetch project list. Please check your internet connection and try again.
"
);
}
else
if
(
projectList
.
value
()
==
m_projectList
)
{
qDebug
(
"No new projects are available"
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
src/serviceConnector.cpp
+
23
−
35
View file @
bbd837c0
...
...
@@ -31,7 +31,7 @@
#include
<QJsonDocument>
#include
<QJsonObject>
QByteArray
ServiceConnector
::
fetchResource
(
const
QString
&
url
,
const
bool
quite
)
std
::
optional
<
QByteArray
>
ServiceConnector
::
fetchResource
(
const
QString
&
url
)
{
qDebug
()
<<
"Fetching resource from"
<<
url
;
...
...
@@ -42,10 +42,7 @@ QByteArray ServiceConnector::fetchResource(const QString &url, const bool quite)
&
QNetworkReply
::
sslErrors
,
this
,
[
&
](
const
QList
<
QSslError
>
&
errors
)
{
if
(
!
quite
)
qCritical
()
<<
errors
.
first
().
errorString
();
else
qWarning
()
<<
errors
.
first
().
errorString
();
qWarning
()
<<
errors
.
first
().
errorString
();
});
QEventLoop
loop
;
...
...
@@ -63,56 +60,42 @@ QByteArray ServiceConnector::fetchResource(const QString &url, const bool quite)
loop
.
exec
();
if
(
reply
->
error
()
!=
QNetworkReply
::
NoError
)
{
if
(
!
quite
)
qCritical
()
<<
reply
->
errorString
();
else
qWarning
()
<<
reply
->
errorString
();
}
else
{
qDebug
()
<<
"Resource fetched successfully"
;
qWarning
()
<<
reply
->
errorString
();
return
{};
}
qDebug
()
<<
"Resource fetched successfully"
;
return
reply
->
readAll
();
}
std
::
optional
<
QByteArray
>
ServiceConnector
::
fetchProject
(
const
QString
&
url
)
{
QString
projectUrl
=
url
;
if
(
projectUrl
.
startsWith
(
"https://designviewer.qt.io/#"
))
{
if
(
projectUrl
.
startsWith
(
m_serviceUrl
+
"/#"
))
{
projectUrl
=
projectUrl
.
split
(
"#"
).
at
(
1
);
projectUrl
.
prepend
(
"https://designviewer.qt.io
/qmlprojects/"
);
projectUrl
.
prepend
(
m_serviceUrl
+
"
/qmlprojects/"
);
}
auto
reply
=
fetchResource
(
projectUrl
);
if
(
reply
.
size
()
==
0
)
return
{};
return
reply
;
return
fetchResource
(
projectUrl
);
}
std
::
optional
<
QByteArray
>
ServiceConnector
::
fetchUserProject
(
const
QString
&
userHash
,
const
QString
&
projectName
)
{
const
QString
projectUrl
=
"https://designviewer.qt.io/qmlprojects/"
+
userHash
+
"/"
+
projectName
+
".qmlrc"
;
auto
reply
=
fetchResource
(
projectUrl
);
if
(
reply
.
size
()
==
0
)
return
{};
const
QString
projectUrl
=
m_serviceUrl
+
"/qmlprojects/"
+
userHash
+
"/"
+
projectName
+
".qmlrc"
;
return
reply
;
return
fetchResource
(
projectUrl
)
;
}
std
::
optional
<
QJsonArray
>
ServiceConnector
::
fetchUserProjectList
(
const
QString
&
userHash
)
{
auto
reply
=
fetchResource
(
"https://designviewer.qt.io/api/v1/qmlrc/list/"
+
userHash
+
"?key=818815"
,
true
);
auto
reply
=
fetchResource
(
m_serviceUrl
+
"/api/v1/qmlrc/list/"
+
userHash
+
"?key=818815"
);
if
(
reply
.
size
()
==
0
)
if
(
!
reply
)
return
{};
QJsonArray
projectList
=
QJsonDocument
::
fromJson
(
reply
)
QJsonArray
projectList
=
QJsonDocument
::
fromJson
(
reply
.
value
()
)
.
object
()
.
value
(
"data"
)
.
toObject
()
...
...
@@ -122,11 +105,16 @@ std::optional<QJsonArray> ServiceConnector::fetchUserProjectList(const QString &
return
projectList
;
}
std
::
optional
<
QJsonArray
>
ServiceConnector
::
fetch
User
DemoList
()
std
::
optional
<
QJsonArray
>
ServiceConnector
::
fetchDemoList
()
{
auto
reply
=
fetchResource
(
"https://designviewer.qt.io
/api/v1/demos"
);
if
(
reply
.
size
()
==
0
)
auto
reply
=
fetchResource
(
m_serviceUrl
+
"
/api/v1/demos"
);
if
(
!
reply
)
return
{};
return
QJsonDocument
::
fromJson
(
reply
).
array
();
return
QJsonDocument
::
fromJson
(
reply
.
value
()).
array
();
}
std
::
optional
<
QByteArray
>
ServiceConnector
::
fetchDemo
(
const
QString
&
demoName
)
{
return
fetchResource
(
m_serviceUrl
+
"/qmlprojects/demos/"
+
demoName
+
".qmlrc"
);
}
This diff is collapsed.
Click to expand it.
src/serviceConnector.h
+
5
−
2
View file @
bbd837c0
...
...
@@ -36,11 +36,14 @@ public:
std
::
optional
<
QByteArray
>
fetchProject
(
const
QString
&
url
);
std
::
optional
<
QByteArray
>
fetchUserProject
(
const
QString
&
userHash
,
const
QString
&
projectName
);
std
::
optional
<
QJsonArray
>
fetchUserProjectList
(
const
QString
&
userHash
);
std
::
optional
<
QJsonArray
>
fetchUserDemoList
();
std
::
optional
<
QJsonArray
>
fetchDemoList
();
std
::
optional
<
QByteArray
>
fetchDemo
(
const
QString
&
demoName
);
private:
QNetworkAccessManager
m_manager
;
QByteArray
fetchResource
(
const
QString
&
url
,
const
bool
quite
=
false
);
std
::
optional
<
QByteArray
>
fetchResource
(
const
QString
&
url
);
const
QString
m_serviceUrl
=
"https://designviewer.qt.io"
;
signals:
void
downloadProgress
(
float
percentage
);
...
...
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