Skip to content
Snippets Groups Projects
Commit c39f7265 authored by Burak Hançerli's avatar Burak Hançerli :headphones:
Browse files

QDS-10704 Show download progress

parent 89869f87
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ cmake \ ...@@ -37,6 +37,7 @@ cmake \
-B build \ -B build \
-G Ninja \ -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=<qt-android-path>/lib/cmake/Qt6/qt.toolchain.cmake \ -DCMAKE_TOOLCHAIN_FILE=<qt-android-path>/lib/cmake/Qt6/qt.toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=<qt-android-path> \
-DANDROID_SDK_ROOT=<android-sdk-path> \ -DANDROID_SDK_ROOT=<android-sdk-path> \
-DANDROID_NDK_ROOT=<android-sdk-path>/ndk/<ndk-version> \ -DANDROID_NDK_ROOT=<android-sdk-path>/ndk/<ndk-version> \
-DANDROID_OPENSSL_PATH=<openssl-path> -DANDROID_OPENSSL_PATH=<openssl-path>
...@@ -73,7 +74,7 @@ source ./emsdk_env.sh ...@@ -73,7 +74,7 @@ source ./emsdk_env.sh
cd .. cd ..
``` ```
Then build and install QtQuickDesigner Components for Android: Then build and install QtQuickDesigner Components for WebAssembly:
```bash ```bash
cd qtquickdesigner-components cd qtquickdesigner-components
...@@ -81,7 +82,8 @@ cmake \ ...@@ -81,7 +82,8 @@ cmake \
-S . \ -S . \
-B build \ -B build \
-G Ninja \ -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=<qt-wasm-path>/wasm/lib/cmake/Qt6/qt.toolchain.cmake -DCMAKE_TOOLCHAIN_FILE=<qt-wasm-path>/wasm/lib/cmake/Qt6/qt.toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=<qt-wasm-path>
cmake --build build cmake --build build
cmake --install build cmake --install build
......
...@@ -77,15 +77,24 @@ QSharedPointer<QNetworkReply> DvAndroid::fetchResource(const QString &url) ...@@ -77,15 +77,24 @@ QSharedPointer<QNetworkReply> DvAndroid::fetchResource(const QString &url)
&QNetworkReply::sslErrors, &QNetworkReply::sslErrors,
this, this,
[&](const QList<QSslError> &errors) { [&](const QList<QSslError> &errors) {
printLog(errors.first().errorString()); printErr(errors.first().errorString());
}); });
QEventLoop loop; QEventLoop loop;
QObject::connect(reply.data(), &QNetworkReply::finished, &loop, &QEventLoop::quit); QObject::connect(reply.data(), &QNetworkReply::finished, &loop, &QEventLoop::quit);
QObject::connect(reply.data(),
&QNetworkReply::downloadProgress,
this,
[&](qint64 bytesReceived, qint64 bytesTotal) {
float percentage = roundf((float) bytesReceived / (float) bytesTotal * 100);
printLog("Download progress " + QString::number(percentage) + "% - "
+ QString::number(bytesReceived) + "/"
+ QString::number(bytesTotal));
});
loop.exec(); loop.exec();
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
printLog(reply->errorString()); printErr(reply->errorString());
} else { } else {
printLog("Resource fetched successfully"); printLog("Resource fetched successfully");
} }
...@@ -106,7 +115,11 @@ void DvAndroid::setupUi() ...@@ -106,7 +115,11 @@ void DvAndroid::setupUi()
m_layout->addWidget(m_button); m_layout->addWidget(m_button);
// show build info // show build info
m_buildInfo->setText(QCoreApplication::applicationVersion()); QString buildInfo = "Qt Design Viewer for Android\n" + QCoreApplication::applicationVersion()
+ "\n" + "Built with Qt " + QString(QT_VERSION_STR) + "\n"
+ "OpenSSL support: " + QVariant(QSslSocket::supportsSsl()).toString();
m_buildInfo->setText(buildInfo);
m_buildInfo->setAlignment(Qt::AlignHCenter);
// configure logs area // configure logs area
m_logs->setWordWrap(true); m_logs->setWordWrap(true);
...@@ -121,8 +134,7 @@ void DvAndroid::setupUi() ...@@ -121,8 +134,7 @@ void DvAndroid::setupUi()
}); });
// configure line edit // configure line edit
m_lineEdit->setText( m_lineEdit->setPlaceholderText("Enter project URL here");
"https://designviewer.qt.io/#17e8907b3b84b8206d45be4f551f4e25/TestTwo.qmlrc");
// configure the button // configure the button
m_button->setText("Download and run project"); m_button->setText("Download and run project");
...@@ -134,21 +146,25 @@ void DvAndroid::setupUi() ...@@ -134,21 +146,25 @@ void DvAndroid::setupUi()
void DvAndroid::printSysInfo() void DvAndroid::printSysInfo()
{ {
const QRect screenGeometry = QGuiApplication::primaryScreen()->geometry();
printLog("Qt Design Viewer"); printLog("Qt Design Viewer");
printLog("System information:"); printLog("System information:");
printLog("-- Qt version: " + QString(QT_VERSION_STR)); printLog("-- Qt version: " + QString(QT_VERSION_STR));
printLog("-- OpenSSL support: " + QVariant(QSslSocket::supportsSsl()).toString()); printLog("-- OpenSSL support: " + QVariant(QSslSocket::supportsSsl()).toString());
printLog("-- Window height: " + QString::number(m_mainWindow.height())); printLog("-- Screen height: " + QString::number(screenGeometry.height()));
printLog("-- Window width: " + QString::number(m_mainWindow.width())); printLog("-- Screen width: " + QString::number(screenGeometry.width()));
} }
void DvAndroid::updateLogo() void DvAndroid::updateLogo()
{ {
printLog("Fetching logo..."); printLog("Fetching logo...");
m_logo->setText("Fetching logo...");
auto logoReply = fetchResource("https://designviewer.qt.io/qtdesignstudioviewer-256.png"); auto logoReply = fetchResource("https://designviewer.qt.io/qtdesignstudioviewer-256.png");
if (logoReply->error() != QNetworkReply::NoError) { if (logoReply->error() != QNetworkReply::NoError) {
printErr("Could not fetch logo"); printErr("Could not fetch logo");
m_logo->setText("Could not fetch logo");
return; return;
} }
...@@ -176,8 +192,6 @@ void DvAndroid::fetchAndRunProject() ...@@ -176,8 +192,6 @@ void DvAndroid::fetchAndRunProject()
printLog("========================="); printLog("=========================");
printLog("Fetching a new project..."); printLog("Fetching a new project...");
// https://designviewer.qt.io/#17e8907b3b84b8206d45be4f551f4e25/TestTwo.qmlrc
// https://designviewer.qt.io/qmlprojects/17e8907b3b84b8206d45be4f551f4e25/TestTwo.qmlrc
QString projectUrl = m_lineEdit->text(); QString projectUrl = m_lineEdit->text();
if (projectUrl.startsWith("https://designviewer.qt.io/#")) { if (projectUrl.startsWith("https://designviewer.qt.io/#")) {
...@@ -216,7 +230,7 @@ void DvAndroid::showAppWindow() ...@@ -216,7 +230,7 @@ void DvAndroid::showAppWindow()
printLog("Calculating the new size and scale..."); printLog("Calculating the new size and scale...");
const QSizeF contentSize = childItem->size(); const QSizeF contentSize = childItem->size();
const QSizeF newContentSize = contentSize.scaled(m_mainWindow.size().toSizeF(), const QSizeF newContentSize = contentSize.scaled(screenGeometry.size().toSizeF(),
Qt::AspectRatioMode::KeepAspectRatio); Qt::AspectRatioMode::KeepAspectRatio);
const qreal newScale = newContentSize.width() / contentSize.width(); const qreal newScale = newContentSize.width() / contentSize.width();
const int leftOffset = childItem->width() - screenGeometry.width(); const int leftOffset = childItem->width() - screenGeometry.width();
......
...@@ -39,7 +39,7 @@ int main(int argc, char *argv[]) ...@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
QSurfaceFormat::setDefaultFormat(format); QSurfaceFormat::setDefaultFormat(format);
QScopedPointer<DvBase> dv; QScopedPointer<DvBase> dv;
QCoreApplication::setApplicationVersion(QString("Built on %1 %2\n").arg(__DATE__, __TIME__)); QCoreApplication::setApplicationVersion(QString("Built on %1 %2").arg(__DATE__, __TIME__));
#ifdef Q_OS_WASM #ifdef Q_OS_WASM
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment