Drop support of Qt 5

Also remove usage of some deprecated stuff.

PR #19338.
This commit is contained in:
Vladimir Golovnev
2023-07-20 11:17:27 +03:00
committed by GitHub
parent 5e610cfdcf
commit dbe79484d2
55 changed files with 48 additions and 462 deletions

View File

@@ -1,11 +1,4 @@
if (QT6)
find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS Widgets Svg)
else()
find_package(Qt5 ${minQt5Version} REQUIRED COMPONENTS Widgets Svg)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
find_package(Qt5 ${minQt5Version} REQUIRED COMPONENTS WinExtras)
endif()
endif()
find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS Widgets Svg)
# CMAKE_AUTO_UI causes unnecessary rebuilds
qt_wrap_ui(UI_HEADERS
@@ -276,9 +269,6 @@ endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(qbt_gui PRIVATE PowrProf)
if (NOT QT6)
target_link_libraries(qbt_gui PRIVATE Qt5::WinExtras)
endif()
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")

View File

@@ -153,16 +153,7 @@ public:
: BitTorrent::TorrentContentLayout::Subfolder);
if (!m_filePriorities.isEmpty())
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
const int currentSize = m_filePriorities.size();
m_filePriorities.resize(filesCount());
for (int i = currentSize; i < filesCount(); ++i)
m_filePriorities[i] = BitTorrent::DownloadPriority::Normal;
#else
m_filePriorities.resize(filesCount(), BitTorrent::DownloadPriority::Normal);
#endif
}
}
bool hasMetadata() const override
@@ -289,13 +280,8 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
, m_storeDialogSize(SETTINGS_KEY(u"DialogSize"_s))
, m_storeDefaultCategory(SETTINGS_KEY(u"DefaultCategory"_s))
, m_storeRememberLastSavePath(SETTINGS_KEY(u"RememberLastSavePath"_s))
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
, m_storeTreeHeaderState(u"GUI/Qt6/" SETTINGS_KEY(u"TreeHeaderState"_s))
, m_storeSplitterState(u"GUI/Qt6/" SETTINGS_KEY(u"SplitterState"_s))
#else
, m_storeTreeHeaderState(SETTINGS_KEY(u"TreeHeaderState"_s))
, m_storeSplitterState(SETTINGS_KEY(u"SplitterState"_s))
#endif
{
// TODO: set dialog file properties using m_torrentParams.filePriorities
m_ui->setupUi(this);

View File

@@ -44,11 +44,7 @@ CookiesDialog::CookiesDialog(QWidget *parent)
, m_ui(new Ui::CookiesDialog)
, m_cookiesModel(new CookiesModel(Net::DownloadManager::instance()->allCookies(), this))
, m_storeDialogSize(SETTINGS_KEY(u"Size"_s))
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
, m_storeViewState("GUI/Qt6/" SETTINGS_KEY(u"ViewState"_s))
#else
, m_storeViewState(SETTINGS_KEY(u"CookiesViewState"_s))
#endif
{
m_ui->setupUi(this);

View File

@@ -98,7 +98,7 @@ FileSystemPathEdit::FileSystemPathEditPrivate::FileSystemPathEditPrivate(
, m_validator {new Private::FileSystemPathValidator(q)}
{
m_browseAction->setIconText(browseButtonBriefText.tr());
m_browseAction->setShortcut(Qt::CTRL + Qt::Key_B);
m_browseAction->setShortcut(Qt::CTRL | Qt::Key_B);
m_browseAction->setToolTip(browseButtonFullText.tr().remove(u'&'));
m_browseBtn->setDefaultAction(m_browseAction);

View File

@@ -39,6 +39,7 @@
#include <versionhelpers.h> // must follow after Windows.h
#endif
#include <QAction>
#include <QActionGroup>
#include <QClipboard>
#include <QCloseEvent>
@@ -49,6 +50,7 @@
#include <QFileSystemWatcher>
#include <QKeyEvent>
#include <QLabel>
#include <QMenu>
#include <QMessageBox>
#include <QMetaObject>
#include <QMimeData>
@@ -870,7 +872,7 @@ void MainWindow::createKeyboardShortcuts()
m_ui->actionIncreaseQueuePos->setShortcut(Qt::CTRL | Qt::Key_Plus);
m_ui->actionTopQueuePos->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_Plus);
#ifdef Q_OS_MACOS
m_ui->actionMinimize->setShortcut(Qt::CTRL + Qt::Key_M);
m_ui->actionMinimize->setShortcut(Qt::CTRL | Qt::Key_M);
addAction(m_ui->actionMinimize);
#endif
}

View File

@@ -52,11 +52,7 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
, m_ui(new Ui::PreviewSelectDialog)
, m_torrent(torrent)
, m_storeDialogSize(SETTINGS_KEY(u"Size"_s))
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
, m_storeTreeHeaderState(u"GUI/Qt6/" SETTINGS_KEY(u"HeaderState"_s))
#else
, m_storeTreeHeaderState(SETTINGS_KEY(u"HeaderState"_s))
#endif
{
m_ui->setupUi(this);

View File

@@ -74,17 +74,10 @@ bool operator==(const PeerEndpoint &left, const PeerEndpoint &right)
return (left.address == right.address) && (left.connectionType == right.connectionType);
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const PeerEndpoint &peerEndpoint, const std::size_t seed = 0)
{
return qHashMulti(seed, peerEndpoint.address, peerEndpoint.connectionType);
}
#else
uint qHash(const PeerEndpoint &peerEndpoint, const uint seed = 0)
{
return (qHash(peerEndpoint.address, seed) ^ ::qHash(peerEndpoint.connectionType));
}
#endif
namespace
{

View File

@@ -144,11 +144,7 @@ bool PiecesBar::event(QEvent *e)
return base::event(e);
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void PiecesBar::enterEvent(QEnterEvent *e)
#else
void PiecesBar::enterEvent(QEvent *e)
#endif
{
m_hovered = true;
base::enterEvent(e);

View File

@@ -59,11 +59,7 @@ public:
protected:
// QWidget interface
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void enterEvent(QEnterEvent *e) override;
#else
void enterEvent(QEvent *e) override;
#endif
void leaveEvent(QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;

View File

@@ -48,7 +48,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"help-about"_s, u"document-properties"_s),
#endif
tr("General"), parent);
mainInfosButton->setShortcut(Qt::ALT + Qt::Key_G);
mainInfosButton->setShortcut(Qt::ALT | Qt::Key_G);
addWidget(mainInfosButton);
m_btnGroup->addButton(mainInfosButton, MainTab);
// Trackers tab
@@ -57,7 +57,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"trackers"_s, u"network-server"_s),
#endif
tr("Trackers"), parent);
trackersButton->setShortcut(Qt::ALT + Qt::Key_C);
trackersButton->setShortcut(Qt::ALT | Qt::Key_C);
addWidget(trackersButton);
m_btnGroup->addButton(trackersButton, TrackersTab);
// Peers tab
@@ -66,7 +66,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"peers"_s),
#endif
tr("Peers"), parent);
peersButton->setShortcut(Qt::ALT + Qt::Key_R);
peersButton->setShortcut(Qt::ALT | Qt::Key_R);
addWidget(peersButton);
m_btnGroup->addButton(peersButton, PeersTab);
// URL seeds tab
@@ -75,7 +75,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"network-server"_s),
#endif
tr("HTTP Sources"), parent);
URLSeedsButton->setShortcut(Qt::ALT + Qt::Key_B);
URLSeedsButton->setShortcut(Qt::ALT | Qt::Key_B);
addWidget(URLSeedsButton);
m_btnGroup->addButton(URLSeedsButton, URLSeedsTab);
// Files tab
@@ -84,7 +84,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"directory"_s),
#endif
tr("Content"), parent);
filesButton->setShortcut(Qt::ALT + Qt::Key_Z);
filesButton->setShortcut(Qt::ALT | Qt::Key_Z);
addWidget(filesButton);
m_btnGroup->addButton(filesButton, FilesTab);
// Spacer
@@ -95,7 +95,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"chart-line"_s),
#endif
tr("Speed"), parent);
speedButton->setShortcut(Qt::ALT + Qt::Key_D);
speedButton->setShortcut(Qt::ALT | Qt::Key_D);
addWidget(speedButton);
m_btnGroup->addButton(speedButton, SpeedTab);
// SIGNAL/SLOT

