diff --git a/src/plugins/coreplugin/navigationsubwidget.cpp b/src/plugins/coreplugin/navigationsubwidget.cpp index 0087980f040..881465af753 100644 --- a/src/plugins/coreplugin/navigationsubwidget.cpp +++ b/src/plugins/coreplugin/navigationsubwidget.cpp @@ -82,12 +82,12 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int pos splitAction->setMenu(m_splitMenu); connect(m_splitMenu, &QMenu::aboutToShow, this, &NavigationSubWidget::populateSplitMenu); - QToolButton *close = new QToolButton(); - close->setIcon(QIcon(QLatin1String(Constants::ICON_BUTTON_CLOSE))); - close->setToolTip(tr("Close")); + m_closeButton = new QToolButton(); + m_closeButton->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_BOTTOM))); + m_closeButton->setToolTip(tr("Close")); toolBarLayout->addWidget(splitAction); - toolBarLayout->addWidget(close); + toolBarLayout->addWidget(m_closeButton); QVBoxLayout *lay = new QVBoxLayout(); lay->setMargin(0); @@ -95,7 +95,7 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int pos setLayout(lay); lay->addWidget(m_toolBar); - connect(close, SIGNAL(clicked()), this, SIGNAL(closeMe())); + connect(m_closeButton, SIGNAL(clicked()), this, SIGNAL(closeMe())); setFactoryIndex(factoryIndex); @@ -189,6 +189,11 @@ Core::Command *NavigationSubWidget::command(const QString &title) const return 0; } +void NavigationSubWidget::setCloseIcon(const QIcon &icon) +{ + m_closeButton->setIcon(icon); +} + int NavigationSubWidget::factoryIndex() const { return m_navigationComboBox->currentIndex(); diff --git a/src/plugins/coreplugin/navigationsubwidget.h b/src/plugins/coreplugin/navigationsubwidget.h index afb56bef8c3..584ee94ad41 100644 --- a/src/plugins/coreplugin/navigationsubwidget.h +++ b/src/plugins/coreplugin/navigationsubwidget.h @@ -70,6 +70,7 @@ public: void restoreSettings(); Command *command(const QString &title) const; + void setCloseIcon(const QIcon &icon); signals: void splitMe(int factoryIndex); @@ -84,6 +85,7 @@ private: NavigationWidget *m_parentWidget; QComboBox *m_navigationComboBox; QMenu *m_splitMenu; + QToolButton *m_closeButton; QWidget *m_navigationWidget; INavigationWidgetFactory *m_navigationWidgetFactory; Utils::StyledBar *m_toolBar; diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 3e359341f33..9e3f6345a81 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -246,13 +246,19 @@ Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position,int d->m_subWidgets.at(pos)->setPosition(pos + 1); } + if (!d->m_subWidgets.isEmpty()) // Make all icons the bottom icon + d->m_subWidgets.at(0)->setCloseIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_BOTTOM))); + Internal::NavigationSubWidget *nsw = new Internal::NavigationSubWidget(this, position, index); connect(nsw, &Internal::NavigationSubWidget::splitMe, this, &NavigationWidget::splitSubWidget); connect(nsw, SIGNAL(closeMe()), this, SLOT(closeSubWidget())); insertWidget(position, nsw); d->m_subWidgets.insert(position, nsw); - + if (d->m_subWidgets.size() == 1) + d->m_subWidgets.at(0)->setCloseIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_LEFT))); + else + d->m_subWidgets.at(0)->setCloseIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_TOP))); return nsw; } @@ -297,6 +303,11 @@ void NavigationWidget::closeSubWidget() d->m_subWidgets.removeOne(subWidget); subWidget->hide(); subWidget->deleteLater(); + // update close button of top item + if (d->m_subWidgets.size() == 1) + d->m_subWidgets.at(0)->setCloseIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_LEFT))); + else + d->m_subWidgets.at(0)->setCloseIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_TOP))); } else { setShown(false); } diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp index 94a0faab467..eda340cdd6c 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -150,7 +150,7 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) : m_minMaxAction->setIcon(m_maximizeIcon); m_minMaxAction->setText(tr("Maximize Output Pane")); - m_closeButton->setIcon(QIcon(QLatin1String(Constants::ICON_BUTTON_CLOSE))); + m_closeButton->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_BOTTOM))); connect(m_closeButton, SIGNAL(clicked()), this, SLOT(slotHide())); connect(ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(saveSettings())); diff --git a/src/plugins/coreplugin/sidebar.cpp b/src/plugins/coreplugin/sidebar.cpp index b2efd1476db..0822e3e2813 100644 --- a/src/plugins/coreplugin/sidebar.cpp +++ b/src/plugins/coreplugin/sidebar.cpp @@ -30,6 +30,7 @@ #include "sidebar.h" #include "sidebarwidget.h" +#include "coreconstants.h" #include "actionmanager/command.h" #include @@ -202,12 +203,18 @@ SideBarItem *SideBar::item(const QString &id) Internal::SideBarWidget *SideBar::insertSideBarWidget(int position, const QString &id) { + d->m_widgets.at(0)->setCloseIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_BOTTOM))); + Internal::SideBarWidget *item = new Internal::SideBarWidget(this, id); connect(item, SIGNAL(splitMe()), this, SLOT(splitSubWidget())); connect(item, SIGNAL(closeMe()), this, SLOT(closeSubWidget())); connect(item, SIGNAL(currentWidgetChanged()), this, SLOT(updateWidgets())); insertWidget(position, item); d->m_widgets.insert(position, item); + if (d->m_widgets.size() == 1) + d->m_widgets.at(0)->setCloseIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_LEFT))); + else + d->m_widgets.at(0)->setCloseIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_TOP))); updateWidgets(); return item; } @@ -235,6 +242,11 @@ void SideBar::closeSubWidget() if (!widget) return; removeSideBarWidget(widget); + // update close button of top item + if (d->m_widgets.size() == 1) + d->m_widgets.at(0)->setCloseIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_LEFT))); + else + d->m_widgets.at(0)->setCloseIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_TOP))); updateWidgets(); } else { if (d->m_closeWhenEmpty) { diff --git a/src/plugins/coreplugin/sidebarwidget.cpp b/src/plugins/coreplugin/sidebarwidget.cpp index c97615928c3..dfb064f4283 100644 --- a/src/plugins/coreplugin/sidebarwidget.cpp +++ b/src/plugins/coreplugin/sidebarwidget.cpp @@ -80,11 +80,11 @@ SideBarWidget::SideBarWidget(SideBar *sideBar, const QString &id) connect(m_splitAction, SIGNAL(triggered()), this, SIGNAL(splitMe())); m_toolbar->addAction(m_splitAction); - QAction *closeAction = new QAction(tr("Close"), m_toolbar); - closeAction->setToolTip(tr("Close")); - closeAction->setIcon(QIcon(QLatin1String(Constants::ICON_BUTTON_CLOSE))); - connect(closeAction, SIGNAL(triggered()), this, SIGNAL(closeMe())); - m_toolbar->addAction(closeAction); + m_closeAction = new QAction(tr("Close"), m_toolbar); + m_closeAction->setToolTip(tr("Close")); + m_closeAction->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_BOTTOM))); + connect(m_closeAction, SIGNAL(triggered()), this, SIGNAL(closeMe())); + m_toolbar->addAction(m_closeAction); QVBoxLayout *lay = new QVBoxLayout(); lay->setMargin(0); @@ -212,5 +212,10 @@ Command *SideBarWidget::command(const QString &title) const return 0; } +void SideBarWidget::setCloseIcon(const QIcon &icon) +{ + m_closeAction->setIcon(icon); +} + } // namespace Internal } // namespace Core diff --git a/src/plugins/coreplugin/sidebarwidget.h b/src/plugins/coreplugin/sidebarwidget.h index f916e1cc8fe..339db62e6ae 100644 --- a/src/plugins/coreplugin/sidebarwidget.h +++ b/src/plugins/coreplugin/sidebarwidget.h @@ -64,6 +64,8 @@ public: Command *command(const QString &title) const; + void setCloseIcon(const QIcon &icon); + signals: void splitMe(); void closeMe(); @@ -77,6 +79,7 @@ private: SideBarItem *m_currentItem; QToolBar *m_toolbar; QAction *m_splitAction; + QAction *m_closeAction; QList m_addedToolBarActions; SideBar *m_sideBar; };