Skip to content

Commit

Permalink
adding more controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Dec 21, 2023
1 parent fde66c7 commit b655efd
Show file tree
Hide file tree
Showing 11 changed files with 310 additions and 101 deletions.
2 changes: 2 additions & 0 deletions app/qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ set(MM_QML
onboarding/MMSignUp.qml
onboarding/MMWhichIndustry.qml
onboarding/MMOnboardingController.qml
onboarding/MMCreateWorkspaceController.qml
onboarding/MMAcceptInvitationController.qml
dialogs/MigrateToMerginDialog.qml
dialogs/MissingAuthDialog.qml
dialogs/NoPermissionsDialog.qml
Expand Down
28 changes: 21 additions & 7 deletions app/qml/ProjectPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ Item {
}
}

function openLoginPage()
function showLogin()
{
onboardingController.openLoginPage()
onboardingController.start()
}

function openChangesPanel()
Expand Down Expand Up @@ -99,7 +99,7 @@ Item {
return false;
}
// do not show the banner in case of accepting invitation or creating a workspace
if (stackView.currentItem && (stackView.currentItem.objectName === "registrationFinishPanel" || stackView.currentItem.objectName === "createWorkspacePanel")) {
if (onboardingController.inProgress) {
return false;
}
return !__merginApi.userInfo.hasWorkspaces
Expand All @@ -112,7 +112,7 @@ Item {
}

onCreateWorkspaceRequested: {
stackView.push(createWorkspaceComponent)
createWorkspaceController.createNewWorkspace()
}
}

Expand Down Expand Up @@ -253,7 +253,7 @@ Item {
}
}
else {
root.openLoginPage()
root.showLogin()
}
}
}
Expand Down Expand Up @@ -496,6 +496,20 @@ Item {
stackView: stackView
}

MMCreateWorkspaceController {
// TODO move to main.qml
id: createWorkspaceController
enabled: root.visible
stackView: stackView
}

MMAcceptInvitationController {
// TODO move to main.qml
id: acceptInvitationController
// TODO enabled add controller.showInvitationsList
enabled: root.visible && __merginApi.apiSupportsWorkspaces
stackView: stackView
}

Component {
id: registrationFinishComponent
Expand Down Expand Up @@ -605,7 +619,7 @@ Item {
function onAuthRequested() {
stackView.pending = false

root.openLoginPage()
root.showLogin()
}

function onAuthChanged() {
Expand All @@ -622,7 +636,7 @@ Item {
}
else {
// log out - reenable openInvitationsListener
onboardingController.showInvitationList()
acceptInvitationController.showInvitationList = true
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ ApplicationWindow {

onSignInRequested: {
stateManager.state = "projects"
projectPanel.openLoginPage()
projectPanel.showLogin()
}

onLocalChangesPanelRequested: {
Expand Down
23 changes: 20 additions & 3 deletions app/qml/onboarding/MMAcceptInvitation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ Page {

required property string user
required property string workspace
required property string workspaceUuid

signal backClicked
signal continueClicked
property bool haveBack: true
property bool showCreate: true

signal joinWorkspaceClicked(string workspaceUuid)
signal createWorkspaceClicked
signal backClicked

readonly property real hPadding: width < __style.maxPageWidth
? 20 * __dp
Expand All @@ -31,6 +35,17 @@ Page {
color: __style.lightGreenColor
}

MMHeader {
id: header

x: mainColumn.leftPadding
y: mainColumn.topPadding
width: parent.width - 2 * root.hPadding
visible: haveBack

onBackClicked: root.backClicked()
}

ScrollView {
width: parent.width
height: parent.height
Expand Down Expand Up @@ -105,17 +120,19 @@ Page {
width: parent.width - 2 * root.hPadding
text: qsTr("Join workspace")

onClicked: root.continueClicked()
onClicked: root.joinWorkspaceClicked(root.workspaceUuid)
}

MMHlineText {
width: parent.width - 2 * root.hPadding
title: qsTr("or")
visible: root.showCreate
}

MMLinkButton {
width: parent.width - 2 * root.hPadding
text: qsTr("Create new workspace")
visible: root.showCreate

onClicked: root.createWorkspaceClicked()
}
Expand Down
81 changes: 81 additions & 0 deletions app/qml/onboarding/MMAcceptInvitationController.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
import QtQuick

import "../"
import QtQuick.Controls
import lc 1.0

/**
* Show accept invitation page directly without onboarding
* e.g. on app start
*/
Item {
id: controller

required property bool enabled
required property var stackView

property bool showInvitationList: false // TODO merge with enabled ?

Connections {
id: openInvitationsListener

target: __merginApi
enabled: root.enabled && root.showInvitationList

function onUserInfoReplyFinished() {
// controller.showInvitationsList = false;

/*
it should be enabled = false in this case from parent!
// let's not show invitations when registration finish page is opened
if ( stackView.containsPage("registrationFinishPanel") ) {
return;
}
*/

if ( !__merginApi.userAuth.hasAuthData() ) {
return;
}

if ( __merginApi.userInfo.hasInvitations ) {
stackView.push( acceptInvitationsPanelComponent )
}
}
}

Connections {
target: __merginApi
enabled: root.enabled && root.showInvitationList

function onProcessInvitationFinished( accepted ) {
stackView.pop(null)
}
}

Component {
id: acceptInvitationsPanelComponent

MMAcceptInvitation {
objectName: "acceptInvitationsPanelDirect"
haveBack: true
showCreate: false

onBackClicked: {
stackView.popOnePageOrClose()
}

onJoinWorkspaceClicked: function (workspaceUuid) {
__merginApi.processInvitation( workspaceUuid, true )
}
}
}
}
10 changes: 8 additions & 2 deletions app/qml/onboarding/MMCreateWorkspace.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ import "../inputs"
Page {
id: root

signal continueClicked
signal createWorkspaceClicked(string name)

readonly property real hPadding: width < __style.maxPageWidth
? 20 * __dp
: (20 + (width - __style.maxPageWidth) / 2) * __dp

// show error message under the respective field
function showErrorMessage( msg ) {
workspaceName.errorMsg = msg
}

Rectangle {
anchors.fill: parent
color: __style.lightGreenColor
Expand Down Expand Up @@ -81,6 +86,7 @@ Page {
Item { width: 1; height: 1 }

MMInputEditor {
id: workspaceName
width: parent.width - 2 * root.hPadding
title: qsTr("Workspace name")
placeholderText: qsTr("Your Workspace")
Expand Down Expand Up @@ -109,7 +115,7 @@ Page {
width: parent.width - 2 * root.hPadding
text: qsTr("Create workspace")

onClicked: root.continueClicked()
onClicked: root.createWorkspaceClicked(workspaceName.text)
}
}
}
49 changes: 49 additions & 0 deletions app/qml/onboarding/MMCreateWorkspaceController.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
import QtQuick

import "../"
import QtQuick.Controls
import lc 1.0

/**
* Directly create workspace but without onboarding questions
* e.g. from account page or projects panel
*/
Item {
id: controller

required property var stackView
required property bool enabled

Connections {
target: __merginApi
enabled: controller.enabled

function onWorkspaceCreated(workspace, result) {
if (result) {
stackView.pop("createWorkspaceDirectPanel")
}
}
}

Component {
id: createWorkspaceComponent

MMCreateWorkspace {
id: createWorkspacePanel

objectName: "createWorkspaceDirectPanel"

onCreateWorkspaceClicked: function (workspaceName) {
__merginApi.createWorkspace(workspaceName)
}
}
}
}
7 changes: 5 additions & 2 deletions app/qml/onboarding/MMHowYouFoundUs.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Page {
property string selectedText: ""

signal backClicked
signal continueClicked(var selectedText)
signal howYouFoundUsSelected(var selectedText)

readonly property string headerTitle: qsTr("How did you learn about us?")
readonly property real hPadding: width < __style.maxPageWidth
Expand Down Expand Up @@ -136,6 +136,9 @@ Page {
anchors.bottomMargin: 20 * __dp
text: qsTr("Continue")

onClicked: root.continueClicked(root.selectedText)
onClicked: {
// TODO not allow in case there is missing selected text!
root.howYouFoundUsSelected(root.selectedText)
}
}
}
Loading

1 comment on commit b655efd

@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 23.12.501511 just submitted!

Please sign in to comment.