Skip to content

Commit

Permalink
wip - reader and guests cant edit
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Nov 18, 2024
1 parent 5cf54a6 commit 36b2f39
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/inpututils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2222,3 +2222,14 @@ double InputUtils::pixelDistanceBetween( const QPointF &p1, const QPointF &p2 )
{
return std::hypot( p1.x() - p2.x(), p1.y() - p2.y() );
}

bool InputUtils::userHasEditableRole( QgsProject *project )
{
const QString &projectDir = project->absolutePath();
QString metadataFilePath = projectDir + "/" + MerginApi::sMetadataFile;
MerginProjectMetadata metadata = MerginProjectMetadata::fromCachedJson( metadataFilePath );
QString role = metadata.role;

bool hasEditableRole = role != "reader" && role != "guest";
return hasEditableRole;
}
5 changes: 5 additions & 0 deletions app/inpututils.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ class InputUtils: public QObject
*/
static double pixelDistanceBetween( const QPointF &p1, const QPointF &p2 );

/**
* Checks if the user can edit the project
*/
Q_INVOKABLE static bool userHasEditableRole( QgsProject *project );

public slots:
void onQgsLogMessageReceived( const QString &message, const QString &tag, Qgis::MessageLevel level );

Expand Down
1 change: 1 addition & 0 deletions app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ ApplicationWindow {
MMToolbarButton {
text: qsTr("Add")
iconSource: __style.addIcon
visible: __inputUtils.userHasEditableRole( __activeProject.qgsProject )
onClicked: {
if ( __recordingLayersModel.rowCount() > 0 ) {
stateManager.state = "map"
Expand Down
1 change: 1 addition & 0 deletions core/merginprojectmetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ MerginProjectMetadata MerginProjectMetadata::fromJson( const QByteArray &data )

project.name = docObj.value( QStringLiteral( "name" ) ).toString();
project.projectNamespace = docObj.value( QStringLiteral( "namespace" ) ).toString();
project.role = docObj.value( QStringLiteral( "role" ) ).toString();

QJsonValue access = docObj.value( QStringLiteral( "access" ) );
if ( access.isObject() )
Expand Down
1 change: 1 addition & 0 deletions core/merginprojectmetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct MerginProjectMetadata
{
QString name;
QString projectNamespace;
QString role;
QList<QString> writersnames;
int version = -1;
QList<MerginFile> files;
Expand Down

1 comment on commit 36b2f39

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

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

iOS - version 24.11.694511 just submitted!

Please sign in to comment.