QTabBar/Widget: use pmf-style connects

Use pmf-style connections instead old string-based ones.

Change-Id: I592a8918f8a06315db2e08da8d4c7fa8b52aa6f8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Christian Ehrlicher 2023-11-22 20:32:50 +01:00
parent 11d8200249
commit 323cf718f6
5 changed files with 29 additions and 30 deletions

View File

@ -366,12 +366,14 @@ void QTabBarPrivate::init()
leftB = new QToolButton(q);
leftB->setObjectName(u"ScrollLeftButton"_s);
leftB->setAutoRepeat(true);
QObject::connect(leftB, SIGNAL(clicked()), q, SLOT(_q_scrollTabs()));
QObjectPrivate::connect(leftB, &QToolButton::clicked,
this, &QTabBarPrivate::scrollTabs);
leftB->hide();
rightB = new QToolButton(q);
rightB->setObjectName(u"ScrollRightButton"_s);
rightB->setAutoRepeat(true);
QObject::connect(rightB, SIGNAL(clicked()), q, SLOT(_q_scrollTabs()));
QObjectPrivate::connect(rightB, &QToolButton::clicked,
this, &QTabBarPrivate::scrollTabs);
rightB->hide();
#ifdef QT_KEYPAD_NAVIGATION
if (QApplicationPrivate::keypadNavigationEnabled()) {
@ -765,7 +767,7 @@ void QTabBarPrivate::autoHideTabs()
q->setVisible(q->count() > 1);
}
void QTabBarPrivate::_q_closeTab()
void QTabBarPrivate::closeTab()
{
Q_Q(QTabBar);
QObject *object = q->sender();
@ -788,7 +790,7 @@ void QTabBarPrivate::_q_closeTab()
emit q->tabCloseRequested(tabToClose);
}
void QTabBarPrivate::_q_scrollTabs()
void QTabBarPrivate::scrollTabs()
{
Q_Q(QTabBar);
const QObject *sender = q->sender();
@ -973,7 +975,8 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)
initStyleOption(&opt, index);
ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, this);
QAbstractButton *closeButton = new CloseButton(this);
connect(closeButton, SIGNAL(clicked()), this, SLOT(_q_closeTab()));
QObjectPrivate::connect(closeButton, &CloseButton::clicked,
d, &QTabBarPrivate::closeTab);
setTabButton(index, closeSide, closeButton);
}
@ -2577,7 +2580,8 @@ void QTabBar::setTabsClosable(bool closable)
continue;
newButtons = true;
QAbstractButton *closeButton = new CloseButton(this);
connect(closeButton, SIGNAL(clicked()), this, SLOT(_q_closeTab()));
QObjectPrivate::connect(closeButton, &CloseButton::clicked,
d, &QTabBarPrivate::closeTab);
setTabButton(i, closeSide, closeButton);
}
if (newButtons)

View File

@ -185,8 +185,6 @@ protected:
private:
Q_DISABLE_COPY(QTabBar)
Q_DECLARE_PRIVATE(QTabBar)
Q_PRIVATE_SLOT(d_func(), void _q_scrollTabs())
Q_PRIVATE_SLOT(d_func(), void _q_closeTab())
};
QT_END_NAMESPACE

View File

@ -187,8 +187,8 @@ public:
inline bool validIndex(int index) const { return index >= 0 && index < tabList.size(); }
void setCurrentNextEnabledIndex(int offset);
void _q_scrollTabs();
void _q_closeTab();
void scrollTabs();
void closeTab();
void moveTab(int index, int offset);
void moveTabFinished(int index);

View File

@ -156,9 +156,9 @@ public:
QTabWidgetPrivate();
~QTabWidgetPrivate();
void updateTabBarPosition();
void _q_showTab(int);
void _q_removeTab(int);
void _q_tabMoved(int from, int to);
void showTab(int);
void removeTab(int);
void tabMoved(int from, int to);
void init();
bool isAutoHidden() const
{
@ -197,7 +197,7 @@ void QTabWidgetPrivate::init()
// hack so that QMacStyle::layoutSpacing() can detect tab widget pages
stack->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::TabWidget));
QObject::connect(stack, SIGNAL(widgetRemoved(int)), q, SLOT(_q_removeTab(int)));
QObjectPrivate::connect(stack, &QStackedWidget::widgetRemoved, this, &QTabWidgetPrivate::removeTab);
QTabBar *tabBar = new QTabBar(q);
tabBar->setObjectName("qt_tabwidget_tabbar"_L1);
tabBar->setDrawBase(false);
@ -720,17 +720,17 @@ void QTabWidget::setTabBar(QTabBar* tb)
delete d->tabs;
d->tabs = tb;
setFocusProxy(d->tabs);
connect(d->tabs, SIGNAL(currentChanged(int)),
this, SLOT(_q_showTab(int)));
connect(d->tabs, SIGNAL(tabMoved(int,int)),
this, SLOT(_q_tabMoved(int,int)));
connect(d->tabs, SIGNAL(tabBarClicked(int)),
this, SIGNAL(tabBarClicked(int)));
connect(d->tabs, SIGNAL(tabBarDoubleClicked(int)),
this, SIGNAL(tabBarDoubleClicked(int)));
QObjectPrivate::connect(d->tabs, &QTabBar::currentChanged,
d, &QTabWidgetPrivate::showTab);
QObjectPrivate::connect(d->tabs, &QTabBar::tabMoved,
d, &QTabWidgetPrivate::tabMoved);
connect(d->tabs, &QTabBar::tabBarClicked,
this, &QTabWidget::tabBarClicked);
connect(d->tabs, &QTabBar::tabBarDoubleClicked,
this, &QTabWidget::tabBarDoubleClicked);
if (d->tabs->tabsClosable())
connect(d->tabs, SIGNAL(tabCloseRequested(int)),
this, SIGNAL(tabCloseRequested(int)));
connect(d->tabs, &QTabBar::tabCloseRequested,
this, &QTabWidget::tabCloseRequested);
tb->setExpanding(!documentMode());
setUpLayout();
}
@ -752,7 +752,7 @@ QTabBar* QTabWidget::tabBar() const
sized.
*/
void QTabWidgetPrivate::_q_showTab(int index)
void QTabWidgetPrivate::showTab(int index)
{
Q_Q(QTabWidget);
if (index < stack->count() && index >= 0)
@ -760,7 +760,7 @@ void QTabWidgetPrivate::_q_showTab(int index)
emit q->currentChanged(index);
}
void QTabWidgetPrivate::_q_removeTab(int index)
void QTabWidgetPrivate::removeTab(int index)
{
Q_Q(QTabWidget);
tabs->removeTab(index);
@ -768,7 +768,7 @@ void QTabWidgetPrivate::_q_removeTab(int index)
q->tabRemoved(index);
}
void QTabWidgetPrivate::_q_tabMoved(int from, int to)
void QTabWidgetPrivate::tabMoved(int from, int to)
{
const QSignalBlocker blocker(stack);
QWidget *w = stack->widget(from);

View File

@ -141,9 +141,6 @@ protected:
private:
Q_DECLARE_PRIVATE(QTabWidget)
Q_DISABLE_COPY(QTabWidget)
Q_PRIVATE_SLOT(d_func(), void _q_showTab(int))
Q_PRIVATE_SLOT(d_func(), void _q_removeTab(int))
Q_PRIVATE_SLOT(d_func(), void _q_tabMoved(int, int))
void setUpLayout(bool = false);
};