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