From 113062025d93065bad2c340d992f06852899195a Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Mon, 23 Nov 2020 22:08:04 +0100 Subject: [PATCH] Qt: fix some Qt 5.15.2 deprecation warnings (cherry picked from commit fb2414ae6dbdc3d81c9ccdd24eb65cd8324065ea) --- ui/qt/packet_list.cpp | 4 ++++ ui/qt/print_dialog.cpp | 20 +++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index a736b85b7b..bfa3214245 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -791,7 +791,11 @@ void PacketList::mousePressEvent (QMouseEvent *event) QModelIndex curIndex = indexAt(event->pos()); mouse_pressed_at_ = curIndex; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) + bool midButton = (event->buttons() & Qt::MiddleButton) == Qt::MiddleButton; +#else bool midButton = (event->buttons() & Qt::MidButton) == Qt::MidButton; +#endif if (midButton && cap_file_ && packet_list_model_) { packet_list_model_->toggleFrameMark(QModelIndexList() << curIndex); diff --git a/ui/qt/print_dialog.cpp b/ui/qt/print_dialog.cpp index 50c99a3d1d..b4988321fb 100644 --- a/ui/qt/print_dialog.cpp +++ b/ui/qt/print_dialog.cpp @@ -136,7 +136,11 @@ PrintDialog::~PrintDialog() gboolean PrintDialog::printHeader() { if (!cap_file_ || !cap_file_->filename || !cur_printer_ || !cur_painter_) return FALSE; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) + int page_top = cur_printer_->pageLayout().paintRectPixels(cur_printer_->resolution()).top(); +#else int page_top = cur_printer_->pageRect().top(); +#endif if (page_pos_ > page_top) { if (in_preview_) { @@ -162,7 +166,7 @@ gboolean PrintDialog::printHeader() gboolean PrintDialog::printLine(int indent, const char *line) { - QRect out_rect; + QRect out_rect, page_rect; QString out_line; if (!line || !cur_printer_ || !cur_painter_) return FALSE; @@ -171,9 +175,15 @@ gboolean PrintDialog::printLine(int indent, const char *line) out_line.fill(' ', indent * 4); out_line += line; - out_rect = cur_painter_->boundingRect(cur_printer_->pageRect(), Qt::TextWordWrap, out_line); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) + page_rect = cur_printer_->pageLayout().paintRectPixels(cur_printer_->resolution()); +#else + page_rect = cur_printer_->pageRect(); +#endif - if (cur_printer_->pageRect().height() < page_pos_ + out_rect.height()) { + out_rect = cur_painter_->boundingRect(page_rect, Qt::TextWordWrap, out_line); + + if (page_rect.height() < page_pos_ + out_rect.height()) { // // We're past the end of the page, so this line will be on // the next page. @@ -233,7 +243,11 @@ void PrintDialog::printPackets(QPrinter *printer, bool in_preview) if (!printer) return; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) + page_pos_ = printer->pageLayout().paintRectPixels(cur_printer_->resolution()).top(); +#else page_pos_ = printer->pageRect().top(); +#endif in_preview_ = in_preview; /* Fill in our print args */