Block changes to selection during resize and tiling

This commit is contained in:
Gaute Lindkvist 2019-04-04 19:19:13 +02:00
parent 000b6713b1
commit 9c2ed5ad92
5 changed files with 37 additions and 9 deletions

View File

@ -116,7 +116,6 @@ RiuMainWindow::RiuMainWindow()
, m_pvtPlotPanel(nullptr)
, m_mohrsCirclePlot(nullptr)
, m_windowMenu(nullptr)
, m_blockSlotSubWindowActivated(false)
, m_holoLensToolBar(nullptr)
{
m_mdiArea = new RiuMdiArea;
@ -1115,9 +1114,9 @@ RiuMessagePanel* RiuMainWindow::messagePanel()
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::removeViewer(QWidget* viewer)
{
m_blockSlotSubWindowActivated = true;
setBlockSlotSubWindowActivated(true);
m_mdiArea->removeSubWindow(findMdiSubWindow(viewer));
m_blockSlotSubWindowActivated = false;
setBlockSlotSubWindowActivated(false);
if (subWindowsAreTiled())
{
tileSubWindows();
@ -1245,7 +1244,7 @@ void RiuMainWindow::slotViewFromBelow()
void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
{
if (!subWindow) return;
if (m_blockSlotSubWindowActivated) return;
if (blockSlotSubWindowActivated()) return;
RimProject* proj = RiaApplication::instance()->project();
if (!proj) return;
@ -1353,12 +1352,12 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::setActiveViewer(QWidget* viewer)
{
m_blockSlotSubWindowActivated = true;
setBlockSlotSubWindowActivated(true);
QMdiSubWindow* swin = findMdiSubWindow(viewer);
if (swin) m_mdiArea->setActiveSubWindow(swin);
m_blockSlotSubWindowActivated = false;
setBlockSlotSubWindowActivated(false);
}
//--------------------------------------------------------------------------------------------------
@ -2036,23 +2035,26 @@ void RiuMainWindow::tileSubWindows()
}
return lhs->frameGeometry().topLeft().rx() > rhs->frameGeometry().topLeft().rx();
});
// Based on workaround described here
// https://forum.qt.io/topic/50053/qmdiarea-tilesubwindows-always-places-widgets-in-activationhistoryorder-in-subwindowview-mode
bool prevActivationBlock = blockSlotSubWindowActivated();
// Force activation order so they end up in the order of the loop.
m_mdiArea->setActivationOrder(QMdiArea::ActivationHistoryOrder);
QMdiSubWindow* a = m_mdiArea->activeSubWindow();
setBlockSlotSubWindowActivated(true);
for (QMdiSubWindow* subWindow : windowList)
{
m_mdiArea->setActiveSubWindow(subWindow);
}
m_mdiArea->tileSubWindows();
// Set back the original activation order to avoid messing with the standard ordering
m_mdiArea->setActivationOrder(currentActivationOrder);
m_mdiArea->setActiveSubWindow(a);
setBlockSlotSubWindowActivated(prevActivationBlock);
storeSubWindowTiling(true);
}

View File

@ -270,5 +270,4 @@ private:
std::vector<QPointer<QDockWidget> > m_additionalProjectViews;
bool m_blockSlotSubWindowActivated;
};

View File

@ -42,6 +42,7 @@ RiuMainWindowBase::RiuMainWindowBase()
: m_projectTreeView(nullptr)
, m_allowActiveViewChangeFromSelection(true)
, m_showFirstVisibleWindowMaximized(true)
, m_blockSlotSubWindowActivated(false)
{
setDockNestingEnabled(true);
}
@ -146,6 +147,22 @@ void RiuMainWindowBase::enableShowFirstVisibleMdiWindowMaximized(bool enable)
m_showFirstVisibleWindowMaximized = enable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::setBlockSlotSubWindowActivated(bool block)
{
m_blockSlotSubWindowActivated = block;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMainWindowBase::blockSlotSubWindowActivated() const
{
return m_blockSlotSubWindowActivated;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -69,6 +69,9 @@ public:
virtual void clearWindowTiling() = 0;
virtual bool subWindowsAreTiled() const = 0;
void setBlockSlotSubWindowActivated(bool block);
bool blockSlotSubWindowActivated() const;
protected slots:
void slotDockWidgetToggleViewActionTriggered();
void addViewerToMdiArea(QMdiArea* mdiArea, QWidget* viewer, const QPoint& subWindowPos, const QSize& subWindowSize);
@ -82,4 +85,6 @@ private:
private:
bool m_showFirstVisibleWindowMaximized;
bool m_blockSlotSubWindowActivated;
};

View File

@ -57,6 +57,9 @@ void RiuMdiArea::resizeEvent(QResizeEvent* resizeEvent)
riuWindow->blockTilingChanges(true);
}
RiuMainWindowBase* mainWindow = dynamic_cast<RiuMainWindowBase*>(window());
mainWindow->setBlockSlotSubWindowActivated(true);
// Workaround for Qt bug #51761: https://bugreports.qt.io/browse/QTBUG-51761
// Set the first window to be the active window then perform resize event and set back.
auto a = activeSubWindow();
@ -67,6 +70,8 @@ void RiuMdiArea::resizeEvent(QResizeEvent* resizeEvent)
setActiveSubWindow(a);
mainWindow->setBlockSlotSubWindowActivated(false);
for (auto subWindow : subWindowList())
{
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>(subWindow);