Skip to content

Commit

Permalink
tweak error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Dec 21, 2023
1 parent b655efd commit 96a7e85
Show file tree
Hide file tree
Showing 19 changed files with 230 additions and 38 deletions.
26 changes: 26 additions & 0 deletions app/icons/WarnLogoImage.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 @@ -63,6 +63,7 @@
<file>WaterResources.svg</file>
<file>XMark.svg</file>
<file>XTwitter.svg</file>
<file>WarnLogoImage.svg</file>
<file>Youtube.svg</file>
<file>ZoomToProject.svg</file>
</qresource>
Expand Down
2 changes: 1 addition & 1 deletion app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "qgsmaplayerproxymodel.h"
#include "qgsnetworkaccessmanager.h"
#include "geodiffutils.h"

#include "merginerrortypes.h"
#include "androidutils.h"
#include "ios/iosutils.h"
#include "inpututils.h"
Expand Down
2 changes: 2 additions & 0 deletions app/mmstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class MMStyle: public QObject
Q_PROPERTY( QUrl acceptInvitationLogoImage READ acceptInvitationLogoImage CONSTANT )
Q_PROPERTY( QUrl reachedDataLimitImage READ reachedDataLimitImage CONSTANT )
Q_PROPERTY( QUrl uploadImage READ uploadImage CONSTANT )
Q_PROPERTY( QUrl warnLogoImage READ warnLogoImage CONSTANT )

// Map items
Q_PROPERTY( double mapItemHeight READ mapItemHeight CONSTANT )
Expand Down Expand Up @@ -279,6 +280,7 @@ class MMStyle: public QObject
QUrl acceptInvitationImage() {return QUrl( "qrc:/AcceptInvitationImage.svg" ); }
QUrl uploadImage() {return QUrl( "qrc:/UploadImage.svg" );}
QUrl reachedDataLimitImage() {return QUrl( "qrc:/ReachedDataLimitImage.svg" );}
QUrl warnLogoImage() {return QUrl( "qrc:/WarnLogoImage.svg" );}

double mapItemHeight() {return 50 * mDp;}

