Resolve TODO regarding QCursor::pos()
This commit is contained in:
parent
793bd00cb6
commit
ee9ec87386
|
@ -168,7 +168,6 @@ void ButtonOverlay::enableInfoButton(const QPixmap &pixmap, const QString &infoT
|
||||||
if (!infoButton) {
|
if (!infoButton) {
|
||||||
m_infoButtonOrAction = infoButton = new IconButton;
|
m_infoButtonOrAction = infoButton = new IconButton;
|
||||||
infoButton->setGeometry(QRect(QPoint(), IconButton::defaultPixmapSize));
|
infoButton->setGeometry(QRect(QPoint(), IconButton::defaultPixmapSize));
|
||||||
QObject::connect(infoButton, &IconButton::clicked, std::bind(&ButtonOverlay::showInfo, this));
|
|
||||||
if (m_clearButton) {
|
if (m_clearButton) {
|
||||||
m_buttonLayout->insertWidget(m_buttonLayout->count() - 2, infoButton);
|
m_buttonLayout->insertWidget(m_buttonLayout->count() - 2, infoButton);
|
||||||
} else {
|
} else {
|
||||||
|
@ -382,18 +381,23 @@ bool ButtonOverlay::isCleared() const
|
||||||
*
|
*
|
||||||
* This method is called when the info button is clicked.
|
* This method is called when the info button is clicked.
|
||||||
*
|
*
|
||||||
* \todo Don't use QCursor::pos() here because it will not work under Wayland.
|
* \remarks
|
||||||
|
* This function avoids using QCursor::pos() because it is problematic to use under Wayland. For the action case it seems not
|
||||||
|
* possible to avoid it because the position of QLineEditIconButton used by QLineEdit is not exposed.
|
||||||
*/
|
*/
|
||||||
void ButtonOverlay::showInfo()
|
void ButtonOverlay::showInfo()
|
||||||
{
|
{
|
||||||
if (!isUsingCustomLayout()) {
|
if (auto const *const le = lineEditForWidget()) {
|
||||||
if (auto *const infoAction = static_cast<QAction *>(m_infoButtonOrAction)) {
|
if (auto *const infoAction = static_cast<QAction *>(m_infoButtonOrAction)) {
|
||||||
QToolTip::showText(QCursor::pos(), infoAction->toolTip(), m_widget);
|
const auto pos = QCursor::pos();
|
||||||
|
if (!pos.isNull()) {
|
||||||
|
QToolTip::showText(pos, infoAction->toolTip(), m_widget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (auto *const infoButton = static_cast<IconButton *>(m_infoButtonOrAction)) {
|
if (auto *const infoButton = static_cast<IconButton *>(m_infoButtonOrAction)) {
|
||||||
QToolTip::showText(QCursor::pos(), infoButton->toolTip(), infoButton);
|
QToolTip::showText(infoButton->mapToGlobal(infoButton->rect().center()), infoButton->toolTip(), infoButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue