Skip to content

Commit

Permalink
UMVE: Fix Qt 5.15 deprecation warnings
Browse files Browse the repository at this point in the history
Fixes the following deprecation warnings when compiling against Qt 5.15:

TODO: Add warning messages
  • Loading branch information
andre-schulz committed Jul 21, 2024
1 parent 417911f commit 2d1b96c
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
3 changes: 2 additions & 1 deletion apps/umve/batchoperations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <QMessageBox>
#include <QProgressDialog>
#include <QApplication>
#include <QAbstractEventDispatcher>

#include "util/file_system.h"
#include "mve/mesh_io_ply.h"
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions apps/umve/clickimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions apps/umve/glwidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/umve/sceneoverview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions apps/umve/viewinspect/scrollimage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(newsize.width())
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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());
Expand All @@ -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");
}
6 changes: 3 additions & 3 deletions apps/umve/viewinspect/scrollimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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*
Expand Down
4 changes: 2 additions & 2 deletions apps/umve/viewinspect/viewinspect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2d1b96c

Please sign in to comment.