Disable trackslider popup on macos
This commit is contained in:
@@ -32,18 +32,24 @@
|
|||||||
|
|
||||||
#include "core/timeconstants.h"
|
#include "core/timeconstants.h"
|
||||||
#include "core/utilities.h"
|
#include "core/utilities.h"
|
||||||
#include "tracksliderpopup.h"
|
#ifndef Q_OS_MACOS
|
||||||
|
# include "tracksliderpopup.h"
|
||||||
|
#endif
|
||||||
#include "tracksliderslider.h"
|
#include "tracksliderslider.h"
|
||||||
|
|
||||||
TrackSliderSlider::TrackSliderSlider(QWidget* parent)
|
TrackSliderSlider::TrackSliderSlider(QWidget* parent)
|
||||||
: QSlider(parent),
|
: QSlider(parent),
|
||||||
|
#ifndef Q_OS_MACOS
|
||||||
popup_(new TrackSliderPopup(window())),
|
popup_(new TrackSliderPopup(window())),
|
||||||
|
#endif
|
||||||
mouse_hover_seconds_(0) {
|
mouse_hover_seconds_(0) {
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
#ifndef Q_OS_MACOS
|
||||||
popup_->hide();
|
popup_->hide();
|
||||||
|
|
||||||
connect(this, SIGNAL(valueChanged(int)), SLOT(UpdateDeltaTime()));
|
connect(this, SIGNAL(valueChanged(int)), SLOT(UpdateDeltaTime()));
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackSliderSlider::mousePressEvent(QMouseEvent* e) {
|
void TrackSliderSlider::mousePressEvent(QMouseEvent* e) {
|
||||||
@@ -94,9 +100,11 @@ void TrackSliderSlider::mouseMoveEvent(QMouseEvent* e) {
|
|||||||
|
|
||||||
mouse_hover_seconds_ = QStyle::sliderValueFromPosition(minimum() / kMsecPerSec, maximum() / kMsecPerSec, e->x() - slider_length / 2 - slider_min + 1, slider_max - slider_min);
|
mouse_hover_seconds_ = QStyle::sliderValueFromPosition(minimum() / kMsecPerSec, maximum() / kMsecPerSec, e->x() - slider_length / 2 - slider_min + 1, slider_max - slider_min);
|
||||||
|
|
||||||
|
#ifndef Q_OS_MACOS
|
||||||
popup_->SetText(Utilities::PrettyTime(mouse_hover_seconds_));
|
popup_->SetText(Utilities::PrettyTime(mouse_hover_seconds_));
|
||||||
UpdateDeltaTime();
|
UpdateDeltaTime();
|
||||||
popup_->SetPopupPosition(mapTo(window(), QPoint(e->x(), rect().center().y())));
|
popup_->SetPopupPosition(mapTo(window(), QPoint(e->x(), rect().center().y())));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackSliderSlider::wheelEvent(QWheelEvent *e) {
|
void TrackSliderSlider::wheelEvent(QWheelEvent *e) {
|
||||||
@@ -111,18 +119,22 @@ void TrackSliderSlider::wheelEvent(QWheelEvent *e) {
|
|||||||
|
|
||||||
void TrackSliderSlider::enterEvent(QEvent* e) {
|
void TrackSliderSlider::enterEvent(QEvent* e) {
|
||||||
QSlider::enterEvent(e);
|
QSlider::enterEvent(e);
|
||||||
|
#ifndef Q_OS_MACOS
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
popup_->show();
|
popup_->show();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackSliderSlider::leaveEvent(QEvent* e) {
|
void TrackSliderSlider::leaveEvent(QEvent* e) {
|
||||||
QSlider::leaveEvent(e);
|
QSlider::leaveEvent(e);
|
||||||
|
#ifndef Q_OS_MACOS
|
||||||
// On some (but not all) systems, displaying the TrackSliderPopup
|
// On some (but not all) systems, displaying the TrackSliderPopup
|
||||||
// generates a leaveEvent. Ensure that this leaveEvent is genuine.
|
// generates a leaveEvent. Ensure that this leaveEvent is genuine.
|
||||||
if (!geometry().contains(mapFromGlobal(QCursor::pos()))) {
|
if (!geometry().contains(mapFromGlobal(QCursor::pos()))) {
|
||||||
popup_->hide();
|
popup_->hide();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackSliderSlider::keyPressEvent(QKeyEvent* event) {
|
void TrackSliderSlider::keyPressEvent(QKeyEvent* event) {
|
||||||
@@ -139,9 +151,11 @@ void TrackSliderSlider::keyPressEvent(QKeyEvent* event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef Q_OS_MACOS
|
||||||
void TrackSliderSlider::UpdateDeltaTime() {
|
void TrackSliderSlider::UpdateDeltaTime() {
|
||||||
if (popup_->isVisible()) {
|
if (popup_->isVisible()) {
|
||||||
int delta_seconds = mouse_hover_seconds_ - (value() / kMsecPerSec);
|
int delta_seconds = mouse_hover_seconds_ - (value() / kMsecPerSec);
|
||||||
popup_->SetSmallText(Utilities::PrettyTimeDelta(delta_seconds));
|
popup_->SetSmallText(Utilities::PrettyTimeDelta(delta_seconds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ class QEvent;
|
|||||||
class QKeyEvent;
|
class QKeyEvent;
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
class QWheelEvent;
|
class QWheelEvent;
|
||||||
|
#ifndef Q_OS_MACOS
|
||||||
class TrackSliderPopup;
|
class TrackSliderPopup;
|
||||||
|
#endif
|
||||||
|
|
||||||
// It's the slider inside the TrackSliderSlider
|
// It's the slider inside the TrackSliderSlider
|
||||||
class TrackSliderSlider : public QSlider {
|
class TrackSliderSlider : public QSlider {
|
||||||
@@ -42,7 +44,7 @@ class TrackSliderSlider : public QSlider {
|
|||||||
public:
|
public:
|
||||||
TrackSliderSlider(QWidget* parent = nullptr);
|
TrackSliderSlider(QWidget* parent = nullptr);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void SeekForward();
|
void SeekForward();
|
||||||
void SeekBackward();
|
void SeekBackward();
|
||||||
void Previous();
|
void Previous();
|
||||||
@@ -57,11 +59,15 @@ signals:
|
|||||||
void leaveEvent(QEvent*);
|
void leaveEvent(QEvent*);
|
||||||
void keyPressEvent(QKeyEvent* event);
|
void keyPressEvent(QKeyEvent* event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
#ifndef Q_OS_MACOS
|
||||||
void UpdateDeltaTime();
|
void UpdateDeltaTime();
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifndef Q_OS_MACOS
|
||||||
TrackSliderPopup* popup_;
|
TrackSliderPopup* popup_;
|
||||||
|
#endif
|
||||||
|
|
||||||
int mouse_hover_seconds_;
|
int mouse_hover_seconds_;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user