]> sigrok.org Git - pulseview.git/commitdiff
Fix depreciation warnings caused by newer Qt versions
authorSoeren Apel <redacted>
Tue, 13 Sep 2022 20:16:31 +0000 (22:16 +0200)
committerSoeren Apel <redacted>
Tue, 13 Sep 2022 20:16:31 +0000 (22:16 +0200)
pv/dialogs/settings.cpp
pv/logging.cpp
pv/subwindows/decoder_selector/model.cpp
pv/views/decoder_binary/view.cpp
pv/views/trace/mathsignal.cpp
pv/views/trace/viewport.cpp
pv/widgets/popup.cpp

index 12c6f0cfede13f370f4d4ae8a880c81465e49f68..00c7dcfc5d29ff9aff8c731811ff58cd1a4800ab 100644 (file)
@@ -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)));
index e42a9e54e94add49cb46b34f3a5ab216650e6c3f..7dab545de93cd3989af8d72a69867e470a5b0753 100644 (file)
@@ -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;
index 2a4182b05840462e2c8a38f9285a26af19f792a9..0c4dab59c3811d1b83ea922d1eb3098f80802070 100644 (file)
@@ -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;
 }
index 05d5ed4612c9ba7b5897ca67076b04f9f42d4ca8..1e40bd1b686c315ce3f5a196b96c351b027c4cf7 100644 (file)
@@ -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_);
index 2d242b9994da3e3c08d1003099b37d676521ddbb..665b1a4b83a0a7034e383e252841737b352dd700 100644 (file)
@@ -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()));
index bf15e41c4387688f926645b51f79378df68e7006..192e8f096303aca51013254b70582e3dd4398d42 100644 (file)
@@ -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());
        }
 }
 
index ec6d29c981c235b86451353ca620d9c5cf147868..9614701b7a9701d9c9cb2d2d277dfb388b4295ab 100644 (file)
@@ -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;