Qt: Remove workarounds for Qt < 5.15

Since Qt 5.15 is the minimum version now, remove a bunch of
QT_VERSION_CHECKs and the like. (Except in qcustomplot.)

Also update some documentation.
This commit is contained in:
John Thacker 2024-10-20 08:01:12 -04:00
parent 7c0cd99106
commit b6c161e1f4
30 changed files with 40 additions and 285 deletions

View File

@ -645,7 +645,7 @@ else() # ! MSVC
if(APPLE)
# MIN_MACOS_VERSION is used to set LSMinimumSystemVersion
# in Info.plist, so start with something low.
set(MIN_MACOS_VERSION 10.11)
set(MIN_MACOS_VERSION 10.13)
if(CMAKE_OSX_DEPLOYMENT_TARGET)
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MIN_MACOS_VERSION)
message(FATAL_ERROR "We don't support building for macOS < ${MIN_MACOS_VERSION}")
@ -1631,10 +1631,6 @@ if (QT_FOUND)
set(MIN_MACOS_VERSION 11.0)
elseif(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "6.0.0" AND MIN_MACOS_VERSION VERSION_LESS "10.14")
set(MIN_MACOS_VERSION 10.14)
elseif(Qt5Widgets_VERSION VERSION_GREATER_EQUAL "5.14.0" AND MIN_MACOS_VERSION VERSION_LESS "10.13")
set(MIN_MACOS_VERSION 10.13)
elseif(Qt5Widgets_VERSION VERSION_GREATER_EQUAL "5.12.0" AND MIN_MACOS_VERSION VERSION_LESS "10.12")
set(MIN_MACOS_VERSION 10.12)
endif()
if(CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MIN_MACOS_VERSION)
message(FATAL_ERROR "Qt version ${Qt${qtver}Widgets_VERSION} requires CMAKE_OSX_DEPLOYMENT_TARGET (${CMAKE_OSX_DEPLOYMENT_TARGET}) >= ${MIN_MACOS_VERSION}")

View File

@ -18,7 +18,7 @@ https://www.wireshark.org/docs/ for those.
installed. Then try running 'pkg-config Qt6Widgets --modversion'
to see if you have Qt 6 installed. If not, then try running
'pkg-config Qt5Widgets --modversion' to see if you have Qt 5.
Wireshark requires Qt 5.12 or later, but the most recent LTS release
Wireshark requires Qt 5.15 or later, but the most recent LTS release
is strongly recommended. Building against Qt 5 will require the
CMake option '-DUSE_qt6=OFF'. Wireshark requires version 2.54.0 or
above of GLib. If you need to install or re-install GLib, you can

View File

@ -430,7 +430,7 @@ own mkstemp implementation for use on platforms that lack mkstemp.
Note: mkstemp does not accept NULL as a parameter.
Wireshark requires minimum versions of each of the libraries it uses, in
particular GLib 2.54.0 and Qt 5.12.0 or newer. If you require a mechanism
particular GLib 2.54.0 and Qt 5.15.0 or newer. If you require a mechanism
that is available only in a newer version of a library then use its
version detection macros, e.g. "#if GLIB_CHECK_VERSION(...)" and "#if
QT_VERSION_CHECK(...)" to conditionally compile code using that

View File

@ -47,7 +47,7 @@ You may also set the library directory to a custom value with the environment va
=== Qt
The Qt library is used to build the UI for Wireshark and is used to provide a platform independent UI.
Wireshark can be built with Qt 5.12 or later, but Qt 6 is the default and recommended version.
Wireshark can be built with Qt 5.15 or later, but Qt 6 is the default and recommended version.
To enable builds with Qt 5, the command-line option `-DUSE_qt6=OFF` has to be set for CMake.

View File

