mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-15 20:31:36 +00:00
Switches to an alternative to window(), for older Qt support.
This commit is contained in:
parent
f7e13356c4
commit
b850183a1e
@ -1,6 +1,9 @@
|
|||||||
#include "scantargetwidget.h"
|
#include "scantargetwidget.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#include <QGuiApplication>
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -24,12 +27,16 @@ void ScanTargetWidget::paintGL() {
|
|||||||
requested_redraw_time_ = 0;
|
requested_redraw_time_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float newOutputScale = float(window()->screen()->devicePixelRatio());
|
// TODO: if Qt 5.14 can be guaranteed, just use window()->screen().
|
||||||
|
const auto screenNumber = QApplication::desktop()->screenNumber(this);
|
||||||
|
QScreen *const screen = QGuiApplication::screens()[screenNumber];
|
||||||
|
|
||||||
|
const float newOutputScale = float(screen->devicePixelRatio());
|
||||||
if(outputScale != newOutputScale) {
|
if(outputScale != newOutputScale) {
|
||||||
outputScale = newOutputScale;
|
outputScale = newOutputScale;
|
||||||
resize();
|
resize();
|
||||||
}
|
}
|
||||||
vsyncPredictor.set_frame_rate(float(window()->screen()->refreshRate()));
|
vsyncPredictor.set_frame_rate(float(screen->refreshRate()));
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
@ -115,6 +122,7 @@ void ScanTargetWidget::stop() {
|
|||||||
setDefaultClearColour();
|
setDefaultClearColour();
|
||||||
vsyncPredictor.pause();
|
vsyncPredictor.pause();
|
||||||
requested_redraw_time_ = 0;
|
requested_redraw_time_ = 0;
|
||||||
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScanTargetWidget::setDefaultClearColour() {
|
void ScanTargetWidget::setDefaultClearColour() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user