Skip to content

Commit

Permalink
Merge pull request #4958 from opengisch/QF-3059-back-on-deleted-cloud…
Browse files Browse the repository at this point in the history
…-project

Do not allow to return to current project if it is a deleted cloud project
  • Loading branch information
suricactus authored Jan 19, 2024
2 parents fb28acf + 51eb1cb commit 29c5727
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/appinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <QImageReader>
#include <qgsapplication.h>
#include <qgsmessagelog.h>
#include <qgsproject.h>
#include <qgsruntimeprofiler.h>
#include <qgsziputils.h>

Expand Down Expand Up @@ -191,6 +192,11 @@ void AppInterface::closeSentry() const
#endif
}

void AppInterface::clearProject() const
{
mApp->clearProject();
}

void AppInterface::importUrl( const QString &url )
{
QString sanitizedUrl = url.trimmed();
Expand Down
5 changes: 5 additions & 0 deletions src/core/appinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ class AppInterface : public QObject
*/
Q_INVOKABLE void closeSentry() const;

/**
* Clears the currently opened project
*/
Q_INVOKABLE void clearProject() const;

static void setInstance( AppInterface *instance ) { sAppInterface = instance; }
static AppInterface *instance() { return sAppInterface; }

Expand Down
8 changes: 8 additions & 0 deletions src/core/qgismobileapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,14 @@ bool QgisMobileapp::event( QEvent *event )
return QQmlApplicationEngine::event( event );
}

void QgisMobileapp::clearProject()
{
mAuthRequestHandler->clearStoredRealms();
mProjectFileName = QString();
mProjectFilePath = QString();
mProject->clear();
}

void QgisMobileapp::saveProjectPreviewImage()
{
if ( !mProjectFilePath.isEmpty() && mMapCanvas && !mMapCanvas->isRendering() )
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgismobileapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ class QFIELD_CORE_EXPORT QgisMobileapp : public QQmlApplicationEngine

bool event( QEvent *event ) override;

/**
* Clear the currently opened project back to a blank project
*/
void clearProject();

signals:
/**
* Emitted when a project file is being loaded
Expand Down
4 changes: 4 additions & 0 deletions src/qml/QFieldCloudScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@ Page {
cloudProjectsModel.removeLocalProject(projectActions.projectId)
iface.removeRecentProject(projectActions.projectLocalPath);
welcomeScreen.model.reloadModel()

if (projectActions.projectLocalPath === qgisProject.fileName) {
iface.clearProject()
}
}
}

Expand Down

1 comment on commit 29c5727

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.