@ -21,11 +21,11 @@ shopt -s extglob
DARWIN_MAJOR_VERSION=$(uname -r | sed 's/\([0-9]*\).*/\1/')
#
# The minimum supported version of Qt is 5.11, so the minimum supported version
# of macOS is OS X 10.11 (El Capitan), aka Darwin 15.0.
# The minimum supported version of Qt is 5.15, so the minimum supported version
# of macOS is OS X 10.13 (High Sierra), aka Darwin 17.0.
#
if [[ $DARWIN_MAJOR_VERSION -lt 15 ]]; then
echo "This script does not support any versions of macOS before El Capitan" 1>&2
if [[ $DARWIN_MAJOR_VERSION -lt 17 ]]; then
echo "This script does not support any versions of macOS before High Sierra" 1>&2
exit 1
fi
@ -1144,13 +1144,10 @@ install_qt() {
5)
case $QT_MINOR_VERSION in
0|1|2|3|4|5|6|7|8|9|10)
0|1|2|3|4|5|6|7|8|9|10|11|12|13|14)
echo "Qt $QT_VERSION" is too old 1>&2
;;
11|12|13|14)
QT_VOLUME=qt-opensource-mac-x64-$QT_VERSION
;;
*)
echo "The Qt Company no longer provides open source offline installers for Qt $QT_VERSION" 1>&2
;;
@ -1203,11 +1200,11 @@ uninstall_qt() {
5*)
case $installed_qt_minor_version in
0|1|2|3|4|5|6|7|8)
0|1|2|3|4|5|6|7|8|9|10|11)
echo "Qt $installed_qt_version" is too old 1>&2
;;
9|10|11|12|13|14)
12|13|14)
installed_qt_volume=qt-opensource-mac-x64-$installed_qt_version.dmg
;;
esac

View File

