Skip to content

Commit 8585bca

Browse files
committed
Add property editor
1 parent f8f080f commit 8585bca

20 files changed

Lines changed: 1015 additions & 17 deletions

src/libs/application/dspxmodel/src/selectionmodel/SelectionModel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace dspx {
2121
class DSPX_MODEL_EXPORT SelectionModel : public QObject {
2222
Q_OBJECT
2323
QML_ELEMENT
24+
QML_UNCREATABLE("")
2425
Q_DECLARE_PRIVATE(SelectionModel)
2526
Q_PROPERTY(Model *model READ model CONSTANT)
2627
Q_PROPERTY(SelectionType selectionType READ selectionType NOTIFY selectionTypeChanged)

src/plugins/coreplugin/core/CoreInterface.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <coreplugin/OpenSaveProjectFileScenario.h>
4646
#include <coreplugin/ProjectDocumentContext.h>
4747
#include <coreplugin/ProjectWindowInterface.h>
48+
#include <coreplugin/PropertyEditorManager.h>
4849

4950
namespace Core {
5051

@@ -59,12 +60,14 @@ namespace Core {
5960
QQmlEngine *qmlEngine;
6061
QAK::ActionRegistry *actionRegistry;
6162
DspxCheckerRegistry *dspxCheckerRegistry;
63+
PropertyEditorManager *propertyEditorManager;
6264

6365
void init() {
6466
Q_Q(CoreInterface);
6567
qmlEngine = new QQmlEngine(q);
6668
actionRegistry = new QAK::ActionRegistry(q);
6769
dspxCheckerRegistry = new DspxCheckerRegistry(q);
70+
propertyEditorManager = new PropertyEditorManager(q);
6871
}
6972
};
7073

@@ -84,11 +87,16 @@ namespace Core {
8487
return instance()->d_func()->actionRegistry;
8588
}
8689

87-
DspxCheckerRegistry * CoreInterface::dspxCheckerRegistry() {
90+
DspxCheckerRegistry *CoreInterface::dspxCheckerRegistry() {
8891
Q_ASSERT(instance());
8992
return instance()->d_func()->dspxCheckerRegistry;
9093
}
9194

95+
PropertyEditorManager *CoreInterface::propertyEditorManager() {
96+
Q_ASSERT(instance());
97+
return instance()->d_func()->propertyEditorManager;
98+
}
99+
92100
int CoreInterface::execSettingsDialog(const QString &id, QWindow *parent) {
93101
static std::unique_ptr<QWindow> dlg;
94102

src/plugins/coreplugin/core/CoreInterface.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace Core {
2525
class ProjectWindowInterface;
2626
class DspxCheckerRegistry;
2727
class ProjectDocumentContext;
28+
class PropertyEditorManager;
2829

2930
class CoreInterfacePrivate;
3031

@@ -34,6 +35,7 @@ namespace Core {
3435
QML_SINGLETON
3536
Q_DECLARE_PRIVATE(CoreInterface)
3637
Q_PROPERTY(QAK::ActionRegistry *actionRegistry READ actionRegistry CONSTANT)
38+
Q_PROPERTY(PropertyEditorManager *propertyEditorManager READ propertyEditorManager CONSTANT)
3739
public:
3840
static CoreInterface *instance();
3941
static inline CoreInterface *create(QQmlEngine *, QJSEngine *) { return instance(); }
@@ -42,6 +44,8 @@ namespace Core {
4244

4345
static DspxCheckerRegistry *dspxCheckerRegistry();
4446

47+
static PropertyEditorManager *propertyEditorManager();
48+
4549
static constexpr const char *dspxEditorId() {
4650
return "org.diffscope.diffscope";
4751
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#include "PropertyEditorManager.h"
2+
#include "PropertyEditorManager_p.h"
3+
4+
#include <QQmlComponent>
5+
6+
namespace Core {
7+
8+
PropertyEditorManager::PropertyEditorManager(QObject *parent)
9+
: QObject(parent), d_ptr(new PropertyEditorManagerPrivate) {
10+
Q_D(PropertyEditorManager);
11+
d->q_ptr = this;
12+
}
13+
14+
PropertyEditorManager::~PropertyEditorManager() = default;
15+
16+
void PropertyEditorManager::addLabelComponent(QQmlComponent *component) {
17+
Q_D(PropertyEditorManager);
18+
d->labelComponents.append(component);
19+
}
20+
21+
void PropertyEditorManager::addTempoComponent(QQmlComponent *component) {
22+
Q_D(PropertyEditorManager);
23+
d->tempoComponents.append(component);
24+
}
25+
26+
void PropertyEditorManager::addTrackComponent(QQmlComponent *component) {
27+
Q_D(PropertyEditorManager);
28+
d->trackComponents.append(component);
29+
}
30+
31+
void PropertyEditorManager::addClipComponent(QQmlComponent *component) {
32+
Q_D(PropertyEditorManager);
33+
d->clipComponents.append(component);
34+
}
35+
36+
void PropertyEditorManager::addNoteComponent(QQmlComponent *component) {
37+
Q_D(PropertyEditorManager);
38+
d->noteComponents.append(component);
39+
}
40+
41+
void PropertyEditorManager::addAnchorNodeComponent(QQmlComponent *component) {
42+
Q_D(PropertyEditorManager);
43+
d->anchorNodeComponents.append(component);
44+
}
45+
46+
QList<QQmlComponent *> PropertyEditorManager::labelComponents() const {
47+
Q_D(const PropertyEditorManager);
48+
return d->labelComponents;
49+
}
50+
51+
QList<QQmlComponent *> PropertyEditorManager::tempoComponents() const {
52+
Q_D(const PropertyEditorManager);
53+
return d->tempoComponents;
54+
}
55+
56+
QList<QQmlComponent *> PropertyEditorManager::trackComponents() const {
57+
Q_D(const PropertyEditorManager);
58+
return d->trackComponents;
59+
}
60+
61+
QList<QQmlComponent *> PropertyEditorManager::clipComponents() const {
62+
Q_D(const PropertyEditorManager);
63+
return d->clipComponents;
64+
}
65+
66+
QList<QQmlComponent *> PropertyEditorManager::noteComponents() const {
67+
Q_D(const PropertyEditorManager);
68+
return d->noteComponents;
69+
}
70+
71+
QList<QQmlComponent *> PropertyEditorManager::anchorNodeComponents() const {
72+
Q_D(const PropertyEditorManager);
73+
return d->anchorNodeComponents;
74+
}
75+
76+
}
77+
78+
#include "moc_PropertyEditorManager.cpp"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#ifndef DIFFSCOPE_COREPLUGIN_PROPERTYEDITORMANAGER_H
2+
#define DIFFSCOPE_COREPLUGIN_PROPERTYEDITORMANAGER_H
3+
4+
#include <QObject>
5+
#include <qqmlintegration.h>
6+
7+
class QQmlComponent;
8+
9+
namespace Core {
10+
11+
class PropertyEditorManagerPrivate;
12+
13+
class PropertyEditorManager : public QObject {
14+
Q_OBJECT
15+
QML_ELEMENT
16+
QML_UNCREATABLE("")
17+
Q_DECLARE_PRIVATE(PropertyEditorManager)
18+
19+
Q_PROPERTY(QList<QQmlComponent *> labelComponents READ labelComponents CONSTANT)
20+
Q_PROPERTY(QList<QQmlComponent *> tempoComponents READ tempoComponents CONSTANT)
21+
Q_PROPERTY(QList<QQmlComponent *> trackComponents READ trackComponents CONSTANT)
22+
Q_PROPERTY(QList<QQmlComponent *> clipComponents READ clipComponents CONSTANT)
23+
Q_PROPERTY(QList<QQmlComponent *> noteComponents READ noteComponents CONSTANT)
24+
Q_PROPERTY(QList<QQmlComponent *> anchorNodeComponents READ anchorNodeComponents CONSTANT)
25+
26+
public:
27+
explicit PropertyEditorManager(QObject *parent = nullptr);
28+
~PropertyEditorManager() override;
29+
30+
void addLabelComponent(QQmlComponent *component);
31+
void addTempoComponent(QQmlComponent *component);
32+
void addTrackComponent(QQmlComponent *component);
33+
void addClipComponent(QQmlComponent *component);
34+
void addNoteComponent(QQmlComponent *component);
35+
void addAnchorNodeComponent(QQmlComponent *component);
36+
37+
QList<QQmlComponent *> labelComponents() const;
38+
QList<QQmlComponent *> tempoComponents() const;
39+
QList<QQmlComponent *> trackComponents() const;
40+
QList<QQmlComponent *> clipComponents() const;
41+
QList<QQmlComponent *> noteComponents() const;
42+
QList<QQmlComponent *> anchorNodeComponents() const;
43+
44+
private:
45+
QScopedPointer<PropertyEditorManagerPrivate> d_ptr;
46+
};
47+
48+
}
49+
50+
#endif // DIFFSCOPE_COREPLUGIN_PROPERTYEDITORMANAGER_H
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef DIFFSCOPE_COREPLUGIN_PROPERTYEDITORMANAGER_P_H
2+
#define DIFFSCOPE_COREPLUGIN_PROPERTYEDITORMANAGER_P_H
3+
4+
#include "PropertyEditorManager.h"
5+
6+
#include <QList>
7+
8+
class QQmlComponent;
9+
10+
namespace Core {
11+
12+
class PropertyEditorManagerPrivate {
13+
Q_DECLARE_PUBLIC(PropertyEditorManager)
14+
public:
15+
PropertyEditorManager *q_ptr;
16+
17+
QList<QQmlComponent *> labelComponents;
18+
QList<QQmlComponent *> tempoComponents;
19+
QList<QQmlComponent *> trackComponents;
20+
QList<QQmlComponent *> clipComponents;
21+
QList<QQmlComponent *> noteComponents;
22+
QList<QQmlComponent *> anchorNodeComponents;
23+
};
24+
25+
}
26+
27+
#endif // DIFFSCOPE_COREPLUGIN_PROPERTYEDITORMANAGER_P_H

src/plugins/coreplugin/internal/CorePlugin.cpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,41 +28,43 @@
2828

2929
#include <QAKCore/actionregistry.h>
3030

31-
#include <SVSCraftQuick/Theme.h>
3231
#include <SVSCraftQuick/MessageBox.h>
32+
#include <SVSCraftQuick/Theme.h>
3333

3434
#include <loadapi/initroutine.h>
3535

3636
#include <coreplugin/CoreInterface.h>
37+
#include <coreplugin/DspxClipboard.h>
3738
#include <coreplugin/HomeWindowInterface.h>
39+
#include <coreplugin/ProjectWindowInterface.h>
3840
#include <coreplugin/internal/AfterSavingNotifyAddOn.h>
3941
#include <coreplugin/internal/AppearancePage.h>
4042
#include <coreplugin/internal/BehaviorPreference.h>
43+
#include <coreplugin/internal/CloseSaveCheckAddOn.h>
4144
#include <coreplugin/internal/ColorSchemeCollection.h>
4245
#include <coreplugin/internal/ColorSchemePage.h>
4346
#include <coreplugin/internal/EditActionsAddOn.h>
4447
#include <coreplugin/internal/FileBackupPage.h>
4548
#include <coreplugin/internal/FindActionsAddOn.h>
4649
#include <coreplugin/internal/GeneralPage.h>
47-
#include <coreplugin/internal/InsertItemAddOn.h>
4850
#include <coreplugin/internal/HomeAddOn.h>
51+
#include <coreplugin/internal/InsertItemAddOn.h>
4952
#include <coreplugin/internal/KeymapPage.h>
5053
#include <coreplugin/internal/LogPage.h>
5154
#include <coreplugin/internal/MenuPage.h>
5255
#include <coreplugin/internal/MetadataAddOn.h>
5356
#include <coreplugin/internal/NotificationAddOn.h>
57+
#include <coreplugin/internal/PlatformJumpListHelper.h>
5458
#include <coreplugin/internal/ProjectStartupTimerAddOn.h>
5559
#include <coreplugin/internal/ProjectWindowNavigatorAddOn.h>
60+
#include <coreplugin/internal/PropertiesAddOn.h>
5661
#include <coreplugin/internal/RecentFileAddOn.h>
5762
#include <coreplugin/internal/TimeIndicatorPage.h>
5863
#include <coreplugin/internal/TimelineAddOn.h>
5964
#include <coreplugin/internal/UndoAddOn.h>
6065
#include <coreplugin/internal/ViewVisibilityAddOn.h>
6166
#include <coreplugin/internal/WorkspaceAddOn.h>
62-
#include <coreplugin/ProjectWindowInterface.h>
63-
#include <coreplugin/internal/CloseSaveCheckAddOn.h>
64-
#include <coreplugin/internal/PlatformJumpListHelper.h>
65-
#include <coreplugin/DspxClipboard.h>
67+
#include <coreplugin/PropertyEditorManager.h>
6668

6769
static auto getCoreActionExtension() {
6870
return QAK_STATIC_ACTION_EXTENSION(coreplugin);
@@ -188,6 +190,7 @@ namespace Core::Internal {
188190
initializeColorScheme();
189191
initializeJumpList();
190192
initializeHelpContents();
193+
initializePropertyEditors();
191194

192195
QApplication::setQuitOnLastWindowClosed(false);
193196

@@ -252,7 +255,7 @@ namespace Core::Internal {
252255
CoreInterface::actionRegistry()->addIconManifest(":/diffscope/coreplugin/icons/config.json");
253256
}
254257

255-
void CorePlugin::initializeSettings() const {
258+
void CorePlugin::initializeSettings() {
256259
GeneralPage::setCorePluginTranslationsPath(pluginSpec()->location() + QStringLiteral("/translations"));
257260
auto sc = CoreInterface::settingCatalog();
258261
auto generalPage = new GeneralPage;
@@ -286,6 +289,7 @@ namespace Core::Internal {
286289
ProjectWindowInterfaceRegistry::instance()->attach<ProjectWindowNavigatorAddOn>();
287290
ProjectWindowInterfaceRegistry::instance()->attach<AfterSavingNotifyAddOn>();
288291
ProjectWindowInterfaceRegistry::instance()->attach<CloseSaveCheckAddOn>();
292+
ProjectWindowInterfaceRegistry::instance()->attach<PropertiesAddOn>();
289293

290294
auto windowSystem = CoreInterface::windowSystem();
291295
connect(windowSystem, &WindowSystem::windowAboutToDestroy, this, [](WindowInterface *windowInterface) {
@@ -374,6 +378,29 @@ namespace Core::Internal {
374378
}
375379
}
376380

381+
void CorePlugin::initializePropertyEditors() {
382+
auto labelPropertyEditorComponent = new QQmlComponent(RuntimeInterface::qmlEngine(), "DiffScope.Core", "LabelPropertyEditor", this);
383+
if (labelPropertyEditorComponent->isError()) {
384+
qFatal() << labelPropertyEditorComponent->errorString();
385+
}
386+
CoreInterface::propertyEditorManager()->addLabelComponent(labelPropertyEditorComponent);
387+
auto tempoPropertyEditorComponent = new QQmlComponent(RuntimeInterface::qmlEngine(), "DiffScope.Core", "TempoPropertyEditor", this);
388+
if (tempoPropertyEditorComponent->isError()) {
389+
qFatal() << tempoPropertyEditorComponent->errorString();
390+
}
391+
CoreInterface::propertyEditorManager()->addTempoComponent(tempoPropertyEditorComponent);
392+
auto trackPropertyEditorComponent = new QQmlComponent(RuntimeInterface::qmlEngine(), "DiffScope.Core", "TrackPropertyEditor", this);
393+
if (trackPropertyEditorComponent->isError()) {
394+
qFatal() << trackPropertyEditorComponent->errorString();
395+
}
396+
CoreInterface::propertyEditorManager()->addTrackComponent(trackPropertyEditorComponent);
397+
auto trackControlPropertyEditorComponent = new QQmlComponent(RuntimeInterface::qmlEngine(), "DiffScope.Core", "ControlPropertyEditor", this);
398+
if (trackControlPropertyEditorComponent->isError()) {
399+
qFatal() << trackControlPropertyEditorComponent->errorString();
400+
}
401+
CoreInterface::propertyEditorManager()->addTrackComponent(trackControlPropertyEditorComponent);
402+
}
403+
377404
void CorePlugin::checkLastRun() {
378405
auto settings = RuntimeInterface::settings();
379406
settings->setValue("lastInitializationAbortedFlag", false);

src/plugins/coreplugin/internal/CorePlugin.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ namespace Core::Internal {
2323

2424
private:
2525
void initializeSingletons();
26-
static void initializeActions();
27-
void initializeSettings() const;
26+
void initializeActions();
27+
void initializeSettings();
2828
void initializeWindows();
29-
static void initializeBehaviorPreference();
30-
static void initializeColorScheme();
31-
static void initializeJumpList();
29+
void initializeBehaviorPreference();
30+
void initializeColorScheme();
31+
void initializeJumpList();
3232
void initializeHelpContents();
33+
void initializePropertyEditors();
3334

3435
static void checkLastRun();
3536
static void checkPlugins();
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include "PropertiesAddOn.h"
2+
3+
#include <QQmlComponent>
4+
#include <QQmlEngine>
5+
6+
#include <CoreApi/runtimeinterface.h>
7+
8+
#include <QAKQuick/quickactioncontext.h>
9+
10+
#include <coreplugin/ProjectWindowInterface.h>
11+
12+
namespace Core::Internal {
13+
PropertiesAddOn::PropertiesAddOn(QObject *parent) {
14+
}
15+
PropertiesAddOn::~PropertiesAddOn() = default;
16+
void PropertiesAddOn::initialize() {
17+
auto windowInterface = windowHandle()->cast<ProjectWindowInterface>();
18+
{
19+
QQmlComponent component(RuntimeInterface::qmlEngine(), "DiffScope.Core", "PropertiesPanel", this);
20+
if (component.isError()) {
21+
qFatal() << component.errorString();
22+
}
23+
auto o = component.createWithInitialProperties({
24+
{"addOn", QVariant::fromValue(this)},
25+
},
26+
RuntimeInterface::qmlEngine()->rootContext());
27+
o->setParent(this);
28+
windowInterface->actionContext()->addAction("org.diffscope.core.panel.properties", o->property("propertiesPanelComponent").value<QQmlComponent *>());
29+
}
30+
}
31+
void PropertiesAddOn::extensionsInitialized() {
32+
}
33+
bool PropertiesAddOn::delayedInitialize() {
34+
return WindowInterfaceAddOn::delayedInitialize();
35+
}
36+
}
37+
38+
#include "moc_PropertiesAddOn.cpp"

0 commit comments

Comments
 (0)