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
this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);
m_centralLayout->setMargin(0);
m_centralLayout->setContentsMargins(QMargins());
}
void FramelessWindow::setCentralWidget(QWidget *widget)
@ -31,7 +31,7 @@ void FramelessWindow::setCentralWidget(QWidget *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
// https://stackoverflow.com/questions/43505580/qt-windows-resizable-frameless-window

View File

@ -3,6 +3,12 @@
#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
class QVBoxLayout;
QT_END_NAMESPACE
@ -16,7 +22,7 @@ public:
void setCentralWidget(QWidget * widget);
protected:
bool nativeEvent(const QByteArray& eventType, void* message, long* result) override;
bool nativeEvent(const QByteArray& eventType, void* message, NATIVE_RESULT* result) override;
private:
QVBoxLayout * m_centralLayout = nullptr;

View File

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

View File

@ -7,6 +7,12 @@
#include <QPropertyAnimation>
#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
class QGraphicsOpacityEffect;
class QGraphicsView;
@ -37,7 +43,7 @@ public:
protected slots:
void showEvent(QShowEvent *event) override;
void enterEvent(QEvent *event) override;
void enterEvent(QT_ENTER_EVENT *event) override;
void leaveEvent(QEvent *event) override;
void mousePressEvent(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));
}
bool MetadataModel::appendSection(const QString &sectionKey, const QString &sectionDisplayName)
bool MetadataModel::appendSection(const QString &sectionKey, QStringView sectionDisplayName)
{
if (m_sections.contains(sectionKey)) {
return false;
}
m_sections.append(sectionKey);
m_sectionProperties[sectionKey] = qMakePair<QString, QList<QString> >(sectionDisplayName, {});
m_sectionProperties[sectionKey] = qMakePair<QString, QList<QString> >(sectionDisplayName.toString(), {});
return true;
}
@ -202,7 +202,7 @@ bool MetadataModel::appendPropertyIfNotEmpty(const QString &sectionKey, const QS
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)) {
return false;
@ -213,7 +213,7 @@ bool MetadataModel::appendProperty(const QString &sectionKey, const QString &pro
propertyList.append(propertyKey);
}
m_properties[propertyKey] = qMakePair<QString, QString>(propertyDisplayName, propertyValue);
m_properties[propertyKey] = qMakePair<QString, QString>(propertyDisplayName.toString(), propertyValue.toString());
return true;
}

View File

@ -15,11 +15,11 @@ public:
void setFile(const QString & imageFilePath);
static QString imageSize(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,
const QString & propertyDisplayName, const QString & propertyValue = QString());
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,
const QString & exiv2propertyKey, const QString & propertyDisplayName = QString(),
bool isXmpString = false);

View File

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