@ -721,34 +721,18 @@ add_custom_command(
# Use the number of dashes for each argument as documented at
# https://doc.qt.io/qt-6/rcc.html.
set(CMAKE_AUTORCC_OPTIONS --format-version 1)
if(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "5.13")
list(APPEND CMAKE_AUTORCC_OPTIONS -compress-algo zlib)
endif()
list(APPEND CMAKE_AUTORCC_OPTIONS -compress-algo zlib)
if(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "5.15")
qt_add_resources(WIRESHARK_QT_QRC
../../resources/about.qrc
../../resources/languages/languages.qrc
../../resources/layout.qrc
../../resources/stock_icons.qrc
../../resources/wsicon.qrc
${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc
${CMAKE_CURRENT_BINARY_DIR}/authors.qrc
OPTIONS ${CMAKE_AUTORCC_OPTIONS}
)
else()
# The unversions qt_add_resources was added in Qt 5.15
qt5_add_resources(WIRESHARK_QT_QRC
../../resources/about.qrc
../../resources/languages/languages.qrc
../../resources/layout.qrc
../../resources/stock_icons.qrc
../../resources/wsicon.qrc
${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc
${CMAKE_CURRENT_BINARY_DIR}/authors.qrc
OPTIONS ${CMAKE_AUTORCC_OPTIONS}
)
endif()
qt_add_resources(WIRESHARK_QT_QRC
../../resources/about.qrc
../../resources/languages/languages.qrc
../../resources/layout.qrc
../../resources/stock_icons.qrc
../../resources/wsicon.qrc
${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc
${CMAKE_CURRENT_BINARY_DIR}/authors.qrc
OPTIONS ${CMAKE_AUTORCC_OPTIONS}
)
if (USE_qt6)
QT6_ADD_TRANSLATION(WIRESHARK_QT_QM ${WIRESHARK_QT_TS} OPTIONS -silent)

View File

@ -76,11 +76,7 @@ AStringListListModel(parent)
while (!ReadFile_authors.atEnd()) {
QString line = ReadFile_authors.readLine();
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList entry = line.split(",", Qt::SkipEmptyParts);
#else
QStringList entry = QStringList() << line.section(',', 0, 0) << line.section(',', 1, 1);
#endif
if (entry.size() == 2) {
appendRow(entry);
}
@ -405,21 +401,12 @@ AboutDialog::AboutDialog(QWidget *parent) :
f_acknowledgements.open(QFile::ReadOnly | QFile::Text);
QTextStream ReadFile_acks(&f_acknowledgements);
/* QTextBrowser markdown support added in 5.14. */
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QTextBrowser *textBrowserAcks = new QTextBrowser();
textBrowserAcks->setMarkdown(ReadFile_acks.readAll());
textBrowserAcks->setReadOnly(true);
textBrowserAcks->setOpenExternalLinks(true);
textBrowserAcks->moveCursor(QTextCursor::Start);
ui->ackVerticalLayout->addWidget(textBrowserAcks);
#else
QPlainTextEdit *pte = new QPlainTextEdit();
pte->setPlainText(ReadFile_acks.readAll());
pte->setReadOnly(true);
pte->moveCursor(QTextCursor::Start);
ui->ackVerticalLayout->addWidget(pte);
#endif
/* License */
f_license.setFileName(":/about/gpl-2.0-standalone.html");

View File

@ -115,11 +115,7 @@ QWidget * ExtArgMultiSelect::createEditor(QWidget * parent)
/* Value can be empty if no items are checked */
if (_argument->pref_valptr && (*_argument->pref_valptr))
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
checked = QString(*_argument->pref_valptr).split(",", Qt::SkipEmptyParts);
#else
checked = QString(*_argument->pref_valptr).split(",", QString::SkipEmptyParts);
#endif
}
viewModel = new QStandardItemModel();
@ -219,11 +215,7 @@ void ExtArgMultiSelect::setDefaultValue()
{
QStringList checked;
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
checked = defaultValue().split(",", Qt::SkipEmptyParts);
#else
checked = defaultValue().split(",", QString::SkipEmptyParts);
#endif
for (int row = 0; row < viewModel->rowCount(); row++)
checkItemsWalker(((QStandardItemModel*)viewModel)->item(row), checked);
}

View File

@ -287,7 +287,6 @@ void FollowStreamDialog::findText(bool go_back)
options |= QTextDocument::FindCaseSensitively;
}
if (use_regex_find_) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
// https://bugreports.qt.io/browse/QTBUG-88721
// QPlainTextEdit::find() searches case-insensitively unless
// QTextDocument::FindCaseSensitively is explicitly given.
@ -297,14 +296,7 @@ void FollowStreamDialog::findText(bool go_back)
// QRegularExpression and QRegExp do not support Perl's /i, but
// the former at least does support the mode modifiers (?i) and
// (?-i), which can override QTextDocument::FindCaseSensitively.
//
// To make matters worse, while the QTextDocument::find() documentation
// is correct, QPlainTextEdit::find() claims that QRegularExpression
// works like QRegExp, which is incorrect.
QRegularExpression regex(ui->leFind->text(), QRegularExpression::UseUnicodePropertiesOption);
#else
QRegExp regex(ui->leFind->text(), (options & QTextDocument::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
#endif
found = ui->teStreamContent->find(regex, options);
} else {
found = ui->teStreamContent->find(ui->leFind->text(), options);

View File

@ -142,11 +142,7 @@ void FunnelAction::setPacketRequiredFields(const char *required_fields_str) {
// Also remove leading and trailing spaces, in case someone writes
// "http, dns" instead of "http,dns"
QString requiredFieldsJoined = QString(required_fields_str);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList requiredFieldsSplit = requiredFieldsJoined.split(",", Qt::SkipEmptyParts);
#else
QStringList requiredFieldsSplit = requiredFieldsJoined.split(",", QString::SkipEmptyParts);
#endif
foreach (QString requiredField, requiredFieldsSplit) {
QString trimmedFieldName = requiredField.trimmed();
if (! trimmedFieldName.isEmpty()) {

View File

@ -406,19 +406,14 @@ macos_enable_layer_backing(void)
{
// At the time of this writing, the QTBUG-87014 for layerEnabledByMacOS is...
//
// ...in https://github.com/qt/qtbase/blob/5.12/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/5.12.10/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...in https://github.com/qt/qtbase/blob/5.15/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/5.15.2/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/6.0/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/6.0.0/src/plugins/platforms/cocoa/qnsview_drawing.mm
//
// We'll assume that it will be fixed in 5.12.11, 5.15.3, and 6.0.1.
// Note that we only ship LTS versions of Qt with our macOS packages.
// Feel free to add other versions if needed.
// We'll assume that it will be fixed in 5.15.3, 6.0.1, and >= 6.1.
#if \
(QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(5, 12, 11) \
|| (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) && QT_VERSION < QT_VERSION_CHECK(5, 15, 3)) \
((QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) && QT_VERSION < QT_VERSION_CHECK(5, 15, 3)) \
|| (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 1)) \
)
QOperatingSystemVersion os_ver = QOperatingSystemVersion::current();
@ -643,7 +638,7 @@ int main(int argc, char *qt_argv[])
// This function must be called before creating the application object.
// Qt::HighDpiScaleFactorRoundingPolicy::PassThrough is the default in Qt6,
// so this doesn't have any effect (Round is the default in 5.14 & 5.15)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) && defined(Q_OS_WIN)
#if defined(Q_OS_WIN)
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif

View File

@ -100,9 +100,7 @@
#endif
#include <QMimeDatabase>
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
#include <QStyleHints>
#endif
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) && defined(Q_OS_WIN)
#include <QStyleFactory>
@ -693,9 +691,7 @@ MainApplication::MainApplication(int &argc, char **argv) :
// Throw various settings at the wall with the hope that one of them will
// enable context menu shortcuts QTBUG-69452, QTBUG-109590
setAttribute(Qt::AA_DontShowShortcutsInContextMenus, false);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
styleHints()->setShowShortcutsInContextMenus(true);
#endif
//
// XXX - this means we try to check for the existence of all files

View File

@ -261,11 +261,7 @@ void FilterListModel::saveList()
QString line = QString("\"%1\"").arg(index(row, ColumnName).data().toString().trimmed());
line.append(QString(" %1").arg(index(row, ColumnExpression).data().toString()));
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
out << line << Qt::endl;
#else
out << line << endl;
#endif
}
file.close();

View File

@ -856,11 +856,7 @@ 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);

View File

@ -139,11 +139,7 @@ PrintDialog::~PrintDialog()
bool 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_) {
@ -180,11 +176,7 @@ bool PrintDialog::printLine(int indent, const char *line)
out_line.fill(' ', indent * 4);
out_line += 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
out_rect = cur_painter_->boundingRect(page_rect, Qt::TextWordWrap, out_line);
@ -248,11 +240,7 @@ 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(printer->resolution()).top();
#else
page_pos_ = printer->pageRect().top();
#endif
in_preview_ = in_preview;
/* Fill in our print args */

View File

@ -257,7 +257,6 @@ void ShowPacketBytesDialog::findText(bool go_back)
options |= QTextDocument::FindCaseSensitively;
}
if (use_regex_find_) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
// https://bugreports.qt.io/browse/QTBUG-88721
// QPlainTextEdit::find() searches case-insensitively unless
// QTextDocument::FindCaseSensitively is explicitly given.
@ -267,14 +266,7 @@ void ShowPacketBytesDialog::findText(bool go_back)
// QRegularExpression and QRegExp do not support Perl's /i, but
// the former at least does support the mode modifiers (?i) and
// (?-i), which can override QTextDocument::FindCaseSensitively.
//
// To make matters worse, while the QTextDocument::find() documentation
// is correct, QPlainTextEdit::find() claims that QRegularExpression
// works like QRegExp, which is incorrect.
QRegularExpression regex(ui->leFind->text(), QRegularExpression::UseUnicodePropertiesOption);
#else
QRegExp regex(ui->leFind->text(), (options & QTextDocument::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
#endif
found = ui->tePacketBytes->find(regex, std::move(options));
} else {
found = ui->tePacketBytes->find(ui->leFind->text(), std::move(options));

View File

@ -86,54 +86,6 @@ void TLSKeylogDialog::on_saveActivated()
prefs_main_write();
}
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
// Splits the string \a command into a list of tokens, and returns the list.
//
// Tokens with spaces can be surrounded by double quotes; three
// consecutive double quotes represent the quote character itself.
//
// Copied from Qt 5.15.2
static QStringList splitCommand(QStringView command)
{
QStringList args;
QString tmp;
int quoteCount = 0;
bool inQuote = false;
// handle quoting. tokens can be surrounded by double quotes
// "hello world". three consecutive double quotes represent
// the quote character itself.
for (int i = 0; i < command.size(); ++i) {
if (command.at(i) == QLatin1Char('"')) {
++quoteCount;
if (quoteCount == 3) {
// third consecutive quote
quoteCount = 0;
tmp += command.at(i);
}
continue;
}
if (quoteCount) {
if (quoteCount == 1)
inQuote = !inQuote;
quoteCount = 0;
}
if (!inQuote && command.at(i).isSpace()) {
if (!tmp.isEmpty()) {
args += tmp;
tmp.clear();
}
} else {
tmp += command.at(i);
}
}
if (!tmp.isEmpty())
args += tmp;
return args;
}
#endif
void TLSKeylogDialog::on_launchActivated()
{
QProcess externalProcess;
@ -145,11 +97,7 @@ void TLSKeylogDialog::on_launchActivated()
QString command = ui->commandLineEdit->text();
if (command.isEmpty())
return;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QStringList commandArgs = QProcess::splitCommand(command);
#else
QStringList commandArgs = splitCommand(command);
#endif
if (commandArgs.isEmpty())
return;

View File

@ -182,25 +182,8 @@ void ColorUtils::setScheme(int)
}
#endif
// Qt < 5.12.6 on macOS always uses Qt::blue for the link color, which is
// unreadable when using a dark theme. Changing the application palette
// via ...Application::setPalette is problematic, since QGuiApplication
// sets a flag (ApplicationPaletteExplicitlySet) which keeps us from
// catching theme changes.
//
// themeLinkBrush and themeLinkStyle provide convenience routines for
// fetching the link brush and style.
//
// We could also override MainApplication::palette, but keeping the
// routines together here seemed to make more sense.
QBrush ColorUtils::themeLinkBrush()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 6)
// https://bugreports.qt.io/browse/QTBUG-71740
if (themeIsDark()) {
return QBrush(tango_sky_blue_2);
}
#endif
return qApp->palette().link();
}

View File

@ -290,17 +290,9 @@ 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, 13, 0)
// For QT_VERSION >= 5.13.0 we call styleHints()->setShowShortcutsInContextMenus(true)
// in WiresharkApplication.
// QTBUG-71471
// QTBUG-61181
foreach (QAction *action, actions) {
action->setShortcutVisibleInContextMenu(true);
}
#else
Q_UNUSED(actions)
#endif
}
QVector<rtpstream_id_t *>qvector_rtpstream_ids_copy(QVector<rtpstream_id_t *> stream_ids)

