Merge remote-tracking branch 'fleischie/chore/small-compilation-improvements'

This commit is contained in:
Tasos Sahanidis
2025-08-11 14:34:35 +03:00
9 changed files with 58 additions and 10 deletions
+1
View File
@@ -73,6 +73,7 @@ find_package(Sanitizers)
include(CMakeDependentOption)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" CACHE STRING "Where to put binaries after compilation.")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE STRING "Where to put libraries after compilation.")
set(UDEV_RULE_DIRECTORY "/lib/udev/rules.d" CACHE STRING "Where to install the udev rule.")
+14 -3
View File
@@ -22,6 +22,13 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
ui(new Ui::AnimSettingDialog), stopCheck(nullptr), kpStopCheck(nullptr),
_anim(anim), lastDuration(1.0)
{
// Re-declare checkStateChanged() signal if Qt Version is below 6.7.0.
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void (QCheckBox::*checkStateChanged)(Qt::CheckState) = &QCheckBox::checkStateChanged;
#else // QT_VERSION < 6.7.0
void (QCheckBox::*checkStateChanged)(int) = &QCheckBox::stateChanged;
#endif
ui->setupUi(this);
setWindowTitle(anim->scriptName() + tr(" Animation"));
ui->animName->setText(anim->name());
@@ -58,7 +65,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
widget = new QCheckBox(param.prefix, this);
((QCheckBox*)widget)->setChecked(value.toBool());
colSpan = 4;
connect((QCheckBox*)widget, &QCheckBox::stateChanged, [=] () {
connect((QCheckBox*)widget, checkStateChanged, [=] () {
emit updateParam(param.name);
});
break;
@@ -223,7 +230,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
check->setChecked(anim->parameter("trigger").toBool());
ui->settingsGrid->addWidget(check, row, 3, 1, 4);
settingWidgets["trigger"] = check;
connect(check, &QCheckBox::stateChanged, [=] () {
connect(check, checkStateChanged, [=] () {
emit updateParam("trigger");
});
row++;
@@ -231,7 +238,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
check->setChecked(anim->parameter("kptrigger").toBool());
ui->settingsGrid->addWidget(check, row, 3, 1, 2);
settingWidgets["kptrigger"] = check;
connect(check, &QCheckBox::stateChanged, [=] () {
connect(check, checkStateChanged, [=] () {
emit updateParam("kptrigger");
});
// Add an option allowing the user to select keypress mode
@@ -526,6 +533,10 @@ void AnimSettingDialog::on_kpRepeatBox_valueChanged(double arg1){
updateParam("kprepeat");
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void AnimSettingDialog::on_kpReleaseBox_checkStateChanged(Qt::CheckState arg1){
#else // QT_VERSION < 6.7.0
void AnimSettingDialog::on_kpReleaseBox_stateChanged(int arg1){
#endif
updateParam("kprelease");
}
+4
View File
@@ -47,7 +47,11 @@ private slots:
void on_repeatBox_valueChanged(double arg1);
void on_kpDelayBox_valueChanged(double arg1);
void on_kpRepeatBox_valueChanged(double arg1);
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void on_kpReleaseBox_checkStateChanged(Qt::CheckState arg1);
#else // QT_VERSION < 6.7.0
void on_kpReleaseBox_stateChanged(int arg1);
#endif
};
#endif // ANIMSETTINGDIALOG_H
+4
View File
@@ -41,6 +41,10 @@ private:
CkbVersionNumber ckbVersion;
ushort productID;
FW();
// Explicit definition of copy and assignment operators to silence the compilation warnings.
FW(const FW& fw) : productID(fw.productID) {};
FW& operator=(const FW& other) { return *this; }
};
QMap<QString, FW> fwTable;
// SHA256 of last downloaded table (redundancy check)
+12 -2
View File
@@ -32,7 +32,11 @@ KbWidget::KbWidget(QWidget *parent, Kb *_device, XWindowDetector* windowDetector
connect(device, &Kb::profileAdded, this, &KbWidget::updateProfileList);
connect(device, &Kb::modeChanged, this, &KbWidget::modeChanged);
connect(device, &Kb::infoUpdated, this, &KbWidget::devUpdate);
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
connect(ui->batteryTrayBox, &QCheckBox::checkStateChanged, this, &KbWidget::batteryTrayBox_checkStateChanged);
#else // QT_VERSION < 6.7.0
connect(ui->batteryTrayBox, &QCheckBox::stateChanged, this, &KbWidget::batteryTrayBox_stateChanged);
#endif
connect(MainWindow::mainWindow, &MainWindow::switchToProfileCLI, this, &KbWidget::switchToProfile);
connect(MainWindow::mainWindow, &MainWindow::switchToModeCLI, this, &KbWidget::switchToMode);
connect(ui->modesList->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &KbWidget::currentSelectionChanged);
@@ -245,12 +249,18 @@ void KbWidget::currentSelectionChanged(const QModelIndex& current, const QModelI
device->setCurrentMode(mode);
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
#define CHECK_VALUE_UNCHECKED Qt::CheckState::Unchecked
void KbWidget::batteryTrayBox_checkStateChanged(Qt::CheckState state){
#else // QT_VERSION < 6.7.0
#define CHECK_VALUE_UNCHECKED 0
void KbWidget::batteryTrayBox_stateChanged(int state){
#endif
if(!device->features.contains("battery"))
return;
device->showBatteryIndicator = state > 0;
device->showBatteryIndicator = state != CHECK_VALUE_UNCHECKED;
device->needsSave();
if(state){
if(device->showBatteryIndicator){
device->batteryIcon->show();
} else {
device->batteryIcon->hide();
+4
View File
@@ -68,7 +68,11 @@ private slots:
void modeChanged();
void currentSelectionChanged(const QModelIndex& current, const QModelIndex& previous);
void on_modesList_customContextMenuRequested(const QPoint &pos);
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void batteryTrayBox_checkStateChanged(Qt::CheckState);
#else // QT_VERSION < 6.7.0
void batteryTrayBox_stateChanged(int state);
#endif
void devUpdate();
void updateBattery(uint battery, BatteryStatus charging);
+2 -3
View File
@@ -203,11 +203,10 @@ void KPerfWidget::uiUpdated(int index){
if(!perf)
return;
// Read HW/SW enable state
bool software;
i_hw hardware;
bool software = false;
i_hw hardware = KbPerf::NONE;
if(indicators[index].enable){
software = indicators[index].enable->isChecked();
hardware = KbPerf::NONE;
} else {
mode2Raw((HwMode)indicators[index].hwEnable->currentIndex(), software, hardware);
}
+8 -1
View File
@@ -8,6 +8,13 @@ const static QString xyLinkPath = "UI/DPI/UnlinkXY";
MPerfWidget::MPerfWidget(QWidget *parent) :
QWidget(parent), ui(new Ui::MPerfWidget), perf(nullptr), profile(nullptr), _xyLink(!CkbSettings::get(xyLinkPath).toBool()), colorLink(false), isSetting(false), isDarkCore(false) {
// Re-declare checkStateChanged() signal if Qt Version is below 6.7.0.
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void (QCheckBox::*checkStateChanged)(Qt::CheckState) = &QCheckBox::checkStateChanged;
#else // QT_VERSION < 6.7.0
void (QCheckBox::*checkStateChanged)(int) = &QCheckBox::stateChanged;
#endif
ui->setupUi(this);
ui->xyBox->setChecked(!_xyLink);
// Set up DPI stages
@@ -64,7 +71,7 @@ MPerfWidget::MPerfWidget(QWidget *parent) :
});
if(stages[i].enableCheck)
// Sniper has no enable
connect(stages[i].enableCheck, &QCheckBox::stateChanged, [=] () {
connect(stages[i].enableCheck, checkStateChanged, [=] () {
emit enableChanged(i);
});
// Hide indicator arrows
+9 -1
View File
@@ -377,7 +377,15 @@ void RebindWidget::setSelection(const QStringList& newSelection, bool applyPrevi
// If the daemon macro string contains even a single delay, then the we set the
// delay to "as typed" instead of "default"
QRegularExpression re("=\\d+");
if(re.match(macroData[0]).hasMatch())
// Use different match function depending on Qt version, 6.5.0 deprecates
// QRegularExpression::match() in favor of QRegularExpression::matchView() when
// using a QStringView parameter.
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
bool has_match = re.matchView(macroData[0]).hasMatch();
#else // QT_VERSION < 6.5.0
bool has_match = re.match(macroData[0]).hasMatch();
#endif
if(has_match)
ui->rb_delay_asTyped->setChecked(true);
else
ui->rb_delay_default->setChecked(true);