17#include "ui_GPUDisplayGUI.h"
20#include <QSignalBlocker>
31 std::lock_guard lock(mChannel.
mutex);
32 setWindowTitle(QString::fromStdString(mChannel.
windowName +
" GUI"));
34 connect(mUi->lineWidthSlider, &QSlider::valueChanged,
this, [
this](int32_t
value) {
35 mUpdate.lineWidth = value * 0.1f;
36 mUi->lineWidthValue->setNum(*mUpdate.lineWidth);
38 connect(&mTimer, &QTimer::timeout,
this, &GPUDisplayGUI::timerTick);
39 mTimer.start(std::chrono::milliseconds(10));
44void GPUDisplayGUI::timerTick()
46 std::unique_lock lock(mChannel.
mutex);
48 if (mUpdate.
empty()) {
49 mChannel.
stateUpdated.wait_for(lock, mChannel.
replyTimeout, [
this] { return !mChannel.displayProcessingCurrentUpdate || mChannel.stop; });
52 mChannel.
stateUpdated.wait_for(lock, mChannel.
replyTimeout, [
this] { return mChannel.state.appliedUpdate == mLastSentId || mChannel.stop; });
62 mState = mChannel.
state;
64 mLastAppliedId = mLastSentId;
70 auto& update = *mChannel.
update;
71 update.keys.insert(update.keys.end(), mUpdate.
keys.begin(), mUpdate.
keys.end());
76 mChannel.
update = std::move(mUpdate);
78 mChannel.
update->id = ++mLastSentId;
89void GPUDisplayGUI::applySettings()
91 const QSignalBlocker blocker(mUi->lineWidthSlider);
92 mUi->lineWidthSlider->setValue(std::lround(mState.
cfg.
cfgL.lineWidth * 10.f));
93 mUi->lineWidthValue->setNum(mState.
cfg.
cfgL.lineWidth);
98 setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
106 const int32_t
key = translateKey(
event);
108 QMainWindow::keyPressEvent(
event);
111 mUpdate.
keys.emplace_back(
key);
114int32_t GPUDisplayGUI::translateKey(
const QKeyEvent*
event)
116 switch (
event->key()) {
127 case Qt::Key_PageDown:
143 if (
event->key() >= Qt::Key_F1 &&
event->key() <= Qt::Key_F12) {
147 const QString text =
event->text();
148 if (text.size() == 1 && text[0].unicode() >= 32 && text[0].unicode() < 127) {
149 return text[0].unicode();
static constexpr int32_t KEY_F12
static constexpr int32_t KEY_END
static constexpr int32_t KEY_PAGEDOWN
static constexpr int32_t KEY_LEFT
static constexpr int32_t KEY_ENTER
static constexpr int32_t KEY_F1
static constexpr int32_t KEY_INSERT
static constexpr int32_t KEY_PAGEUP
static constexpr int32_t KEY_HOME
static constexpr int32_t KEY_UP
static constexpr int32_t KEY_DOWN
static constexpr int32_t KEY_RIGHT
static constexpr int32_t KEY_ESCAPE
~GPUDisplayGUI() override
void keyPressEvent(QKeyEvent *event) override
GPUDisplayGUI(GPUDisplayGUIChannel &channel, QWidget *parent=nullptr)
GLsizei const GLfloat * value
GPUSettingsDisplayLight cfgL
std::optional< float > lineWidth
std::vector< int32_t > keys
std::chrono::milliseconds replyTimeout
std::condition_variable stateUpdated
std::optional< Update > update