View File

@ -199,13 +199,8 @@ CaptureFilterEdit::CaptureFilterEdit(QWidget *parent, bool plain) :
QComboBox *cf_combo = qobject_cast<QComboBox *>(parent);
if (cf_combo) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
connect(cf_combo, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::textActivated),
this, &CaptureFilterEdit::textEdited);
#else
connect(cf_combo, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated),
this, &CaptureFilterEdit::textEdited);
#endif
}
line_edit_timer_ = new QTimer(this);

View File

@ -42,12 +42,7 @@ CompressionGroupBox::CompressionGroupBox(QWidget *parent) :
setLayout(vbox);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
connect(bg_, &QButtonGroup::idToggled, [=] { emit stateChanged(); });
#else
connect(bg_, QOverload<int, bool>::of(&QButtonGroup::buttonToggled), [=] { emit stateChanged(); });
#endif
}
CompressionGroupBox::~CompressionGroupBox()

View File

@ -73,14 +73,13 @@ DisplayFilterCombo::DisplayFilterCombo(QWidget *parent) :
updateStyleSheet();
setToolTip(tr("Select from previously used filters."));
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
// Setting the placeholderText keeps newly added items from being the
// current item. It only works for the placeholderText of the QComboBox,
// not the lineEdit (even though the lineEdit's placeholderText is shown
// instead.) This only matters for any combobox created before the recent
// display filter list is read (i.e., the main window one.)
// https://bugreports.qt.io/browse/QTBUG-127279
setPlaceholderText(dfe->placeholderText());
#endif
if (cur_model == nullptr) {
cur_model = new QStandardItemModel();
@ -91,30 +90,11 @@ DisplayFilterCombo::DisplayFilterCombo(QWidget *parent) :
connect(mainApp, &MainApplication::preferencesChanged, this, &DisplayFilterCombo::updateMaxCount);
connect(dfe, &DisplayFilterEdit::filterPackets, this, &DisplayFilterCombo::filterApplied);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect(cur_model, &QAbstractItemModel::rowsAboutToBeInserted, this, &DisplayFilterCombo::rowsAboutToBeInserted);
#endif
connect(cur_model, &QAbstractItemModel::rowsInserted, this, &DisplayFilterCombo::rowsInserted);
}
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
void DisplayFilterCombo::rowsAboutToBeInserted(const QModelIndex&, int, int)
{
// If the current text is blank but we're inserting a row, that means
// it is being added programmatically from the model, and we want to
// clear it afterwards and show the placeholder text instead.
clear_state_ = (currentText() == QString());
}
#endif
void DisplayFilterCombo::rowsInserted(const QModelIndex&, int first, int last)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
if (clear_state_) {
clearEditText();
}
#endif
// Set the last used times of newly inserted items to the current
// time, in order. We could subclass QStandardItemModel instead.
QStandardItemModel *m = qobject_cast<QStandardItemModel*>(this->model());

