Some finalizations for tab bar.
This commit is contained in:
parent
fe0614ad8c
commit
5713b3015d
@ -21,7 +21,7 @@ TabBar::~TabBar() {
|
|||||||
void TabBar::setTabType(int index, const TabBar::TabType &type) {
|
void TabBar::setTabType(int index, const TabBar::TabType &type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TabBar::Closable: {
|
case TabBar::Closable: {
|
||||||
QToolButton *close_button = new QToolButton();
|
QToolButton *close_button = new QToolButton(this);
|
||||||
|
|
||||||
close_button->setIcon(IconThemeFactory::instance()->fromTheme("application-exit"));
|
close_button->setIcon(IconThemeFactory::instance()->fromTheme("application-exit"));
|
||||||
close_button->setToolTip(tr("Close this tab."));
|
close_button->setToolTip(tr("Close this tab."));
|
||||||
@ -29,6 +29,7 @@ void TabBar::setTabType(int index, const TabBar::TabType &type) {
|
|||||||
close_button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
close_button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
close_button->setFixedSize(iconSize());
|
close_button->setFixedSize(iconSize());
|
||||||
|
|
||||||
|
// Close underlying tab when button is clicked.
|
||||||
connect(close_button, SIGNAL(clicked()),
|
connect(close_button, SIGNAL(clicked()),
|
||||||
this, SLOT(closeTabViaButton()));
|
this, SLOT(closeTabViaButton()));
|
||||||
|
|
||||||
@ -48,9 +49,9 @@ void TabBar::setTabType(int index, const TabBar::TabType &type) {
|
|||||||
|
|
||||||
void TabBar::closeTabViaButton() {
|
void TabBar::closeTabViaButton() {
|
||||||
QToolButton *close_button = qobject_cast<QToolButton*>(sender());
|
QToolButton *close_button = qobject_cast<QToolButton*>(sender());
|
||||||
QTabBar::ButtonPosition button_position = (ButtonPosition) style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition,
|
QTabBar::ButtonPosition button_position = static_cast<ButtonPosition>(style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition,
|
||||||
0,
|
0,
|
||||||
this);;
|
this));
|
||||||
|
|
||||||
if (close_button != NULL) {
|
if (close_button != NULL) {
|
||||||
// Find index of tab for this close button.
|
// Find index of tab for this close button.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user