qWarning() << "Translation resource" << resource << "not found";
// Qt translations
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QString tr_path(QLibraryInfo::path(QLibraryInfo::TranslationsPath));
+#else
QString tr_path(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+#endif
if (qt_translator_.load("qt_" + language, tr_path))
installTranslator(&qt_translator_);
#include <limits>
#include <QDebug>
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+#include <QRegularExpression>
+#endif
#include "logic.hpp"
#include "logicsegment.hpp"
continue;
QString ch_name = ch.name.toLower();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ ch_name = ch_name.replace(QRegularExpression("[-_.]"), " ");
+#else
ch_name = ch_name.replace(QRegExp("[-_.]"), " ");
+#endif
shared_ptr<data::SignalBase> match;
for (const shared_ptr<data::SignalBase>& s : session_.signalbases()) {
continue;
QString s_name = s->name().toLower();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ s_name = s_name.replace(QRegularExpression("[-_.]"), " ");
+#else
s_name = s_name.replace(QRegExp("[-_.]"), " ");
+#endif
if (s->logic_data() &&
((ch_name.contains(s_name)) || (s_name.contains(ch_name)))) {
for (const shared_ptr<Decoder>& decoder : stack_) {
settings.beginGroup("decoder" + QString::number(decoder_idx++));
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ settings.setValue("id", (const char *)decoder->get_srd_decoder()->id);
+#else
settings.setValue("id", decoder->get_srd_decoder()->id);
+#endif
settings.setValue("visible", decoder->visible());
// Save decoder options
QVariant value = settings.value("color");
// Workaround for Qt QColor serialization bug on OSX
- if ((QMetaType::Type)(value.type()) == QMetaType::QColor)
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ bool is_qcolor = (QMetaType::Type)(value.typeId()) == QMetaType::QColor;
+#else
+ bool is_qcolor = (QMetaType::Type)(value.type()) == QMetaType::QColor;
+#endif
+ if (is_qcolor)
set_color(value.value<QColor>());
else
set_color(QColor::fromRgba(value.value<uint32_t>()));
language_cb->setCurrentIndex(index);
}
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ connect(language_cb, SIGNAL(currentTextChanged(const QString&)),
+ this, SLOT(on_general_language_changed(const QString&)));
+#else
connect(language_cb, SIGNAL(currentIndexChanged(const QString&)),
this, SLOT(on_general_language_changed(const QString&)));
+#endif
general_layout->addRow(tr("User interface language"), language_cb);
// Theme combobox
g_variant_get_size(v));
settings.setValue("value", var_data);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ settings.setValue("type", (const char *)var_type_str);
+#else
settings.setValue("type", var_type_str);
+#endif
g_free(var_type_str);
}
void MainWindow::show_session_error(const QString text, const QString info_text)
{
// TODO Emulate noquote()
- qDebug() << "Notifying user of session error:" << info_text;
+ qDebug() << "Notifying user of session error: " << text << "; " << info_text;
QMessageBox msg;
msg.setText(text + "\n\n" + info_text);
session_selector_.setCornerWidget(static_tab_widget_, Qt::TopLeftCorner);
session_selector_.setTabsClosable(true);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ close_application_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q), this, SLOT(close()));
+ close_current_tab_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_W), this, SLOT(on_close_current_tab()));
+#else
close_application_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close()));
- close_application_shortcut_->setAutoRepeat(false);
-
close_current_tab_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this, SLOT(on_close_current_tab()));
+#endif
+ close_application_shortcut_->setAutoRepeat(false);
connect(new_session_button_, SIGNAL(clicked(bool)),
this, SLOT(on_new_session_clicked()));
layout_.addRow(&filter_buttons_bar_);
// Connect the check-box signal mapper
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ connect(&check_box_mapper_, SIGNAL(mappedObject(QObject*)),
+ this, SLOT(on_channel_checked(QObject*)));
+#else
connect(&check_box_mapper_, SIGNAL(mapped(QWidget*)),
this, SLOT(on_channel_checked(QWidget*)));
+#endif
}
void Channels::set_all_channels(bool set)
updating_channels_ = false;
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+void Channels::on_channel_checked(QObject *widget)
+#else
void Channels::on_channel_checked(QWidget *widget)
+#endif
{
if (updating_channels_)
return;
void showEvent(QShowEvent *event);
private Q_SLOTS:
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ void on_channel_checked(QObject *widget);
+#else
void on_channel_checked(QWidget *widget);
+#endif
void enable_all_channels();
void disable_all_channels();
action_open_->setText(tr("&Open..."));
action_open_->setIcon(QIcon::fromTheme("document-open",
QIcon(":/icons/document-open.png")));
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ action_open_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_O));
+#else
action_open_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
+#endif
connect(action_open_, SIGNAL(triggered(bool)),
this, SLOT(on_actionOpen_triggered()));
action_save_->setText(tr("&Save..."));
action_save_->setIcon(QIcon::fromTheme("document-save-as",
QIcon(":/icons/document-save-as.png")));
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ action_save_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S));
+#else
action_save_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
+#endif
connect(action_save_, SIGNAL(triggered(bool)),
this, SLOT(on_actionSave_triggered()));
action_save_selection_as_->setText(tr("Save Selected &Range As..."));
action_save_selection_as_->setIcon(QIcon::fromTheme("document-save-as",
QIcon(":/icons/document-save-as.png")));
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ action_save_selection_as_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R));
+#else
action_save_selection_as_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
+#endif
connect(action_save_selection_as_, SIGNAL(triggered(bool)),
this, SLOT(on_actionSaveSelectionAs_triggered()));
painter.setPen(palette().color(QPalette::HighlightedText));
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ painter.drawText(x, y, QString(QChar(ch)));
+#else
painter.drawText(x, y, QString(ch));
+#endif
x += charWidth_;
}
save_action_->setText(tr("&Save..."));
save_action_->setIcon(QIcon::fromTheme("document-save-as",
QIcon(":/icons/document-save-as.png")));
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ save_action_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S));
+#else
save_action_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
+#endif
connect(save_action_, SIGNAL(triggered(bool)),
this, SLOT(on_actionSave_triggered()));
save_action_->setText(tr("&Save..."));
save_action_->setIcon(QIcon::fromTheme("document-save-as",
QIcon(":/icons/document-save-as.png")));
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ save_action_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S));
+#else
save_action_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
+#endif
connect(save_action_, SIGNAL(triggered(bool)),
this, SLOT(on_actionSave_triggered()));
// https://txt2re.com/index-c++.php3?s=0.1V&1&-13
QString re1 = "([+-]?\\d*[\\.,]?\\d*)"; // Float value
QString re2 = "([a-zA-Z]*)"; // SI unit
- QRegExp regex(re1 + re2);
-
const QString text = conv_threshold_cb_->currentText();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QRegularExpression regex(re1 + re2);
+ if (!regex.match(text).hasMatch())
+ return; // String doesn't match the regex
+
+ QStringList tokens = regex.match(text).capturedTexts();
+#else
+ QRegExp regex(re1 + re2);
if (!regex.exactMatch(text))
return; // String doesn't match the regex
QStringList tokens = regex.capturedTexts();
+#endif
// For now, we simply assume that the unit is volt without modifiers
const double thr = tokens.at(1).toDouble();
QString re3 = "\\/"; // Forward slash, not captured
QString re4 = "([+-]?\\d*[\\.,]?\\d*)"; // Float value
QString re5 = "([a-zA-Z]*)"; // SI unit
+ const QString text = conv_threshold_cb_->currentText();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QRegularExpression regex(re1 + re2 + re3 + re4 + re5);
+
+ if (!regex.match(text).hasMatch())
+ return; // String doesn't match the regex
+
+ QStringList tokens = regex.match(text).capturedTexts();
+#else
QRegExp regex(re1 + re2 + re3 + re4 + re5);
- const QString text = conv_threshold_cb_->currentText();
if (!regex.exactMatch(text))
return; // String doesn't match the regex
QStringList tokens = regex.capturedTexts();
+#endif
// For now, we simply assume that the unit is volt without modifiers
const double low_thr = tokens.at(1).toDouble();
this, SLOT(on_decode_finished()));
connect(decode_signal_.get(), SIGNAL(channels_updated()),
this, SLOT(on_channels_updated()));
-
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ connect(&delete_mapper_, SIGNAL(mappedInt(int)),
+ this, SLOT(on_delete_decoder(int)));
+ connect(&show_hide_mapper_, SIGNAL(mappedInt(int)),
+ this, SLOT(on_show_hide_decoder(int)));
+ connect(&row_show_hide_mapper_, SIGNAL(mappedInt(int)),
+ this, SLOT(on_show_hide_row(int)));
+ connect(&class_show_hide_mapper_, SIGNAL(mappedObject(QObject*)),
+ this, SLOT(on_show_hide_class(QObject*)));
+#else
connect(&delete_mapper_, SIGNAL(mapped(int)),
this, SLOT(on_delete_decoder(int)));
connect(&show_hide_mapper_, SIGNAL(mapped(int)),
this, SLOT(on_show_hide_row(int)));
connect(&class_show_hide_mapper_, SIGNAL(mapped(QWidget*)),
this, SLOT(on_show_hide_class(QWidget*)));
+#endif
connect(&delayed_trace_updater_, SIGNAL(timeout()),
this, SLOT(on_delayed_trace_update()));
continue;
unsigned int y = get_row_y(&r);
- if ((event->x() > 0) && (event->x() <= (int)(ArrowSize + 3 + r.title_width)) &&
- (event->y() > (int)(y - (default_row_height_ / 2))) &&
- (event->y() <= (int)(y + (default_row_height_ / 2)))) {
-
+ bool need_anim = true;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ need_anim &= event->position().x() > 0;
+ need_anim &= event->position().x() <= (int)(ArrowSize + 3 + r.title_width);
+ need_anim &= event->position().y() > (int)(y - (default_row_height_ / 2));
+ need_anim &= event->position().y() <= (int)(y + (default_row_height_ / 2));
+#else
+ need_anim &= event->x() > 0;
+ need_anim &= event->x() <= (int)(ArrowSize + 3 + r.title_width);
+ need_anim &= event->y() > (int)(y - (default_row_height_ / 2));
+ need_anim &= event->y() <= (int)(y + (default_row_height_ / 2));
+#endif
+ if (need_anim) {
if (r.expanded) {
r.collapsing = true;
r.expanded = false;
QPalette header_palette = owner_->view()->palette();
QPalette selector_palette = owner_->view()->palette();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ if (GlobalSettings::current_theme_is_dark()) {
+ header_palette.setColor(QPalette::Window,
+ QColor(255, 255, 255, ExpansionAreaHeaderAlpha));
+ selector_palette.setColor(QPalette::Window,
+ QColor(255, 255, 255, ExpansionAreaAlpha));
+ } else {
+ header_palette.setColor(QPalette::Window,
+ QColor(0, 0, 0, ExpansionAreaHeaderAlpha));
+ selector_palette.setColor(QPalette::Window,
+ QColor(0, 0, 0, ExpansionAreaAlpha));
+ }
+#else
if (GlobalSettings::current_theme_is_dark()) {
header_palette.setColor(QPalette::Background,
QColor(255, 255, 255, ExpansionAreaHeaderAlpha));
selector_palette.setColor(QPalette::Background,
QColor(0, 0, 0, ExpansionAreaAlpha));
}
+#endif
const int w = m.boundingRect(r->decode_row->title()).width() + RowTitleMargin;
r->title_width = w;
owner_->row_item_appearance_changed(false, true);
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+void DecodeTrace::on_show_hide_class(QObject* sender)
+#else
void DecodeTrace::on_show_hide_class(QWidget* sender)
+#endif
{
void* ann_class_ptr = sender->property("ann_class_ptr").value<void*>();
assert(ann_class_ptr);
void on_show_hide_decoder(int index);
void on_show_hide_row(int row_id);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ void on_show_hide_class(QObject* sender);
+#else
void on_show_hide_class(QWidget* sender);
+#endif
void on_show_all_classes();
void on_hide_all_classes();
void on_row_container_resized(QWidget* sender);
void Ruler::mouseDoubleClickEvent(QMouseEvent *event)
{
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ hover_item_ = view_.add_flag(get_absolute_time_from_x_pos(event->pos().x()));
+#else
hover_item_ = view_.add_flag(get_absolute_time_from_x_pos(event->x()));
+#endif
}
void Ruler::paintEvent(QPaintEvent*)
QMenu *const menu = new QMenu(parent);
QAction *const ungroup = new QAction(tr("Ungroup"), this);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ ungroup->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U));
+#else
ungroup->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U));
+#endif
connect(ungroup, SIGNAL(triggered()), this, SLOT(on_ungroup()));
menu->addAction(ungroup);
else if (object == ruler_)
hover_point_ = mouse_event->pos();
else if (object == header_)
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ hover_point_ = QPoint(0, mouse_event->pos().y());
+#else
hover_point_ = QPoint(0, mouse_event->y());
+#endif
else
hover_point_ = QPoint(-1, -1);
bool Viewport::touch_event(QTouchEvent *event)
{
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QList<QEventPoint> touchPoints = event->points();
+#else
QList<QTouchEvent::TouchPoint> touchPoints = event->touchPoints();
+#endif
if (touchPoints.count() != 2) {
pinch_zoom_active_ = false;
return false;
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ if (event->device()->type() == QInputDevice::DeviceType::TouchPad) {
+ return false;
+ }
+
+ const QEventPoint &touchPoint0 = touchPoints.first();
+ const QEventPoint &touchPoint1 = touchPoints.last();
+
+ if (!pinch_zoom_active_ ||
+ (event->touchPointStates() & QEventPoint::Pressed)) {
+ pinch_offset0_ = (view_.offset() + view_.scale() * touchPoint0.position().x()).convert_to<double>();
+ pinch_offset1_ = (view_.offset() + view_.scale() * touchPoint1.position().x()).convert_to<double>();
+ pinch_zoom_active_ = true;
+ }
+
+ double w = touchPoint1.position().x() - touchPoint0.position().x();
+ if (abs(w) >= 1.0) {
+ const double scale =
+ fabs((pinch_offset1_ - pinch_offset0_) / w);
+ double offset = pinch_offset0_ - touchPoint0.position().x() * scale;
+ if (scale > 0)
+ view_.set_scale_offset(scale, offset);
+ }
+#else
if (event->device()->type() == QTouchDevice::TouchPad) {
return false;
}
if (scale > 0)
view_.set_scale_offset(scale, offset);
}
+#endif
if (event->touchPointStates() & Qt::TouchPointReleased) {
pinch_zoom_active_ = false;
} else {
// Update the mouse down fields so that continued
// dragging with the primary touch will work correctly
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ mouse_down_point_ = touchPoint0.position().toPoint();
+#else
mouse_down_point_ = touchPoint0.pos().toPoint();
+#endif
drag();
}
}
{
assert(event);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ if (event->buttons() & Qt::LeftButton)
+ view_.zoom(2.0, event->position().x());
+ else if (event->buttons() & Qt::RightButton)
+ view_.zoom(-2.0, event->position().x());
+#else
if (event->buttons() & Qt::LeftButton)
view_.zoom(2.0, event->x());
else if (event->buttons() & Qt::RightButton)
view_.zoom(-2.0, event->x());
+#endif
}
void Viewport::wheelEvent(QWheelEvent *event)
}
g_slist_free(li);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ connect(&mapper_, SIGNAL(mappedObject(QObject*)), this, SLOT(on_action(QObject*)));
+#else
connect(&mapper_, SIGNAL(mapped(QObject*)), this, SLOT(on_action(QObject*)));
+#endif
}
int DecoderMenu::decoder_name_cmp(const void *a, const void *b)
setDefaultAction(connect_action_);
setMinimumWidth(QFontMetrics(font()).averageCharWidth() * 24);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ connect(&mapper_, SIGNAL(mappedObject(QObject*)),
+ this, SLOT(on_action(QObject*)));
+#else
connect(&mapper_, SIGNAL(mapped(QObject*)),
this, SLOT(on_action(QObject*)));
+#endif
connect(&menu_, SIGNAL(hovered(QAction*)),
this, SLOT(on_menu_hovered(QAction*)));
connect(action, SIGNAL(triggered()), &mapper_, SLOT(map()));
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ connect(&mapper_, SIGNAL(mappedObject(QObject*)),
+ this, SLOT(on_action(QObject*)));
+#else
connect(&mapper_, SIGNAL(mapped(QObject*)),
this, SLOT(on_action(QObject*)));
+#endif
}
void ExportMenu::on_action(QObject *action)
size.setHeight(h);
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ int left, top, right, bottom;
+ getContentsMargins(&left, &top, &right, &bottom);
+ size += QSize(left + right, top + bottom);
+#else
size += QSize(2 * margin(), 2 * margin());
+#endif
return size;
}
connect(action, SIGNAL(triggered()), &mapper_, SLOT(map()));
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ connect(&mapper_, SIGNAL(mappedObject(QObject*)),
+ this, SLOT(on_action(QObject*)));
+#else
connect(&mapper_, SIGNAL(mapped(QObject*)),
this, SLOT(on_action(QObject*)));
+#endif
}
void ImportMenu::on_action(QObject *action)
#include <cassert>
#include <QApplication>
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+#include <QScreen>
+#else
#include <QDesktopWidget>
+#endif
#include <QLineEdit>
#include <QScrollBar>
#include <QStyle>
this, SIGNAL(value_changed()));
setLayout(&layout_);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ layout_.setContentsMargins(0, 0, 0, 0);
+#else
layout_.setMargin(0);
+#endif
layout_.addWidget(&list_);
layout_.addWidget(&value_);
#include "timestampspinbox.hpp"
#include <QLineEdit>
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+#include <QRegularExpression>
+#else
#include <QRegExp>
+#endif
namespace pv {
namespace widgets {
void TimestampSpinBox::on_editingFinished()
{
- QRegExp re(R"(\s*([-+]?)\s*([0-9]+\.?[0-9]*).*)");
+ static const auto re_pattern = R"(\s*([-+]?)\s*([0-9]+\.?[0-9]*).*)";
+
+ bool has_match;
+ QStringList captures;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QRegularExpression re(re_pattern);
+ has_match = re.match(text()).hasMatch();
+ if (has_match) {
+ captures = re.match(text()).capturedTexts();
+ }
+#else
+ QRegExp re(re_pattern);
+ has_match = re.exactMatch(text());
+ if (has_match) {
+ captures = re.capturedTexts();
+ }
+#endif
- if (re.exactMatch(text())) {
- QStringList captures = re.capturedTexts();
+ if (has_match) {
captures.removeFirst(); // remove entire match
QString str = captures.join("");
setValue(pv::util::Timestamp(str.toStdString()));