View File

@@ -67,13 +67,8 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent)
, m_ui {new Ui::AutomatedRssDownloader}
, m_addTorrentParamsWidget {new AddTorrentParamsWidget}
, m_storeDialogSize {u"RssFeedDownloader/geometrySize"_s}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
, m_storeMainSplitterState {u"GUI/Qt6/RSSFeedDownloader/HSplitterSizes"_s}
, m_storeRuleDefSplitterState {u"GUI/Qt6/RSSFeedDownloader/RuleDefSplitterState"_s}
#else
, m_storeMainSplitterState {u"RssFeedDownloader/qt5/hsplitterSizes"_s}
, m_storeRuleDefSplitterState {u"RssFeedDownloader/qt5/RuleDefSplitterState"_s}
#endif
{
m_ui->setupUi(this);

View File

@@ -242,7 +242,7 @@ void FeedListWidget::dragMoveEvent(QDragMoveEvent *event)
{
QTreeWidget::dragMoveEvent(event);
QTreeWidgetItem *item = itemAt(event->pos());
QTreeWidgetItem *item = itemAt(event->position().toPoint());
if ((item == m_unreadStickyItem) // Prohibit dropping onto global unread counter
|| selectedItems().contains(m_unreadStickyItem) // Prohibit dragging of global unread counter
|| (item && isFeed(item))) // Prohibit dropping onto feeds
@@ -253,7 +253,7 @@ void FeedListWidget::dragMoveEvent(QDragMoveEvent *event)
void FeedListWidget::dropEvent(QDropEvent *event)
{
QTreeWidgetItem *destFolderItem = itemAt(event->pos());
QTreeWidgetItem *destFolderItem = itemAt(event->position().toPoint());
RSS::Folder *destFolder = (destFolderItem
? static_cast<RSS::Folder *>(getRSSItem(destFolderItem))
: RSS::Session::instance()->rootFolder());

View File

@@ -40,9 +40,6 @@
#if defined(Q_OS_WIN)
#include <Windows.h>
#include <Shellapi.h>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QtWin>
#endif
#else
#include <QMimeDatabase>
#include <QMimeType>
@@ -133,11 +130,7 @@ namespace
if (FAILED(hr))
return {};
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
const auto iconPixmap = QPixmap::fromImage(QImage::fromHICON(sfi.hIcon));
#else
const QPixmap iconPixmap = QtWin::fromHICON(sfi.hIcon);
#endif
::DestroyIcon(sfi.hIcon);
return iconPixmap;
}

View File

@@ -217,15 +217,15 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
connect(editHotkey, &QShortcut::activated, this, &TransferListWidget::renameSelectedTorrent);
const auto *deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(deleteHotkey, &QShortcut::activated, this, &TransferListWidget::softDeleteSelectedTorrents);
const auto *permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, nullptr, nullptr, Qt::WidgetShortcut);
const auto *permDeleteHotkey = new QShortcut((Qt::SHIFT | Qt::Key_Delete), this, nullptr, nullptr, Qt::WidgetShortcut);
connect(permDeleteHotkey, &QShortcut::activated, this, &TransferListWidget::permDeleteSelectedTorrents);
const auto *doubleClickHotkeyReturn = new QShortcut(Qt::Key_Return, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(doubleClickHotkeyReturn, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked);
const auto *doubleClickHotkeyEnter = new QShortcut(Qt::Key_Enter, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(doubleClickHotkeyEnter, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked);
const auto *recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, nullptr, nullptr, Qt::WidgetShortcut);
const auto *recheckHotkey = new QShortcut((Qt::CTRL | Qt::Key_R), this, nullptr, nullptr, Qt::WidgetShortcut);
connect(recheckHotkey, &QShortcut::activated, this, &TransferListWidget::recheckSelectedTorrents);
const auto *forceStartHotkey = new QShortcut(Qt::CTRL + Qt::Key_M, this, nullptr, nullptr, Qt::WidgetShortcut);
const auto *forceStartHotkey = new QShortcut((Qt::CTRL | Qt::Key_M), this, nullptr, nullptr, Qt::WidgetShortcut);
connect(forceStartHotkey, &QShortcut::activated, this, &TransferListWidget::forceStartSelectedTorrents);
}