Skip to content

Commit deb444d

Browse files
committed
Fix panel context for free parameter selections
1 parent 4da2154 commit deb444d

5 files changed

Lines changed: 69 additions & 10 deletions

File tree

‎src/plugins/audio/internal/addon/EffectsAddOn.cpp‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <transactional/TransactionController.h>
4444

4545
#include <coreplugin/DspxDocument.h>
46+
#include <coreplugin/FreeParameterSelectionModel.h>
4647
#include <coreplugin/ProjectDocumentContext.h>
4748
#include <coreplugin/ProjectWindowInterface.h>
4849

@@ -139,6 +140,11 @@ namespace Audio::Internal {
139140
connect(m_selectionModel->dynamicMixingAnchorSelectionModel(),
140141
&dspx::DynamicMixingAnchorSelectionModel::dynamicMixingAnchorSequenceWithSelectedItemsChanged,
141142
this, &EffectsAddOn::refreshSelection);
143+
auto freeSelection = document->freeParameterSelectionModel();
144+
connect(freeSelection, &Core::FreeParameterSelectionModel::contextChanged,
145+
this, &EffectsAddOn::refreshSelection);
146+
connect(freeSelection, &Core::FreeParameterSelectionModel::activeChanged,
147+
this, &EffectsAddOn::refreshSelection);
142148

143149
auto collection = EffectsUnitCollection::instance();
144150
connect(collection, &EffectsUnitCollection::effectsUnitIdsChanged,
@@ -452,6 +458,16 @@ namespace Audio::Internal {
452458
};
453459

454460
switch (m_selectionModel->selectionType()) {
461+
case dspx::SelectionModel::ST_None: {
462+
auto document = windowHandle()->cast<Core::ProjectWindowInterface>()->projectDocumentContext()->document();
463+
auto freeSelection = document->freeParameterSelectionModel();
464+
if (freeSelection->isActive()) {
465+
auto singingClip = freeSelection->singingClip();
466+
addTrack(trackFromSingingClip(singingClip));
467+
watch(singingClip, &dspx::Clip::clipSequenceChanged);
468+
}
469+
break;
470+
}
455471
case dspx::SelectionModel::ST_Track:
456472
for (auto track : m_selectionModel->trackSelectionModel()->selectedItems()) {
457473
addTrack(track);

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
#include <QAKQuick/quickactioncontext.h>
1212

13+
#include <dspxmodelORM/SingingClip.h>
14+
#include <dspxmodelSelectionModel/SelectionModel.h>
15+
16+
#include <coreplugin/DspxDocument.h>
17+
#include <coreplugin/FreeParameterSelectionModel.h>
18+
#include <coreplugin/ProjectDocumentContext.h>
1319
#include <coreplugin/ProjectWindowInterface.h>
1420

1521
namespace Core::Internal {
@@ -18,6 +24,28 @@ namespace Core::Internal {
1824
PropertiesAddOn::~PropertiesAddOn() = default;
1925
void PropertiesAddOn::initialize() {
2026
auto windowInterface = windowHandle()->cast<ProjectWindowInterface>();
27+
auto document = windowInterface->projectDocumentContext()->document();
28+
auto freeSelection = document->freeParameterSelectionModel();
29+
// Property mapping must not replace the document's active selection context.
30+
m_freeParameterClipSelectionModel = new dspx::SelectionModel(document->model(), this);
31+
const auto updatePropertySelectionModel = [this, document, freeSelection] {
32+
auto singingClip = freeSelection->isActive() ? freeSelection->singingClip() : nullptr;
33+
if (singingClip) {
34+
if (!m_freeParameterClipSelectionModel->isItemSelected(singingClip)) {
35+
m_freeParameterClipSelectionModel->select(singingClip, dspx::SelectionModel::ClearPreviousSelection | dspx::SelectionModel::Select);
36+
}
37+
} else {
38+
m_freeParameterClipSelectionModel->select(nullptr, dspx::SelectionModel::ClearPreviousSelection);
39+
}
40+
auto selectionModel = singingClip ? m_freeParameterClipSelectionModel : document->selectionModel();
41+
if (m_propertySelectionModel != selectionModel) {
42+
m_propertySelectionModel = selectionModel;
43+
Q_EMIT propertySelectionModelChanged();
44+
}
45+
};
46+
connect(freeSelection, &FreeParameterSelectionModel::contextChanged, this, updatePropertySelectionModel);
47+
connect(freeSelection, &FreeParameterSelectionModel::activeChanged, this, updatePropertySelectionModel);
48+
updatePropertySelectionModel();
2149
{
2250
QQmlComponent component(RuntimeInterface::qmlEngine(), "DiffScope.Core", "PropertiesPanel", this);
2351
if (component.isError()) {
@@ -39,6 +67,9 @@ namespace Core::Internal {
3967
bool PropertiesAddOn::delayedInitialize() {
4068
return WindowInterfaceAddOn::delayedInitialize();
4169
}
70+
dspx::SelectionModel *PropertiesAddOn::propertySelectionModel() const {
71+
return m_propertySelectionModel;
72+
}
4273
QList<QQmlComponent *> PropertiesAddOn::getComponents(const QString &id) {
4374
auto list = RuntimeInterface::instance()->getObjects("org.diffscope.core.propertyeditor." + id);
4475
QList<QQmlComponent *> result;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@
88

99
class QQmlComponent;
1010

11+
namespace dspx {
12+
class SelectionModel;
13+
}
14+
1115
namespace Core::Internal {
1216

1317
class PropertiesAddOn : public WindowInterfaceAddOn {
1418
Q_OBJECT
19+
Q_PROPERTY(dspx::SelectionModel *propertySelectionModel READ propertySelectionModel NOTIFY propertySelectionModelChanged)
20+
1521
public:
1622
explicit PropertiesAddOn(QObject *parent = nullptr);
1723
~PropertiesAddOn() override;
@@ -20,9 +26,15 @@ namespace Core::Internal {
2026
void extensionsInitialized() override;
2127
bool delayedInitialize() override;
2228

29+
dspx::SelectionModel *propertySelectionModel() const;
2330
Q_INVOKABLE static QList<QQmlComponent *> getComponents(const QString &id) ;
2431

32+
Q_SIGNALS:
33+
void propertySelectionModelChanged();
34+
2535
private:
36+
dspx::SelectionModel *m_propertySelectionModel{};
37+
dspx::SelectionModel *m_freeParameterClipSelectionModel{};
2638
};
2739

2840
}

‎src/plugins/coreplugin/qml/panels/PropertiesPanel.qml‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,35 +142,35 @@ QtObject {
142142
id: propertyMappers
143143
readonly property QtObject nonePropertyMapper: null
144144
readonly property QtObject anchorNodePropertyMapper: AnchorNodePropertyMapper {
145-
selectionModel: d.addOn?.windowHandle.projectDocumentContext.document.selectionModel ?? null
145+
selectionModel: d.addOn?.propertySelectionModel ?? null
146146
readonly property bool inactive: selectionModel?.selectionType !== 1 || !selectionModel?.selectedCount
147147
}
148148
readonly property QtObject clipPropertyMapper: ClipPropertyMapper {
149-
selectionModel: d.addOn?.windowHandle.projectDocumentContext.document.selectionModel ?? null
149+
selectionModel: d.addOn?.propertySelectionModel ?? null
150150
readonly property bool inactive: ![1, 2, 4, 8].includes(selectionModel?.selectionType) || (selectionModel?.selectionType === 2 && !selectionModel?.selectedCount)
151151
}
152152
readonly property QtObject labelPropertyMapper: LabelPropertyMapper {
153-
selectionModel: d.addOn?.windowHandle.projectDocumentContext.document.selectionModel ?? null
153+
selectionModel: d.addOn?.propertySelectionModel ?? null
154154
readonly property bool inactive: selectionModel?.selectionType !== 3 || !selectionModel?.selectedCount
155155
}
156156
readonly property QtObject notePropertyMapper: NotePropertyMapper {
157-
selectionModel: d.addOn?.windowHandle.projectDocumentContext.document.selectionModel ?? null
157+
selectionModel: d.addOn?.propertySelectionModel ?? null
158158
readonly property bool inactive: selectionModel?.selectionType !== 4 || !selectionModel?.selectedCount
159159
}
160160
readonly property QtObject tempoPropertyMapper: TempoPropertyMapper {
161-
selectionModel: d.addOn?.windowHandle.projectDocumentContext.document.selectionModel ?? null
161+
selectionModel: d.addOn?.propertySelectionModel ?? null
162162
readonly property bool inactive: selectionModel?.selectionType !== 5 || !selectionModel?.selectedCount
163163
}
164164
readonly property QtObject trackPropertyMapper: TrackPropertyMapper {
165-
selectionModel: d.addOn?.windowHandle.projectDocumentContext.document.selectionModel ?? null
165+
selectionModel: d.addOn?.propertySelectionModel ?? null
166166
readonly property bool inactive: ![1, 2, 4, 6, 8].includes(selectionModel?.selectionType) || (selectionModel?.selectionType === 6 && !selectionModel?.selectedCount)
167167
}
168168
readonly property QtObject keySignaturePropertyMapper: KeySignaturePropertyMapper {
169-
selectionModel: d.addOn?.windowHandle.projectDocumentContext.document.selectionModel ?? null
169+
selectionModel: d.addOn?.propertySelectionModel ?? null
170170
readonly property bool inactive: selectionModel?.selectionType !== 7 || !selectionModel?.selectedCount
171171
}
172172
readonly property QtObject dynamicMixingAnchorPropertyMapper: DynamicMixingAnchorPropertyMapper {
173-
selectionModel: d.addOn?.windowHandle.projectDocumentContext.document.selectionModel ?? null
173+
selectionModel: d.addOn?.propertySelectionModel ?? null
174174
readonly property bool inactive: selectionModel?.selectionType !== 8 || !selectionModel?.selectedCount
175175
}
176176
}
@@ -181,7 +181,7 @@ QtObject {
181181
anchors.right: parent.right
182182
anchors.margins: 12
183183
currentIndex: {
184-
let selectionModel = d.addOn?.windowHandle.projectDocumentContext.document.selectionModel
184+
let selectionModel = d.addOn?.propertySelectionModel
185185
if (!selectionModel)
186186
return 0
187187
let t = selectionModel.selectionType

‎src/plugins/coreplugin/qml/propertyeditors/VirtualSingerPropertyEditor.qml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PropertyEditorGroupBox {
2323
required property ProjectWindowInterface windowHandle
2424
required property QtObject propertyMapper
2525

26-
readonly property QtObject selectionModel: windowHandle?.projectDocumentContext.document.selectionModel ?? null
26+
readonly property QtObject selectionModel: propertyMapper?.selectionModel ?? null
2727
readonly property bool multipleClips: selectionModel?.selectionType
2828
=== DspxSelectionModel.SelectionModel.ST_Clip
2929
&& (selectionModel?.selectedCount ?? 0) > 1

0 commit comments

Comments
 (0)