Expand Down
1 change: 1 addition & 0 deletions app/qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ set(MM_QML
components/MMToolbarButton.qml
components/MMToolbarLongButton.qml
components/MMToolbarMenuButton.qml
components/MMWarningBubble.qml
onboarding/MMAcceptInvitation.qml
onboarding/MMCreateWorkspace.qml
onboarding/MMHowYouFoundUs.qml
Expand Down
53 changes: 53 additions & 0 deletions app/qml/components/MMWarningBubble.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/***************************************************************************
* *
* 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 QtQuick.Layouts

Item {
id: root

height: row.height

required property string text

Rectangle {
width: root.width
height: row.height
color: __style.nightColor
radius: __style.inputRadius
}

Row {
id: row

padding: 20 * __dp
spacing: 10 * __dp

Image {
id: icon

width: 50 * __dp
height: width

source: __style.warnLogoImage
}

Text {
width: root.width - icon.width - 4 * row.spacing - 2 * row.padding
height: icon.height
text: root.text
font: __style.t3
color: __style.whiteColor
wrapMode: Label.WordWrap
lineHeight: 1.5
}
}
}
4 changes: 2 additions & 2 deletions app/qml/onboarding/MMCreateWorkspace.qml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ Page {

MMTextBubble {
width: root.width - 2 * root.hPadding
title: "Tip from Mergin Maps"
description: "A good candidate for a workspace name is the name of your team or organisation"
title: qsTr("Tip from Mergin Maps")
description: qsTr("A good candidate for a workspace name is the name of your team or organisation")
}

MMButton {
Expand Down
34 changes: 29 additions & 5 deletions app/qml/onboarding/MMHowYouFoundUs.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import QtQuick.Controls
import "../components"
import "../inputs"

import notificationType 1.0

Page {
id: root

Expand All @@ -28,6 +30,8 @@ Page {
? 20 * __dp
: (20 + (width - __style.maxPageWidth) / 2) * __dp

readonly property string specifySourceText: qsTr("Please specify the source")

Rectangle {
anchors.fill: parent
color: __style.lightGreenColor
Expand Down Expand Up @@ -104,22 +108,34 @@ Page {
checked: listView.currentIndex === index

onClicked: {
root.selectedText = model.name

listView.currentIndex = index

if(listView.model.count === listView.currentIndex + 1)
{
root.selectedText = ""
listView.positionViewAtEnd()
}
else {
if (model.icon === __style.socialMediaIcon) {
// need to select subcategory
root.selectedText = ""
} else {
root.selectedText = model.name
}
}
}
}

footer: Column {
width: root.width - 2 * root.hPadding
topPadding: 20 * __dp
visible: listView.model.count === listView.currentIndex + 1
visible: listView.model.count === listView.currentIndex + 1 // === Other

MMInputEditor {
id: otherSourceText
title: qsTr("Source")
placeholderText: qsTr("Please specify the source")
placeholderText: root.specifySourceText
onTextChanged: root.selectedText = text
onVisibleChanged: if(visible) hasFocus = true
}
Expand All @@ -137,8 +153,16 @@ Page {
text: qsTr("Continue")

onClicked: {
// TODO not allow in case there is missing selected text!
root.howYouFoundUsSelected(root.selectedText)
if (root.selectedText.length > 0 ) {
root.howYouFoundUsSelected(root.selectedText)
} else {
notificationModel.add(
root.specifySourceText,
5,
NotificationType.Error,
NotificationType.None
)
}
}
}
}
10 changes: 8 additions & 2 deletions app/qml/onboarding/MMLogin.qml
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,21 @@ Page {

Text {
// !TODO - need graphic designer input!
visible: root.warningMsg

width: parent.width - 2 * root.hPadding
text: root.warningMsg

font: __style.h2
color: __style.negativeColor
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
}

MMWarningBubble {
visible: root.warningMsg
text: root.warningMsg
width: root.width - 2 * root.hPadding
}

MMInputEditor {
id: username
width: parent.width - 2 * root.hPadding
Expand Down
2 changes: 2 additions & 0 deletions app/qml/onboarding/MMWhichIndustry.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import QtQuick.Controls
import "../components"
import "../inputs"

import notificationType 1.0

Page {
id: root

Expand Down
1 change: 1 addition & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(MM_CORE_HDRS
coreutils.h
merginapi.h
merginapistatus.h
merginerrortypes.h
merginsubscriptioninfo.h
merginsubscriptionstatus.h
merginservertype.h
Expand Down
1 change: 1 addition & 0 deletions core/merginapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "geodiffutils.h"
#include "localprojectsmanager.h"
#include "../app/enumhelper.h"
#include "merginerrortypes.h"

#include <geodiff.h>

Expand Down
16 changes: 0 additions & 16 deletions core/merginapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@
#include "merginworkspaceinfo.h"
#include "merginuserauth.h"

class RegistrationError
{
Q_GADGET
public:
enum RegistrationErrorType
{
OTHER = 0,
USERNAME,
EMAIL,
PASSWORD,
CONFIRM_PASSWORD,
TOC
};
Q_ENUM( RegistrationErrorType )
};

struct ProjectDiff
{
// changes that should be pushed
Expand Down
31 changes: 31 additions & 0 deletions core/merginerrortypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/

#ifndef MERGINERRORTYPES_H
#define MERGINERRORTYPES_H

#include <QObject>

class RegistrationError
{
Q_GADGET
public:
enum RegistrationErrorType
{
OTHER = 0,
USERNAME,
EMAIL,
PASSWORD,
CONFIRM_PASSWORD,
TOC
};
Q_ENUM( RegistrationErrorType )
};

#endif
9 changes: 7 additions & 2 deletions gallery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ find_package(
qt_standard_project_setup()
qt_policy(SET QTP0001 NEW)

set(GALLERY_HDRS helper.h notificationmodel.h ../app/mmstyle.h)
set(GALLERY_HDRS
helper.h
notificationmodel.h
../app/mmstyle.h
../core/merginerrortypes.h
)

set(GALLERY_SRCS helper.cpp notificationmodel.cpp main.cpp)

Expand Down Expand Up @@ -74,7 +79,7 @@ set_target_properties(
)

target_link_libraries(MerginMapsGallery PRIVATE Qt6::Quick)
target_include_directories(MerginMapsGallery PRIVATE ../app)
target_include_directories(MerginMapsGallery PRIVATE ../app ../core)

install(
TARGETS MerginMapsGallery
Expand Down
7 changes: 7 additions & 0 deletions gallery/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <QFont>
#include <QFontDatabase>
#include "notificationmodel.h"
#include "merginerrortypes.h"

int main( int argc, char *argv[] )
{
QGuiApplication app( argc, argv );
Expand All @@ -26,6 +28,10 @@ int main( int argc, char *argv[] )

QQmlApplicationEngine engine;

// Register C++ enums
qmlRegisterUncreatableType<RegistrationError>( "lc", 1, 0, "RegistrationError", "RegistrationError Enum" );


#ifdef DESKTOP_OS
HotReload hotReload( engine );
engine.rootContext()->setContextProperty( "_hotReload", &hotReload );
Expand All @@ -36,6 +42,7 @@ int main( int argc, char *argv[] )
NotificationModel notificationModel;

engine.rootContext()->setContextProperty( "notificationModel", &notificationModel );

// path to local wrapper pages
engine.rootContext()->setContextProperty( "_qmlWrapperPath", QGuiApplication::applicationDirPath() + "/HotReload/qml/pages/" );
engine.rootContext()->setContextProperty( "__dp", dp );
Expand Down
1 change: 1 addition & 0 deletions gallery/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@
<file>../app/qml/components/MMBackButton.qml</file>
<file>../app/qml/components/MMIconCheckBoxHorizontal.qml</file>
<file>../app/qml/components/MMIconCheckBoxVertical.qml</file>
<file>../app/qml/components/MMWarningBubble.qml</file>
</qresource>
</RCC>
21 changes: 21 additions & 0 deletions gallery/qml/pages/MiscPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,26 @@ ScrollView {
}
}
}

GroupBox {
title: "MMWarningBubble"
background: Rectangle {
color: "white"
}
label: Label {
color: "black"
text: parent.title
padding: 5
}

Column {
spacing: 20
anchors.fill: parent
MMWarningBubble {
width: page.width - 64
text: "Server is broken, sorry. \n Please wait for tomorrow"
}
}
}
}
}
Loading

0 comments on commit 96a7e85

Please sign in to comment.