-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #283179 add back some objects and properties to plugin framework
- Loading branch information
Showing
10 changed files
with
207 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//============================================================================= | ||
// MuseScore | ||
// Music Composition & Notation | ||
// | ||
// Copyright (C) 2019 Werner Schweer and others | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2 | ||
// as published by the Free Software Foundation and appearing in | ||
// the file LICENCE.GPL | ||
//============================================================================= | ||
|
||
#include "excerpt.h" | ||
#include "score.h" | ||
#include "libmscore/score.h" | ||
|
||
namespace Ms { | ||
namespace PluginAPI { | ||
|
||
//--------------------------------------------------------- | ||
// Excerpt::partScore | ||
//--------------------------------------------------------- | ||
|
||
Score* Excerpt::partScore() | ||
{ | ||
return wrap<Score>(e->partScore(), Ownership::SCORE); | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// wrap | ||
//--------------------------------------------------------- | ||
|
||
Excerpt* excerptWrap(Ms::Excerpt* e) | ||
{ | ||
return excerptWrap<Excerpt>(e); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
//============================================================================= | ||
// MuseScore | ||
// Music Composition & Notation | ||
// | ||
// Copyright (C) 2019 Werner Schweer and others | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2 | ||
// as published by the Free Software Foundation and appearing in | ||
// the file LICENCE.GPL | ||
//============================================================================= | ||
|
||
#ifndef __PLUGIN_API_EXCERPT_H__ | ||
#define __PLUGIN_API_EXCERPT_H__ | ||
|
||
#include "libmscore/excerpt.h" | ||
|
||
namespace Ms { | ||
|
||
namespace PluginAPI { | ||
|
||
class Score; | ||
|
||
//--------------------------------------------------------- | ||
// Excerpt | ||
// Wrapper class for Excerpt | ||
// | ||
// This is based on the wrapper in scoreelement.h, which | ||
// we cannot use here, because Ms::Excerpt is not derived | ||
// from Ms::ScoreElement. | ||
// Since a plugin should never need to create an Excerpt | ||
// instance by itself, we don't care for Ownership here. | ||
//--------------------------------------------------------- | ||
|
||
class Excerpt : public QObject { | ||
Q_OBJECT | ||
Q_PROPERTY(Ms::PluginAPI::Score* partScore READ partScore) | ||
Q_PROPERTY(QString title READ title) | ||
|
||
protected: | ||
Ms::Excerpt* const e; | ||
|
||
public: | ||
Excerpt(Ms::Excerpt* _e = nullptr) | ||
: QObject(), e(_e) {} | ||
Excerpt(const Excerpt&) = delete; | ||
Excerpt& operator=(const Excerpt&) = delete; | ||
virtual ~Excerpt() {}; | ||
|
||
Score* partScore(); | ||
QString title() { return e->title(); } | ||
}; | ||
|
||
//--------------------------------------------------------- | ||
// wrap | ||
//--------------------------------------------------------- | ||
template <class Wrapper, class T> | ||
Wrapper* excerptWrap(T* t) | ||
{ | ||
Wrapper* w = t ? new Wrapper(t) : nullptr; | ||
// All wrapper objects should belong to JavaScript code. | ||
QQmlEngine::setObjectOwnership(w, QQmlEngine::JavaScriptOwnership); | ||
return w; | ||
} | ||
|
||
extern Excerpt* excerptWrap(Ms::Excerpt* e); | ||
|
||
//--------------------------------------------------------- | ||
// qml access to containers of Excerpt | ||
// | ||
// QmlExcerptsListAccess provides a convenience interface | ||
// for QQmlListProperty providing read-only access to | ||
// plugins for Excerpts containers. | ||
// | ||
// based on QmlListAccess in scoreelement.h | ||
//--------------------------------------------------------- | ||
|
||
template <typename T, class Container> | ||
class QmlExcerptsListAccess : public QQmlListProperty<T> { | ||
public: | ||
QmlExcerptsListAccess(QObject* obj, Container& container) | ||
: QQmlListProperty<T>(obj, &container, &count, &at) {}; | ||
|
||
static int count(QQmlListProperty<T>* l) { return int(static_cast<Container*>(l->data)->size()); } | ||
static T* at(QQmlListProperty<T>* l, int i) { return excerptWrap<T>(static_cast<Container*>(l->data)->at(i)); } | ||
}; | ||
|
||
template<typename T, class Container> | ||
QmlExcerptsListAccess<T, Container> wrapExcerptsContainerProperty(QObject* obj, Container& c) | ||
{ | ||
return QmlExcerptsListAccess<T, Container>(obj, c); | ||
} | ||
|
||
} // namespace PluginAPI | ||
} // namespace Ms | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//============================================================================= | ||
// MuseScore | ||
// Music Composition & Notation | ||
// | ||
// Copyright (C) 2019 Werner Schweer and others | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2 | ||
// as published by the Free Software Foundation and appearing in | ||
// the file LICENCE.GPL | ||
//============================================================================= | ||
|
||
#ifndef __PLUGIN_API_PART_H__ | ||
#define __PLUGIN_API_PART_H__ | ||
|
||
#include "scoreelement.h" | ||
#include "libmscore/part.h" | ||
|
||
namespace Ms { | ||
namespace PluginAPI { | ||
|
||
//--------------------------------------------------------- | ||
// Part | ||
//--------------------------------------------------------- | ||
|
||
class Part : public Ms::PluginAPI::ScoreElement { | ||
Q_OBJECT | ||
Q_PROPERTY(int startTrack READ startTrack) | ||
Q_PROPERTY(int endTrack READ endTrack) | ||
|
||
public: | ||
Part(Ms::Part* p = nullptr, Ownership o = Ownership::SCORE) | ||
: ScoreElement(p, o) {} | ||
|
||
Ms::Part* part() { return toPart(e); } | ||
const Ms::Part* part() const { return toPart(e); } | ||
|
||
int startTrack() const { return part()->startTrack(); } | ||
int endTrack() const { return part()->endTrack(); } | ||
}; | ||
} // namespace PluginAPI | ||
} // namespace Ms | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters