Merge pull request #14593 from glassez/qt6-compat

Make current codebase more compatible with Qt6
This commit is contained in:
Vladimir Golovnev
2021-03-29 14:00:23 +03:00
committed by GitHub
12 changed files with 48 additions and 17 deletions

View File

@@ -549,10 +549,10 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
const QModelIndexList selectedRows = m_ui->contentTreeView->selectionModel()->selectedRows(0);
const int priorityGroups = 3;
const int priorityGroupSize = std::max((selectedRows.length() / priorityGroups), 1);
const qsizetype priorityGroups = 3;
const auto priorityGroupSize = std::max<qsizetype>((selectedRows.length() / priorityGroups), 1);
for (int i = 0; i < selectedRows.length(); ++i)
for (qsizetype i = 0; i < selectedRows.length(); ++i)
{
auto priority = BitTorrent::DownloadPriority::Ignored;
switch (i / priorityGroupSize)

View File

@@ -143,7 +143,11 @@ 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

@@ -54,15 +54,19 @@ public:
virtual void clear();
// QObject interface
virtual bool event(QEvent*) override;
virtual bool event(QEvent *e) override;
protected:
// QWidget interface
void enterEvent(QEvent*) override;
void leaveEvent(QEvent*) override;
void mouseMoveEvent(QMouseEvent*) override;
#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;
void paintEvent(QPaintEvent*) override;
void paintEvent(QPaintEvent *e) override;
void requestImageUpdate();
QColor backgroundColor() const;

View File

@@ -637,10 +637,10 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
const QModelIndexList selectedRows = m_ui->filesList->selectionModel()->selectedRows(0);
const int priorityGroups = 3;
const int priorityGroupSize = std::max((selectedRows.length() / priorityGroups), 1);
const qsizetype priorityGroups = 3;
const auto priorityGroupSize = std::max<qsizetype>((selectedRows.length() / priorityGroups), 1);
for (int i = 0; i < selectedRows.length(); ++i)
for (qsizetype i = 0; i < selectedRows.length(); ++i)
{
auto priority = BitTorrent::DownloadPriority::Ignored;
switch (i / priorityGroupSize)

View File

@@ -37,7 +37,9 @@
#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>
@@ -118,7 +120,11 @@ namespace
if (FAILED(hr))
return {};
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
auto iconPixmap = QPixmap::fromImage(QImage::fromHICON(sfi.hIcon));
#else
QPixmap iconPixmap = QtWin::fromHICON(sfi.hIcon);
#endif
::DestroyIcon(sfi.hIcon);
return iconPixmap;
}