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

QDS-11911 Project list dropdown update issues

parent 20733343
No related branches found
No related tags found
1 merge request!37QDS-11911 Project list dropdown update issues
Pipeline #67177 passed
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.qt.qtdesignviewer"
android:installLocation="auto" android:versionCode="24" android:versionName="1.2">
android:installLocation="auto" android:versionCode="25" android:versionName="1.2">
<!-- %%INSERT_PERMISSIONS -->
<!-- %%INSERT_FEATURES -->
<supports-screens android:anyDensity="true" android:largeScreens="true"
......
......@@ -92,7 +92,9 @@ void Backend::initialize()
updateUserProjectList();
}
// Check if updateInBackground is enabled
// Initialize background update
connect(&m_backgroundTimer, &QTimer::timeout, this, &Backend::updateUserProjectList);
m_backgroundTimer.setInterval(1000 * 10);
enableBackgroundUpdate(updateInBackground());
qDebug() << "Initialization complete";
}
......@@ -100,26 +102,6 @@ void Backend::initialize()
void Backend::enableBackgroundUpdate(const bool &enabled)
{
if (enabled) {
m_backgroundTimer.setInterval(1000 * 10);
connect(&m_backgroundTimer, &QTimer::timeout, this, [&] {
qDebug() << "Checking for updates in background";
const QString userHash = Backend::userHash();
if (userHash.isEmpty())
return;
QJsonArray projectList = m_serviceConnector.fetchUserProjectList(userHash);
if (projectList.isEmpty()) {
qWarning() << "Could not fetch project list. Please check your internet "
"connection and try again";
return;
}
qDebug() << "New projects available. Updating project list";
updateUserProjectList();
});
m_backgroundTimer.start();
} else {
m_backgroundTimer.stop();
......@@ -150,7 +132,7 @@ void Backend::setAutoScaleProject(const bool &enabled)
void Backend::setUserHash(const QString &userHash)
{
QSettings().setValue("user/hash", userHash);
emit userRegistered();
emit userHashChanged();
}
bool Backend::updateInBackground()
......@@ -504,23 +486,23 @@ void Backend::updateUserProjectList()
qDebug() << "Fetching available project list for user:" << userHash;
QJsonArray projectList = m_serviceConnector.fetchUserProjectList(userHash);
if (projectList.isEmpty()) {
qCritical("Could not fetch available project list");
return;
}
if (projectList == m_projectList) {
qDebug("No new projects available");
return;
qDebug("No new projects are available");
} else if (projectList.isEmpty()) {
qWarning("Could not fetch project list. Either there are no projects or there is a "
"network issue");
} else {
qDebug("List of available projects fetched:");
for (const auto &project : projectList) {
const QString projectName{project.toObject().value("appName").toString()};
qDebug() << "--" << projectName;
}
}
// we need to set m_projectList even if it is empty
// because this triggers the onModelChanged function in the QML
// in order to update the UI
m_projectList = projectList;
qDebug("List of available projects fetched:");
for (const auto &project : projectList) {
const QString projectName{project.toObject().value("appName").toString()};
qDebug() << "--" << projectName;
}
emit projectListChanged();
}
......
......@@ -89,23 +89,29 @@ private:
QTimer m_backgroundTimer;
// member functions
void updateUserProjectList();
void updatePopup(const QString &text, bool indeterminate = true);
signals:
// UI signals
// UI signals - Home page
void projectListChanged();
void urlUpdated(QString);
void userHashChanged();
// UI signals - Logs page
void logsChanged(QString);
// UI signals - About page
void buildInfoChanged(QString);
// UI signals - Popup
void downloadProgress(float);
void projectListChanged();
void popupProgressIndeterminateChanged(bool indeterminate);
void popupTextChanged(QString text);
void popupOpen();
void popupClose();
void userRegistered();
// UI signals - Network page
void networkUpdated(QString);
void urlUpdated(QString);
void userHashChanged(QString);
public slots:
void scanQrCode();
......@@ -133,6 +139,7 @@ public slots:
private slots:
void initializeProjectManager();
void enableBackgroundUpdate(const bool &enabled);
void updateUserProjectList();
};
#endif // DV_ANDROID_H
......@@ -27,7 +27,7 @@ Item {
Layout.fillWidth: true
Connections {
target: backend
function onUserRegistered(){
function onUserHashChanged(){
qrCodeStatus.text = "User registration is completed.\nScan a new QR code to access the shared project from a different user.";
qrCodeInstructions.text = "";
}
......@@ -67,11 +67,19 @@ Item {
id: projectList
Layout.fillWidth: true
enabled: true
onCurrentIndexChanged: {
displayText = textAt(currentIndex)
}
textRole: "appName"
model: backend.projectList
onModelChanged: {
if (backend.projectList.length > 0) {
projectList.displayText = backend.projectList[0].appName;
projectList.enabled = true;
downloadUserProject.enabled = true;
} else {
projectList.displayText = "No projects are available";
projectList.enabled = false;
downloadUserProject.enabled = false;
}
}
displayText: "Scan QR code to access your projects";
currentIndex: -1
Layout.preferredHeight: 50
......@@ -85,19 +93,6 @@ Item {
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
}
Connections {
target: backend
function onUserRegistered(){
projectList.displayText = "No projects available for the user";
projectList.enabled = false;
downloadUserProject.enabled = false;
}
function onProjectListChanged(){
projectList.enabled = true;
downloadUserProject.enabled = true;
}
}
}
Item {
......
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