Skip to content

Commit 84e5ed0

Browse files
committed
Refactor property editor management
1 parent b48a998 commit 84e5ed0

9 files changed

Lines changed: 44 additions & 225 deletions

File tree

src/plugins/coreplugin/core/CoreInterface.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
#include <coreplugin/OpenSaveProjectFileScenario.h>
4848
#include <coreplugin/ProjectDocumentContext.h>
4949
#include <coreplugin/ProjectWindowInterface.h>
50-
#include <coreplugin/PropertyEditorManager.h>
5150
#include <coreplugin/TrackColorSchema.h>
5251
#include <coreplugin/DefaultLyricManager.h>
5352

@@ -64,7 +63,6 @@ namespace Core {
6463
QQmlEngine *qmlEngine;
6564
QAK::ActionRegistry *actionRegistry;
6665
DspxCheckerRegistry *dspxCheckerRegistry;
67-
PropertyEditorManager *propertyEditorManager;
6866
TrackColorSchema *trackColorSchema;
6967
DefaultLyricManager *defaultLyricManager;
7068

@@ -73,7 +71,6 @@ namespace Core {
7371
qmlEngine = new QQmlEngine(q);
7472
actionRegistry = new QAK::ActionRegistry(q);
7573
dspxCheckerRegistry = new DspxCheckerRegistry(q);
76-
propertyEditorManager = new PropertyEditorManager(q);
7774
trackColorSchema = new TrackColorSchema(q);
7875
defaultLyricManager = new DefaultLyricManager(q);
7976
}
@@ -100,11 +97,6 @@ namespace Core {
10097
return instance()->d_func()->dspxCheckerRegistry;
10198
}
10299

103-
PropertyEditorManager *CoreInterface::propertyEditorManager() {
104-
Q_ASSERT(instance());
105-
return instance()->d_func()->propertyEditorManager;
106-
}
107-
108100
TrackColorSchema *CoreInterface::trackColorSchema() {
109101
Q_ASSERT(instance());
110102
return instance()->d_func()->trackColorSchema;

src/plugins/coreplugin/core/CoreInterface.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ namespace Core {
3737
QML_SINGLETON
3838
Q_DECLARE_PRIVATE(CoreInterface)
3939
Q_PROPERTY(QAK::ActionRegistry *actionRegistry READ actionRegistry CONSTANT)
40-
Q_PROPERTY(PropertyEditorManager *propertyEditorManager READ propertyEditorManager CONSTANT)
4140
Q_PROPERTY(TrackColorSchema *trackColorSchema READ trackColorSchema CONSTANT)
4241
Q_PROPERTY(DefaultLyricManager *defaultLyricManager READ defaultLyricManager CONSTANT)
4342
public:
@@ -48,8 +47,6 @@ namespace Core {
4847

4948
static DspxCheckerRegistry *dspxCheckerRegistry();
5049

51-
static PropertyEditorManager *propertyEditorManager();
52-
5350
static TrackColorSchema *trackColorSchema();
5451

5552
static DefaultLyricManager *defaultLyricManager();

src/plugins/coreplugin/core/PropertyEditorManager.cpp

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/plugins/coreplugin/core/PropertyEditorManager.h

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/plugins/coreplugin/core/PropertyEditorManager_p.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/plugins/coreplugin/internal/CorePlugin.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
#include <coreplugin/internal/UndoAddOn.h>
6464
#include <coreplugin/internal/ViewVisibilityAddOn.h>
6565
#include <coreplugin/internal/WorkspaceAddOn.h>
66-
#include <coreplugin/PropertyEditorManager.h>
6766

6867
static auto getCoreActionExtension() {
6968
return QAK_STATIC_ACTION_EXTENSION(coreplugin);
@@ -377,38 +376,38 @@ namespace Core::Internal {
377376
}
378377

379378
void CorePlugin::initializePropertyEditors() {
380-
const auto f = [=, this](const QString &typeName, void(PropertyEditorManager::*addMethod)(QQmlComponent *)) {
379+
const auto f = [=, this](const QString &typeName, const QString &id) {
381380
auto component = new QQmlComponent(RuntimeInterface::qmlEngine(), "DiffScope.Core", typeName, this);
382381
if (component->isError()) {
383382
qFatal() << component->errorString();
384383
}
385-
(CoreInterface::propertyEditorManager()->*addMethod)(component);
384+
RuntimeInterface::instance()->addObject(id, component);
386385
};
387-
f("MetadataPropertyEditor", &PropertyEditorManager::addNoneComponent);
388-
f("MasterControlPropertyEditor", &PropertyEditorManager::addNoneComponent);
389-
f("LoopPropertyEditor", &PropertyEditorManager::addNoneComponent);
386+
f("MetadataPropertyEditor", "org.diffscope.core.propertyeditor.document");
387+
f("MasterControlPropertyEditor", "org.diffscope.core.propertyeditor.document");
388+
f("LoopPropertyEditor", "org.diffscope.core.propertyeditor.document");
390389

391-
f("ClipPropertyEditor", &PropertyEditorManager::addClipComponent);
392-
f("AudioPropertyEditor", &PropertyEditorManager::addClipComponent);
393-
f("VirtualSingerPropertyEditor", &PropertyEditorManager::addClipComponent);
394-
f("ControlPropertyEditor", &PropertyEditorManager::addClipComponent);
395-
f("ClipTimePropertyEditor", &PropertyEditorManager::addClipComponent);
390+
f("ClipPropertyEditor", "org.diffscope.core.propertyeditor.clip");
391+
f("AudioPropertyEditor", "org.diffscope.core.propertyeditor.clip");
392+
f("VirtualSingerPropertyEditor", "org.diffscope.core.propertyeditor.clip");
393+
f("ControlPropertyEditor", "org.diffscope.core.propertyeditor.clip");
394+
f("ClipTimePropertyEditor", "org.diffscope.core.propertyeditor.clip");
396395

397-
f("LabelPropertyEditor", &PropertyEditorManager::addLabelComponent);
396+
f("LabelPropertyEditor", "org.diffscope.core.propertyeditor.label");
398397

399-
f("NotePropertyEditor", &PropertyEditorManager::addNoteComponent);
400-
f("NoteLyricPropertyEditor", &PropertyEditorManager::addNoteComponent);
401-
f("NotePitchPropertyEditor", &PropertyEditorManager::addNoteComponent);
402-
f("NoteTimePropertyEditor", &PropertyEditorManager::addNoteComponent);
403-
f("NotePhonemePropertyEditor", &PropertyEditorManager::addNoteComponent);
398+
f("NotePropertyEditor", "org.diffscope.core.propertyeditor.note");
399+
f("NoteLyricPropertyEditor", "org.diffscope.core.propertyeditor.note");
400+
f("NotePitchPropertyEditor", "org.diffscope.core.propertyeditor.note");
401+
f("NoteTimePropertyEditor", "org.diffscope.core.propertyeditor.note");
402+
f("NotePhonemePropertyEditor", "org.diffscope.core.propertyeditor.note");
404403

405-
f("TempoPropertyEditor", &PropertyEditorManager::addTempoComponent);
404+
f("TempoPropertyEditor", "org.diffscope.core.propertyeditor.tempo");
406405

407-
f("TrackPropertyEditor", &PropertyEditorManager::addTrackComponent);
408-
f("ControlPropertyEditor", &PropertyEditorManager::addTrackComponent);
409-
f("TrackDisplayPropertyEditor", &PropertyEditorManager::addTrackComponent);
406+
f("TrackPropertyEditor", "org.diffscope.core.propertyeditor.track");
407+
f("ControlPropertyEditor", "org.diffscope.core.propertyeditor.track");
408+
f("TrackDisplayPropertyEditor", "org.diffscope.core.propertyeditor.track");
410409

411-
f("KeySignaturePropertyEditor", &PropertyEditorManager::addKeySignatureComponent);
410+
f("KeySignaturePropertyEditor", "org.diffscope.core.propertyeditor.keysignature");
412411

413412
}
414413

src/plugins/coreplugin/internal/addon/PropertiesAddOn.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ namespace Core::Internal {
3333
bool PropertiesAddOn::delayedInitialize() {
3434
return WindowInterfaceAddOn::delayedInitialize();
3535
}
36+
QList<QQmlComponent *> PropertiesAddOn::getComponents(const QString &id) {
37+
auto list = RuntimeInterface::instance()->getObjects("org.diffscope.core.propertyeditor." + id);
38+
QList<QQmlComponent *> result;
39+
for (auto obj : list) {
40+
if (auto component = qobject_cast<QQmlComponent *>(obj)) {
41+
result.append(component);
42+
}
43+
}
44+
return result;
45+
}
3646
}
3747

3848
#include "moc_PropertiesAddOn.cpp"

src/plugins/coreplugin/internal/addon/PropertiesAddOn.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include <CoreApi/windowinterface.h>
55

6+
class QQmlComponent;
7+
68
namespace Core::Internal {
79

810
class PropertiesAddOn : public WindowInterfaceAddOn {
@@ -15,6 +17,8 @@ namespace Core::Internal {
1517
void extensionsInitialized() override;
1618
bool delayedInitialize() override;
1719

20+
Q_INVOKABLE static QList<QQmlComponent *> getComponents(const QString &id) ;
21+
1822
private:
1923
};
2024

0 commit comments

Comments
 (0)