chore: initial Qt6 build support

This commit is contained in:
Gary Wang 2021-10-02 19:57:42 +08:00
parent 26c4c8871d
commit a4416cd77c
7 changed files with 25 additions and 11 deletions

View File

@ -17,7 +17,7 @@ FramelessWindow::FramelessWindow(QWidget *parent)
// https://bugreports.qt.io/browse/QTBUG-91226 // https://bugreports.qt.io/browse/QTBUG-91226
this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint); this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);
m_centralLayout->setMargin(0); m_centralLayout->setContentsMargins(QMargins());
} }
void FramelessWindow::setCentralWidget(QWidget *widget) void FramelessWindow::setCentralWidget(QWidget *widget)
@ -31,7 +31,7 @@ void FramelessWindow::setCentralWidget(QWidget *widget)
m_centralWidget = widget; m_centralWidget = widget;
} }
bool FramelessWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) bool FramelessWindow::nativeEvent(const QByteArray &eventType, void *message, NATIVE_RESULT *result)
{ {
#ifdef _WIN32 #ifdef _WIN32
// https://stackoverflow.com/questions/43505580/qt-windows-resizable-frameless-window // https://stackoverflow.com/questions/43505580/qt-windows-resizable-frameless-window

View File

@ -3,6 +3,12 @@
#include <QWidget> #include <QWidget>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
typedef qintptr NATIVE_RESULT;
#else
typedef long NATIVE_RESULT;
#endif // QT_VERSION_CHECK(6, 0, 0)
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QVBoxLayout; class QVBoxLayout;
QT_END_NAMESPACE QT_END_NAMESPACE
@ -16,7 +22,7 @@ public:
void setCentralWidget(QWidget * widget); void setCentralWidget(QWidget * widget);
protected: protected:
bool nativeEvent(const QByteArray& eventType, void* message, long* result) override; bool nativeEvent(const QByteArray& eventType, void* message, NATIVE_RESULT* result) override;
private: private:
QVBoxLayout * m_centralLayout = nullptr; QVBoxLayout * m_centralLayout = nullptr;

View File

@ -25,6 +25,7 @@
#include <QClipboard> #include <QClipboard>
#include <QMimeData> #include <QMimeData>
#include <QWindow> #include <QWindow>
#include <QFile>
#include <QTimer> #include <QTimer>
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
@ -245,7 +246,7 @@ void MainWindow::showEvent(QShowEvent *event)
return FramelessWindow::showEvent(event); return FramelessWindow::showEvent(event);
} }
void MainWindow::enterEvent(QEvent *event) void MainWindow::enterEvent(QT_ENTER_EVENT *event)
{ {
m_bottomButtonGroup->setOpacity(1); m_bottomButtonGroup->setOpacity(1);
m_gv->setOpacity(1); m_gv->setOpacity(1);

View File

@ -7,6 +7,12 @@
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include <QPushButton> #include <QPushButton>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
typedef QEnterEvent QT_ENTER_EVENT;
#else
typedef QEvent QT_ENTER_EVENT;
#endif // QT_VERSION_CHECK(6, 0, 0)
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QGraphicsOpacityEffect; class QGraphicsOpacityEffect;
class QGraphicsView; class QGraphicsView;
@ -37,7 +43,7 @@ public:
protected slots: protected slots:
void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
void enterEvent(QEvent *event) override; void enterEvent(QT_ENTER_EVENT *event) override;
void leaveEvent(QEvent *event) override; void leaveEvent(QEvent *event) override;
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;

View File

@ -183,14 +183,14 @@ QString MetadataModel::imageSizeRatio(const QSize &size)
return tr("%1 : %2").arg(QString::number(size.width() / gcd), QString::number(size.height() / gcd)); return tr("%1 : %2").arg(QString::number(size.width() / gcd), QString::number(size.height() / gcd));
} }
bool MetadataModel::appendSection(const QString &sectionKey, const QString &sectionDisplayName) bool MetadataModel::appendSection(const QString &sectionKey, QStringView sectionDisplayName)
{ {
if (m_sections.contains(sectionKey)) { if (m_sections.contains(sectionKey)) {
return false; return false;
} }
m_sections.append(sectionKey); m_sections.append(sectionKey);
m_sectionProperties[sectionKey] = qMakePair<QString, QList<QString> >(sectionDisplayName, {}); m_sectionProperties[sectionKey] = qMakePair<QString, QList<QString> >(sectionDisplayName.toString(), {});
return true; return true;
} }
@ -202,7 +202,7 @@ bool MetadataModel::appendPropertyIfNotEmpty(const QString &sectionKey, const QS
return appendProperty(sectionKey, propertyKey, propertyDisplayName, propertyValue); return appendProperty(sectionKey, propertyKey, propertyDisplayName, propertyValue);
} }
bool MetadataModel::appendProperty(const QString &sectionKey, const QString &propertyKey, const QString &propertyDisplayName, const QString &propertyValue) bool MetadataModel::appendProperty(const QString &sectionKey, const QString &propertyKey, QStringView propertyDisplayName, QStringView propertyValue)
{ {
if (!m_sections.contains(sectionKey)) { if (!m_sections.contains(sectionKey)) {
return false; return false;
@ -213,7 +213,7 @@ bool MetadataModel::appendProperty(const QString &sectionKey, const QString &pro
propertyList.append(propertyKey); propertyList.append(propertyKey);
} }
m_properties[propertyKey] = qMakePair<QString, QString>(propertyDisplayName, propertyValue); m_properties[propertyKey] = qMakePair<QString, QString>(propertyDisplayName.toString(), propertyValue.toString());
return true; return true;
} }

View File

@ -15,11 +15,11 @@ public:
void setFile(const QString & imageFilePath); void setFile(const QString & imageFilePath);
static QString imageSize(const QSize &size); static QString imageSize(const QSize &size);
static QString imageSizeRatio(const QSize &size); static QString imageSizeRatio(const QSize &size);
bool appendSection(const QString & sectionKey, const QString & sectionDisplayName); bool appendSection(const QString & sectionKey, QStringView sectionDisplayName);
bool appendPropertyIfNotEmpty(const QString & sectionKey, const QString & propertyKey, bool appendPropertyIfNotEmpty(const QString & sectionKey, const QString & propertyKey,
const QString & propertyDisplayName, const QString & propertyValue = QString()); const QString & propertyDisplayName, const QString & propertyValue = QString());
bool appendProperty(const QString & sectionKey, const QString & propertyKey, bool appendProperty(const QString & sectionKey, const QString & propertyKey,
const QString & propertyDisplayName, const QString & propertyValue = QString()); QStringView propertyDisplayName, QStringView propertyValue = QString());
bool appendExivPropertyIfExist(const Exiv2Wrapper & wrapper, const QString & sectionKey, bool appendExivPropertyIfExist(const Exiv2Wrapper & wrapper, const QString & sectionKey,
const QString & exiv2propertyKey, const QString & propertyDisplayName = QString(), const QString & exiv2propertyKey, const QString & propertyDisplayName = QString(),
bool isXmpString = false); bool isXmpString = false);

View File

@ -1,4 +1,5 @@
QT += core widgets gui svg QT += core widgets gui svg
greaterThan(QT_MAJOR_VERSION, 5): QT += svgwidgets
TARGET = ppic TARGET = ppic
TEMPLATE = app TEMPLATE = app