forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix tooltips for qopengl based wglwidgets
- Loading branch information
Showing
6 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "widget/tooltipqopengl.h" | ||
|
||
#include <QStyle> | ||
#include <QTimer> | ||
#include <QToolTip> | ||
|
||
ToolTipQOpenGL::ToolTipQOpenGL() { | ||
m_timer = new QTimer(); | ||
m_timer->setSingleShot(true); | ||
m_timer->callOnTimeout(this, [this]() { | ||
if (m_widget) { | ||
QToolTip::showText(m_pos, m_widget->toolTip(), m_widget); | ||
} | ||
}); | ||
} | ||
|
||
ToolTipQOpenGL::~ToolTipQOpenGL() { | ||
delete m_timer; | ||
} | ||
|
||
ToolTipQOpenGL* ToolTipQOpenGL::singleton() { | ||
static ToolTipQOpenGL* instance = new ToolTipQOpenGL(); | ||
return instance; | ||
} | ||
|
||
void ToolTipQOpenGL::setActive(bool active) { | ||
m_active = active; | ||
if (!m_active) { | ||
m_timer->stop(); | ||
} | ||
} | ||
|
||
void ToolTipQOpenGL::start(WGLWidget* widget, QPoint pos) { | ||
if (m_active) { | ||
m_widget = widget; | ||
m_pos = pos; | ||
m_timer->start(widget->style()->styleHint(QStyle::SH_ToolTip_WakeUpDelay)); | ||
} | ||
} | ||
|
||
void ToolTipQOpenGL::stop(WGLWidget* widget) { | ||
m_timer->stop(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <QStyle> | ||
#include <QTimer> | ||
#include <QToolTip> | ||
|
||
#include "widget/wglwidget.h" | ||
|
||
// Tooltips don't work for the qopengl-based WGLWidget. This | ||
// singleton mimics the standard tooltip behaviour for them. | ||
class ToolTipQOpenGL : public QObject { | ||
bool m_active{true}; | ||
QTimer* m_timer{}; | ||
QPoint m_pos{}; | ||
WGLWidget* m_widget{}; | ||
ToolTipQOpenGL(); | ||
|
||
public: | ||
~ToolTipQOpenGL(); | ||
static ToolTipQOpenGL* singleton(); | ||
void setActive(bool active); | ||
void start(WGLWidget* widget, QPoint pos); | ||
void stop(WGLWidget* widget); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters