From a7bc97705692ddd3ce643fe14e6ff4126dd671e9 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 25 Jul 2017 15:05:56 +0200 Subject: [PATCH] Fix close icon for right side navigation panes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there is only one view, it should show the "close to the right" icon, not "close to the left". Change-Id: Ifb7c4261cb74e35310dc3d634720d9daa20df3f1 Reviewed-by: André Hartmann --- src/plugins/coreplugin/navigationwidget.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 61d9feb63df..ff9c6cc5810 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -312,6 +312,15 @@ void NavigationWidget::resizeEvent(QResizeEvent *re) MiniSplitter::resizeEvent(re); } +static QIcon closeIconForSide(Side side, int itemCount) +{ + if (itemCount > 1) + return Utils::Icons::CLOSE_SPLIT_TOP.icon(); + return side == Side::Left + ? Utils::Icons::CLOSE_SPLIT_LEFT.icon() + : Utils::Icons::CLOSE_SPLIT_RIGHT.icon(); +} + Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position, int factoryIndex) { for (int pos = position + 1; pos < d->m_subWidgets.size(); ++pos) { @@ -331,9 +340,7 @@ Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position, int insertWidget(position, nsw); d->m_subWidgets.insert(position, nsw); - d->m_subWidgets.at(0)->setCloseIcon(d->m_subWidgets.size() == 1 - ? Utils::Icons::CLOSE_SPLIT_LEFT.icon() - : Utils::Icons::CLOSE_SPLIT_TOP.icon()); + d->m_subWidgets.at(0)->setCloseIcon(closeIconForSide(d->m_side, d->m_subWidgets.size())); NavigationWidgetPrivate::updateActivationsMap(nsw->factory()->id(), {d->m_side, position}); return nsw; } @@ -386,10 +393,8 @@ void NavigationWidget::closeSubWidget() subWidget->hide(); subWidget->deleteLater(); // update close button of top item - if (d->m_subWidgets.size() == 1) - d->m_subWidgets.at(0)->setCloseIcon(d->m_subWidgets.size() == 1 - ? Utils::Icons::CLOSE_SPLIT_LEFT.icon() - : Utils::Icons::CLOSE_SPLIT_TOP.icon()); + if (!d->m_subWidgets.isEmpty()) + d->m_subWidgets.at(0)->setCloseIcon(closeIconForSide(d->m_side, d->m_subWidgets.size())); } else { setShown(false); }