aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2023-02-05 10:12:36 -0500
committerAndersBroman <a.broman58@gmail.com>2023-11-02 15:28:01 +0000
commit520f0d8e260436ddbdc5460d240de94e9e683fd2 (patch)
treec834385fcd6d24ee5005f84d7f92f0808ad8bb9a /ui
parent8fc6ea322999efb60080e4b50cd1cd19ffabb242 (diff)
Qt: Enforce Minimum Qt version 5.11
We already strongly recommend Qt version 5.12 and enforce 5.10. Commit 06cd84a6e9f8bd0807cca35595b94b07de254b07 said "[a]lthough build support for 5.10 and 5.11 is not being removed at this point, it might be for 4.x at a later time." Move to enforcing 5.11, and update macos-setup for that as well. Remove the QT_VERSION_CHECKs for 5.10 and 5.11 (except in qcustomplot.) Hold off on enforcing 5.12 for now, because there isn't any code that needs 5.12 or greater (there are two places for a workaround for Qt 5.12.0 through 5.12.5), and because Debian Buster is on Qt 5.11.3. There are not any known supported OS distributions on Qt 5.10.
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/main_application.cpp8
-rw-r--r--ui/qt/packet_diagram.cpp12
-rw-r--r--ui/qt/packet_list.cpp10
-rw-r--r--ui/qt/progress_frame.cpp4
-rw-r--r--ui/qt/sequence_diagram.cpp8
-rw-r--r--ui/qt/utils/qt_ui_utils.cpp2
-rw-r--r--ui/qt/widgets/byte_view_text.cpp4
7 files changed, 2 insertions, 46 deletions
diff --git a/ui/qt/main_application.cpp b/ui/qt/main_application.cpp
index 111aed8ace..56965d09e4 100644
--- a/ui/qt/main_application.cpp
+++ b/ui/qt/main_application.cpp
@@ -409,11 +409,7 @@ void MainApplication::setMonospaceFont(const char *font_string) {
int MainApplication::monospaceTextSize(const char *str)
{
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
return QFontMetrics(mono_font_).horizontalAdvance(str);
-#else
- return QFontMetrics(mono_font_).width(str);
-#endif
}
void MainApplication::setConfigurationProfile(const gchar *profile_name, bool write_recent_file)
@@ -710,15 +706,13 @@ MainApplication::MainApplication(int &argc, char **argv) :
setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
-#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
setAttribute(Qt::AA_DisableWindowContextHelpButton);
#endif
// Throw various settings at the wall with the hope that one of them will
// enable context menu shortcuts QTBUG-69452, QTBUG-109590
-#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
setAttribute(Qt::AA_DontShowShortcutsInContextMenus, false);
-#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
styleHints()->setShowShortcutsInContextMenus(true);
#endif
diff --git a/ui/qt/packet_diagram.cpp b/ui/qt/packet_diagram.cpp
index 67f5c0a8e4..a420050bcd 100644
--- a/ui/qt/packet_diagram.cpp
+++ b/ui/qt/packet_diagram.cpp
@@ -322,19 +322,11 @@ private:
QFontMetrics fm = QFontMetrics(layout_->regularFont());
painter->setFont(layout_->regularFont());
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int label_w = fm.horizontalAdvance(label);
-#else
- int label_w = fm.width(label);
-#endif
if (label_w > label_rect.width()) {
painter->setFont(layout_->smallFont());
fm = QFontMetrics(layout_->smallFont());
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
label_w = fm.horizontalAdvance(label);
-#else
- label_w = fm.width(label);
-#endif
if (label_w > label_rect.width()) {
// XXX Use parent+ItemClipsChildrenToShape or setScale instead?
label = fm.elidedText(label, Qt::ElideRight, label_rect.width());
@@ -564,11 +556,7 @@ void PacketDiagram::addDiagram(proto_node *tl_node)
qreal y_bottom = y_pos_ + bit_width;
QGraphicsItem *tl_item = scene()->addLine(x, y_bottom, x + diag_w, y_bottom);
QFontMetrics sfm = QFontMetrics(layout_->smallFont());
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int space_w = sfm.horizontalAdvance(' ');
-#else
- int space_w = sfm.width(' ');
-#endif
#ifdef Q_OS_WIN
// t_item->boundingRect() has a pixel of space on the left on my (gcc)
// Windows VM.
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index 955172487a..102700fdb3 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -248,9 +248,7 @@ PacketList::PacketList(QWidget *parent) :
connect(packet_list_header_, &PacketListHeader::columnsChanged, this, &PacketList::columnsChanged);
setHeader(packet_list_header_);
-#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
header()->setFirstSectionMovable(true);
-#endif
setSelectionMode(QAbstractItemView::ExtendedSelection);
@@ -1021,19 +1019,11 @@ void PacketList::setRecentColumnWidth(int col)
const char *long_str = get_column_width_string(fmt, col);
QFontMetrics fm = QFontMetrics(mainApp->monospaceFont());
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
if (long_str) {
col_width = fm.horizontalAdvance(long_str);
} else {
col_width = fm.horizontalAdvance(MIN_COL_WIDTH_STR);
}
-#else
- if (long_str) {
- col_width = fm.width(long_str);
- } else {
- col_width = fm.width(MIN_COL_WIDTH_STR);
- }
-#endif
// Custom delegate padding
if (itemDelegateForColumn(col)) {
QStyleOptionViewItem option;
diff --git a/ui/qt/progress_frame.cpp b/ui/qt/progress_frame.cpp
index 2e40ac8086..853118c5a8 100644
--- a/ui/qt/progress_frame.cpp
+++ b/ui/qt/progress_frame.cpp
@@ -161,11 +161,7 @@ struct progdlg *ProgressFrame::showProgress(const QString &title, bool animate,
ui->progressBar->setValue(value);
QString elided_title = title;
int max_w = fontMetrics().height() * 20; // em-widths, arbitrary
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int title_w = fontMetrics().horizontalAdvance(title);
-#else
- int title_w = fontMetrics().width(title);
-#endif
if (title_w > max_w) {
elided_title = fontMetrics().elidedText(title, Qt::ElideRight, max_w);
}
diff --git a/ui/qt/sequence_diagram.cpp b/ui/qt/sequence_diagram.cpp
index 4628915b1a..4452f095e5 100644
--- a/ui/qt/sequence_diagram.cpp
+++ b/ui/qt/sequence_diagram.cpp
@@ -327,11 +327,7 @@ void SequenceDiagram::draw(QCPPainter *painter)
double arrow_width = (arrow_end.x() - arrow_start.x()) * dir_mul;
QString arrow_label = cfm.elidedText(sai->frame_label, Qt::ElideRight, arrow_width);
int arrow_label_width = 0;
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
arrow_label_width = cfm.horizontalAdvance(arrow_label);
-#else
- arrow_label_width = cfm.width(arrow_label);
-#endif
QPoint text_pt(comment_start + ((arrow_width - arrow_label_width) / 2),
arrow_start.y() - (en_w / 2));
@@ -344,11 +340,7 @@ void SequenceDiagram::draw(QCPPainter *painter)
QString port_left = QString::number(dir_mul > 0 ? sai->port_src : sai->port_dst);
QString port_right = QString::number(dir_mul > 0 ? sai->port_dst : sai->port_src);
int port_left_width = 0;
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
port_left_width = cfm.horizontalAdvance(port_left);
-#else
- port_left_width = cfm.width(port_left);
-#endif
text_pt = QPoint(left_x - en_w - port_left_width, arrow_start.y() + (en_w / 2));
painter->drawText(text_pt, port_left);
diff --git a/ui/qt/utils/qt_ui_utils.cpp b/ui/qt/utils/qt_ui_utils.cpp
index eb6308bf0c..84658377f1 100644
--- a/ui/qt/utils/qt_ui_utils.cpp
+++ b/ui/qt/utils/qt_ui_utils.cpp
@@ -251,7 +251,7 @@ bool rect_on_screen(const QRect &rect)
void set_action_shortcuts_visible_in_context_menu(QList<QAction *> actions)
{
-#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) && QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
+#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
// For QT_VERSION >= 5.13.0 we call styleHints()->setShowShortcutsInContextMenus(true)
// in WiresharkApplication.
// QTBUG-71471
diff --git a/ui/qt/widgets/byte_view_text.cpp b/ui/qt/widgets/byte_view_text.cpp
index e81dc0acab..ba9f2de0c3 100644
--- a/ui/qt/widgets/byte_view_text.cpp
+++ b/ui/qt/widgets/byte_view_text.cpp
@@ -407,11 +407,7 @@ void ByteViewText::updateLayoutMetrics()
int ByteViewText::stringWidth(const QString &line)
{
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
return viewport()->fontMetrics().horizontalAdvance(line);
-#else
- return viewport()->fontMetrics().boundingRect(line).width();
-#endif
}
// Draw a line of byte view text for a given offset.