Fixed auto reordering panels for mixer

This commit is contained in:
Eism 2023-05-02 12:37:38 +03:00
parent d7e80082d2
commit 527fd0e9bf
12 changed files with 103 additions and 25 deletions

View file

@ -363,7 +363,11 @@ DockPage {
dropDestinations: root.horizontalPanelDropDestinations
navigationSection: root.navigationPanelSec(pianoKeyboardPanel.location)
PianoKeyboardPanel {
navigationSection: pianoKeyboardPanel.navigationSection
Component.onCompleted: {
pianoKeyboardPanel.contextMenuModel = contextMenuModel
}
@ -389,7 +393,11 @@ DockPage {
dropDestinations: root.horizontalPanelDropDestinations
Timeline {}
navigationSection: root.navigationPanelSec(timelinePanel.location)
Timeline {
navigationSection: timelinePanel.navigationSection
}
},
DockPanel {
@ -410,7 +418,11 @@ DockPage {
location: Location.Bottom
DrumsetPanel {}
navigationSection: root.navigationPanelSec(drumsetPanel.location)
DrumsetPanel {
navigationSection: timelinePanel.navigationSection
}
}
]

View file

@ -64,11 +64,11 @@ DockPage {
contentBottomPadding: 2
NotationToolBar {
navigation.section: root.topToolKeyNavSec
navigation.order: 2
navigationPanel.section: root.topToolKeyNavSec
navigationPanel.order: 2
onActiveFocusRequested: {
if (navigation.active) {
if (navigationPanel.active) {
notationToolBar.forceActiveFocus()
}
}
@ -86,8 +86,8 @@ DockPage {
contentBottomPadding: 2
PlaybackToolBar {
navigation.section: root.topToolKeyNavSec
navigation.order: 3
navigationPanel.section: root.topToolKeyNavSec
navigationPanel.order: 3
floating: playbackToolBar.floating
}
@ -108,8 +108,8 @@ DockPage {
contentBottomPadding: 2
UndoRedoToolBar {
navigation.section: root.topToolKeyNavSec
navigation.order: 4
navigationPanel.section: root.topToolKeyNavSec
navigationPanel.order: 4
}
}
]

View file

@ -45,7 +45,8 @@ DockPageView {
centralDock: DockCentralView {
objectName: root.objectName + "_central"
contentNavigationPanel: Boolean(central.item) ? central.item.navigationPanel : null
contentNavigationPanel: Boolean(central.item) && Boolean(central.item.navigationPanel) ?
central.item.navigationPanel : null
Loader {
id: central

View file

@ -28,7 +28,8 @@ DockPanelView {
default property alias contentComponent : contentLoader.sourceComponent
contentNavigationPanel: Boolean(contentLoader.item) ? contentLoader.item.navigationPanel : null
contentNavigationPanel: Boolean(contentLoader.item) && Boolean(contentLoader.item.navigationPanel) ?
contentLoader.item.navigationPanel : null
Loader {
id: contentLoader

View file

@ -41,7 +41,8 @@ DockToolBarView {
minimumWidth: root.inited ? Math.min(root.contentWidth, root.maximumWidth) : prv.minimumLength
minimumHeight: root.inited ? Math.min(root.contentHeight, root.maximumHeight) : prv.minimumLength
contentNavigationPanel: Boolean(contentLoader.item) ? contentLoader.item.navigationPanel : null
contentNavigationPanel: Boolean(contentLoader.item) && Boolean(contentLoader.item.navigationPanel) ?
contentLoader.item.navigationPanel : null
onFloatingChanged: {
if (!root.floating) {

View file

@ -29,7 +29,14 @@ Item {
id: root
property alias contextMenuModel: contextMenuModel
property NavigationPanel navigationPanel: null
property NavigationSection navigationSection: null
property NavigationPanel navigationPanel: NavigationPanel {
name: "PianoKeyboardSection"
section: root.navigationSection
direction: NavigationPanel.Vertical
enabled: root.enabled && root.visible
}
PianoKeyboardPanelContextMenuModel {
id: contextMenuModel

View file

@ -31,7 +31,6 @@ Item {
enabled: selectionFilterModel.enabled
property NavigationSection navigationSection: null
property NavigationPanel navigationPanel: NavigationPanel {
name: "SelectionFilter"
section: root.navigationSection

View file

@ -26,7 +26,15 @@ import MuseScore.Ui 1.0
import MuseScore.NotationScene 1.0
Item {
property NavigationPanel navigationPanel: null // first panel
id: root
property NavigationSection navigationSection: null
property NavigationPanel navigationPanel: NavigationPanel {
name: "TimelineSection"
section: root.navigationSection
direction: NavigationPanel.Vertical
enabled: root.enabled && root.visible
}
TimelineView {
anchors.fill: parent

View file

@ -27,7 +27,15 @@ import MuseScore.UiComponents 1.0
import MuseScore.Palette 1.0
Item {
property NavigationPanel navigationPanel: null // first panel
id: root
property NavigationSection navigationSection: null
property NavigationPanel navigationPanel: NavigationPanel {
name: "DrumsetSection"
section: root.navigationSection
direction: NavigationPanel.Vertical
enabled: root.enabled && root.visible
}
RowLayout {
anchors.fill: parent

View file

@ -36,6 +36,7 @@ ColumnLayout {
property alias contextMenuModel: contextMenuModel
property NavigationSection navigationSection: null
property NavigationPanel navigationPanel: mixerPanelModel.count > 0 ? mixerPanelModel.get(0).channelItem.panel : null // first panel
signal resizeRequested(var newWidth, var newHeight)
@ -70,8 +71,10 @@ ColumnLayout {
MixerPanelModel {
id: mixerPanelModel
navigationSection: root.navigationSection
Component.onCompleted: {
mixerPanelModel.load(root.navigationSection)
mixerPanelModel.load()
}
onModelReset: {

View file

@ -39,11 +39,11 @@ MixerPanelModel::MixerPanelModel(QObject* parent)
: QAbstractListModel(parent)
{
controller()->currentTrackSequenceIdChanged().onNotify(this, [this]() {
load(QVariant::fromValue(m_itemsNavigationSection));
load();
});
}
void MixerPanelModel::load(const QVariant& navigationSection)
void MixerPanelModel::load()
{
TRACEFUNC;
@ -53,7 +53,6 @@ void MixerPanelModel::load(const QVariant& navigationSection)
return;
}
m_itemsNavigationSection = navigationSection.value<ui::NavigationSection*>();
m_currentTrackSequenceId = sequenceId;
controller()->trackAdded().onReceive(this, [this](const TrackId trackId) {
@ -217,8 +216,25 @@ void MixerPanelModel::updateItemsPanelsOrder()
{
TRACEFUNC;
ui::NavigationPanel* previousPanel = nullptr;
for (MixerChannelItem* item : m_mixerChannelList) {
disconnect(item->panel(), &ui::NavigationPanel::orderChanged, this, nullptr);
}
for (int i = 0; i < m_mixerChannelList.size(); i++) {
m_mixerChannelList[i]->setPanelOrder(i);
if (previousPanel) {
disconnect(previousPanel, &ui::NavigationPanel::orderChanged, this, nullptr);
connect(previousPanel, &ui::NavigationPanel::orderChanged, this, [this, i](int order){
if (i < m_mixerChannelList.count()) {
m_mixerChannelList[i]->setPanelOrder(order + 1);
}
});
}
previousPanel = m_mixerChannelList[i]->panel();
}
}
@ -358,7 +374,7 @@ MixerChannelItem* MixerPanelModel::buildInstrumentChannelItem(const audio::Track
MixerChannelItem* item = new MixerChannelItem(this, type, false /*outputOnly*/, trackId);
item->setInstrumentTrackId(instrumentTrackId);
item->setPanelSection(m_itemsNavigationSection);
item->setPanelSection(m_navigationSection);
item->loadSoloMuteState(audioSettings()->soloMuteState(instrumentTrackId));
playback()->tracks()->inputParams(m_currentTrackSequenceId, trackId)
@ -431,7 +447,7 @@ MixerChannelItem* MixerPanelModel::buildInstrumentChannelItem(const audio::Track
MixerChannelItem* MixerPanelModel::buildAuxChannelItem(const TrackId trackId)
{
MixerChannelItem* item = new MixerChannelItem(this, MixerChannelItem::Type::Aux, true /*outputOnly*/, trackId);
item->setPanelSection(m_itemsNavigationSection);
item->setPanelSection(m_navigationSection);
playback()->tracks()->trackName(m_currentTrackSequenceId, trackId)
.onResolve(this, [this, trackId](const TrackName& trackName) {
@ -476,7 +492,7 @@ MixerChannelItem* MixerPanelModel::buildAuxChannelItem(const TrackId trackId)
MixerChannelItem* MixerPanelModel::buildMasterChannelItem()
{
MixerChannelItem* item = new MixerChannelItem(this, MixerChannelItem::Type::Master, true /*outputOnly*/);
item->setPanelSection(m_itemsNavigationSection);
item->setPanelSection(m_navigationSection);
item->setTitle(qtrc("playback", "Master"));
playback()->audioOutput()->masterOutputParams()
@ -563,3 +579,18 @@ INotationPartsPtr MixerPanelModel::masterNotationParts() const
{
return currentProject() ? currentProject()->masterNotation()->parts() : nullptr;
}
mu::ui::NavigationSection* MixerPanelModel::navigationSection() const
{
return m_navigationSection;
}
void MixerPanelModel::setNavigationSection(ui::NavigationSection* navigationSection)
{
if (m_navigationSection == navigationSection) {
return;
}
m_navigationSection = navigationSection;
emit navigationSectionChanged();
}

View file

@ -45,19 +45,26 @@ class MixerPanelModel : public QAbstractListModel, public async::Asyncable
INJECT(IPlaybackController, controller)
INJECT(context::IGlobalContext, context)
Q_PROPERTY(
mu::ui::NavigationSection * navigationSection READ navigationSection WRITE setNavigationSection NOTIFY navigationSectionChanged)
Q_PROPERTY(int count READ rowCount NOTIFY rowCountChanged)
public:
explicit MixerPanelModel(QObject* parent = nullptr);
Q_INVOKABLE void load(const QVariant& navigationSection);
Q_INVOKABLE void load();
Q_INVOKABLE QVariantMap get(int index);
QVariant data(const QModelIndex& index, int role) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QHash<int, QByteArray> roleNames() const override;
ui::NavigationSection* navigationSection() const;
void setNavigationSection(ui::NavigationSection* navigationSection);
signals:
void navigationSectionChanged();
void rowCountChanged();
private:
@ -94,7 +101,7 @@ private:
MixerChannelItem* m_masterChannelItem = nullptr;
audio::TrackSequenceId m_currentTrackSequenceId = -1;
ui::NavigationSection* m_itemsNavigationSection = nullptr;
ui::NavigationSection* m_navigationSection = nullptr;
};
}