Skip to content
Permalink
Browse files

Add QOverload implementation for Qt < 5.7

  • Loading branch information...
tatokis committed Sep 5, 2019
1 parent bdba530 commit 050231f2560fdfa25668cea1a57301dc79b944d4
Showing with 24 additions and 11 deletions.
  1. +1 −0 src/gui/CMakeLists.txt
  2. +9 −8 src/gui/animsettingdialog.cpp
  3. +2 −1 src/gui/kperfwidget.cpp
  4. +3 −2 src/gui/mperfwidget.cpp
  5. +9 −0 src/gui/qoverloadlegacy.h
@@ -199,6 +199,7 @@ if (MACOS OR LINUX)
modeselectdialog.h
mperfwidget.h
nowheelcombobox.h
qoverloadlegacy.h
rebindwidget.h
rlistwidget.h
settingswidget.h
@@ -7,6 +7,7 @@
#include "ui_animsettingdialog.h"
#include "colorbutton.h"
#include "gradientbutton.h"
#include "qoverloadlegacy.h"

// QDial shows angles upside down (180° = top, 0° = bottom), so flip it
static inline int angleFlip(int angle){
@@ -70,7 +71,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
((QSpinBox*)widget)->setSuffix(postfix);
postfix = "";
}
connect((QSpinBox*)widget, QOverload<int>::of(&QSpinBox::valueChanged), [=] () {
connect((QSpinBox*)widget, OVERLOAD_PTR(int, QSpinBox, valueChanged), [=] () {
emit updateParam(param.name);
});
break;
@@ -84,7 +85,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
((QDoubleSpinBox*)widget)->setSuffix(postfix);
postfix = "";
}
connect((QDoubleSpinBox*)widget, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=] () {
connect((QDoubleSpinBox*)widget, OVERLOAD_PTR(double, QDoubleSpinBox, valueChanged), [=] () {
emit updateParam(param.name);
});
break;
@@ -181,7 +182,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
spinner->setSuffix("°");
spinner->setValue(value.toInt());
angleSpinners[param.name] = spinner;
connect(spinner, QOverload<int>::of(&QSpinBox::valueChanged), [=] () {
connect(spinner, OVERLOAD_PTR(int, QSpinBox, valueChanged), [=] () {
emit angleSpinnerChanged(param.name);
});
ui->settingsGrid->addWidget(spinner, row, 4);
@@ -250,7 +251,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
combo->setCurrentIndex(selected);
ui->settingsGrid->addWidget(combo, row, 5, 1, 2);
settingWidgets["kpmode"] = combo;
connect(combo, QOverload<int>::of(&QComboBox::activated), [=] () {
connect(combo, OVERLOAD_PTR(int, QComboBox, activated), [=] () {
emit updateParam("kpmode");
});
row++;
@@ -287,7 +288,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
spinner->setMaximum(1000000);
spinner->setValue(anim->parameter("stop").toInt());
settingWidgets["stop"] = spinner;
connect(spinner, QOverload<int>::of(&QSpinBox::valueChanged), [=] () {
connect(spinner, OVERLOAD_PTR(int, QSpinBox, valueChanged), [=] () {
emit updateParam("stop");
});
ui->timeGrid->addWidget(spinner, 4, 3);
@@ -299,7 +300,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
spinner->setMaximum(1000000);
spinner->setValue(anim->parameter("kpstop").toInt());
settingWidgets["kpstop"] = spinner;
connect(spinner, QOverload<int>::of(&QSpinBox::valueChanged), [=] () {
connect(spinner, OVERLOAD_PTR(int, QSpinBox, valueChanged), [=] () {
emit updateParam("kpstop");
});
ui->timeGrid->addWidget(spinner, 12, 3);
@@ -334,7 +335,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
else
spinner->setValue(stop);
settingWidgets["stop"] = spinner;
connect(spinner, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=] () {
connect(spinner, OVERLOAD_PTR(double, QDoubleSpinBox, valueChanged), [=] () {
emit updateParam("stop");
});
ui->timeGrid->addWidget(spinner, 4, 3);
@@ -350,7 +351,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
else
spinner->setValue(kpstop);
settingWidgets["kpstop"] = spinner;
connect(spinner, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=] () {
connect(spinner, OVERLOAD_PTR(double, QDoubleSpinBox, valueChanged), [=] () {
emit updateParam("kpstop");
});
ui->timeGrid->addWidget(spinner, 12, 3);
@@ -2,6 +2,7 @@
#include "ui_kperfwidget.h"
#include "modeselectdialog.h"
#include <cmath>
#include "qoverloadlegacy.h"

///
/// \brief KPerfWidget::KPerfWidget sets up the UI for Keyboard Performace panel
@@ -40,7 +41,7 @@ KPerfWidget::KPerfWidget(QWidget *parent) :
});
}
if(indicators[i].hwEnable){
connect(indicators[i].hwEnable, QOverload<int>::of(&QComboBox::activated), [=] () {
connect(indicators[i].hwEnable, OVERLOAD_PTR(int, QComboBox, activated), [=] () {
emit uiUpdated(i);
});
}
@@ -2,6 +2,7 @@
#include "ui_mperfwidget.h"
#include "modeselectdialog.h"
#include <cmath>
#include "qoverloadlegacy.h"

const static QString xyLinkPath = "UI/DPI/UnlinkXY";

@@ -44,10 +45,10 @@ MPerfWidget::MPerfWidget(QWidget *parent) :
connect(stages[i].ySlider, &QSlider::valueChanged, [=] () {
emit sliderYMoved(i);
});
connect(stages[i].xBox, QOverload<int>::of(&QSpinBox::valueChanged), [=] () {
connect(stages[i].xBox, OVERLOAD_PTR(int, QSpinBox, valueChanged), [=] () {
emit boxXChanged(i);
});
connect(stages[i].yBox, QOverload<int>::of(&QSpinBox::valueChanged), [=] () {
connect(stages[i].yBox, OVERLOAD_PTR(int, QSpinBox, valueChanged), [=] () {
emit boxYChanged(i);
});
if(stages[i].enableCheck)
@@ -0,0 +1,9 @@
#ifndef QOVERLOADLEGACY_H
#define QOVERLOADLEGACY_H
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
#include <QtGlobal>
#define OVERLOAD_PTR(type, cl, func) (QOverload<type>::of(&cl::func))
#else
#define OVERLOAD_PTR(type, cl, func) (static_cast<void (cl::*)(type)>(&cl::func))
#endif
#endif // QOVERLOADLEGACY_H

0 comments on commit 050231f

Please sign in to comment.
You can’t perform that action at this time.