Fix issue with translation of tool groups.
This commit is contained in:
parent
27e07d16f2
commit
717225ce03
|
@ -28,19 +28,41 @@
|
|||
#include "vtoolbuttonpopup.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QEvent>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolButtonPopup::VToolButtonPopup(QWidget *parent)
|
||||
: QToolButton(parent)
|
||||
{
|
||||
setPopupMode(QToolButton::MenuButtonPopup);
|
||||
QObject::connect(this, &QToolButton::triggered, this,
|
||||
[this](QAction *action)
|
||||
QObject::connect(this, &QToolButton::triggered, this, [this](QAction *action) { setDefaultAction(action); });
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolButtonPopup::SetToolGroupTooltip(const QString &toolGroupTooltip)
|
||||
{
|
||||
m_toolGroupTooltip = toolGroupTooltip;
|
||||
CorrectToolTip();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VToolButtonPopup::event(QEvent *event) -> bool
|
||||
{
|
||||
if (event->type() == QEvent::ToolTipChange && !handlingToolTipChange)
|
||||
{
|
||||
setDefaultAction(action);
|
||||
handlingToolTipChange = true;
|
||||
CorrectToolTip();
|
||||
handlingToolTipChange = false;
|
||||
}
|
||||
|
||||
return QToolButton::event(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolButtonPopup::CorrectToolTip()
|
||||
{
|
||||
if (!m_toolGroupTooltip.isEmpty())
|
||||
{
|
||||
setToolTip(m_toolGroupTooltip);
|
||||
setToolTip(QStringLiteral("<b><i>%1</i></b>:<br/>%2").arg(m_toolGroupTooltip, toolTip()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -45,10 +45,16 @@ public:
|
|||
auto GetToolGroupTooltip() const -> QString;
|
||||
void SetToolGroupTooltip(const QString &toolGroupTooltip);
|
||||
|
||||
protected:
|
||||
auto event(QEvent *event) -> bool override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(VToolButtonPopup) // NOLINT
|
||||
|
||||
QString m_toolGroupTooltip{};
|
||||
bool handlingToolTipChange{false};
|
||||
|
||||
void CorrectToolTip();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -57,10 +63,4 @@ inline auto VToolButtonPopup::GetToolGroupTooltip() const -> QString
|
|||
return m_toolGroupTooltip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void VToolButtonPopup::SetToolGroupTooltip(const QString &toolGroupTooltip)
|
||||
{
|
||||
m_toolGroupTooltip = toolGroupTooltip;
|
||||
}
|
||||
|
||||
#endif // VTOOLBUTTONPOPUP_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user