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);
|
splitAction->setMenu(m_splitMenu);
|
||||||
connect(m_splitMenu, &QMenu::aboutToShow, this, &NavigationSubWidget::populateSplitMenu);
|
connect(m_splitMenu, &QMenu::aboutToShow, this, &NavigationSubWidget::populateSplitMenu);
|
||||||
|
|
||||||
QToolButton *close = new QToolButton();
|
m_closeButton = new QToolButton();
|
||||||
close->setIcon(QIcon(QLatin1String(Constants::ICON_BUTTON_CLOSE)));
|
m_closeButton->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_BOTTOM)));
|
||||||
close->setToolTip(tr("Close"));
|
m_closeButton->setToolTip(tr("Close"));
|
||||||
|
|
||||||
toolBarLayout->addWidget(splitAction);
|
toolBarLayout->addWidget(splitAction);
|
||||||
toolBarLayout->addWidget(close);
|
toolBarLayout->addWidget(m_closeButton);
|
||||||
|
|
||||||
QVBoxLayout *lay = new QVBoxLayout();
|
QVBoxLayout *lay = new QVBoxLayout();
|
||||||
lay->setMargin(0);
|
lay->setMargin(0);
|
||||||
@@ -95,7 +95,7 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int pos
|
|||||||
setLayout(lay);
|
setLayout(lay);
|
||||||
lay->addWidget(m_toolBar);
|
lay->addWidget(m_toolBar);
|
||||||
|
|
||||||
connect(close, SIGNAL(clicked()), this, SIGNAL(closeMe()));
|
connect(m_closeButton, SIGNAL(clicked()), this, SIGNAL(closeMe()));
|
||||||
|
|
||||||
setFactoryIndex(factoryIndex);
|
setFactoryIndex(factoryIndex);
|
||||||
|
|
||||||
@@ -189,6 +189,11 @@ Core::Command *NavigationSubWidget::command(const QString &title) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NavigationSubWidget::setCloseIcon(const QIcon &icon)
|
||||||
|
{
|
||||||
|
m_closeButton->setIcon(icon);
|
||||||
|
}
|
||||||
|
|
||||||
int NavigationSubWidget::factoryIndex() const
|
int NavigationSubWidget::factoryIndex() const
|
||||||
{
|
{
|
||||||
return m_navigationComboBox->currentIndex();
|
return m_navigationComboBox->currentIndex();
|
||||||
|
@@ -70,6 +70,7 @@ public:
|
|||||||
void restoreSettings();
|
void restoreSettings();
|
||||||
|
|
||||||
Command *command(const QString &title) const;
|
Command *command(const QString &title) const;
|
||||||
|
void setCloseIcon(const QIcon &icon);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void splitMe(int factoryIndex);
|
void splitMe(int factoryIndex);
|
||||||
@@ -84,6 +85,7 @@ private:
|
|||||||
NavigationWidget *m_parentWidget;
|
NavigationWidget *m_parentWidget;
|
||||||
QComboBox *m_navigationComboBox;
|
QComboBox *m_navigationComboBox;
|
||||||
QMenu *m_splitMenu;
|
QMenu *m_splitMenu;
|
||||||
|
QToolButton *m_closeButton;
|
||||||
QWidget *m_navigationWidget;
|
QWidget *m_navigationWidget;
|
||||||
INavigationWidgetFactory *m_navigationWidgetFactory;
|
INavigationWidgetFactory *m_navigationWidgetFactory;
|
||||||
Utils::StyledBar *m_toolBar;
|
Utils::StyledBar *m_toolBar;
|
||||||
|
@@ -246,13 +246,19 @@ Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position,int
|
|||||||
d->m_subWidgets.at(pos)->setPosition(pos + 1);
|
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);
|
Internal::NavigationSubWidget *nsw = new Internal::NavigationSubWidget(this, position, index);
|
||||||
connect(nsw, &Internal::NavigationSubWidget::splitMe,
|
connect(nsw, &Internal::NavigationSubWidget::splitMe,
|
||||||
this, &NavigationWidget::splitSubWidget);
|
this, &NavigationWidget::splitSubWidget);
|
||||||
connect(nsw, SIGNAL(closeMe()), this, SLOT(closeSubWidget()));
|
connect(nsw, SIGNAL(closeMe()), this, SLOT(closeSubWidget()));
|
||||||
insertWidget(position, nsw);
|
insertWidget(position, nsw);
|
||||||
d->m_subWidgets.insert(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;
|
return nsw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,6 +303,11 @@ void NavigationWidget::closeSubWidget()
|
|||||||
d->m_subWidgets.removeOne(subWidget);
|
d->m_subWidgets.removeOne(subWidget);
|
||||||
subWidget->hide();
|
subWidget->hide();
|
||||||
subWidget->deleteLater();
|
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 {
|
} else {
|
||||||
setShown(false);
|
setShown(false);
|
||||||
}
|
}
|
||||||
|
@@ -150,7 +150,7 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) :
|
|||||||
m_minMaxAction->setIcon(m_maximizeIcon);
|
m_minMaxAction->setIcon(m_maximizeIcon);
|
||||||
m_minMaxAction->setText(tr("Maximize Output Pane"));
|
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(m_closeButton, SIGNAL(clicked()), this, SLOT(slotHide()));
|
||||||
|
|
||||||
connect(ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(saveSettings()));
|
connect(ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(saveSettings()));
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "sidebar.h"
|
#include "sidebar.h"
|
||||||
#include "sidebarwidget.h"
|
#include "sidebarwidget.h"
|
||||||
|
#include "coreconstants.h"
|
||||||
|
|
||||||
#include "actionmanager/command.h"
|
#include "actionmanager/command.h"
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
@@ -202,12 +203,18 @@ SideBarItem *SideBar::item(const QString &id)
|
|||||||
|
|
||||||
Internal::SideBarWidget *SideBar::insertSideBarWidget(int position, 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);
|
Internal::SideBarWidget *item = new Internal::SideBarWidget(this, id);
|
||||||
connect(item, SIGNAL(splitMe()), this, SLOT(splitSubWidget()));
|
connect(item, SIGNAL(splitMe()), this, SLOT(splitSubWidget()));
|
||||||
connect(item, SIGNAL(closeMe()), this, SLOT(closeSubWidget()));
|
connect(item, SIGNAL(closeMe()), this, SLOT(closeSubWidget()));
|
||||||
connect(item, SIGNAL(currentWidgetChanged()), this, SLOT(updateWidgets()));
|
connect(item, SIGNAL(currentWidgetChanged()), this, SLOT(updateWidgets()));
|
||||||
insertWidget(position, item);
|
insertWidget(position, item);
|
||||||
d->m_widgets.insert(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();
|
updateWidgets();
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@@ -235,6 +242,11 @@ void SideBar::closeSubWidget()
|
|||||||
if (!widget)
|
if (!widget)
|
||||||
return;
|
return;
|
||||||
removeSideBarWidget(widget);
|
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();
|
updateWidgets();
|
||||||
} else {
|
} else {
|
||||||
if (d->m_closeWhenEmpty) {
|
if (d->m_closeWhenEmpty) {
|
||||||
|
@@ -80,11 +80,11 @@ SideBarWidget::SideBarWidget(SideBar *sideBar, const QString &id)
|
|||||||
connect(m_splitAction, SIGNAL(triggered()), this, SIGNAL(splitMe()));
|
connect(m_splitAction, SIGNAL(triggered()), this, SIGNAL(splitMe()));
|
||||||
m_toolbar->addAction(m_splitAction);
|
m_toolbar->addAction(m_splitAction);
|
||||||
|
|
||||||
QAction *closeAction = new QAction(tr("Close"), m_toolbar);
|
m_closeAction = new QAction(tr("Close"), m_toolbar);
|
||||||
closeAction->setToolTip(tr("Close"));
|
m_closeAction->setToolTip(tr("Close"));
|
||||||
closeAction->setIcon(QIcon(QLatin1String(Constants::ICON_BUTTON_CLOSE)));
|
m_closeAction->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_BOTTOM)));
|
||||||
connect(closeAction, SIGNAL(triggered()), this, SIGNAL(closeMe()));
|
connect(m_closeAction, SIGNAL(triggered()), this, SIGNAL(closeMe()));
|
||||||
m_toolbar->addAction(closeAction);
|
m_toolbar->addAction(m_closeAction);
|
||||||
|
|
||||||
QVBoxLayout *lay = new QVBoxLayout();
|
QVBoxLayout *lay = new QVBoxLayout();
|
||||||
lay->setMargin(0);
|
lay->setMargin(0);
|
||||||
@@ -212,5 +212,10 @@ Command *SideBarWidget::command(const QString &title) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SideBarWidget::setCloseIcon(const QIcon &icon)
|
||||||
|
{
|
||||||
|
m_closeAction->setIcon(icon);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -64,6 +64,8 @@ public:
|
|||||||
|
|
||||||
Command *command(const QString &title) const;
|
Command *command(const QString &title) const;
|
||||||
|
|
||||||
|
void setCloseIcon(const QIcon &icon);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void splitMe();
|
void splitMe();
|
||||||
void closeMe();
|
void closeMe();
|
||||||
@@ -77,6 +79,7 @@ private:
|
|||||||
SideBarItem *m_currentItem;
|
SideBarItem *m_currentItem;
|
||||||
QToolBar *m_toolbar;
|
QToolBar *m_toolbar;
|
||||||
QAction *m_splitAction;
|
QAction *m_splitAction;
|
||||||
|
QAction *m_closeAction;
|
||||||
QList<QAction *> m_addedToolBarActions;
|
QList<QAction *> m_addedToolBarActions;
|
||||||
SideBar *m_sideBar;
|
SideBar *m_sideBar;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user