View File

@ -23,16 +23,10 @@ public:
void updateStyleSheet();
protected:
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
void rowsAboutToBeInserted(const QModelIndex&, int, int);
#endif
void rowsInserted(const QModelIndex&, int, int);
virtual bool event(QEvent *event);
private:
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
bool clear_state_;
#endif
public slots:
bool checkDisplayFilter();

View File

@ -194,11 +194,7 @@ void PacketListHeader::contextMenuEvent(QContextMenuEvent *event)
contextMenu->addSeparator();
QActionGroup * alignmentActions = new QActionGroup(contextMenu);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14 ,0)
alignmentActions->setExclusionPolicy(QActionGroup::ExclusionPolicy::ExclusiveOptional);
#else
alignmentActions->setExclusive(false);
#endif
alignmentActions->setProperty("column", QVariant::fromValue(sectionIdx));
action = alignmentActions->addAction(tr("Align Left"));
action->setCheckable(true);

View File

@ -496,11 +496,7 @@ TrafficTab::writeGeoIPMapFile(QFile * fp, bool json_only, TrafficDataFilterProxy
QTextStream in(&ipmap);
QString line;
while (in.readLineInto(&line)) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
out << line << Qt::endl;
#else
out << line << endl;
#endif
}
out << QString("<script id=\"ipmap-data\" type=\"application/json\">\n");

