diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 379bcabd06a49e9f49051d5356389e6c0e3f2b82..ea1ee57c63f0d069604efd4bd4aa27ef78cbeaa7 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -11,7 +11,7 @@ android:allowNativeHeapPointerTagging="false" android:icon="@mipmap/app_icon"> <activity android:name="org.qtproject.qt.android.bindings.QtActivity" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" - android:label="Qt UI Viewer" android:launchMode="singleTop" + android:label="Qt UI Viewer" android:launchMode="singleTask" android:screenOrientation="unspecified" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN"/> diff --git a/src/backend.h b/src/backend.h index 8f17b7ffff9c12de721cbf86240f81ab0914c3dc..4d9dae1844d954e95f7be4ea88fc42ad2e2599b8 100644 --- a/src/backend.h +++ b/src/backend.h @@ -44,7 +44,6 @@ public: void setLogs(const QString &logs) { m_logs = logs; - qDebug() << "emitting logs changed signal"; emit logsChanged(m_logs); } diff --git a/src/main.cpp b/src/main.cpp index 71747aeaa72daa3a8fd648417b2a6773cabe5dd9..678f21455ad3514463ae6cc022809371cc1659ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,6 +64,14 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt newLog += logPrefix + localMsg + logSuffix + "\n"; __android_log_print(ANDROID_LOG_DEBUG, "Qt_UI_Viewer", "%s", qPrintable(newLog)); + static int logCounter = 0; + if (logCounter++ == 100) { + // remove the first line + int index = appLogs.indexOf('\n'); + if (index > 0) + appLogs.remove(0, index + 1); + logCounter = 99; + } if (backend) backend->setLogs(appLogs += newLog); } diff --git a/src/projectManager.cpp b/src/projectManager.cpp index 8ac5a736b7e47a64b00d7b7f31c3cd702c5ba8b6..83c4734bd3327e21d1dd30c9ed5131d3b3032187 100644 --- a/src/projectManager.cpp +++ b/src/projectManager.cpp @@ -246,6 +246,7 @@ bool ProjectManager::runProject(const QString &projectPath) qDebug() << "Loading mainQmlUrl: " << mainQmlUrl.toString(); m_qmlComponent.reset(new QQmlComponent(m_qmlEngine.data())); + m_qmlComponent->loadUrl(mainQmlUrl); qDebug() << "Waiting for qmlComponent to load"; @@ -333,7 +334,7 @@ bool ProjectManager::cacheProject(const QByteArray &projectData, const QJsonObje const QString filePath = it.filePath(); const QString relativeFilePath = filePath.mid(tempProjectPath.length()); const QString newFilePath = cachePath + relativeFilePath; - qDebug() << "Copying " << filePath << " to " << newFilePath; + if (QFileInfo(filePath).isDir()) { QDir().mkpath(newFilePath); } else { @@ -425,7 +426,7 @@ bool ProjectManager::cacheDemoProject(const QByteArray &projectData, const QStri const QString filePath = it.filePath(); const QString relativeFilePath = filePath.mid(tempProjectPath.length()); const QString newFilePath = demoProjectPath + relativeFilePath; - qDebug() << "Copying " << filePath << " to " << newFilePath; + if (QFileInfo(filePath).isDir()) { QDir().mkpath(newFilePath); } else if (!QFile::copy(filePath, newFilePath)) { @@ -494,16 +495,20 @@ void ProjectManager::orientateWindow(Qt::ScreenOrientation orientation) void ProjectManager::showAppWindow() { + qDebug("Initializing and showing the QML app window"); + QScreen *screen = QGuiApplication::primaryScreen(); connect(screen, &QScreen::orientationChanged, this, &ProjectManager::orientateWindow); orientateWindow(screen->orientation()); - qDebug("Initializing and showing the QML app window"); - connect(m_quickWindow.data(), &QQuickWindow::closing, this, [this]() { + connect(m_quickWindow.data(), &QQuickWindow::closing, this, [this, screen]() { qDebug() << "QML app window is closing"; m_qmlEngine.reset(); m_qmlComponent.reset(); + disconnect(screen, &QScreen::orientationChanged, this, &ProjectManager::orientateWindow); }); + + m_quickWindow->setFlags(Qt::Window | Qt::WindowStaysOnTopHint); m_quickWindow->showMaximized(); } diff --git a/ui/HomePage.qml b/ui/HomePage.qml index 515b68cb07068e049ab5907cb02d52053945ac18..b57576675cb2a560e723fff8f821c93622b37387 100644 --- a/ui/HomePage.qml +++ b/ui/HomePage.qml @@ -87,6 +87,7 @@ Item { id: downloadButton text: qsTr("Download and Run") onClicked: backend.runUserProject(urlTextField.text) + enabled: urlTextField.text !== '' Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter }