Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Project Page #3036

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/icons/Personal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@
<file>Direction.svg</file>
<file>TrackingDirection.svg</file>
<file>AddImage.svg</file>
<file>Personal.svg</file>
</qresource>
</RCC>
2 changes: 2 additions & 0 deletions app/mmstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class MMStyle: public QObject
Q_PROPERTY( QUrl nextIcon READ nextIcon CONSTANT )
Q_PROPERTY( QUrl otherIcon READ otherIcon CONSTANT )
Q_PROPERTY( QUrl othersIcon READ othersIcon CONSTANT )
Q_PROPERTY( QUrl personalIcon READ personalIcon CONSTANT )
Q_PROPERTY( QUrl plusIcon READ plusIcon CONSTANT )
Q_PROPERTY( QUrl previousIcon READ previousIcon CONSTANT )
Q_PROPERTY( QUrl projectButtonMoreIcon READ projectButtonMoreIcon CONSTANT )
Expand Down Expand Up @@ -295,6 +296,7 @@ class MMStyle: public QObject
QUrl nextIcon() {return QUrl( "qrc:/Next.svg" );}
QUrl otherIcon() {return QUrl( "qrc:/Other.svg" );}
QUrl othersIcon() {return QUrl( "qrc:/Others.svg" );}
QUrl personalIcon() {return QUrl( "qrc:/Personal.svg" );}
QUrl plusIcon() {return QUrl( "qrc:/Plus.svg" );}
QUrl previousIcon() {return QUrl( "qrc:/Previous.svg" );}
QUrl projectButtonMoreIcon() {return QUrl( "qrc:/ProjectButtonMore.svg" );}
Expand Down
37 changes: 37 additions & 0 deletions app/qml/components/MMHeader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Item {

property string title: ""
property font titleFont: __style.t3
property color color: __style.transparentColor

property bool personIconVisible: false
property bool backVisible: true
property alias backButton: backBtn

Expand All @@ -29,10 +31,16 @@ Item {
property real rightMarginShift: 0

signal backClicked
signal personIconClicked

implicitHeight: 60 * __dp
implicitWidth: ApplicationWindow.window?.width ?? 0

Rectangle {
anchors.fill: parent
color: root.color
}

Text {
// If there is a right or a left icon, we need to shift the margin
// of the opposite side to keep the text centred to the center of the screen
Expand Down Expand Up @@ -73,6 +81,35 @@ Item {
onClicked: root.backClicked()
}

Rectangle {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not correct approach. Personal Icon should be bound from parent as right item

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can discuss it. This is a special item and should be extended by the new design, it can contain a red mark on the top right corner of this icon or can contain user initials instead of the icon.

id: personIconRect

anchors {
right: parent.right
rightMargin: internal.pageMargin
verticalCenter: parent.verticalCenter
}

width: 40 * __dp
height: width
radius: width / 2
color: __style.fieldColor
visible: root.personIconVisible

MMIcon {
anchors.centerIn: parent
source: __style.personalIcon
useCustomSize: true
width: 24 * __dp
height: 24 * __dp
}

MouseArea {
anchors.fill: parent
onClicked: root.personIconClicked()
}
}

QtObject {
id: internal

Expand Down
35 changes: 24 additions & 11 deletions app/qml/components/MMProjectItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@
import QtQuick
import QtQuick.Controls

import notificationType 1.0

Rectangle {
id: root

required property string projectDisplayName
required property string projectId
required property string projectDescription
required property int projectStatus
required property bool projectIsValid
required property bool projectIsLocal
required property bool projectIsMergin
property string projectDisplayName
property string projectId
property string projectDescription
property int projectStatus
property bool projectIsValid
property bool projectIsLocal
property bool projectIsMergin
property bool projectIsPending: false
property real projectSyncProgress: 0.0
property bool highlight: false
property string projectRemoteError

signal openRequested()
signal syncRequested()
Expand All @@ -46,7 +49,7 @@ Rectangle {

width: parent.width
padding: 20 * __dp
spacing: 12 * __dp
spacing: 15 * __dp

Row {
id: row
Expand All @@ -56,12 +59,12 @@ Rectangle {
Column {
id: column

spacing: 6 * __dp

Text {
width: mainColumn.width - 2 * mainColumn.padding - icon.width - row.spacing
height: 26 * __dp

text: root.projectDisplayName
verticalAlignment: Text.AlignVCenter
font: __style.t3
color: root.highlight ? __style.whiteColor : __style.nightColor
elide: Text.ElideRight
Expand All @@ -82,8 +85,10 @@ Rectangle {

Text {
width: parent.width - errorIcon.width
height: 24 * __dp

text: root.projectDescription
verticalAlignment: Text.AlignVCenter
font: __style.p6
elide: Text.ElideRight
color: {
Expand Down Expand Up @@ -196,7 +201,15 @@ Rectangle {
}

onClicked: function(type) {
console.log(type)
if ( projectRemoteError ) {
__notificationModel.add(
qsTr( "Notification: Could not synchronize project, please make sure you are logged in and have sufficient rights." ),
3,
NotificationType.Error,
NotificationType.None
)
return
}
switch(type) {
case "download": root.syncRequested(); break
case "sync": root.syncRequested(); break
Expand Down
128 changes: 128 additions & 0 deletions app/qml/project/MMProjectListPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/***************************************************************************
* *
* 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 QtQuick.Controls

import lc 1.0
import "../components"
import "../inputs"

Page {
id: root

property string headerTitle: qsTr("Projects")
property bool withSearch: false
property alias model: listView.model
property bool showCreateProjectButton: false

property string activeProjectId: ""
property int projectModelType: ProjectsModel.EmptyProjectsModel

property var controllerModel

signal backClicked
signal createProjectClicked
signal personIconClicked

signal openProjectRequested( string projectFilePath )
signal showLocalChangesRequested( string projectId )
signal activeProjectDeleted()

Rectangle {
anchors.fill: parent
color: __style.lightGreenColor
}

header: MMHeader {
id: header

title: root.headerTitle
color: __style.lightGreenColor
personIconVisible: true
rightMarginShift: 40 * __dp

onBackClicked: root.backClicked()
onPersonIconClicked: root.personIconClicked()
}

Column {
width: parent.width - 40 * __dp
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 10 * __dp
spacing: 20 * __dp

MMSearchEditor {
id: searchBar

width: parent.width - 2 * root.padding
placeholderText: qsTr("Search for projects...")
visible: root.withSearch

onSearchTextChanged: function(text) {
//root.model.searchExpression = text
}
}

ListView {
id: listView

width: parent.width - 2 * root.padding
height: ApplicationWindow.window ? ApplicationWindow.window.height - searchBar.height - 130 * __dp : 0
clip: true
spacing: 10 * __dp

delegate: MMProjectItem {
width: listView.width

highlight: model.ProjectId === root.activeProjectId
projectId: model.ProjectId
projectStatus: model.ProjectStatus ? model.ProjectStatus : ProjectStatus.NoVersion
projectDisplayName: root.projectModelType === ProjectsModel.CreatedProjectsModel ? model.ProjectName : model.ProjectFullName
projectDescription: model.ProjectDescription
projectIsValid: model.ProjectIsValid
projectIsLocal: model.ProjectIsLocal
projectIsMergin: model.ProjectIsMergin
projectIsPending: model.ProjectSyncPending ? model.ProjectSyncPending : false
projectSyncProgress: model.ProjectSyncProgress ? model.ProjectSyncProgress : -1
projectRemoteError: model.ProjectRemoteError ? model.ProjectRemoteError : ""

onOpenRequested: {
if ( model.ProjectIsLocal )
root.openProjectRequested( model.ProjectFilePath )
else if ( !model.ProjectIsLocal && model.ProjectIsMergin && !model.ProjectSyncPending) {
console.log("Download project with Id: " + model.ProjectId)
}
}
onStopSyncRequested: controllerModel.stopProjectSync( model.ProjectId )
onShowChangesRequested: root.showLocalChangesRequested( model.ProjectId )
onSyncRequested: controllerModel.syncProject( model.ProjectId )
onRemoveRequested: console.log("Remove project with Id: " + model.ProjectId)
onMigrateRequested: controllerModel.migrateProject( model.ProjectId )
}

footer: Item { width: 1; height: createProjectButton.visible ? 80 * __dp : 0 }
}
}

MMButton {
id: createProjectButton

width: root.width - 2 * 20 * __dp
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 20 * __dp

visible: root.showCreateProjectButton
text: qsTr("Create project")

onClicked: root.createProjectClicked()
}
}

3 changes: 2 additions & 1 deletion gallery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ qt_policy(SET QTP0001 NEW)

set(GALLERY_HDRS
helper.h
project.h
qrcodedecoder.h
inpututils.h
scalebarkit.h
Expand All @@ -42,7 +43,7 @@ set(GALLERY_HDRS
../core/merginerrortypes.h
)

set(GALLERY_SRCS helper.cpp ../app/notificationmodel.cpp main.cpp)
set(GALLERY_SRCS helper.cpp project.cpp ../app/notificationmodel.cpp main.cpp)

if (IOS OR ANDROID)
add_compile_definitions(MOBILE_OS)
Expand Down
3 changes: 3 additions & 0 deletions gallery/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "qrcodedecoder.h"
#include "inpututils.h"
#include "scalebarkit.h"
#include "project.h"
#include "positionkit.h"
#include "relationfeaturesmodel.h"

Expand All @@ -43,6 +44,8 @@ int main( int argc, char *argv[] )
qmlRegisterUncreatableType<RegistrationError>( "lc", 1, 0, "RegistrationError", "RegistrationError Enum" );
qmlRegisterType<QrCodeDecoder>( "lc", 1, 0, "QrCodeDecoder" );
qmlRegisterType<ScaleBarKit>( "lc", 1, 0, "ScaleBarKit" );
qmlRegisterType<ProjectsModel>( "lc", 1, 0, "ProjectsModel" );
qmlRegisterUncreatableMetaObject( ProjectStatus::staticMetaObject, "lc", 1, 0, "ProjectStatus", "ProjectStatus Enum" );
qmlRegisterType<RelationFeaturesModel>( "lc", 1, 0, "RelationFeaturesModel" );

#ifdef DESKTOP_OS
Expand Down
62 changes: 62 additions & 0 deletions gallery/project.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/

#include "project.h"

QString LocalProject::id() const
{
return fullName();
}

QString LocalProject::fullName() const
{
if ( !projectName.isEmpty() && !projectNamespace.isEmpty() )
return QString( "/getFullProjectName/%1/%2" ).arg( projectNamespace, projectName );

if ( projectDir.isEmpty() )
return QString();

QDir dir( projectDir );
return dir.dirName();
}

QString MerginProject::id() const
{
return QString( "/getFullProjectName/%1/%2" ).arg( projectNamespace, projectName );
}

ProjectStatus::Status ProjectStatus::projectStatus( const Project &project )
{
if ( !project.isMergin() || !project.isLocal() ) // This is not a Mergin project or not downloaded project
return ProjectStatus::NoVersion;

// There was no sync yet
if ( !project.local.hasMerginMetadata() )
{
return ProjectStatus::NoVersion;
}

// Version is lower than latest one, last sync also before updated
if ( project.local.localVersion < project.mergin.serverVersion )
{
return ProjectStatus::NeedsSync;
}

if ( ProjectStatus::hasLocalChanges( project.local ) )
{
return ProjectStatus::NeedsSync;
}

return ProjectStatus::UpToDate;
}

bool ProjectStatus::hasLocalChanges( const LocalProject &project )
{
return false;
}
Loading
Loading