mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-12 00:00:25 +08:00
Helper function internal::setToolTip() to remove as many #ifndef QT_NO_TOOLTIP tests as possible to cleanup the code
This commit is contained in:
parent
505f14a601
commit
acb423872a
@ -207,9 +207,7 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
#endif
|
||||
_this->connect(TabsMenu, SIGNAL(aboutToShow()), SLOT(onTabsMenuAboutToShow()));
|
||||
TabsMenuButton->setMenu(TabsMenu);
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
TabsMenuButton->setToolTip(QObject::tr("List all tabs"));
|
||||
#endif
|
||||
internal::setToolTip(TabsMenuButton, QObject::tr("List all tabs"));
|
||||
TabsMenuButton->setSizePolicy(ButtonSizePolicy);
|
||||
TopLayout->addWidget(TabsMenuButton, 0);
|
||||
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
|
||||
@ -220,9 +218,7 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
UndockButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasUndockButton));
|
||||
UndockButton->setObjectName("undockButton");
|
||||
UndockButton->setAutoRaise(true);
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
UndockButton->setToolTip(QObject::tr("Detach Group"));
|
||||
#endif
|
||||
internal::setToolTip(UndockButton, QObject::tr("Detach Group"));
|
||||
setTitleBarButtonIcon(UndockButton, QStyle::SP_TitleBarNormalButton, ads::DockAreaUndockIcon);
|
||||
UndockButton->setSizePolicy(ButtonSizePolicy);
|
||||
TopLayout->addWidget(UndockButton, 0);
|
||||
@ -233,16 +229,14 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
CloseButton->setObjectName("closeButton");
|
||||
CloseButton->setAutoRaise(true);
|
||||
setTitleBarButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
if (testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
||||
{
|
||||
CloseButton->setToolTip(QObject::tr("Close Active Tab"));
|
||||
internal::setToolTip(CloseButton, QObject::tr("Close Active Tab"));
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseButton->setToolTip(QObject::tr("Close Group"));
|
||||
internal::setToolTip(CloseButton, QObject::tr("Close Group"));
|
||||
}
|
||||
#endif
|
||||
CloseButton->setSizePolicy(ButtonSizePolicy);
|
||||
CloseButton->setIconSize(QSize(16, 16));
|
||||
TopLayout->addWidget(CloseButton, 0);
|
||||
@ -342,9 +336,7 @@ void CDockAreaTitleBar::onTabsMenuAboutToShow()
|
||||
}
|
||||
auto Tab = d->TabBar->tab(i);
|
||||
QAction* Action = menu->addAction(Tab->icon(), Tab->text());
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
Action->setToolTip(Tab->toolTip());
|
||||
#endif
|
||||
internal::setToolTip(Action, Tab->toolTip());
|
||||
Action->setData(i);
|
||||
}
|
||||
|
||||
|
@ -184,9 +184,7 @@ void DockWidgetTabPrivate::createLayout()
|
||||
CloseButton->setIcon(CloseIcon);
|
||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
_this->onDockWidgetFeaturesChanged();
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
CloseButton->setToolTip(QObject::tr("Close Tab"));
|
||||
#endif
|
||||
internal::setToolTip(CloseButton, QObject::tr("Close Tab"));
|
||||
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
|
||||
|
||||
QFontMetrics fm(TitleLabel->font());
|
||||
@ -499,9 +497,7 @@ void CDockWidgetTab::setIcon(const QIcon& Icon)
|
||||
d->IconLabel = new QLabel();
|
||||
d->IconLabel->setAlignment(Qt::AlignVCenter);
|
||||
d->IconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
d->IconLabel->setToolTip(d->TitleLabel->toolTip());
|
||||
#endif
|
||||
internal::setToolTip(d->IconLabel, d->TitleLabel->toolTip());
|
||||
Layout->insertWidget(0, d->IconLabel, Qt::AlignVCenter);
|
||||
Layout->insertSpacing(1, qRound(1.5 * Layout->contentsMargins().left() / 2.0));
|
||||
}
|
||||
|
@ -88,9 +88,7 @@ CElidingLabel::CElidingLabel(const QString& text, QWidget* parent, Qt::WindowFla
|
||||
d(new ElidingLabelPrivate(this))
|
||||
{
|
||||
d->Text = text;
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
setToolTip(text);
|
||||
#endif
|
||||
internal::setToolTip(this, text);
|
||||
}
|
||||
|
||||
|
||||
@ -193,9 +191,7 @@ void CElidingLabel::setText(const QString &text)
|
||||
else
|
||||
{
|
||||
d->Text = text;
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
setToolTip( text );
|
||||
#endif
|
||||
internal::setToolTip(this, text);
|
||||
d->elideText(this->size().width());
|
||||
}
|
||||
}
|
||||
|
@ -215,6 +215,22 @@ void setFlag(T& Flags, typename T::enum_type flag, bool on = true)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for settings tooltips without cluttering the code with
|
||||
* tests for preprocessor macros
|
||||
*/
|
||||
template <class QObjectPtr>
|
||||
void setToolTip(QObjectPtr obj, const QString &tip)
|
||||
{
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
obj->setToolTip(tip);
|
||||
#else
|
||||
Q_UNUSED(obj);
|
||||
Q_UNUSED(tip);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ads
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user