From 2d1b96c0dd672823c2a78e932d76efd1bfb1dc1a Mon Sep 17 00:00:00 2001 From: Andre Schulz Date: Sun, 21 Jul 2024 16:22:16 +0200 Subject: [PATCH] UMVE: Fix Qt 5.15 deprecation warnings Fixes the following deprecation warnings when compiling against Qt 5.15: TODO: Add warning messages --- apps/umve/batchoperations.cc | 3 ++- apps/umve/clickimage.h | 6 +++--- apps/umve/glwidget.cc | 6 +++--- apps/umve/sceneoverview.cc | 2 +- apps/umve/viewinspect/scrollimage.cc | 12 ++++++------ apps/umve/viewinspect/scrollimage.h | 6 +++--- apps/umve/viewinspect/viewinspect.cc | 4 ++-- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/apps/umve/batchoperations.cc b/apps/umve/batchoperations.cc index 5aae0b056..f0ab730e4 100644 --- a/apps/umve/batchoperations.cc +++ b/apps/umve/batchoperations.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include "util/file_system.h" #include "mve/mesh_io_ply.h" @@ -549,7 +550,7 @@ BatchGenerateThumbs::on_generate (void) return; this->setDisabled(true); - while (QApplication::hasPendingEvents()) + while (QApplication::eventDispatcher()->hasPendingEvents()) QApplication::processEvents(); std::string embedding_name = this->embedding_name.text().toStdString(); diff --git a/apps/umve/clickimage.h b/apps/umve/clickimage.h index 7863b3377..01435067d 100644 --- a/apps/umve/clickimage.h +++ b/apps/umve/clickimage.h @@ -69,7 +69,7 @@ ClickImage::set_scale_factor (double factor) if (this->scale_factor == 1.0) this->adjustSize(); else - this->resize(this->scale_factor * this->pixmap()->size()); + this->resize(this->scale_factor * this->pixmap(Qt::ReturnByValue).size()); } inline void @@ -102,7 +102,7 @@ ClickImage::mouseMoveEvent (QMouseEvent* event) inline void ClickImage::wheelEvent (QWheelEvent* event) { - QPoint const& pnt = this->get_image_coordinates(event->pos()); + QPoint const& pnt = this->get_image_coordinates(event->position().toPoint()); emit this->mouse_zoomed(pnt.x(), pnt.y(), event); } @@ -111,7 +111,7 @@ ClickImage::get_image_coordinates (QPoint pnt) const { if (this->hasScaledContents()) { - QSize ps(this->pixmap()->size()); + QSize ps(this->pixmap(Qt::ReturnByValue).size()); QSize ws(this->size()); float scale_x = (float)ps.width() / (float)ws.width(); diff --git a/apps/umve/glwidget.cc b/apps/umve/glwidget.cc index c9e691c1b..bccf29e33 100644 --- a/apps/umve/glwidget.cc +++ b/apps/umve/glwidget.cc @@ -159,14 +159,14 @@ GLWidget::wheelEvent (QWheelEvent* event) { this->makeCurrent(); ogl::MouseEvent e; - if (event->delta() < 0) + if (event->angleDelta().y() < 0) e.type = ogl::MOUSE_EVENT_WHEEL_DOWN; else e.type = ogl::MOUSE_EVENT_WHEEL_UP; e.button = ogl::MOUSE_BUTTON_NONE; e.button_mask = event->buttons(); - e.x = event->x() * this->device_pixel_ratio; - e.y = event->y() * this->device_pixel_ratio; + e.x = event->position().x() * this->device_pixel_ratio; + e.y = event->position().y() * this->device_pixel_ratio; this->context->mouse_event(e); this->repaint_async(); } diff --git a/apps/umve/sceneoverview.cc b/apps/umve/sceneoverview.cc index 0828e00a0..4157fa8ac 100644 --- a/apps/umve/sceneoverview.cc +++ b/apps/umve/sceneoverview.cc @@ -147,7 +147,7 @@ SceneOverview::add_view_to_layout (std::size_t id, mve::View::Ptr view) QListWidgetItem* item = new QListWidgetItem(icon, tr("%1\n%2").arg(name, images)); if (!cam_valid) - item->setBackgroundColor(QColor(255, 221, 221)); // #ffdddd + item->setBackground(QColor(255, 221, 221)); // #ffdddd item->setData(Qt::UserRole, (int)id); this->viewlist->addItem(item); } diff --git a/apps/umve/viewinspect/scrollimage.cc b/apps/umve/viewinspect/scrollimage.cc index 4810b6d7b..1a84e97c7 100644 --- a/apps/umve/viewinspect/scrollimage.cc +++ b/apps/umve/viewinspect/scrollimage.cc @@ -54,7 +54,7 @@ ScrollImage::update_image_size (void) void ScrollImage::max_image_size (void) { - QSize imgsize(this->image->pixmap()->size()); + QSize imgsize(this->image->pixmap(Qt::ReturnByValue).size()); QSize newsize = imgsize.scaled(this->maximumViewportSize(), Qt::KeepAspectRatio); this->image->set_scale_factor(static_cast(newsize.width()) @@ -83,7 +83,7 @@ ScrollImage::resizeEvent (QResizeEvent* event) //std::cout << "Resize Event: " << event->size().width() << "x" // << event->size().height() << std::endl; - if (this->scale_contents && this->image->pixmap()) + if (this->scale_contents && !!this->image->pixmap(Qt::ReturnByValue)) this->max_image_size(); } @@ -119,12 +119,12 @@ ScrollImage::mouse_zoomed (int x, int y, QWheelEvent* event) return; } QPoint old_pnt(x, y); - if (event->delta() > 0) + if (event->angleDelta().y() > 0) this->set_scale(this->get_scale() * MOUSE_ZOOM_IN_FACTOR); else this->set_scale(this->get_scale() * MOUSE_ZOOM_OUT_FACTOR); - QPoint new_pnt = this->image->get_image_coordinates(event->pos()); + QPoint new_pnt = this->image->get_image_coordinates(event->position().toPoint()); QPoint diff = (old_pnt - new_pnt) * this->get_scale(); this->move_scrollbar(this->horizontalScrollBar(), diff.x()); this->move_scrollbar(this->verticalScrollBar(), diff.y()); @@ -151,10 +151,10 @@ ScrollImage::move_scrollbar (QScrollBar* bar, int delta) void ScrollImage::save_image (std::string const& filename) { - QPixmap const* pm = this->image->pixmap(); + QPixmap pm = this->image->pixmap(Qt::ReturnByValue); if (!pm) throw std::runtime_error("No image set"); - bool ret = pm->save(filename.c_str()); + bool ret = pm.save(filename.c_str()); if (!ret) throw std::runtime_error("Unable to save image"); } diff --git a/apps/umve/viewinspect/scrollimage.h b/apps/umve/viewinspect/scrollimage.h index cdcd6e8be..99c7347b9 100644 --- a/apps/umve/viewinspect/scrollimage.h +++ b/apps/umve/viewinspect/scrollimage.h @@ -46,7 +46,7 @@ private slots: ScrollImage (void); void set_pixmap (QPixmap const& pixmap); - QPixmap const* get_pixmap (void) const; + QPixmap get_pixmap (void) const; ClickImage* get_image (void); void set_auto_scale (bool value); @@ -116,10 +116,10 @@ ScrollImage::set_scale (double scale) return this->image->set_scale_factor(scale); } -inline QPixmap const* +inline QPixmap ScrollImage::get_pixmap (void) const { - return this->image->pixmap(); + return this->image->pixmap(Qt::ReturnByValue); } inline ClickImage* diff --git a/apps/umve/viewinspect/viewinspect.cc b/apps/umve/viewinspect/viewinspect.cc index e7a1045de..3e936666c 100644 --- a/apps/umve/viewinspect/viewinspect.cc +++ b/apps/umve/viewinspect/viewinspect.cc @@ -229,7 +229,7 @@ ViewInspect::show_details (bool show) void ViewInspect::update_actions (void) { - bool active = this->scroll_image->get_pixmap() != nullptr; + bool active = !!this->scroll_image->get_pixmap(); this->action_zoom_fit->setEnabled(active); this->action_zoom_in->setEnabled(active); this->action_zoom_out->setEnabled(active); @@ -700,7 +700,7 @@ ViewInspect::on_ply_export (void) void ViewInspect::on_image_export (void) { - if (!this->scroll_image->get_image()->pixmap()) + if (!this->scroll_image->get_image()->pixmap(Qt::ReturnByValue)) { QMessageBox::critical(this, "Cannot save image", "No such image"); return;