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 \
-B build \
-G Ninja \
-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_NDK_ROOT=<android-sdk-path>/ndk/<ndk-version> \
-DANDROID_OPENSSL_PATH=<openssl-path>
......@@ -73,7 +74,7 @@ source ./emsdk_env.sh
cd ..
```
Then build and install QtQuickDesigner Components for Android:
Then build and install QtQuickDesigner Components for WebAssembly:
```bash
cd qtquickdesigner-components
......@@ -81,7 +82,8 @@ cmake \
-S . \
-B build \
-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 --install build
......
......@@ -77,15 +77,24 @@ QSharedPointer<QNetworkReply> DvAndroid::fetchResource(const QString &url)
&QNetworkReply::sslErrors,
this,
[&](const QList<QSslError> &errors) {
printLog(errors.first().errorString());
printErr(errors.first().errorString());
});
QEventLoop loop;
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();
if (reply->error() != QNetworkReply::NoError) {
printLog(reply->errorString());
printErr(reply->errorString());
} else {
printLog("Resource fetched successfully");
}
......@@ -106,7 +115,11 @@ void DvAndroid::setupUi()
m_layout->addWidget(m_button);
// 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
m_logs->setWordWrap(true);
......@@ -121,8 +134,7 @@ void DvAndroid::setupUi()
});
// configure line edit
m_lineEdit->setText(
"https://designviewer.qt.io/#17e8907b3b84b8206d45be4f551f4e25/TestTwo.qmlrc");
m_lineEdit->setPlaceholderText("Enter project URL here");
// configure the button
m_button->setText("Download and run project");
......@@ -134,21 +146,25 @@ void DvAndroid::setupUi()
void DvAndroid::printSysInfo()
{
const QRect screenGeometry = QGuiApplication::primaryScreen()->geometry();
printLog("Qt Design Viewer");
printLog("System information:");
printLog("-- Qt version: " + QString(QT_VERSION_STR));
printLog("-- OpenSSL support: " + QVariant(QSslSocket::supportsSsl()).toString());
printLog("-- Window height: " + QString::number(m_mainWindow.height()));
printLog("-- Window width: " + QString::number(m_mainWindow.width()));
printLog("-- Screen height: " + QString::number(screenGeometry.height()));
printLog("-- Screen width: " + QString::number(screenGeometry.width()));
}
void DvAndroid::updateLogo()
{
printLog("Fetching logo...");
m_logo->setText("Fetching logo...");
auto logoReply = fetchResource("https://designviewer.qt.io/qtdesignstudioviewer-256.png");
if (logoReply->error() != QNetworkReply::NoError) {
printErr("Could not fetch logo");
m_logo->setText("Could not fetch logo");
return;
}
......@@ -176,8 +192,6 @@ void DvAndroid::fetchAndRunProject()
printLog("=========================");
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();
if (projectUrl.startsWith("https://designviewer.qt.io/#")) {
......@@ -216,7 +230,7 @@ void DvAndroid::showAppWindow()
printLog("Calculating the new size and scale...");
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);
const qreal newScale = newContentSize.width() / contentSize.width();
const int leftOffset = childItem->width() - screenGeometry.width();
......
......@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
QSurfaceFormat::setDefaultFormat(format);
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
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