diff --git a/examples/collections/buttonexample.cpp b/examples/collections/buttonexample.cpp index 44c6272ae..c6842ad0d 100644 --- a/examples/collections/buttonexample.cpp +++ b/examples/collections/buttonexample.cpp @@ -71,7 +71,7 @@ DPushButtonExample::DPushButtonExample(QWidget *parent) DPushButton *pButtonDisabled = new DPushButton("button disabled", this); pButtonDisabled->setFixedSize(DSizeModeHelper::element(QSize(200, 24), QSize(200, 36))); // connect `sizeModeChanged()` signal to update Size. - connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, [pButtonDisabled](DGuiApplicationHelper::SizeMode mode) { + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, [pButtonDisabled](DGuiApplicationHelper::SizeMode) { pButtonDisabled->setFixedSize(DSizeModeHelper::element(QSize(200, 24), QSize(200, 36))); }); pButtonDisabled->setEnabled(false); @@ -402,7 +402,7 @@ DIconButtonExample::DIconButtonExample(QWidget *parent) pButton_8->setIconSize(QSize(16, 16)); DStyle::setFocusRectVisible(pButton_8, false); - auto updateButtonSize = [](QWidget *widget, int mode) { + auto updateButtonSize = [](QWidget *widget, int) { for (auto button : widget->findChildren(QString(), Qt::FindDirectChildrenOnly)) { if (button->iconSize() == QSize(16, 16)) { button->setFixedSize(DSizeModeHelper::element(QSize(20, 20), QSize(24, 24))); diff --git a/examples/collections/main.cpp b/examples/collections/main.cpp index fd63029f8..3e8c00c06 100644 --- a/examples/collections/main.cpp +++ b/examples/collections/main.cpp @@ -20,7 +20,9 @@ int main(int argc, char *argv[]) #endif DApplication *a = DApplication::globalApplication(argc, argv); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) DApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); +#endif DLogManager::registerConsoleAppender(); a->loadTranslator(); diff --git a/examples/collections/widgetexample.cpp b/examples/collections/widgetexample.cpp index af1301d03..9645af6f2 100644 --- a/examples/collections/widgetexample.cpp +++ b/examples/collections/widgetexample.cpp @@ -153,7 +153,7 @@ QVariant CalendarModel::data(const QModelIndex &index, int role) const return QString::number(days); } } -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) case Qt::TextColorRole: { #else case Qt::ForegroundRole:{ @@ -179,7 +179,7 @@ QVariant CalendarModel::data(const QModelIndex &index, int role) const QVariant CalendarModel::headerData(int section, Qt::Orientation orientation, int role) const { if ( -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) role == Qt::BackgroundColorRole || #endif role == Qt::BackgroundRole) diff --git a/include/util/dapplicationsettings.h b/include/util/dapplicationsettings.h index b058ed1eb..730f9cd3e 100644 --- a/include/util/dapplicationsettings.h +++ b/include/util/dapplicationsettings.h @@ -19,7 +19,7 @@ class DApplicationSettings : public QObject, public DCORE_NAMESPACE::DObject D_DECLARE_PRIVATE(DApplicationSettings) public: - Q_DECL_DEPRECATED_X("The feature has been moved to DGuiApplicationHelper, We can disable it by setting DGuiApplicationHelper::DontSaveApplicationTheme enum with setAttribute.") + D_DECL_DEPRECATED_X("The feature has been moved to DGuiApplicationHelper, We can disable it by setting DGuiApplicationHelper::DontSaveApplicationTheme enum with setAttribute.") explicit DApplicationSettings(QObject *parent = nullptr); private: diff --git a/include/util/dhidpihelper.h b/include/util/dhidpihelper.h index b9e13b0fb..0d35ebdb5 100644 --- a/include/util/dhidpihelper.h +++ b/include/util/dhidpihelper.h @@ -9,10 +9,10 @@ DWIDGET_BEGIN_NAMESPACE -class Q_DECL_DEPRECATED DHiDPIHelper +class D_DECL_DEPRECATED DHiDPIHelper { public: - Q_DECL_DEPRECATED_X("Use Dtk::Gui::DIcon::loadNxPixmap") static QPixmap loadNxPixmap(const QString &fileName); + D_DECL_DEPRECATED_X("Use Dtk::Gui::DIcon::loadNxPixmap") static QPixmap loadNxPixmap(const QString &fileName); }; DWIDGET_END_NAMESPACE diff --git a/plugin/dtkuiplugin/dcustomermacrowidget.h b/plugin/dtkuiplugin/dcustomermacrowidget.h index e8a1a8030..6880f02a8 100644 --- a/plugin/dtkuiplugin/dcustomermacrowidget.h +++ b/plugin/dtkuiplugin/dcustomermacrowidget.h @@ -36,10 +36,8 @@ #include #include #include -#include #include #include -#include #include #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 795075076..52ea18abe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,6 +33,7 @@ target_compile_definitions(${LIBNAME} PRIVATE DTK_NO_MULTIMEDIA DWIDGET_TRANSLATIONS_DIR="${TRANSLATIONS_INSTALL_DIR}" LIBDTKWIDGET_LIBRARY + D_IGNORE_DEPRECATIONS ) if(DTK_STATIC_TRANSLATION) diff --git a/src/util/dwidgetutil.cpp b/src/util/dwidgetutil.cpp index 31e41ffdf..65118cb04 100644 --- a/src/util/dwidgetutil.cpp +++ b/src/util/dwidgetutil.cpp @@ -12,6 +12,7 @@ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #endif +#include QT_BEGIN_NAMESPACE //extern Q_WIDGETS_EXPORT void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0); @@ -60,7 +61,7 @@ QImage dropShadow(const QPixmap &px, qreal radius, const QColor &color) void moveToCenter(QWidget *w) { Q_ASSERT(w != nullptr); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) QDesktopWidget *dw = QApplication::desktop(); QRect parentRect = dw->availableGeometry(dw->primaryScreen()); #else diff --git a/src/widgets/daboutdialog.cpp b/src/widgets/daboutdialog.cpp index c04535306..3aae73334 100644 --- a/src/widgets/daboutdialog.cpp +++ b/src/widgets/daboutdialog.cpp @@ -375,7 +375,8 @@ QPixmap DAboutDialog::companyLogo() const #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return d->companyLogoLabel->pixmap(Qt::ReturnByValue); #else - return d->companyLogoLabel->pixmap(); + const_cast(d)->companyLogoPixmap = d->companyLogoLabel->pixmap(Qt::ReturnByValue); + return &(d->companyLogoPixmap); #endif } diff --git a/src/widgets/dbaseexpand.cpp b/src/widgets/dbaseexpand.cpp index d5e1b0033..13b2d4789 100644 --- a/src/widgets/dbaseexpand.cpp +++ b/src/widgets/dbaseexpand.cpp @@ -115,6 +115,7 @@ DBaseExpandPrivate::~DBaseExpandPrivate() @fn void DBaseExpand::expandChange(bool e) @brief content widget visibility signal @param[in] e If "true", the content widget becomes visible, otherwise, the content widget becomes invisible. +*/ /*! @~english diff --git a/src/widgets/dfontcombobox.cpp b/src/widgets/dfontcombobox.cpp index d41fa49ae..7658204d5 100644 --- a/src/widgets/dfontcombobox.cpp +++ b/src/widgets/dfontcombobox.cpp @@ -52,6 +52,8 @@ DFontComboBoxPrivate::~DFontComboBoxPrivate() @endcode @image html DFontComboBox.png +*/ + /*! @~english @brief DFontComboBox constructor. diff --git a/src/widgets/dlineedit.cpp b/src/widgets/dlineedit.cpp index ebb377e07..ac09a9c9c 100644 --- a/src/widgets/dlineedit.cpp +++ b/src/widgets/dlineedit.cpp @@ -494,7 +494,7 @@ bool DLineEdit::eventFilter(QObject *watched, QEvent *event) D_D(DLineEdit); if (event->type() == QEvent::FocusIn) { - if (DGuiApplicationHelper::IsTableEnvironment && QGuiApplication::inputMethod()) + if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsTableEnvironment) && QGuiApplication::inputMethod() != nullptr) QGuiApplication::inputMethod()->show(); Q_EMIT focusChanged(true); } else if (event->type() == QEvent::FocusOut) { diff --git a/src/widgets/dprintpreviewwidget.cpp b/src/widgets/dprintpreviewwidget.cpp index 1898aa442..b8d494f41 100644 --- a/src/widgets/dprintpreviewwidget.cpp +++ b/src/widgets/dprintpreviewwidget.cpp @@ -1222,7 +1222,7 @@ QVector DPrintPreviewWidgetPrivate::requestPages(int page) \a parent 父控件 */ DPrintPreviewWidget::DPrintPreviewWidget(DPrinter *printer, QWidget *parent) - : DFrame(*new DPrintPreviewWidgetPrivate(this)) + : DFrame(*new DPrintPreviewWidgetPrivate(this), parent) { Q_D(DPrintPreviewWidget); d->previewPrinter = printer; diff --git a/src/widgets/dstyle.cpp b/src/widgets/dstyle.cpp index ad69aa235..6129cca59 100644 --- a/src/widgets/dstyle.cpp +++ b/src/widgets/dstyle.cpp @@ -2194,7 +2194,7 @@ void DStyle::drawControl(QStyle::ControlElement ce, const QStyleOption *opt, QPa */ int DStyle::pixelMetric(QStyle::PixelMetric m, const QStyleOption *opt, const QWidget *widget) const { - switch (m) { + switch (static_cast(m)) { case PM_ButtonDefaultIndicator: case PM_ButtonShiftHorizontal: case PM_ButtonShiftVertical: diff --git a/src/widgets/dstyleditemdelegate.cpp b/src/widgets/dstyleditemdelegate.cpp index fbdaf819b..b10a4043d 100644 --- a/src/widgets/dstyleditemdelegate.cpp +++ b/src/widgets/dstyleditemdelegate.cpp @@ -83,6 +83,7 @@ DWIDGET_END_NAMESPACE Q_DECLARE_METATYPE(DTK_WIDGET_NAMESPACE::ActionList) DWIDGET_BEGIN_NAMESPACE +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) static void saveDViewItemActionList(QDataStream &s, const void *d) { const ActionList &data = *static_cast(d); @@ -95,17 +96,18 @@ static void loadDViewItemActionList(QDataStream &s, void *d) s >> data; } -__attribute__((constructor)) static void registerMetaType () { - #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // register DViewItemActionList's stream operator to support that QMetaType can using save and load function. QMetaType::registerStreamOperators(QMetaTypeId::qt_metatype_id(), saveDViewItemActionList, loadDViewItemActionList); - #endif } +Q_CONSTRUCTOR_FUNCTION(registerMetaType) + +#endif + static DViewItemActionList qvariantToActionList(const QVariant &v) { const ActionList &wrapper = v.value(); diff --git a/src/widgets/private/daboutdialog_p.h b/src/widgets/private/daboutdialog_p.h index b0006c65a..7808a33b7 100644 --- a/src/widgets/private/daboutdialog_p.h +++ b/src/widgets/private/daboutdialog_p.h @@ -44,6 +44,9 @@ class DAboutDialogPrivate : public DDialogPrivate QLabel *licenseTipLabel = nullptr; QLabel *licenseLabel = nullptr; QLabel *companyLogoLabel = nullptr; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QPixmap companyLogoPixmap; +#endif QLabel *websiteLabel = nullptr; QLabel *featureLabel = nullptr; DRedPointLabel *redPointLabel = nullptr; diff --git a/src/widgets/private/dprintpreviewwidget_p.h b/src/widgets/private/dprintpreviewwidget_p.h index 21139c32e..ead21a91c 100644 --- a/src/widgets/private/dprintpreviewwidget_p.h +++ b/src/widgets/private/dprintpreviewwidget_p.h @@ -409,7 +409,7 @@ struct DPrintPreviewWidgetPrivate::NumberUpData { QVector updatePositions(const qreal &scale) { -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) QRectF pageRect = parent->previewPrinter->pageLayout().paintRectPixels(parent->previewPrinter->resolution()); #else QRectF pageRect = parent->previewPrinter->pageRect(); @@ -474,7 +474,7 @@ struct DPrintPreviewWidgetPrivate::NumberUpData { { if (waterList.isEmpty()) return; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) QRectF pageRect = parent->previewPrinter->pageLayout().paintRectPixels(parent->previewPrinter->resolution()); #else QRectF pageRect = parent->previewPrinter->pageRect(); diff --git a/src/widgets/private/dtitlebareditpanel.cpp b/src/widgets/private/dtitlebareditpanel.cpp index 0c50c2434..9b4e5234c 100644 --- a/src/widgets/private/dtitlebareditpanel.cpp +++ b/src/widgets/private/dtitlebareditpanel.cpp @@ -351,7 +351,7 @@ void DCollapseWidget::updateMinimumValue() continue; minimum += w->width(); qDebug() << "+" << w->width(); - if (auto dragDropWidget = qobject_cast(w)) { + if (qobject_cast(w)) { if (m_settingsImpl->isSpacerTool(m_settingsImpl->findKeyByPos(i)) && !m_settingsImpl->isStrecherTool(m_settingsImpl->findKeyByPos(i))) { minimum += SPACING; qDebug() << "+" << SPACING; @@ -402,7 +402,7 @@ void DCollapseWidget::collapse() } if (auto item = m_mainHLayout->takeAt(index)) { - if (auto spacerItem = item->spacerItem()) { // 如果是spacer,只存数据,不处理expand按钮 + if (item->spacerItem()) { // 如果是spacer,只存数据,不处理expand按钮 QPair tmp{m_settingsImpl->findKeyByPos(index), nullptr}; m_viewsInMenu.append(tmp); qDebug() << "collapse:" << m_viewsInMenu; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2156dde7b..6a5efd32b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -133,6 +133,7 @@ target_compile_definitions(${BINNAME} PRIVATE SN_API_NOT_YET_FROZEN DTK_NO_MULTIMEDIA DWIDGET_TRANSLATIONS_DIR="dtk${PROJECT_VERSION_MAJOR}/DWidget/translations" + D_IGNORE_DEPRECATIONS ) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") diff --git a/tests/testcases/widgets/ut_dcombobox.cpp b/tests/testcases/widgets/ut_dcombobox.cpp index b8145aa4a..cc528b198 100644 --- a/tests/testcases/widgets/ut_dcombobox.cpp +++ b/tests/testcases/widgets/ut_dcombobox.cpp @@ -30,7 +30,7 @@ TEST_F(ut_DComboBox, maxVisibleItems) target->addItem(QString::number(i)); } target->show(); - QTest::qWaitForWindowExposed(target->windowHandle()); + (void)QTest::qWaitForWindowExposed(target->windowHandle()); const QPoint arrowPos(target->rect().right() - 1, target->rect().center().y()); QTest::mouseClick(target, Qt::LeftButton, Qt::KeyboardModifiers(), arrowPos); diff --git a/tests/testcases/widgets/ut_dtextedit.cpp b/tests/testcases/widgets/ut_dtextedit.cpp index ec9f04dbc..4e9d2abbe 100644 --- a/tests/testcases/widgets/ut_dtextedit.cpp +++ b/tests/testcases/widgets/ut_dtextedit.cpp @@ -75,6 +75,10 @@ TEST_F(ut_DTextEdit, testDTextEditKeyPressEvent) TEST_F(ut_DTextEdit, testDTextEditContextMenuEvent) { +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + QContextMenuEvent menuEvent(QContextMenuEvent::Mouse, QPoint(0,0), QPoint(0,0)); +#else QContextMenuEvent menuEvent(QContextMenuEvent::Mouse, QPoint(0,0)); +#endif widget->contextMenuEvent(&menuEvent); }