forked from qt-creator/qt-creator
Make "close view" buttons more consistent
Use the same icons that we already use for editor splits. Change-Id: Ice052f637968918a15b16e00a39c5dbc06948dbc Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com> Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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()));
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "sidebar.h"
|
||||
#include "sidebarwidget.h"
|
||||
#include "coreconstants.h"
|
||||
|
||||
#include "actionmanager/command.h"
|
||||
#include <utils/algorithm.h>
|
||||
@@ -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) {
|
||||
|
@@ -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
|
||||
|
@@ -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<QAction *> m_addedToolBarActions;
|
||||
SideBar *m_sideBar;
|
||||
};
|
||||
|
Reference in New Issue
Block a user