Skip to content

Commit

Permalink
update qt version for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
pifopi committed Dec 10, 2024
1 parent 9696ab5 commit 5bcf725
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cpp-ci-serial-programs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
fail-fast: false
matrix:
os: [windows-2022, macos-13, ubuntu-24.04]
qt_version: ['5.12.12', '6.7.2']
qt_version: ['5.12.12', '6.8.1']
include:
- qt_version: '5.12.12'
qt_version_major: '5'
qt_modules: ''

- qt_version: '6.7.2'
- qt_version: '6.8.1'
qt_version_major: '6'
qt_modules: 'qtmultimedia qtserialport'

Expand All @@ -37,7 +37,7 @@ jobs:
if: startsWith(matrix.os, 'mac')
run: |
brew install opencv
- uses: jurplel/install-qt-action@v3
- uses: jurplel/install-qt-action@v4
with:
version: ${{ matrix.qt_version }}
modules: ${{ matrix.qt_modules }}
Expand Down
18 changes: 18 additions & 0 deletions Common/Qt/Options/BooleanCheckBoxWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ BooleanCheckBoxCellWidget::BooleanCheckBoxCellWidget(QWidget& parent, BooleanChe
m_box = new QCheckBox(this);
m_box->setChecked(m_value);
layout->addWidget(m_box);
#if QT_VERSION < 0x060700
connect(
m_box, &QCheckBox::stateChanged,
this, [this](int){
m_value = m_box->isChecked();
}
);
#else
connect(
m_box, &QCheckBox::checkStateChanged,
this, [this](Qt::CheckState){
m_value = m_box->isChecked();
}
);
#endif
value.add_listener(*this);
}
void BooleanCheckBoxCellWidget::update_value(){
Expand Down Expand Up @@ -81,12 +90,21 @@ BooleanCheckBoxOptionWidget::BooleanCheckBoxOptionWidget(QWidget& parent, Boolea
m_box = new QCheckBox(this);
m_box->setChecked(m_value);
layout->addWidget(m_box, 1);
#if QT_VERSION < 0x060700
connect(
m_box, &QCheckBox::stateChanged,
this, [this](int){
m_value = m_box->isChecked();
}
);
#else
connect(
m_box, &QCheckBox::checkStateChanged,
this, [this](int){
m_value = m_box->isChecked();
}
);
#endif
value.add_listener(*this);
}
void BooleanCheckBoxOptionWidget::update_value(){
Expand Down
9 changes: 5 additions & 4 deletions Common/Qt/TimeQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include <QDateTime>
#include <QTimeZone>
#include "Common/Cpp/Exceptions.h"
#include "Common/Cpp/PrettyPrint.h"
#include "TimeQt.h"
Expand Down Expand Up @@ -45,7 +46,7 @@ std::string to_utc_time_str(WallClock time){
#endif

int64_t secs_since_epoch = std::chrono::duration_cast<std::chrono::seconds>(time.time_since_epoch()).count();
QDateTime qdatetime = QDateTime::fromSecsSinceEpoch(secs_since_epoch, Qt::UTC);
QDateTime qdatetime = QDateTime::fromSecsSinceEpoch(secs_since_epoch, QTimeZone::utc());
QDate qdate = qdatetime.date();
QTime qtime = qdatetime.time();
std::string str;
Expand Down Expand Up @@ -142,7 +143,7 @@ WallClock parse_utc_time_str(const std::string& str){
throw ParseException("Invalid time.");
}

QDateTime qdatetime(qdate, qtime, Qt::UTC);
QDateTime qdatetime(qdate, qtime, QTimeZone::utc());
int64_t secs_since_epoch = qdatetime.toSecsSinceEpoch();

return WallClock{} + std::chrono::seconds(secs_since_epoch);
Expand All @@ -153,12 +154,12 @@ WallClock parse_utc_time_str(const std::string& str){
int64_t to_seconds_since_epoch(const DateTime& date){
QDate qdate(date.year, date.month, date.day);
QTime qtime(date.hour, date.minute, date.second);
QDateTime qdatetime(qdate, qtime, Qt::UTC);
QDateTime qdatetime(qdate, qtime, QTimeZone::utc());
int64_t secs_since_epoch = qdatetime.toSecsSinceEpoch();
return secs_since_epoch;
}
DateTime from_seconds_since_epoch(int64_t seconds_since_epoch){
QDateTime qdatetime = QDateTime::fromSecsSinceEpoch(seconds_since_epoch, Qt::UTC);
QDateTime qdatetime = QDateTime::fromSecsSinceEpoch(seconds_since_epoch, QTimeZone::utc());
QDate qdate = qdatetime.date();
QTime qtime = qdatetime.time();
return DateTime{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ void PreloadSettings::load(const JsonValue& json){
const std::string* dev_token = obj->get_string("DEVELOPER_TOKEN");
if (dev_token){
QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256);
hash.addData(dev_token->c_str(), (int)dev_token->size());
QByteArrayView dataView(dev_token->data(), dev_token->size());
hash.addData(dataView);
DEVELOPER_MODE = TOKENS.find(hash.result().toHex().toStdString()) != TOKENS.end();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ CommandRow::CommandRow(
m_overlay_boxes, &QCheckBox::clicked,
this, [this](bool checked){ m_session.set_enabled_boxes(checked); }
);
#if QT_VERSION < 0x060700
connect(
m_overlay_text, &QCheckBox::stateChanged,
this, [this](bool checked){ m_session.set_enabled_text(checked); }
Expand All @@ -93,6 +94,20 @@ CommandRow::CommandRow(
m_overlay_stats, &QCheckBox::stateChanged,
this, [this](bool checked){ m_session.set_enabled_stats(checked); }
);
#else
connect(
m_overlay_text, &QCheckBox::checkStateChanged,
this, [this](Qt::CheckState state){ m_session.set_enabled_text(state == Qt::Checked); }
);
connect(
m_overlay_log, &QCheckBox::checkStateChanged,
this, [this](Qt::CheckState state){ m_session.set_enabled_log(state == Qt::Checked); }
);
connect(
m_overlay_stats, &QCheckBox::checkStateChanged,
this, [this](Qt::CheckState state){ m_session.set_enabled_stats(state == Qt::Checked); }
);
#endif
connect(
m_load_profile_button, &QPushButton::clicked,
this, [this](bool) { emit load_profile(); }
Expand Down

0 comments on commit 5bcf725

Please sign in to comment.