diff --git a/debian/control b/debian/control index b1112901..cc4fe686 100644 --- a/debian/control +++ b/debian/control @@ -5,9 +5,13 @@ Maintainer: Deepin Packages Builder Uploaders: Ma Aiguo , Build-Depends: debhelper-compat (=11), python3, - qt5-qmake, - qttools5-dev-tools, - qtbase5-dev, + qt6-base-dev, + qt6-base-dev-tools, + qt6-base-private-dev, + qt6-l10n-tools, + qt6-tools-dev-tools, + qt6-tools-dev, + qt6-svg-dev, pkg-config, libxcb-util0-dev, libmtdev-dev, @@ -16,9 +20,9 @@ Build-Depends: debhelper-compat (=11), libfontconfig-dev, libegl1-mesa-dev, libstartup-notification0-dev, - libdtkwidget-dev, + libdtk6widget-dev, libgtest-dev, - libpolkit-qt5-1-dev + libpolkit-qt6-1-dev Standards-Version: 4.5.1 Homepage: https://github.com/linuxdeepin/deepin-boot-maker Vcs-Git: https://salsa.debian.org/pkg-deepin-team/deepin-boot-maker.git @@ -28,7 +32,7 @@ Package: deepin-boot-maker Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, p7zip-full, mtools, udisks2, syslinux [linux-amd64 linux-i386], - syslinux-common [linux-amd64 linux-i386],genisoimage,dde-qt5integration + syslinux-common [linux-amd64 linux-i386],genisoimage,dde-qt6integration Description: Simple tool for user to create a boot usb stick quickly and easily It's designed to support deepin system iso, it can works for Debian and ubuntu iso too. diff --git a/debian/rules b/debian/rules index 06a2707f..ea046b4a 100755 --- a/debian/rules +++ b/debian/rules @@ -1,10 +1,29 @@ #!/usr/bin/make -f -export QT_SELECT=qt5 +# 设置 Qt6 环境 +export QT_SELECT=qt6 +# 使用系统 PATH 中的 qmake6 +export QMAKE=qmake6 + include /usr/share/dpkg/default.mk -override_dh_auto_configure: - dh_auto_configure -- DAPP_VERSION=$(DEB_VERSION_UPSTREAM) DEFINES+="VERSION=$(DEB_VERSION_UPSTREAM)" LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) +# 指定使用 qmake 构建系统 +export DH_OPTIONS := --buildsystem=qmake %: - dh $@ + dh $@ --buildsystem=qmake + +override_dh_auto_configure: + $(QMAKE) \ + VERSION=$(VERSION) \ + PREFIX=/usr \ + LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) \ + VERSION_UPSTREAM=$(DEB_VERSION_UPSTREAM) \ + DEFINES+="VERSION=$(DEB_VERSION_UPSTREAM)" +override_dh_shlibdeps: + dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info + +override_dh_auto_test: + # Skip running tests + echo "Skipping tests" + \ No newline at end of file diff --git a/rpm/deepin-boot-maker.spec b/rpm/deepin-boot-maker.spec index 44c4f942..c198debc 100644 --- a/rpm/deepin-boot-maker.spec +++ b/rpm/deepin-boot-maker.spec @@ -17,7 +17,7 @@ Source0: %{name}_%{version}.orig.tar.xz BuildRequires: python3 -BuildRequires: qt5-devel +#BuildRequires: qt6-devel BuildRequires: xcb-util-devel BuildRequires: mtdev-devel BuildRequires: libXrender-devel @@ -48,9 +48,9 @@ Requires: genisoimage %build -# help find (and prefer) qt5 utilities, e.g. qmake, lrelease -export PATH=%{_qt5_bindir}:$PATH -%qmake_qt5 DAPP_VERSION=%{version} DEFINES+="VERSION=%{version}" +# help find (and prefer) qt6 utilities, e.g. qmake, lrelease +export PATH=%{_qt6_bindir}:$PATH +%qmake_qt6 DAPP_VERSION=%{version} DEFINES+="VERSION=%{version}" %make_build diff --git a/src/app/app.pro b/src/app/app.pro index 4d0c4281..d5f43c01 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -15,12 +15,19 @@ QMAKE_CXXFLAGS += -fstack-protector-all # QMAKE_LFLAGS += -g -fsanitize=address -O2 #} - QT += core gui widgets concurrent network svg CONFIG += c++11 link_pkgconfig CONFIG += resources_big +versionAtLeast(QT_VERSION, 6.0.0) { + PKGCONFIG += dtk6widget + PKGCONFIG += polkit-qt6-1 +} else { + PKGCONFIG += dtkwidget + PKGCONFIG += polkit-qt5-1 +} + RESOURCES += \ ../translate.qrc \ view/resource/resource.qrc diff --git a/src/app/bmwindow.cpp b/src/app/bmwindow.cpp index 40bb0da5..98454dcf 100644 --- a/src/app/bmwindow.cpp +++ b/src/app/bmwindow.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -56,7 +56,12 @@ BMWindow::BMWindow(QWidget *parent) setFixedSize(440, 550); + // TODO +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) d->interface = BMInterface::instance(); +#else + d->interface = &BMInterface::ref(); +#endif // init about info QString descriptionText = tr("Boot Maker is a simple tool to write system image files into USB flash drives and other media."); @@ -80,7 +85,8 @@ BMWindow::BMWindow(QWidget *parent) titlebar()->setWindowFlags(flags); QPalette pal(palette()); - pal.setColor(QPalette::Background, Qt::white); + pal.setColor(QPalette::Window, QColor(255, 255, 255)); + setAutoFillBackground(true); setPalette(pal); #endif @@ -92,7 +98,7 @@ BMWindow::BMWindow(QWidget *parent) auto viewWidth = 440; QStackedLayout *actionsLayout = new QStackedLayout; - actionsLayout->setMargin(0); + actionsLayout->setContentsMargins(0, 0, 0, 0); d->isoWidget = new ISOSelectView(); d->isoWidget->setAccessibleName("centralWidget_isoSelectWidget"); d->isoWidget->resize(440, 466); @@ -128,7 +134,7 @@ BMWindow::BMWindow(QWidget *parent) d->wsib->setPointDistance(12); QVBoxLayout *mainLayout = new QVBoxLayout(); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); mainLayout->addLayout(actionsLayout); mainLayout->addWidget(d->wsib); @@ -265,14 +271,22 @@ void BMWindow :: slot_ThemeChange() DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); if (themeType == DGuiApplicationHelper::LightType) { pa = d->wsib->palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor(255, 255, 255)); +#else + pa.setColor(DPalette::Window, QColor(255, 255, 255)); +#endif d->wsib->setPalette(pa); d->wsib->setPointColor(QColor("#2CA7F8")); // d->wsib->setSecondaryPointColor(QColor("#96ACBD")); d->wsib->setSecondaryPointColor(QColor(150, 172, 189, 51)); } else if (themeType == DGuiApplicationHelper::DarkType) { pa = d->wsib->palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor("#292929")); +#else + pa.setColor(DPalette::Window, QColor("#292929")); +#endif d->wsib->setPalette(pa); d->wsib->setPointColor(QColor("#0082FA")); // d->wsib->setSecondaryPointColor(QColor("#555555")); diff --git a/src/app/main.cpp b/src/app/main.cpp index 001e84fe..20375784 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -9,11 +9,10 @@ #include "bmwindow.h" #include #include - +#include #include #include #include -#include #include DCORE_USE_NAMESPACE @@ -65,8 +64,8 @@ int main(int argc, char **argv) // DApplication::loadDXcbPlugin(); //去除为兼容wayland环境 DApplication app(argc, argv); - app.setAttribute(Qt::AA_UseHighDpiPixmaps); - app.setAttribute(Qt::AA_EnableHighDpiScaling); + // app.setAttribute(Qt::AA_UseHighDpiPixmaps); + // app.setAttribute(Qt::AA_EnableHighDpiScaling); app.setOrganizationName("deepin"); app.setApplicationName("deepin-boot-maker"); app.setApplicationVersion(DApplication::buildVersion("20191031")); @@ -99,15 +98,19 @@ int main(int argc, char **argv) app.setApplicationDisplayName(QObject::tr("Boot Maker")); qDebug() << "Boot Maker UI started."; - +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) DApplicationSettings savetheme; +#endif BMWindow w; Dtk::Widget::moveToCenter(&w); w.show(); // w.waitAuth(); - auto ret = app.exec(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) BMInterface::instance()->stop(); +#else + BMInterface::ref().stop(); +#endif return ret; } diff --git a/src/app/vendor.pri b/src/app/vendor.pri index 17c83e38..b115d7a1 100644 --- a/src/app/vendor.pri +++ b/src/app/vendor.pri @@ -1,18 +1,28 @@ include($$PWD/../vendor/env.pri) -QT += dtkwidget - unix{ QT += network CONFIG += link_pkgconfig } -linux{ - QT += x11extras dbus x11extras - CONFIG += link_pkgconfig - PKGCONFIG += dtkwidget -# PKGCONFIG += xcb-util libstartup-notification-1.0 -# LIBS += -lxcb -lX11 -lXext +versionAtLeast(QT_VERSION, 6.0.0) { + # Qt 6 specific configurations + linux{ + QT += dbus + CONFIG += link_pkgconfig + PKGCONFIG += dtk6widget + # PKGCONFIG += xcb-util libstartup-notification-1.0 + # LIBS += -lxcb -lX11 -lXext + } +} else { + # Qt 5 specific configurations + linux{ + QT += dbus + CONFIG += link_pkgconfig + PKGCONFIG += dtkwidget + # PKGCONFIG += xcb-util libstartup-notification-1.0 + # LIBS += -lxcb -lX11 -lXext + } } win32{ diff --git a/src/app/view/deviceinfoitem.cpp b/src/app/view/deviceinfoitem.cpp index 23031e68..e0aeed6a 100644 --- a/src/app/view/deviceinfoitem.cpp +++ b/src/app/view/deviceinfoitem.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include @@ -44,8 +44,8 @@ DeviceInfoItem::DeviceInfoItem(const QString &name, const QString &device, auto m_deviceLabel = new DLabel; m_deviceLabel->setObjectName("DeviceInfoLabel"); - DPalette pa = DApplicationHelper::instance()->palette(m_deviceLabel); - QBrush brush = DApplicationHelper::instance()->palette(m_deviceLabel).text(); + QPalette pa = m_deviceLabel->palette(); + QBrush brush = pa.text(); pa.setBrush(DPalette::Text, brush); m_deviceLabel->setText(name); m_deviceLabel->setFixedHeight(25); @@ -79,12 +79,12 @@ DeviceInfoItem::DeviceInfoItem(const QString &name, const QString &device, auto m_bodywidget = new DWidget; auto bodyLayout = new QVBoxLayout(m_bodywidget); - bodyLayout->setMargin(0); + bodyLayout->setContentsMargins(0, 0, 0, 0); auto m_middlewidget = new DWidget; m_middlewidget->setFixedWidth(292); m_middlewidget->setFixedHeight(18); auto middleLayout = new QHBoxLayout(m_middlewidget); - middleLayout->setMargin(0); + middleLayout->setContentsMargins(0, 0, 0, 0); middleLayout->addWidget(m_deviceDevName, 0, Qt::AlignLeft); middleLayout->addWidget(m_deviceCapacity, 0, Qt::AlignRight); diff --git a/src/app/view/dropframe.cpp b/src/app/view/dropframe.cpp index 81257d3d..efff2735 100644 --- a/src/app/view/dropframe.cpp +++ b/src/app/view/dropframe.cpp @@ -4,7 +4,7 @@ #include "dropframe.h" -#include +#include #include #include @@ -69,12 +69,23 @@ void DropFrame::paintEvent(QPaintEvent *e) { if (this->property("active").toBool()) { QPixmap pixmap; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + // Qt5: 使用 DGuiApplicationHelper DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); if (themeType == DGuiApplicationHelper::LightType) { pixmap = QPixmap(":/theme/light/image/dash.svg").scaled(this->size()); } else if (themeType == DGuiApplicationHelper::DarkType) { pixmap = QPixmap(":/theme/dark/image/dash.svg").scaled(this->size()); } +#else + // Qt6: 使用 QPalette + QPalette palette = this->palette(); + if (palette.color(QPalette::Window).lightnessF() > 0.5) { + pixmap = QPixmap(":/theme/light/image/dash.svg").scaled(this->size()); + } else { + pixmap = QPixmap(":/theme/dark/image/dash.svg").scaled(this->size()); + } +#endif QPainter painter(this); painter.drawPixmap(this->rect(), pixmap); } diff --git a/src/app/view/formatdialog.cpp b/src/app/view/formatdialog.cpp index f6e23d4e..4ee825ea 100644 --- a/src/app/view/formatdialog.cpp +++ b/src/app/view/formatdialog.cpp @@ -19,7 +19,7 @@ NewStr autoCutText(const QString &text, DLabel *pDesLbl) QFont font; // 应用使用字体对象 QFontMetrics font_label(font); QString strText = text; - int titlewidth = font_label.width(strText); + int titlewidth = font_label.horizontalAdvance(strText); QString str; NewStr newstr; int width = pDesLbl->width(); @@ -29,8 +29,8 @@ NewStr autoCutText(const QString &text, DLabel *pDesLbl) } else { for (int i = 0; i < strText.count(); i++) { str += strText.at(i); - - if (font_label.width(str) > width) { //根据label宽度调整每行字符数 + + if (font_label.horizontalAdvance(str) > width) { //根据label宽度调整每行字符数 str.remove(str.count() - 1, 1); newstr.strList.append(str); newstr.resultStr += str + "\n"; diff --git a/src/app/view/isoselectview.cpp b/src/app/view/isoselectview.cpp index 333dc246..777321fb 100644 --- a/src/app/view/isoselectview.cpp +++ b/src/app/view/isoselectview.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -44,6 +44,7 @@ void ThreadCheckFile::setRestart() void ThreadCheckFile::run() { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) restart = true; bool checkok = false; while (restart) { @@ -51,6 +52,16 @@ void ThreadCheckFile::run() checkok = BMInterface::instance()->checkfile(m_file); } emit checkFileFinish(checkok); +#else + restart = true; + bool checkok = false; + while (restart) { + restart = false; + //BMInterface::instance() 在dtk6中被屏蔽了 + checkok = BMInterface::ref().checkfile(m_file); + } + emit checkFileFinish(checkok); +#endif } ISOSelectView::ISOSelectView(DWidget *parent) : DWidget(parent) @@ -64,8 +75,8 @@ ISOSelectView::ISOSelectView(DWidget *parent) : DWidget(parent) m_title = new DLabel(tr("Select an ISO image file")); m_title->setAccessibleName("isoSelectWidget_titleLabel"); - DPalette pa = DApplicationHelper::instance()->palette(m_title); - QBrush brush = DApplicationHelper::instance()->palette(m_title).text(); + QPalette pa = m_title->palette(); + QBrush brush = pa.text(); pa.setBrush(DPalette::Text, brush); m_title->setPalette(pa); m_title->setWordWrap(true); @@ -91,7 +102,7 @@ ISOSelectView::ISOSelectView(DWidget *parent) : DWidget(parent) isoPanel->setFixedSize(410, 300); QVBoxLayout *isoPanelLayout = new QVBoxLayout(isoPanel); - isoPanelLayout->setMargin(0); + isoPanelLayout->setContentsMargins(0, 0, 0, 0); #ifdef Q_OS_WIN m_fileLabel = new DLabel(""); @@ -143,8 +154,8 @@ ISOSelectView::ISOSelectView(DWidget *parent) : DWidget(parent) m_checkFile = new DLabel(); m_checkFile->setAccessibleName("isoSelectWidget_checkFileLabel"); m_checkFile->setObjectName("IsoFileSelect"); - pa = DApplicationHelper::instance()->palette(m_checkFile); - brush = DApplicationHelper::instance()->palette(m_checkFile).text(); + pa = m_checkFile->palette(); + brush = pa.text(); pa.setBrush(DPalette::Text, brush); DFontSizeManager::instance()->bind(m_checkFile, DFontSizeManager::T8); @@ -262,10 +273,18 @@ void ISOSelectView :: slot_ThemeChange() DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); if (themeType == DGuiApplicationHelper::LightType) { pa = palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor(255, 255, 255)); +#else + pa.setColor(DPalette::Window, QColor(255, 255, 255)); +#endif setPalette(pa); pa = isoPanel->palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor(255, 255, 255, 13)); +#else + pa.setColor(DPalette::Window, QColor(255, 255, 255, 13)); +#endif isoPanel->setPalette(pa); pa = m_fileLabel->palette(); pa.setColor(DPalette::Text, QColor("#B1B1B1")); @@ -282,10 +301,18 @@ void ISOSelectView :: slot_ThemeChange() m_checkFile->setPalette(pa); } else if (themeType == DGuiApplicationHelper::DarkType) { pa = palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor("#292929")); +#else + pa.setColor(DPalette::Window, QColor("#292929")); +#endif setPalette(pa); pa = isoPanel->palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor(0, 0, 0, 13)); +#else + pa.setColor(DPalette::Window, QColor(0, 0, 0, 13)); +#endif isoPanel->setPalette(pa); pa = m_fileLabel->palette(); pa.setColor(DPalette::Text, QColor("#6D7C88")); diff --git a/src/app/view/progressview.cpp b/src/app/view/progressview.cpp index d4c3bffc..9899a0ed 100644 --- a/src/app/view/progressview.cpp +++ b/src/app/view/progressview.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -33,8 +33,8 @@ ProgressView::ProgressView(DWidget *parent) : DWidget(parent) DLabel *m_title = new DLabel(tr("Burning")); m_title->setAccessibleName("progressWidget_title"); - DPalette pa = DApplicationHelper::instance()->palette(m_title); - QBrush brush = DApplicationHelper::instance()->palette(m_title).text(); + QPalette pa = m_title->palette(); + QBrush brush = pa.text(); pa.setBrush(DPalette::Text, brush); m_title->setPalette(pa); DFontSizeManager::instance()->bind(m_title, DFontSizeManager::T3); @@ -90,7 +90,11 @@ ProgressView::ProgressView(DWidget *parent) : DWidget(parent) if (themeType == DGuiApplicationHelper::LightType) { pa = palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor(255, 255, 255)); +#else + pa.setColor(DPalette::Window, QColor(255, 255, 255)); +#endif setPalette(pa); pa = m_hitsTitle->palette(); @@ -98,8 +102,12 @@ ProgressView::ProgressView(DWidget *parent) : DWidget(parent) m_hitsTitle->setPalette(pa); } else if (themeType == DGuiApplicationHelper::DarkType) { - pa = palette(); + pa = palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor("#292929")); +#else + pa.setColor(DPalette::Window, QColor("#292929")); +#endif setPalette(pa); pa = m_hitsTitle->palette(); pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); @@ -108,8 +116,9 @@ ProgressView::ProgressView(DWidget *parent) : DWidget(parent) }); emit DGuiApplicationHelper::instance()->themeTypeChanged(DGuiApplicationHelper::instance()->themeType()); - - connect(BMInterface::instance(), &BMInterface::reportProgress, + + // TODO dtk6 中BMInterface::instance()被屏蔽了 + connect(&BMInterface::ref(), &BMInterface::reportProgress, this, [ = ](quint32 current, quint32 error, const QString & title, const QString & description) { qDebug() << error << current << title << description; @@ -132,6 +141,7 @@ ProgressView::ProgressView(DWidget *parent) : DWidget(parent) emit finish(current, error, title, description); } }); + } void ProgressView::timerEvent(QTimerEvent *event) diff --git a/src/app/view/resultview.cpp b/src/app/view/resultview.cpp index 678cc07b..ec34e539 100644 --- a/src/app/view/resultview.cpp +++ b/src/app/view/resultview.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include @@ -38,8 +38,8 @@ ResultView::ResultView(DWidget *parent) : DWidget(parent) m_title = new DLabel(); m_title->setAccessibleName("resultWidget_title"); - DPalette pa = DApplicationHelper::instance()->palette(m_title); - QBrush brush = DApplicationHelper::instance()->palette(m_title).text(); + QPalette pa = m_title->palette(); + QBrush brush = pa.text(); pa.setBrush(DPalette::Text, brush); m_title->setPalette(pa); DFontSizeManager::instance()->bind(m_title, DFontSizeManager::T3); @@ -52,8 +52,9 @@ ResultView::ResultView(DWidget *parent) : DWidget(parent) m_hitsTitle = new DLabel(tr("Successful")); m_hitsTitle->setAccessibleName("resultWidget_hitsTitleLabel"); m_hitsTitle->setObjectName("ResulteHitsTitle"); - pa = DApplicationHelper::instance()->palette(m_hitsTitle); - brush = DApplicationHelper::instance()->palette(m_hitsTitle).text(); + // TODO + pa = QApplication::palette(m_hitsTitle); + brush = pa.text(); pa.setBrush(DPalette::Text, brush); m_hitsTitle->setPalette(pa); m_hitsTitle->setAlignment(Qt::AlignCenter); @@ -95,11 +96,19 @@ ResultView::ResultView(DWidget *parent) : DWidget(parent) mainLayout->addWidget(m_logHits); mainLayout->addStretch(); mainLayout->addWidget(m_rebootLater, 0, Qt::AlignHCenter|Qt::AlignBottom); - + + // TODO +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) connect(m_rebootNow, &DPushButton::clicked, this, [ = ]() { BMInterface::instance()->reboot(); }); +#else + connect(m_rebootNow, &DPushButton::clicked, + this, [ = ]() { + BMInterface::ref().reboot(); + }); +#endif connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [ = ] { @@ -108,7 +117,11 @@ ResultView::ResultView(DWidget *parent) : DWidget(parent) if (themeType == DGuiApplicationHelper::LightType) { pa = palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor(255, 255, 255)); +#else + pa.setColor(DPalette::Window, QColor(255, 255, 255)); +#endif setPalette(pa); pa = m_hitsTitle->palette(); @@ -119,7 +132,11 @@ ResultView::ResultView(DWidget *parent) : DWidget(parent) m_logHits->setPalette(pa); } else if (themeType == DGuiApplicationHelper::DarkType) { pa = palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor("#292929")); +#else + pa.setColor(DPalette::Window, QColor("#292929")); +#endif setPalette(pa); pa = m_hitsTitle->palette(); pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); diff --git a/src/app/view/unmountusbview.cpp b/src/app/view/unmountusbview.cpp index d8cc37cc..c3274f34 100644 --- a/src/app/view/unmountusbview.cpp +++ b/src/app/view/unmountusbview.cpp @@ -15,9 +15,9 @@ UnmountUsbView::UnmountUsbView(DWidget *parent): DWidget(parent) m_spinner->setObjectName("spinner"); m_spinner->setFixedSize(32, 32); m_hitTitle = new DLabel(tr("Verifying data and safely removing the media, please wait...")); - DPalette pa = DApplicationHelper::instance()->palette(m_hitTitle); - QBrush brush = DApplicationHelper::instance()->palette(m_hitTitle).text(); - pa.setBrush(DPalette::Text, brush); + QPalette pa = m_hitTitle->palette(); + QBrush brush = pa.text(); + pa.setBrush(QPalette::Text, brush); m_hitTitle->setPalette(pa); m_hitTitle->setFixedWidth(440); m_hitTitle->setFixedHeight(50); @@ -30,8 +30,12 @@ UnmountUsbView::UnmountUsbView(DWidget *parent): DWidget(parent) MainLayout->addSpacing(10); MainLayout->addWidget(m_hitTitle, 0, Qt::AlignCenter); MainLayout->addStretch(); - DPalette pa1 = DApplicationHelper::instance()->palette(this); + DPalette pa1 = this->palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setBrush(DPalette::Background, pa.color(DPalette::Base)); +#else + pa.setBrush(DPalette::Window, pa.color(DPalette::Base)); +#endif this->setPalette(pa1); connect(this, &UnmountUsbView::startSpinner, this, [ = ]() { m_spinner->start(); diff --git a/src/app/view/unmountusbview.h b/src/app/view/unmountusbview.h index a426504d..21f2c960 100644 --- a/src/app/view/unmountusbview.h +++ b/src/app/view/unmountusbview.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include "widgetutil.h" diff --git a/src/app/view/usbselectview.cpp b/src/app/view/usbselectview.cpp index 8337f0f8..47907c25 100644 --- a/src/app/view/usbselectview.cpp +++ b/src/app/view/usbselectview.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -74,8 +74,9 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) DLabel *m_title = new DLabel(tr("Select a partition")); m_title->setAccessibleName("usbSelectWidget_titleLabel"); - DPalette pa = DApplicationHelper::instance()->palette(m_title); - QBrush brush = DApplicationHelper::instance()->palette(m_title).text(); + // TODO + DPalette pa = m_title->palette(); + QBrush brush = pa.text(); pa.setBrush(DPalette::Text, brush); m_title->setPalette(pa); m_title->setWordWrap(true); @@ -181,7 +182,11 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) if (themeType == DGuiApplicationHelper::LightType) { pa = palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor(255, 255, 255)); +#else + pa.setColor(DPalette::Window, QColor(255, 255, 255)); +#endif setPalette(pa); pa = m_warningHint->palette(); pa.setColor(DPalette::WindowText, QColor("#FF5800")); @@ -193,7 +198,11 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) else if (themeType == DGuiApplicationHelper::DarkType) { pa = palette(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor("#292929")); +#else + pa.setColor(DPalette::Window, QColor("#292929")); +#endif setPalette(pa); pa = m_warningHint->palette(); pa.setColor(DPalette::WindowText, QColor("#9A2F2F")); @@ -218,7 +227,9 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) handleFormat(checked); }); - connect(BMInterface::instance(), &BMInterface::deviceListChanged, + // TODO + + connect(&BMInterface::ref(), &BMInterface::deviceListChanged, this, [ = ](const QList &addlist, const QList& dellist) { bool hasPartitionSelected = false; @@ -241,7 +252,11 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) } this->m_mountDevs += addlist; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) qSort(m_mountDevs.begin(), m_mountDevs.end(), caseInsensitiveLessThan); +#else + std::sort(m_mountDevs.begin(), m_mountDevs.end(), caseInsensitiveLessThan); +#endif m_formatDiskCheck->setVisible(this->m_mountDevs.size()); m_emptyHint->setVisible(!this->m_mountDevs.size()); m_deviceList->setVisible(this->m_mountDevs.size()); diff --git a/src/libdbm/util/deviceinfo.h b/src/libdbm/util/deviceinfo.h index 020e68c4..f39f381c 100644 --- a/src/libdbm/util/deviceinfo.h +++ b/src/libdbm/util/deviceinfo.h @@ -29,7 +29,7 @@ class DeviceInfo bool needFormat = false; QMap children; - bool operator==(const DeviceInfo& otherInfo) + bool operator==(const DeviceInfo& otherInfo) const { return (this->path == otherInfo.path); } diff --git a/src/libdbm/util/sevenzip.cpp b/src/libdbm/util/sevenzip.cpp index 7f190bd6..bc9dc03a 100644 --- a/src/libdbm/util/sevenzip.cpp +++ b/src/libdbm/util/sevenzip.cpp @@ -32,8 +32,13 @@ SevenZip::SevenZip(const QString &image, const QString &target, QObject *parent) m_archiveFile = image; m_outputDir = "-o" + target; // connect(&m_szpp, &SevenZipProcessParser::progressChanged, this, &SevenZip::progressChanged); - connect(&m_sevenz, static_cast(&QProcess::finished), - this, &SevenZip::handleFinished); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + connect(&m_sevenz, static_cast(&QProcess::finished), + this, &SevenZip::handleFinished); +#else + connect(&m_sevenz, &QProcess::finished, + this, &SevenZip::handleFinished); +#endif } void SevenZip::setArchiveFile(const QString &archiveFile) @@ -81,7 +86,7 @@ bool SevenZip::extract() m_sevenz.waitForStarted(-1); #ifdef Q_OS_LINUX - QProcess::execute(QString("ionice -c3 -p %1").arg(m_sevenz.pid())); + QProcess::execute(QString("ionice -c3 -p %1").arg(m_sevenz.processId())); #endif m_szpp->setProgressName(progress.fileName()); @@ -107,10 +112,10 @@ bool SevenZip::check() m_sevenz.setArguments(args); m_sevenz.start(); - if (m_sevenz.waitForStarted(-1) && m_sevenz.pid()) { - #ifdef Q_OS_LINUX - QProcess::execute(QString("ionice -c3 -p %1").arg(m_sevenz.pid())); - #endif + if (m_sevenz.waitForStarted(-1) && m_sevenz.processId()) { +#ifdef Q_OS_LINUX + QProcess::execute(QString("ionice -c3 -p %1").arg(m_sevenz.processId())); +#endif m_eventLoop.exec(); } qInfo() << "check iso result" << m_sevenz.exitStatus() << m_sevenz.exitCode(); diff --git a/src/libdbm/util/utils.cpp b/src/libdbm/util/utils.cpp index ee3d306b..c24cec82 100644 --- a/src/libdbm/util/utils.cpp +++ b/src/libdbm/util/utils.cpp @@ -9,9 +9,15 @@ #include #include -#include #include + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include +#include +#else +#include +#endif + #include #ifdef Q_OS_WIN32 #include @@ -315,15 +321,24 @@ QMap CommandLsblkParse() break; QString type; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QRegExp reg("NAME=\"(.*)\" LABEL=\"(.*)\" SIZE=\"(.*)\" UUID=\"(.*)\" FSTYPE=\"(.*)\" TYPE=\"(.*)\""); - if (reg.indexIn(line) >= 0) { info.path = reg.cap(1); info.label = reg.cap(2); info.uuid = reg.cap(4); info.fstype = reg.cap(5); type = reg.cap(6); - +#else + QRegularExpression reg("NAME=\"(.*)\" LABEL=\"(.*)\" SIZE=\"(.*)\" UUID=\"(.*)\" FSTYPE=\"(.*)\" TYPE=\"(.*)\""); + QRegularExpressionMatch match = reg.match(line); + if (match.hasMatch()) { + info.path = match.captured(1); + info.label = match.captured(2); + info.uuid = match.captured(4); + info.fstype = match.captured(5); + type = match.captured(6); +#endif if (!type.compare("disk")) { diskDevPath = info.path; isPart = false; @@ -340,12 +355,21 @@ QMap CommandLsblkParse() if (info.label.contains("\\x", Qt::CaseInsensitive)) { QByteArray byArr = unescapeLimited(info.label); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (isUft8(byArr)) { strLabel = QTextCodec::codecForName("UTF-8")->toUnicode(byArr); } else if(isGBK(byArr)) { strLabel = QTextCodec::codecForName("GBK")->toUnicode(byArr); } +#else + if (isUft8(byArr)) { + strLabel = QString::fromUtf8(byArr); + } + else if(isGBK(byArr)) { + strLabel = QString::fromLocal8Bit(byArr); + } +#endif else { strLabel = QString::fromLocal8Bit(byArr); } @@ -415,7 +439,7 @@ bool isUsbDisk(const QString &dev) QString info = outfile.readAll(); outfile.close(); outfile.remove(); - return info.contains(QRegExp("Protocol:\\s+USB")); + return info.contains(QRegularExpression("Protocol:\\s+USB")); } QList ListUsbDrives() @@ -449,7 +473,11 @@ QList ListUsbDrives() QMap removeDevice; for (int i = 0; i < usbfileinfoL.size(); ++i) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (usbfileinfoL.at(i).fileName().contains(QRegExp("^usb-\\S{1,}$")) || usbfileinfoL.at(i).fileName().contains(QRegExp("^mmc-\\S{1,}$"))) { +#else + if (usbfileinfoL.at(i).fileName().contains(QRegularExpression("^usb-\\S{1,}$")) || usbfileinfoL.at(i).fileName().contains(QRegularExpression("^mmc-\\S{1,}$"))) { +#endif QString path = usbfileinfoL.at(i).canonicalFilePath(); removeDevice.insert(path, usbfileinfoL.at(i).fileName()); } @@ -497,7 +525,8 @@ QList ListUsbDrives() QFile outfile(out); outfile.open(QIODevice::ReadOnly); QString diskutilList = outfile.readAll(); - QStringList usbdevsL = diskutilList.split("\n").filter(QRegExp("(FAT|Microsoft)")).join(" ").split(" ").filter("disk"); + + QStringList usbdevsL = diskutilList.split("\n").filter(QRegularExpression("(FAT|Microsoft)")).join(" ").split(" ").filter("disk"); for (int i = 0; i < usbdevsL.size(); ++i) { if (isUsbDisk("/dev/" + usbdevsL.at(i))) { diff --git a/src/libdbm/vendor.pri b/src/libdbm/vendor.pri index ea3d894e..b192096d 100644 --- a/src/libdbm/vendor.pri +++ b/src/libdbm/vendor.pri @@ -1,6 +1,8 @@ include($$PWD/../vendor/env.pri) -QT += dtkcore +# QT += dtk6core + +PKGCONFIG += dtk6core unix{ QT += dbus diff --git a/src/service/bootmakerservice.cpp b/src/service/bootmakerservice.cpp index c9a74f09..15392de2 100644 --- a/src/service/bootmakerservice.cpp +++ b/src/service/bootmakerservice.cpp @@ -24,10 +24,18 @@ #include + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if defined (Q_OS_LINUX) || defined (Q_OS_UNIX) || defined (Q_OS_MAC) #include #include #endif +#else +#if defined (Q_OS_LINUX) || defined (Q_OS_UNIX) || defined (Q_OS_MAC) +#include +#include +#endif +#endif const QString s_PolkitActionCreate = "com.deepin.bootmaker.create"; const QString s_PolkitActionReboot = "com.deepin.bootmaker.reboot"; diff --git a/src/service/main.cpp b/src/service/main.cpp index b06dc25a..a467fd3a 100644 --- a/src/service/main.cpp +++ b/src/service/main.cpp @@ -34,7 +34,10 @@ int main(int argc, char *argv[]) } qputenv("QT_LOGGING_RULES", strDebug.toLatin1()); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + // 在Qt6中,这个步骤是不必要的,因为Qt6默认使用UTF-8 QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); +#endif Utils::initResource(); QCoreApplication a(argc, argv); diff --git a/src/service/vendor.pri b/src/service/vendor.pri index f6e34098..8f0ee35b 100644 --- a/src/service/vendor.pri +++ b/src/service/vendor.pri @@ -3,13 +3,13 @@ include($$PWD/../vendor/env.pri) unix{ QT += dbus CONFIG += link_pkgconfig - PKGCONFIG += dtkcore polkit-qt5-1 + PKGCONFIG += dtk6core polkit-qt6-1 } win32{ INCLUDEPATH += $$DTK_INCLUDE\DCore DEPENDPATH += $$DTK_DEPEND\DCore - LIBS += -L$$DTK_LIBRARY -ldtkcore + LIBS += -L$$DTK_LIBRARY -ldtk6core } ################################################################## diff --git a/src/src.pro b/src/src.pro index 290a4c4d..3db67142 100644 --- a/src/src.pro +++ b/src/src.pro @@ -20,7 +20,11 @@ mac* { TRANSLATIONS = $$files($$PWD/translations/*.ts) for(tsfile, TRANSLATIONS) { qmfile = $$replace(tsfile, .ts$, .qm) - system(lrelease $$tsfile -qm $$qmfile) | error("Failed to lrelease") + versionAtLeast(QT_VERSION, 6.0.0) { + system(/usr/lib/qt6/bin/lrelease $$tsfile -qm $$qmfile) | error("Failed to lrelease") + } else { + system(lrelease $$tsfile -qm $$qmfile) | error("Failed to lrelease") + } } linux { dtk_translations.path = /usr/share/deepin-boot-maker/translations @@ -28,3 +32,4 @@ mac* { INSTALLS += dtk_translations } } + diff --git a/src/tests/tests.pro b/src/tests/tests.pro index 7726b200..26ed38c3 100644 --- a/src/tests/tests.pro +++ b/src/tests/tests.pro @@ -20,9 +20,16 @@ QT += core gui widgets testlib CONFIG += c++14 console link_pkgconfig CONFIG += testcase no_testcase_installs CONFIG += resources_big -PKGCONFIG += dtkwidget -PKGCONFIG += dtkcore -PKGCONFIG += polkit-qt5-1 + +versionAtLeast(QT_VERSION, 6.0.0) { + PKGCONFIG += dtk6widget + PKGCONFIG += dtk6core + PKGCONFIG += polkit-qt6-1 +} else { + PKGCONFIG += dtkwidget + PKGCONFIG += dtkcore + PKGCONFIG += polkit-qt5-1 +} # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings diff --git a/src/tests/unittestobj.cpp b/src/tests/unittestobj.cpp index d9c478e4..83a90211 100644 --- a/src/tests/unittestobj.cpp +++ b/src/tests/unittestobj.cpp @@ -12,7 +12,8 @@ BMInterface* UnitTestObj::m_pBMinterFace = nullptr; void UnitTestObj::SetUpTestCase() { - m_pBMinterFace = BMInterface::instance(); + // m_pBMinterFace = BMInterface::instance(); + m_pBMinterFace = &BMInterface::ref(); } void UnitTestObj::TearDownTestCase() diff --git a/src/tests/vendor.pri b/src/tests/vendor.pri index 32955a7c..32544017 100644 --- a/src/tests/vendor.pri +++ b/src/tests/vendor.pri @@ -1,13 +1,29 @@ include($$PWD/../vendor/env.pri) + +versionAtLeast(QT_VERSION, 6.0.0) { unix{ QT += dbus CONFIG += link_pkgconfig - PKGCONFIG += dtkcore + PKGCONFIG += dtk6core +} + +win32{ + INCLUDEPATH += $$DTK_INCLUDE\DCore + DEPENDPATH += $$DTK_DEPEND\DCore + LIBS += -L$$DTK_LIBRARY -ldtkcore } +} else { +unix{ + QT += dbus + CONFIG += link_pkgconfig + PKGCONFIG += dtkcore +} win32{ INCLUDEPATH += $$DTK_INCLUDE\DCore DEPENDPATH += $$DTK_DEPEND\DCore LIBS += -L$$DTK_LIBRARY -ldtkcore -} \ No newline at end of file +} +} + diff --git a/src/tools/importPo b/src/tools/importPo index c4eb37fd..eb734df5 100644 --- a/src/tools/importPo +++ b/src/tools/importPo @@ -1,6 +1,6 @@ #!/bin/bash -qtPath=/opt/qt5-static/5.3/linuxg64 +qtPath=/opt/qt6-static/5.3/linuxg64 qtPath=/opt/qtstatic/5.3/linuxg64 qtBin=$qtPath/bin diff --git a/src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp b/src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp index 94b319b7..3ef8280b 100644 --- a/src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp +++ b/src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #ifdef Q_OS_WIN32 #include @@ -359,10 +360,10 @@ bool Mount(const QString &targetDev, const QString &path) QString GetPartitionDisk(QString targetDev) { - if (targetDev.contains(QRegExp("p\\d$"))) { - return QString(targetDev).remove(QRegExp("p\\d$")); + if (targetDev.contains(QRegularExpression("p\\d$"))) { + return QString(targetDev).remove(QRegularExpression("p\\d$")); } else { - return QString(targetDev).remove(QRegExp("\\d$")); + return QString(targetDev).remove(QRegularExpression("\\d$")); } } @@ -492,12 +493,12 @@ qint64 GetPartitionFreeSpace(const QString &targetDev) qDebug() << "Call df Failed"; return 0; } - return ret.result().split("\n").filter(targetDev).first().split(" ").filter(QRegExp("[^\\s]")).at(3).toLongLong() * 512; + return ret.result().split("\n").filter(targetDev).first().split(" ").filter(QRegularExpression("[^\\s]")).at(3).toLongLong() * 512; } QString GetPartitionDisk(QString targetDev) { - return QString(targetDev).remove(QRegExp("s\\d$")); + return QString(targetDev).remove(QRegularExpression("s\\d$")); } XSys::Result UmountDisk(const QString &targetDev) @@ -510,7 +511,7 @@ bool CheckFormatFat32(const QString &targetDev) XSys::Result ret = XSys::SynExec("diskutil", "info " + targetDev); QString partitionType = ret.result().split("\n").filter("Partition Type:").first(); - if (partitionType.contains(QRegExp("_FAT_32"))) { + if (partitionType.contains(QRegularExpression("_FAT_32"))) { return true; } diff --git a/src/vendor/src/libxsys/FileSystem/FileSystem.cpp b/src/vendor/src/libxsys/FileSystem/FileSystem.cpp index c3d4b28d..24c280fa 100644 --- a/src/vendor/src/libxsys/FileSystem/FileSystem.cpp +++ b/src/vendor/src/libxsys/FileSystem/FileSystem.cpp @@ -11,10 +11,12 @@ #include #include #include +#include static QString randString(const QString &str) { - QString seedStr = str + QTime::currentTime().toString(Qt::SystemLocaleLongDate) + QString("%1").arg(qrand()); + QString seedStr = str + + QTime::currentTime().toString(Qt::TextDate) + QString("%1").arg(QRandomGenerator::global()->generate()); return QString("").append(QCryptographicHash::hash(seedStr.toLatin1(), QCryptographicHash::Md5).toHex()); }