Skip to content

Commit d5acce1

Browse files
authored
Merge pull request #31822 from cbjeukendrup/fix_textstylepopup_init
2 parents 265574f + e80ae81 commit d5acce1

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

src/inspector/qml/MuseScore/Inspector/abstractinspectormodel.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ using MeasurementUnits = CommonTypes::MeasurementUnits;
5151
class AbstractInspectorModel : public QObject, public QQmlParserStatus, public muse::async::Asyncable, public muse::Injectable
5252
{
5353
Q_OBJECT
54-
QML_ELEMENT;
55-
QML_UNCREATABLE("Not creatable as it is abstract base class")
54+
Q_INTERFACES(QQmlParserStatus)
5655

5756
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
5857
Q_PROPERTY(int icon READ icon CONSTANT)
@@ -63,6 +62,9 @@ class AbstractInspectorModel : public QObject, public QQmlParserStatus, public m
6362
Q_PROPERTY(bool isSystemObjectBelowBottomStaff READ isSystemObjectBelowBottomStaff NOTIFY isSystemObjectBelowBottomStaffChanged)
6463
Q_PROPERTY(mu::inspector::CommonTypes::MeasurementUnits measurementUnits READ measurementUnits NOTIFY measurementUnitsChanged)
6564

65+
QML_ELEMENT;
66+
QML_UNCREATABLE("Not creatable as it is abstract base class")
67+
6668
public:
6769
muse::Inject<context::IGlobalContext> context = { this };
6870
muse::Inject<muse::actions::IActionsDispatcher> dispatcher = { this };

src/inspector/qml/MuseScore/Inspector/text/textsettingsmodel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class TextSettingsModel : public AbstractInspectorModel
8282
public:
8383
explicit TextSettingsModel(QObject* parent, IElementRepositoryService* repository, bool isTextLineText);
8484

85+
void classBegin() override;
86+
8587
Q_INVOKABLE void insertSpecialCharacters();
8688
Q_INVOKABLE void showStaffTextProperties();
8789

@@ -165,8 +167,6 @@ public slots:
165167
void rightPositionTextChanged(QString rightPositionText);
166168

167169
private:
168-
void classBegin() override;
169-
170170
bool isTextEditingStarted() const;
171171
muse::async::Notification isTextEditingChanged() const;
172172

src/inspector/qml/MuseScore/Inspector/text/textstylepopup/textstylepopupmodel.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,27 @@ using namespace mu::inspector;
2929

3030
TextStylePopupModel::TextStylePopupModel(QObject* parent)
3131
: AbstractElementPopupModel(PopupModelType::TYPE_TEXT, parent)
32-
3332
, m_elementRepositoryService{std::make_unique<ElementRepositoryService>()}
33+
, m_textSettingsModel(new TextSettingsModel(this, m_elementRepositoryService.get(), /*isTextLineText*/ false))
3434
{
35-
m_textSettingsModel = new TextSettingsModel(this, m_elementRepositoryService.get(), /*isTextLineText*/ false);
36-
m_textSettingsModel->init();
3735
}
3836

3937
TextStylePopupModel::~TextStylePopupModel() = default;
4038

41-
void TextStylePopupModel::init()
39+
void TextStylePopupModel::classBegin()
4240
{
4341
AbstractElementPopupModel::init();
4442

43+
m_textSettingsModel->classBegin();
44+
m_textSettingsModel->init();
45+
4546
m_elementRepositoryService->updateElementList({ m_item }, notation::SelectionState::LIST);
4647
}
4748

49+
void TextStylePopupModel::init()
50+
{
51+
}
52+
4853
TextSettingsModel* TextStylePopupModel::textSettingsModel() const
4954
{
5055
return m_textSettingsModel;

src/inspector/qml/MuseScore/Inspector/text/textstylepopup/textstylepopupmodel.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <memory>
2626

27+
#include <QQmlParserStatus>
2728
#include <qqmlintegration.h>
2829

2930
#include "notationscene/qml/MuseScore/NotationScene/abstractelementpopupmodel.h"
@@ -33,14 +34,16 @@
3334
namespace mu::inspector {
3435
class ElementRepositoryService;
3536

36-
class TextStylePopupModel : public notation::AbstractElementPopupModel
37+
class TextStylePopupModel : public notation::AbstractElementPopupModel, public QQmlParserStatus
3738
{
3839
Q_OBJECT
39-
QML_ELEMENT
40+
Q_INTERFACES(QQmlParserStatus)
4041

41-
Q_PROPERTY(TextSettingsModel* textSettingsModel READ textSettingsModel CONSTANT)
42+
Q_PROPERTY(TextSettingsModel * textSettingsModel READ textSettingsModel CONSTANT)
4243
Q_PROPERTY(bool placeAbove READ placeAbove NOTIFY placeAboveChanged)
4344

45+
QML_ELEMENT
46+
4447
public:
4548
explicit TextStylePopupModel(QObject* parent = nullptr);
4649
~TextStylePopupModel();
@@ -55,12 +58,14 @@ class TextStylePopupModel : public notation::AbstractElementPopupModel
5558
void placeAboveChanged();
5659

5760
private:
61+
void classBegin() override;
62+
void componentComplete() override {}
63+
5864
void updateItemRect() override;
5965
bool ignoreTextEditingChanges() const override { return false; }
6066

61-
TextSettingsModel* m_textSettingsModel = nullptr;
62-
6367
std::unique_ptr<ElementRepositoryService> m_elementRepositoryService;
68+
TextSettingsModel* m_textSettingsModel = nullptr;
6469

6570
bool m_placeAbove = true;
6671
};

0 commit comments

Comments
 (0)