Merge pull request #9457 from RomanPudashkin/statusbar_fix

[MU4] Fixed the status bar disappearing
This commit is contained in:
Elnur Ismailzada 2021-10-15 05:29:15 -07:00 committed by GitHub
commit 29f4ed1e25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 81 additions and 40 deletions

View file

@ -67,6 +67,7 @@ DockPage {
objectName: "devtoolsPanel"
width: maximumWidth
minimumWidth: 200
maximumWidth: 292

View file

@ -67,6 +67,7 @@ DockPage {
DockPanel {
objectName: "homeMenu"
width: maximumWidth
minimumWidth: 76
maximumWidth: 292

View file

@ -113,6 +113,7 @@ Rectangle {
width: parent.width
visible: tabs.count > 1
clip: true
color: ui.theme.backgroundSecondaryColor
@ -143,7 +144,6 @@ Rectangle {
orientation: Qt.Horizontal
interactive: false
clip: true
spacing: 0
currentIndex: tabsPanel.currentIndex

View file

@ -214,12 +214,40 @@ void DockPageView::setDockOpen(const QString& dockName, bool open)
return;
}
if (open) {
dock->open();
} else {
constexpr bool UNLOAD_CONTENT = true;
dock->close(UNLOAD_CONTENT);
if (!open) {
dock->close();
return;
}
DockPanelView* panel = dynamic_cast<DockPanelView*>(dock);
if (!panel) {
dock->open();
return;
}
DockPanelView* destinationPanel = findPanelForTab(panel);
if (destinationPanel) {
destinationPanel->addPanelAsTab(panel);
} else {
panel->open();
}
}
DockPanelView* DockPageView::findPanelForTab(const DockPanelView* tab) const
{
for (DockPanelView* panel : panels()) {
if (panel->tabifyPanel() != tab) {
continue;
}
if (panel->isOpen()) {
return panel;
}
return findPanelForTab(panel);
}
return nullptr;
}
bool DockPageView::isDockFloating(const QString& dockName) const
@ -268,15 +296,6 @@ void DockPageView::setStatusBar(DockStatusBarView* statusBar)
emit statusBarChanged(statusBar);
}
void DockPageView::close()
{
TRACEFUNC;
for (DockBase* dock : allDocks()) {
dock->close();
}
}
void DockPageView::componentComplete()
{
QQuickItem::componentComplete();

View file

@ -54,7 +54,6 @@ public:
explicit DockPageView(QQuickItem* parent = nullptr);
void init();
void close();
QString uri() const;
@ -98,6 +97,8 @@ signals:
private:
void componentComplete() override;
DockPanelView* findPanelForTab(const DockPanelView* tab) const;
QString m_uri;
uicomponents::QmlListProperty<DockToolBarView> m_mainToolBars;
uicomponents::QmlListProperty<DockToolBarView> m_toolBars;

View file

@ -23,6 +23,7 @@
#include "dockpanelview.h"
#include "thirdparty/KDDockWidgets/src/DockWidgetQuick.h"
#include "thirdparty/KDDockWidgets/src/private/Frame_p.h"
#include "log.h"
#include "translation.h"
@ -230,3 +231,25 @@ void DockPanelView::setContextMenuModel(AbstractMenuModel* model)
m_menuModel->setCustomMenuModel(model);
emit contextMenuModelChanged();
}
void DockPanelView::addPanelAsTab(DockPanelView* tab)
{
IF_ASSERT_FAILED(tab && dockWidget()) {
return;
}
dockWidget()->addDockWidgetAsTab(tab->dockWidget());
tab->setVisible(true);
}
void DockPanelView::setCurrentTabIndex(int index)
{
IF_ASSERT_FAILED(dockWidget()) {
return;
}
KDDockWidgets::Frame* frame = dockWidget()->frame();
if (frame) {
frame->setCurrentTabIndex(index);
}
}

View file

@ -50,6 +50,9 @@ public:
QObject* navigationSection() const;
ui::AbstractMenuModel* contextMenuModel() const;
void addPanelAsTab(DockPanelView* tab);
void setCurrentTabIndex(int index);
public slots:
void setTabifyPanel(DockPanelView* panel);
void setNavigationSection(QObject* newNavigation);

View file

@ -24,8 +24,8 @@
#include "thirdparty/KDDockWidgets/src/DockWidgetQuick.h"
#include "thirdparty/KDDockWidgets/src/LayoutSaver.h"
#include "thirdparty/KDDockWidgets/src/private/Frame_p.h"
#include "thirdparty/KDDockWidgets/src/private/quick/MainWindowQuick_p.h"
#include "thirdparty/KDDockWidgets/src/private/DockRegistry_p.h"
#include "dockcentralview.h"
#include "dockpageview.h"
@ -129,7 +129,7 @@ void DockWindow::loadPage(const QString& uri)
DockPageView* currentPage = this->currentPage();
if (currentPage) {
savePageState(currentPage->objectName());
currentPage->close();
KDDockWidgets::DockRegistry::self()->clear();
}
loadPageContent(newPage);
@ -139,10 +139,6 @@ void DockWindow::loadPage(const QString& uri)
QStringList allDockNames;
for (DockBase* dock : newPage->allDocks()) {
if (!dock->isVisible()) {
dock->close();
}
allDockNames << dock->objectName();
}
@ -264,24 +260,18 @@ void DockWindow::loadPageContent(const DockPageView* page)
}
addDock(m_mainToolBarDockingHolder, KDDockWidgets::Location_OnTop);
m_mainToolBarDockingHolder->close();
unitePanelsToTabs(page);
}
void DockWindow::unitePanelsToTabs(const DockPageView* page)
{
for (const DockPanelView* panel : page->panels()) {
const DockPanelView* tab = panel->tabifyPanel();
if (!tab) {
continue;
}
for (DockPanelView* panel : page->panels()) {
DockPanelView* tab = panel->tabifyPanel();
panel->dockWidget()->addDockWidgetAsTab(tab->dockWidget());
KDDockWidgets::Frame* frame = panel->dockWidget()->frame();
if (frame) {
frame->setCurrentTabIndex(0);
if (tab && tab->isVisible()) {
panel->addPanelAsTab(tab);
panel->setCurrentTabIndex(0);
}
}
}
@ -388,7 +378,13 @@ void DockWindow::addDock(DockBase* dock, KDDockWidgets::Location location, const
}
KDDockWidgets::DockWidgetBase* relativeDock = relativeTo ? relativeTo->dockWidget() : nullptr;
m_mainWindow->addDockWidget(dock->dockWidget(), location, relativeDock, dock->preferredSize());
auto visibilityOption = dock->isVisible() ? KDDockWidgets::InitialVisibilityOption::StartVisible
: KDDockWidgets::InitialVisibilityOption::StartHidden;
KDDockWidgets::InitialOption options(visibilityOption, dock->preferredSize());
m_mainWindow->addDockWidget(dock->dockWidget(), location, relativeDock, options);
}
DockPageView* DockWindow::pageByUri(const QString& uri) const

View file

@ -218,17 +218,14 @@ void DockBase::open()
setVisible(true);
}
void DockBase::close(bool unloadContent)
void DockBase::close()
{
IF_ASSERT_FAILED(m_dockWidget) {
return;
}
m_dockWidget->forceClose();
if (unloadContent) {
setVisible(false);
}
setVisible(false);
}
DockBase::DockLocation DockBase::location() const

View file

@ -77,7 +77,7 @@ public:
bool isOpen() const;
void open();
void close(bool unloadContent = false);
void close();
DockLocation location() const;