From: Soeren Apel Date: Tue, 13 Sep 2022 20:16:31 +0000 (+0200) Subject: Fix depreciation warnings caused by newer Qt versions X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ffad6cd6856a0e0de36cad164d9d09e06c0ec52a;p=pulseview.git Fix depreciation warnings caused by newer Qt versions --- diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index 12c6f0cf..00c7dcfc 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -84,7 +84,7 @@ public: }; Settings::Settings(DeviceManager &device_manager, QWidget *parent) : - QDialog(parent, nullptr), + QDialog(parent), device_manager_(device_manager) { resize(600, 400); @@ -261,7 +261,7 @@ QWidget *Settings::get_general_settings_form(QWidget *parent) const if (current_style.isEmpty()) style_cb->setCurrentIndex(0); else - style_cb->setCurrentIndex(style_cb->findText(current_style, nullptr)); + style_cb->setCurrentIndex(style_cb->findText(current_style)); connect(style_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(on_general_style_changed(int))); diff --git a/pv/logging.cpp b/pv/logging.cpp index e42a9e54..7dab545d 100644 --- a/pv/logging.cpp +++ b/pv/logging.cpp @@ -191,8 +191,13 @@ int Logging::log_srd(void *cb_data, int loglevel, const char *format, va_list ar char *text = g_strdup_vprintf(format, args); QString s = QString::fromUtf8(text); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + for (QString& substring : s.split("\n", Qt::SkipEmptyParts)) + logging.log(substring, LogSource_srd); +#else for (QString& substring : s.split("\n", QString::SkipEmptyParts)) logging.log(substring, LogSource_srd); +#endif g_free(text); return SR_OK; diff --git a/pv/subwindows/decoder_selector/model.cpp b/pv/subwindows/decoder_selector/model.cpp index 2a4182b0..0c4dab59 100644 --- a/pv/subwindows/decoder_selector/model.cpp +++ b/pv/subwindows/decoder_selector/model.cpp @@ -134,7 +134,7 @@ QVariant DecoderCollectionModel::data(const QModelIndex& index, int role) const Qt::ItemFlags DecoderCollectionModel::flags(const QModelIndex& index) const { if (!index.isValid()) - return nullptr; + return Qt::NoItemFlags; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } diff --git a/pv/views/decoder_binary/view.cpp b/pv/views/decoder_binary/view.cpp index 05d5ed46..1e40bd1b 100644 --- a/pv/views/decoder_binary/view.cpp +++ b/pv/views/decoder_binary/view.cpp @@ -327,10 +327,18 @@ void View::save_data_as_hex_dump(bool with_offset, bool with_ascii) const while (offset < selection.second) { size_t end = std::min((uint64_t)(selection.second), offset + n); offset = hex_view_->create_hex_line(offset, end, &s, with_offset, with_ascii); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + out_stream << s << Qt::endl; +#else out_stream << s << endl; +#endif } +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + out_stream << Qt::endl; +#else out_stream << endl; +#endif if (out_stream.status() != QTextStream::Ok) { QMessageBox msg(parent_); diff --git a/pv/views/trace/mathsignal.cpp b/pv/views/trace/mathsignal.cpp index 2d242b99..665b1a4b 100644 --- a/pv/views/trace/mathsignal.cpp +++ b/pv/views/trace/mathsignal.cpp @@ -259,7 +259,11 @@ MathEditDialog::MathEditDialog(pv::Session &session, root_layout->addWidget(button_box); // Set tab width to 4 characters +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + expr_edit_->setTabStopDistance(util::text_width(QFontMetrics(font()), "XXXX")); +#else expr_edit_->setTabStopWidth(util::text_width(QFontMetrics(font()), "XXXX")); +#endif connect(button_box, SIGNAL(accepted()), this, SLOT(accept())); connect(button_box, SIGNAL(rejected()), this, SLOT(reject())); diff --git a/pv/views/trace/viewport.cpp b/pv/views/trace/viewport.cpp index bf15e41c..192e8f09 100644 --- a/pv/views/trace/viewport.cpp +++ b/pv/views/trace/viewport.cpp @@ -225,20 +225,34 @@ void Viewport::wheelEvent(QWheelEvent *event) { assert(event); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + int delta = (event->angleDelta().x() != 0) ? event->angleDelta().x() : event->angleDelta().y(); +#else + int delta = event->delta(); +#endif + +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + if (event->angleDelta().y() != 0) { +#else if (event->orientation() == Qt::Vertical) { +#endif if (event->modifiers() & Qt::ControlModifier) { // Vertical scrolling with the control key pressed // is intrepretted as vertical scrolling view_.set_v_offset(-view_.owner_visual_v_offset() - - (event->delta() * height()) / (8 * 120)); + (delta * height()) / (8 * 120)); } else { // Vertical scrolling is interpreted as zooming in/out - view_.zoom(event->delta() / 120.0, event->x()); + view_.zoom(delta / 120.0, event->position().x()); } +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + } else if (event->angleDelta().x() != 0) { +#else } else if (event->orientation() == Qt::Horizontal) { +#endif // Horizontal scrolling is interpreted as moving left/right view_.set_scale_offset(view_.scale(), - event->delta() * view_.scale() + view_.offset()); + delta * view_.scale() + view_.offset()); } } diff --git a/pv/widgets/popup.cpp b/pv/widgets/popup.cpp index ec6d29c9..9614701b 100644 --- a/pv/widgets/popup.cpp +++ b/pv/widgets/popup.cpp @@ -252,8 +252,12 @@ void Popup::reposition_widget() { QPoint o; +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + const QRect screen_rect = QApplication::screenAt(point_)->availableGeometry(); +#else const QRect screen_rect = QApplication::desktop()->availableGeometry( QApplication::desktop()->screenNumber(point_)); +#endif if (pos_ == Right || pos_ == Left) o.ry() = -height() / 2;