Commit bccc7d35 authored by Jan Paul Batrina's avatar Jan Paul Batrina
Browse files

Hide plugin views when their sidebar is collapsed

When their sidebar is collapsed, plugin views are still
technically visible (e.g. isVisible() returns true), but
visually they are hidden. This leads to a visual mismatch
of state (e.g. toggling the plugin view will disable it
instead of showing).

This commit makes it so that active plugin views are hidden
when their sidebar is collapsed, and then they are restored
when their sidebar is expanded again.
parent 378c65d5
......@@ -286,10 +286,17 @@ Sidebar::Sidebar(KMultiTabBar::KMultiTabBarPosition pos, MainWindow *mainwin, QW
void Sidebar::setSplitter(QSplitter *sp)
// if splitter was set before, disconnect handler for collapse
if (m_splitter) {
disconnect(m_splitter, &QSplitter::splitterMoved, this, &Sidebar::handleCollapse);
m_splitter = sp;
m_ownSplit = new QSplitter((position() == KMultiTabBar::Top || position() == KMultiTabBar::Bottom) ? Qt::Horizontal : Qt::Vertical, m_splitter);
connect(m_splitter, &QSplitter::splitterMoved, this, &Sidebar::handleCollapse);
ToolView *Sidebar::addWidget(const QIcon &icon, const QString &text, ToolView *widget)
......@@ -493,6 +500,21 @@ bool Sidebar::isCollapsed()
return wsizes[ownSplitIndex] == 0;
void Sidebar::handleCollapse()
if (!isCollapsed()) {
// If the sidebar is collapsed, we need to hide the activated plugin-views since they are,
// visually speaking, hidden from the user but technically isVisible() would still return true
for (const auto &[id, wid] : m_idToWidget) {
if (wid->isVisible()) {
void Sidebar::expandSidebar(ToolView *widget)
if (m_widgetToId.find(widget) == m_widgetToId.end()) {
......@@ -511,6 +533,14 @@ void Sidebar::expandSidebar(ToolView *widget)
wsizes[ownSplitIndex] = qMax(widget->minimumSizeHint().width(), m_widgetToSize[widget].width());
// when the sidebar was collapsed, the activated widgets were hidden, so we need to show them again
// see Sidebar::handleCollapse
for (const auto &[id, wid] : m_idToWidget) {
if (isTabRaised(id)) {
......@@ -183,6 +183,7 @@ public:
bool hideWidget(ToolView *widget);
bool isCollapsed();
void handleCollapse();
void expandSidebar(ToolView *widget);
void setLastSize(int s)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment