Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MU4] Fix #10477: Mixer and timeline should be tabbed by default, and height adjustment interaction needs fixing #10874

Merged
merged 2 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/appshell/qml/NotationPage/NotationPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ DockPage {
readonly property int horizontalPanelMinHeight: 100
readonly property int horizontalPanelMaxHeight: 520

readonly property string verticalPanelsGroup: "VERTICAL_PANELS"
readonly property string horizontalPanelsGroup: "HORIZONTAL_PANELS"

readonly property var verticalPanelDropDestinations: [
{ "dock": root.centralDock, "dropLocation": Location.Left, "dropDistance": root.verticalPanelDefaultWidth },
{ "dock": root.centralDock, "dropLocation": Location.Right, "dropDistance": root.verticalPanelDefaultWidth }
Expand Down Expand Up @@ -213,7 +216,7 @@ DockPage {
minimumWidth: root.verticalPanelDefaultWidth
maximumWidth: root.verticalPanelDefaultWidth

tabifyPanel: instrumentsPanel
groupName: root.verticalPanelsGroup

dropDestinations: root.verticalPanelDropDestinations

Expand All @@ -238,7 +241,7 @@ DockPage {
minimumWidth: root.verticalPanelDefaultWidth
maximumWidth: root.verticalPanelDefaultWidth

tabifyPanel: inspectorPanel
groupName: root.verticalPanelsGroup

dropDestinations: root.verticalPanelDropDestinations

Expand All @@ -262,8 +265,8 @@ DockPage {
width: root.verticalPanelDefaultWidth
minimumWidth: root.verticalPanelDefaultWidth
maximumWidth: root.verticalPanelDefaultWidth
tabifyPanel: selectionFilterPanel

groupName: root.verticalPanelsGroup

dropDestinations: root.verticalPanelDropDestinations

Expand All @@ -284,6 +287,8 @@ DockPage {
minimumWidth: root.verticalPanelDefaultWidth
maximumWidth: root.verticalPanelDefaultWidth

groupName: root.verticalPanelsGroup

//! NOTE: hidden by default
visible: false

Expand All @@ -308,7 +313,7 @@ DockPage {
minimumHeight: root.horizontalPanelMinHeight
maximumHeight: root.horizontalPanelMaxHeight

tabifyPanel: pianoKeyboardPanel
groupName: root.horizontalPanelsGroup

//! NOTE: hidden by default
visible: false
Expand Down Expand Up @@ -342,7 +347,7 @@ DockPage {
minimumHeight: root.horizontalPanelMinHeight
maximumHeight: root.horizontalPanelMaxHeight

tabifyPanel: timelinePanel
groupName: root.horizontalPanelsGroup

//! NOTE: hidden by default
visible: false
Expand All @@ -368,6 +373,8 @@ DockPage {
minimumHeight: root.horizontalPanelMinHeight
maximumHeight: root.horizontalPanelMaxHeight

groupName: root.horizontalPanelsGroup

//! NOTE: hidden by default
visible: false

Expand Down
61 changes: 8 additions & 53 deletions src/appshell/view/dockwindow/dockpageview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,51 +155,17 @@ DockingHolderView* DockPageView::holder(DockType type, Location location) const
return nullptr;
}

QList<DockPanelView*> DockPageView::possibleTabs(const DockPanelView* panel) const
QList<DockPanelView*> DockPageView::possiblePanelsForTab(const DockPanelView* tab) const
{
QList<DockPanelView*> tabs;
QList<DockPanelView*> result;

auto isPanelAllowedAsTab = [panel](const DockPanelView* p) {
if (!p || p == panel) {
return false;
}

return p->isOpen() && !p->floating();
};

DockPanelView* rootPanel = findRootPanel(panel);
DockPanelView* nextPanel = rootPanel ? rootPanel->tabifyPanel() : nullptr;

while (nextPanel) {
if (isPanelAllowedAsTab(nextPanel)) {
tabs << nextPanel;
}

nextPanel = nextPanel->tabifyPanel();
}

if (!tabs.contains(rootPanel) && isPanelAllowedAsTab(rootPanel)) {
tabs.prepend(rootPanel);
}

return tabs;
}

DockPanelView* DockPageView::findRootPanel(const DockPanelView* panel) const
{
for (DockPanelView* panel_ : panels()) {
DockPanelView* tabifyPanel = panel_->tabifyPanel();

while (tabifyPanel) {
if (tabifyPanel == panel) {
return panel_;
}

tabifyPanel = tabifyPanel->tabifyPanel();
for (DockPanelView* panel : panels()) {
if (panel->isTabAllowed(tab)) {
result << panel;
}
}

return const_cast<DockPanelView*>(panel);
return result;
}

bool DockPageView::isDockOpen(const QString& dockName) const
Expand Down Expand Up @@ -241,19 +207,8 @@ void DockPageView::setDockOpen(const QString& dockName, bool open)

DockPanelView* DockPageView::findPanelForTab(const DockPanelView* tab) const
{
for (DockPanelView* panel : panels()) {
if (panel->tabifyPanel() != tab) {
continue;
}

if (panel->isOpen() && !panel->floating()) {
return panel;
}

return findPanelForTab(panel);
}

return nullptr;
QList<DockPanelView*> panels = possiblePanelsForTab(tab);
return !panels.isEmpty() ? panels.first() : nullptr;
}

bool DockPageView::isDockFloating(const QString& dockName) const
Expand Down
3 changes: 1 addition & 2 deletions src/appshell/view/dockwindow/dockpageview.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class DockPageView : public QQuickItem

DockBase* dockByName(const QString& dockName) const;
DockingHolderView* holder(DockType type, Location location) const;
QList<DockPanelView*> possibleTabs(const DockPanelView* panel) const;
QList<DockPanelView*> possiblePanelsForTab(const DockPanelView* tab) const;

bool isDockOpen(const QString& dockName) const;
void toggleDock(const QString& dockName);
Expand All @@ -100,7 +100,6 @@ public slots:
void componentComplete() override;

DockPanelView* findPanelForTab(const DockPanelView* tab) const;
DockPanelView* findRootPanel(const DockPanelView* panel) const;

QString m_uri;
uicomponents::QmlListProperty<DockToolBarView> m_mainToolBars;
Expand Down
41 changes: 35 additions & 6 deletions src/appshell/view/dockwindow/dockpanelview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,19 @@ DockPanelView::~DockPanelView()
dockWidget->setProperty(CONTEXT_MENU_MODEL_PROPERTY, QVariant::fromValue(nullptr));
}

DockPanelView* DockPanelView::tabifyPanel() const
QString DockPanelView::groupName() const
{
return m_tabifyPanel;
return m_groupName;
}

void DockPanelView::setTabifyPanel(DockPanelView* panel)
void DockPanelView::setGroupName(const QString& name)
{
if (panel == m_tabifyPanel) {
if (m_groupName == name) {
return;
}

m_tabifyPanel = panel;
emit tabifyPanelChanged(panel);
m_groupName = name;
emit groupNameChanged();
}

DockType DockPanelView::type() const
Expand Down Expand Up @@ -236,12 +236,41 @@ void DockPanelView::setContextMenuModel(AbstractMenuModel* model)
emit contextMenuModelChanged();
}

bool DockPanelView::isTabAllowed(const DockPanelView* tab) const
{
IF_ASSERT_FAILED(tab) {
return false;
}

if (tab == this) {
return false;
}

if (!isOpen()) {
return false;
}

if (floating()) {
return false;
}

if (m_groupName.isEmpty() || tab->m_groupName.isEmpty()) {
return false;
}

return m_groupName == tab->m_groupName;
}

void DockPanelView::addPanelAsTab(DockPanelView* tab)
{
IF_ASSERT_FAILED(tab && dockWidget()) {
return;
}

if (!isTabAllowed(tab)) {
return;
}

dockWidget()->addDockWidgetAsTab(tab->dockWidget());
tab->setVisible(true);
}
Expand Down
13 changes: 7 additions & 6 deletions src/appshell/view/dockwindow/dockpanelview.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,39 @@ class DockPanelView : public DockBase
{
Q_OBJECT

Q_PROPERTY(DockPanelView * tabifyPanel READ tabifyPanel WRITE setTabifyPanel NOTIFY tabifyPanelChanged)
Q_PROPERTY(QString groupName READ groupName WRITE setGroupName NOTIFY groupNameChanged)
Q_PROPERTY(QObject * navigationSection READ navigationSection WRITE setNavigationSection NOTIFY navigationSectionChanged)
Q_PROPERTY(
mu::uicomponents::AbstractMenuModel
* contextMenuModel READ contextMenuModel WRITE setContextMenuModel NOTIFY contextMenuModelChanged)

public:
explicit DockPanelView(QQuickItem* parent = nullptr);
~DockPanelView();
~DockPanelView() override;

DockPanelView* tabifyPanel() const;
QString groupName() const;
QObject* navigationSection() const;
uicomponents::AbstractMenuModel* contextMenuModel() const;

bool isTabAllowed(const DockPanelView* tab) const;
void addPanelAsTab(DockPanelView* tab);
void setCurrentTabIndex(int index);

public slots:
void setTabifyPanel(DockPanelView* panel);
void setGroupName(const QString& name);
void setNavigationSection(QObject* newNavigation);
void setContextMenuModel(uicomponents::AbstractMenuModel* model);

signals:
void tabifyPanelChanged(DockPanelView* panel);
void groupNameChanged();
void navigationSectionChanged();
void contextMenuModelChanged();

private:
DockType type() const override;
void componentComplete() override;

DockPanelView* m_tabifyPanel = nullptr;
QString m_groupName;
QObject* m_navigationSection = nullptr;

class DockPanelMenuModel;
Expand Down
38 changes: 21 additions & 17 deletions src/appshell/view/dockwindow/dockwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ void DockWindow::onQuit()
{
TRACEFUNC;

m_quiting = true;

IF_ASSERT_FAILED(m_currentPage) {
return;
}
Expand Down Expand Up @@ -171,16 +169,12 @@ void DockWindow::init()
dockWindowProvider()->init(this);

uiConfiguration()->windowGeometryChanged().onNotify(this, [this]() {
if (!m_quiting) {
updatePageState();
}
reloadCurrentPage();
});

workspaceManager()->currentWorkspaceAboutToBeChanged().onNotify(this, [this]() {
if (DockPageView* page = currentPage()) {
m_workspaceChanging = true;
if (const DockPageView* page = currentPage()) {
savePageState(page->objectName());
m_workspaceChanging = false;
}
});

Expand Down Expand Up @@ -291,11 +285,15 @@ void DockWindow::restoreDefaultLayout()
}
}

m_reloadCurrentPageAllowed = false;
for (const DockPageView* page : m_pages.list()) {
uiConfiguration()->setPageState(page->objectName(), QByteArray());
}

uiConfiguration()->setWindowGeometry(QByteArray());
m_reloadCurrentPageAllowed = true;

reloadCurrentPage();
}

void DockWindow::loadPageContent(const DockPageView* page)
Expand Down Expand Up @@ -349,13 +347,9 @@ void DockWindow::loadPanels(const DockPageView* page)
{
TRACEFUNC;

auto canAddAsTab = [](const DockPanelView* panel, const DockPanelView* destination) {
return panel->isVisible() && destination->isOpen() && destination->tabifyPanel() == panel;
};

auto addPanel = [this, page, canAddAsTab](DockPanelView* panel, Location location) {
auto addPanel = [this, page](DockPanelView* panel, Location location) {
for (DockPanelView* destinationPanel : page->panels()) {
if (canAddAsTab(panel, destinationPanel)) {
if (destinationPanel->isTabAllowed(panel)) {
registerDock(panel);

destinationPanel->addPanelAsTab(panel);
Expand Down Expand Up @@ -504,7 +498,9 @@ void DockWindow::saveGeometry()
/// and restore only the application geometry.
/// Therefore, for correct operation after saving or restoring geometry,
/// it is necessary to apply the appropriate method for the state.
m_reloadCurrentPageAllowed = false;
uiConfiguration()->setWindowGeometry(windowState());
m_reloadCurrentPageAllowed = true;
}

void DockWindow::restoreGeometry()
Expand All @@ -526,7 +522,9 @@ void DockWindow::savePageState(const QString& pageName)
{
TRACEFUNC;

m_reloadCurrentPageAllowed = false;
uiConfiguration()->setPageState(pageName, windowState());
m_reloadCurrentPageAllowed = true;
}

void DockWindow::restorePageState(const QString& pageName)
Expand All @@ -544,8 +542,8 @@ void DockWindow::restorePageState(const QString& pageName)
if (!pageStateValNt.notification.isConnected()) {
pageStateValNt.notification.onNotify(this, [this, pageName]() {
bool isCurrentPage = m_currentPage && (m_currentPage->objectName() == pageName);
if (isCurrentPage && !m_quiting && !m_workspaceChanging) {
updatePageState();
if (isCurrentPage) {
reloadCurrentPage();
}
});
}
Expand Down Expand Up @@ -574,8 +572,14 @@ QByteArray DockWindow::windowState() const
return layoutSaver.serializeLayout();
}

void DockWindow::updatePageState()
void DockWindow::reloadCurrentPage()
{
if (!m_reloadCurrentPageAllowed) {
return;
}

TRACEFUNC;

QString currentPageUriBackup = currentPageUri();

/// NOTE: for reset geometry
Expand Down