Skip to content

Commit

Permalink
added the ability to register tour from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Eism committed Feb 19, 2025
1 parent 77fb2ce commit f8b13b9
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 54 deletions.
1 change: 0 additions & 1 deletion src/appshell/appshell.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
<file>qml/platform/mac/Main.qml</file>
<file>qml/platform/win/Main.qml</file>
<file>resources/win_opengl_buglist.json</file>
<file>resources/tours.json</file>
<file>qml/Preferences/internal/BaseSection.qml</file>
<file>qml/Preferences/internal/LanguagesSection.qml</file>
<file>qml/Preferences/internal/AutoSaveSection.qml</file>
Expand Down
17 changes: 17 additions & 0 deletions src/appshell/qml/NotationPage/NotationPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -608,4 +608,21 @@ DockPage {
id: content
}
}

tours: [
{
"eventCode": "project_opened",
"tour": {
"id": "input-by-duration",
"steps": [
{
"title": qsTrc("notation", "Note input modes"),
"description": qsTrc("notation", "Discover different ways to input notes in MuseScore Studio."),
"controlUri": "control://NoteInputSection/NoteInputBar/note-input-by-duration",
"videoExplanationUrl": "https://www.youtube.com/watch?v=OUXf7Y2CPQE&t"
}
]
}
}
]
}
53 changes: 0 additions & 53 deletions src/appshell/resources/tours.json

This file was deleted.

42 changes: 42 additions & 0 deletions src/framework/dockwindow/view/dockpageview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,45 @@ void DockPageView::setDefaultNavigationControl(muse::ui::NavigationControl* cont
muse::ui::INavigationControl* _control = dynamic_cast<muse::ui::INavigationControl*>(control);
navigationController()->setDefaultNavigationControl(_control);
}

QVariant DockPageView::tours() const
{
return m_tours;
}

void DockPageView::setTours(const QVariant& newTours)
{
if (m_tours == newTours) {
return;
}

for (const QVariant& tourVar: newTours.toList()) {
QVariantMap tourMap = tourVar.toMap();

String eventCode = tourMap.value("eventCode").toString();

QVariantMap tourInfoMap = tourMap.value("tour").toMap();

tours::Tour tour;

tour.id = tourInfoMap.value("id").toString();

for (const QVariant& stepVar: tourInfoMap.value("steps").toList()) {
QVariantMap stepMap = stepVar.toMap();

tours::TourStep step;
step.title = stepMap.value("title").toString();
step.description = stepMap.value("description").toString();
step.videoExplanationUrl = stepMap.value("videoExplanationUrl").toString();
step.controlUri = Uri(stepMap.value("controlUri").toString());

tour.steps.emplace_back(step);
}

if (!tour.steps.empty()) {
toursService()->registerTour(eventCode, tour);
}
}

m_tours = newTours;
}
11 changes: 11 additions & 0 deletions src/framework/dockwindow/view/dockpageview.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "modularity/ioc.h"
#include "ui/inavigationcontroller.h"
#include "tours/itoursservice.h"

#include "internal/dockbase.h"
#include "docktypes.h"
Expand Down Expand Up @@ -58,7 +59,10 @@ class DockPageView : public QQuickItem, public muse::Injectable
Q_PROPERTY(muse::dock::DockCentralView * centralDock READ centralDock WRITE setCentralDock NOTIFY centralDockChanged)
Q_PROPERTY(muse::dock::DockStatusBarView * statusBar READ statusBar WRITE setStatusBar NOTIFY statusBarChanged)

Q_PROPERTY(QVariant tours READ tours WRITE setTours CONSTANT)

Inject<ui::INavigationController> navigationController = { this };
Inject<tours::IToursService> toursService = { this };

public:
explicit DockPageView(QQuickItem* parent = nullptr);
Expand Down Expand Up @@ -98,6 +102,9 @@ class DockPageView : public QQuickItem, public muse::Injectable

Q_INVOKABLE void setDefaultNavigationControl(muse::ui::NavigationControl* control);

QVariant tours() const;
void setTours(const QVariant& newTours);

public slots:
void setUri(const QString& uri);
void setCentralDock(DockCentralView* central);
Expand All @@ -110,6 +117,8 @@ public slots:
void centralDockChanged(DockCentralView* central);
void statusBarChanged(DockStatusBarView* statusBar);

void toursChanged();

private:
void componentComplete() override;

Expand All @@ -128,6 +137,8 @@ public slots:
uicomponents::QmlListProperty<DockingHolderView> m_panelsDockingHolders;
DockCentralView* m_central = nullptr;
DockStatusBarView* m_statusBar = nullptr;

QVariant m_tours;
};
}

Expand Down
9 changes: 9 additions & 0 deletions src/framework/tours/internal/toursservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ void ToursService::init()
initTours();
}

void ToursService::registerTour(const String& eventCode, const Tour& tour)
{
if (muse::contains(m_eventsMap, eventCode)) {
return;
}

m_eventsMap.insert({ eventCode, tour });
}

void ToursService::onEvent(const String& eventCode)
{
if (!muse::contains(m_eventsMap, eventCode)) {
Expand Down
2 changes: 2 additions & 0 deletions src/framework/tours/internal/toursservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ToursService : public IToursService, public Injectable, public async::Asyn

void init();

void registerTour(const String& eventCode, const Tour& tour) override;

void onEvent(const String& eventCode) override;

private:
Expand Down
4 changes: 4 additions & 0 deletions src/framework/tours/itoursservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include "modularity/imoduleinterface.h"

#include "tourstypes.h"

namespace muse::tours {
class IToursService : MODULE_EXPORT_INTERFACE
{
Expand All @@ -34,6 +36,8 @@ class IToursService : MODULE_EXPORT_INTERFACE
public:
virtual ~IToursService() = default;

virtual void registerTour(const String& eventCode, const Tour& tour) = 0;

virtual void onEvent(const String& eventCode) = 0;
};
}

0 comments on commit f8b13b9

Please sign in to comment.