View File

@ -420,11 +420,7 @@ void WirelessTimeline::wheelEvent(QWheelEvent *event)
zoom_level += steps;
if (zoom_level < 0) zoom_level = 0;
if (zoom_level > TIMELINE_MAX_ZOOM) zoom_level = TIMELINE_MAX_ZOOM;
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
zoom(event->position().x() / width());
#else
zoom(event->posF().x() / width());
#endif
}
}

View File

@ -1725,11 +1725,7 @@ void WiresharkMainWindow::addStatsPluginsToMenu() {
parent_menu = main_ui_->menuStatistics;
// gtk/main_menubar.c compresses double slashes, hence SkipEmptyParts
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList cfg_name_parts = QString(cfg->path).split(STATS_TREE_MENU_SEPARATOR, Qt::SkipEmptyParts);
#else
QStringList cfg_name_parts = QString(cfg->path).split(STATS_TREE_MENU_SEPARATOR, QString::SkipEmptyParts);
#endif
if (cfg_name_parts.isEmpty()) continue;
QString stat_name = cfg_name_parts.takeLast().trimmed();

View File

@ -635,34 +635,18 @@ add_custom_command(
# Use the number of dashes for each argument as documented at
# https://doc.qt.io/qt-6/rcc.html.
set(CMAKE_AUTORCC_OPTIONS --format-version 1)
if(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "5.13")
list(APPEND CMAKE_AUTORCC_OPTIONS -compress-algo zlib)
endif()
list(APPEND CMAKE_AUTORCC_OPTIONS -compress-algo zlib)
if(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "5.15")
qt_add_resources(STRATOSHARK_QT_QRC
${CMAKE_SOURCE_DIR}/resources/about.qrc
${CMAKE_SOURCE_DIR}/resources/languages/languages.qrc
${CMAKE_SOURCE_DIR}/resources/layout.qrc
${CMAKE_SOURCE_DIR}/resources/ssicon.qrc
${CMAKE_SOURCE_DIR}/resources/stock_icons.qrc
${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc
${CMAKE_CURRENT_BINARY_DIR}/authors.qrc
OPTIONS ${CMAKE_AUTORCC_OPTIONS}
)
else()
# The unversioned qt_add_resources was added in Qt 5.15
qt5_add_resources(STRATOSHARK_QT_QRC
${CMAKE_SOURCE_DIR}/resources/about.qrc
${CMAKE_SOURCE_DIR}/resources/languages/languages.qrc
${CMAKE_SOURCE_DIR}/resources/layout.qrc
${CMAKE_SOURCE_DIR}/resources/ssicon.qrc
${CMAKE_SOURCE_DIR}/resources/stock_icons.qrc
${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc
${CMAKE_CURRENT_BINARY_DIR}/authors.qrc
OPTIONS ${CMAKE_AUTORCC_OPTIONS}
)
endif()
qt_add_resources(STRATOSHARK_QT_QRC
${CMAKE_SOURCE_DIR}/resources/about.qrc
${CMAKE_SOURCE_DIR}/resources/languages/languages.qrc
${CMAKE_SOURCE_DIR}/resources/layout.qrc
${CMAKE_SOURCE_DIR}/resources/ssicon.qrc
${CMAKE_SOURCE_DIR}/resources/stock_icons.qrc
${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc
${CMAKE_CURRENT_BINARY_DIR}/authors.qrc
OPTIONS ${CMAKE_AUTORCC_OPTIONS}
)
if (USE_qt6)
QT6_ADD_TRANSLATION(STRATOSHARK_QT_QM ${STRATOSHARK_QT_TS} OPTIONS -silent)

View File

@ -376,19 +376,16 @@ macos_enable_layer_backing(void)
{
// At the time of this writing, the QTBUG-87014 for layerEnabledByMacOS is...
//
// ...in https://github.com/qt/qtbase/blob/5.12/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/5.12.10/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...in https://github.com/qt/qtbase/blob/5.15/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/5.15.2/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/6.0/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/6.0.0/src/plugins/platforms/cocoa/qnsview_drawing.mm
//
// We'll assume that it will be fixed in 5.12.11, 5.15.3, and 6.0.1.
// We'll assume that it will be fixed in 5.15.3, 6.0.1, and >= 6.1
// Note that we only ship LTS versions of Qt with our macOS packages.
// Feel free to add other versions if needed.
#if \
(QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(5, 12, 11) \
|| (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) && QT_VERSION < QT_VERSION_CHECK(5, 15, 3)) \
((QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) && QT_VERSION < QT_VERSION_CHECK(5, 15, 3)) \
|| (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 1)) \
)
QOperatingSystemVersion os_ver = QOperatingSystemVersion::current();
@ -662,7 +659,7 @@ int main(int argc, char *qt_argv[])
// This function must be called before creating the application object.
// Qt::HighDpiScaleFactorRoundingPolicy::PassThrough is the default in Qt6,
// so this doesn't have any effect (Round is the default in 5.14 & 5.15)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) && defined(Q_OS_WIN)
#if defined(Q_OS_WIN)
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif

View File

@ -1617,11 +1617,7 @@ void StratosharkMainWindow::addStatsPluginsToMenu() {
parent_menu = main_ui_->menuStatistics;
// gtk/main_menubar.c compresses double slashes, hence SkipEmptyParts
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList cfg_name_parts = QString(cfg->path).split(STATS_TREE_MENU_SEPARATOR, Qt::SkipEmptyParts);
#else
QStringList cfg_name_parts = QString(cfg->path).split(STATS_TREE_MENU_SEPARATOR, QString::SkipEmptyParts);
#endif
if (cfg_name_parts.isEmpty()) continue;
QString stat_name = cfg_name_parts.takeLast().trimmed();