diff --git a/.github/workflows/backup-to-gitlab.yml b/.github/workflows/backup-to-gitlab.yml index c1763359..9863040f 100644 --- a/.github/workflows/backup-to-gitlab.yml +++ b/.github/workflows/backup-to-gitlab.yml @@ -8,10 +8,8 @@ concurrency: jobs: backup-to-gitlabwh: uses: linuxdeepin/.github/.github/workflows/backup-to-gitlabwh.yml@master - secrets: - BRIDGETOKEN: ${{ secrets.BRIDGETOKEN }} + secrets: inherit backup-to-gitee: uses: linuxdeepin/.github/.github/workflows/backup-to-gitee.yml@master - secrets: - GITEE_SYNC_TOKEN: ${{ secrets.GITEE_SYNC_TOKEN }} + secrets: inherit diff --git a/.github/workflows/call-build-distribution.yml b/.github/workflows/call-build-distribution.yml index c4c277ef..a509d5f8 100644 --- a/.github/workflows/call-build-distribution.yml +++ b/.github/workflows/call-build-distribution.yml @@ -10,8 +10,4 @@ on: jobs: check_job: uses: linuxdeepin/.github/.github/workflows/build-distribution.yml@master - secrets: - BUILD_GPG_PRIVATE_KEY: ${{ secrets.BUILD_GPG_PRIVATE_KEY }} - BUILD_SSH_PRIVATE_KEY: ${{ secrets.BUILD_SSH_PRIVATE_KEY }} - WEBDAV_PASSWD: ${{ secrets.WEBDAV_PASSWD }} - WEBDAV_USER: ${{ secrets.WEBDAV_USER }} + secrets: inherit diff --git a/.github/workflows/call-clacheck.yml b/.github/workflows/call-clacheck.yml index 3fa07a30..fe16a073 100644 --- a/.github/workflows/call-clacheck.yml +++ b/.github/workflows/call-clacheck.yml @@ -12,5 +12,4 @@ concurrency: jobs: clacheck: uses: linuxdeepin/.github/.github/workflows/cla-check.yml@master - secrets: - APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} + secrets: inherit diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index 6a92b546..e808a89b 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - run: export - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} persist-credentials: false diff --git a/.tx/deepin.conf b/.tx/deepin.conf new file mode 100644 index 00000000..45cd054c --- /dev/null +++ b/.tx/deepin.conf @@ -0,0 +1,2 @@ +[transifex] +branch = m20 \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index cc5d21e2..cf222a73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,12 @@ cmake_minimum_required(VERSION 3.1.0) #工程名 project(downloader) -set(PROJECT_VERSION "5.3.70") +if (CVERSION) + message("CVERSION: ${CVERSION}") + set(PROJECT_VERSION ${CVERSION}) +else () + set(PROJECT_VERSION "5.3.70") +endif () set(PROJECT_VERSION_MAJOR 5) set(QT_MIN_VERSION "5.11.0") set(DLM_NAME "downloader") @@ -68,8 +73,9 @@ set(QT Core Gui Widgets Network DBus Sql LinguistTools Svg Test WebChannel WebSo find_package(Qt5 COMPONENTS ${QT} REQUIRED) #应用DTK库 -set(DTK Widget Core Gui) -find_package(Dtk COMPONENTS ${DTK} REQUIRED) +find_package(DtkWidget REQUIRED) +find_package(DtkCore REQUIRED) +find_package(DtkGui REQUIRED) #安装 # qm files. @@ -97,7 +103,9 @@ install(FILES data/downloader.svg DESTINATION share/downloader/icons/logo/) # 添加子模块test add_subdirectory(src) add_subdirectory(translations) +if (CMAKE_BUILD_TYPE STREQUAL "Debug") add_subdirectory(tests) +endif() install(TARGETS downloader dlmlog dlmdatabase dlmaria2 dlmcontrolui RUNTIME DESTINATION bin diff --git a/README.md b/README.md index 44539ac3..b6768516 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Download Manager is Deepin Desktop Environment download manager. 2. Build: ``` -$ cd downloadmanager +$ cd deepin-downloader $ mkdir Build $ cd Build $ cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr .. diff --git a/README.zh_CN.md b/README.zh_CN.md index 93a4120d..d28ead42 100644 --- a/README.zh_CN.md +++ b/README.zh_CN.md @@ -25,7 +25,7 @@ 2. Build: ``` -$ cd downloadmanager +$ cd deepin-downloader $ mkdir Build $ cd Build $ cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr .. diff --git a/debian/changelog b/debian/changelog index 6c164264..51af8bcc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,21 @@ +deepin-downloader (5.3.75) stable; urgency=medium + + * changelog 5.3.75 + + -- muyuankai Mon, 25 Sep 2023 16:57:38 +0800 + +deepin-downloader (5.3.74) stable; urgency=medium + + * update changelog 5.3.74. + + -- wangcong Mon, 30 Aug 2023 16:39:01 +0800 + +deepin-downloader (5.3.73) stable; urgency=medium + + * merge gerrit dev. + + -- muyuankai Mon, 24 Jul 2023 16:00:01 +0800 + downloadmanager (5.3.70) stable; urgency=medium * 升级版本到5.3.70. diff --git a/debian/control b/debian/control index 38b4981f..30db687d 100644 --- a/debian/control +++ b/debian/control @@ -1,8 +1,8 @@ -Source: downloadmanager +Source: deepin-downloader Section: utils Priority: optional Maintainer: Deepin Packages Builder -Build-Depends: +Build-Depends: debhelper (>= 12), cmake, pkg-config, @@ -25,8 +25,7 @@ Homepage: https://www.deepin.org/ Package: org.deepin.downloader Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libdlmaria2, - libdlmcontrolui, libdlmdatabase, libdlmlog, libglib2.0-bin, dde-application-manager +Depends: ${shlibs:Depends}, ${misc:Depends}, libdlmaria2, libdlmcontrolui, libdlmdatabase, libdlmlog Description: it's a user-friendly download manager, supporting URLs and torrent files. downloader for deepin desktop environment. diff --git a/debian/rules b/debian/rules index 8a1b7184..599ea252 100755 --- a/debian/rules +++ b/debian/rules @@ -1,6 +1,8 @@ #!/usr/bin/make -f export QT_SELECT=qt5 +include /usr/share/dpkg/default.mk + %: dh $@ @@ -13,4 +15,4 @@ override_dh_auto_configure: -DUSE_AM_DBUS=ON \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ - -DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib + -DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DCVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib diff --git a/rpm/downloader.spec b/rpm/downloader.spec index da8558dd..ee2f7515 100644 --- a/rpm/downloader.spec +++ b/rpm/downloader.spec @@ -1,4 +1,4 @@ -%global repo downloadmanager +%global repo deepin-downloader %define pkgrelease 1 %if 0%{?openeuler} @@ -13,7 +13,7 @@ Release: 1%{pkgrelease} Summary: a user-friendly download tool, supporting URLs and torrent files License: GPLv3+ URL: https://github.com/linuxdeepin/org.deepin.downloader -Source0: downloadmanager_%{version}.orig.tar.gz +Source0: deepin-downloader_%{version}.orig.tar.gz BuildRequires: gcc-c++ BuildRequires: cmake diff --git a/src/include/ui/global.h b/src/include/ui/global.h index 6f36e52b..faf76279 100644 --- a/src/include/ui/global.h +++ b/src/include/ui/global.h @@ -36,6 +36,9 @@ #include #include namespace Global { +const int tableView_NormalMode_Width = 48; +const int tableView_CompactMode_Width = 36; +const float compactMode_ratio = (2.f/3); const QString ACTIVE = QObject::tr("Downloading"); const QString WAITING = QObject::tr("Waiting"); diff --git a/src/src/ui/CMakeLists.txt b/src/src/ui/CMakeLists.txt index f10e0593..5e84f9e0 100644 --- a/src/src/ui/CMakeLists.txt +++ b/src/src/ui/CMakeLists.txt @@ -129,9 +129,9 @@ target_link_libraries(dlmcontrolui dlmlog dlmaria2 dlmdatabase - Dtk::Core - Dtk::Widget - Dtk::Gui + ${DtkCore_LIBRARIES} + ${DtkWidget_LIBRARIES} + ${DtkGui_LIBRARIES} Qt5::Core Qt5::Network Qt5::Widgets diff --git a/src/src/ui/createTask/btinfodelegate.cpp b/src/src/ui/createTask/btinfodelegate.cpp index f1bd7c94..cad69f31 100644 --- a/src/src/ui/createTask/btinfodelegate.cpp +++ b/src/src/ui/createTask/btinfodelegate.cpp @@ -77,7 +77,6 @@ void BtInfoDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option painter->restore(); painter->save(); QFont font; - font.setPointSize(10); painter->setFont(font); if (index.column() == 0) { @@ -99,15 +98,15 @@ void BtInfoDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option icon = prov.icon(QFileIconProvider::File); } QPixmap pic = icon.pixmap(20, 20); - painter->drawPixmap(option.rect.x() + 32, option.rect.y() + 13, pic); + painter->drawPixmap(option.rect.x() + 32, option.rect.y() + (option.rect.height() - 20)/2, pic); painter->setPen(Qt::darkGray); QString text = painter->fontMetrics().elidedText(index.model()->data(index.model()->index(index.row(), 1)).toString(), Qt::ElideRight, option.rect.width() - 55); - painter->drawText(option.rect.x() + 55, option.rect.y() + 28, text); + painter->drawText(option.rect.marginsRemoved(QMargins(55, 2, 0, 2)), Qt::AlignVCenter | Qt::AlignLeft, text); } else { painter->setPen(Qt::darkGray); QString text = painter->fontMetrics().elidedText(index.data().toString(), Qt::ElideRight, option.rect.width() - 25); - painter->drawText(option.rect.x() + 5, option.rect.y() + 28, text); + painter->drawText(option.rect.marginsRemoved(QMargins(5, 2, 0, 2)), Qt::AlignVCenter | Qt::AlignLeft, text); } painter->restore(); } diff --git a/src/src/ui/createTask/btinfodialog.cpp b/src/src/ui/createTask/btinfodialog.cpp index fc818304..87bf9016 100644 --- a/src/src/ui/createTask/btinfodialog.cpp +++ b/src/src/ui/createTask/btinfodialog.cpp @@ -109,32 +109,35 @@ void BtInfoDialog::initUI() // setWindowTitle(tr("")); QFont font; font.setFamily("Source Han Sans"); - font.setPixelSize(13); m_labelTitle = new DLabel(this); - m_labelTitle->setFixedSize(width(), 30); m_labelTitle->setAlignment(Qt::AlignCenter); - m_labelTitle->move(0, 48); m_labelTitle->setText(tr("New Task")); m_labelTitle->setFont(font); + addContent(m_labelTitle, Qt::AlignHCenter); + addSpacing(20); + QHBoxLayout *hlinfo = new QHBoxLayout(); m_folderIcon = new DLabel(this); m_folderIcon->setPixmap(QPixmap(":/icons/icon/folder.svg")); ///usr/share/icons/bloom/places/32/folder.svg - m_folderIcon->move(45, 92); - //下载信息名称 m_labelInfoName = new DLabel(this); - m_labelInfoName->setGeometry(85, 89, 356, 40); + m_labelInfoName->setMinimumWidth(400); if(m_ariaInfo.name.isEmpty() && !m_ariaInfo.files.isEmpty()){ m_ariaInfo.name = m_ariaInfo.files[0].path; } m_labelInfoName->setText(m_ariaInfo.name); m_labelInfoName->setFont(font); m_labelInfoName->setWordWrap(true); + hlinfo->addWidget(m_folderIcon); + hlinfo->addWidget(m_labelInfoName); + hlinfo->addStretch(); + QWidget *infoWidget = new QWidget(this); + infoWidget->setLayout(hlinfo); + addContent(infoWidget); //总大小标签 QFont font2; - font2.setPixelSize(12); QPalette pal; pal.setColor(QPalette::WindowText, QColor("#8AA1B4")); m_labelFileSize = new DLabel(this); @@ -154,17 +157,19 @@ void BtInfoDialog::initUI() m_widget = new DWidget(this); m_tableView = new BtInfoTableView(m_widget); m_tableView->setMouseTracking(true); - m_widget->setGeometry(15, 142, 471, 235); m_widget->setAutoFillBackground(true); - QVBoxLayout *vb = new QVBoxLayout(m_widget); vb->setContentsMargins(10, 0, 10, 5); vb->addWidget(m_tableView); - QSharedPointer hb = QSharedPointer(new QHBoxLayout); + m_widget->setLayout(vb); + addContent(m_widget); + QHBoxLayout* hb = new QHBoxLayout; hb->addWidget(m_labelSelectedFileNum, Qt::AlignLeft); hb->addStretch(); hb->addWidget(m_labelFileSize, Qt::AlignRight); - hb->setGeometry(QRect(15, 381, 471, 20)); + QWidget *SelinfoWidget = new QWidget(this); + SelinfoWidget->setLayout(hb); + addContent(SelinfoWidget); //Checkbox m_checkAll = new DCheckBox(this); @@ -177,7 +182,6 @@ void BtInfoDialog::initUI() m_checkVideo = new DCheckBox(this); m_checkVideo->setObjectName("checkVideo"); - m_checkVideo->setGeometry(100, 401, 95, 29); m_checkVideo->setText(tr("Videos")); m_checkVideo->setFont(font); m_checkVideo->setChecked(true); @@ -185,7 +189,6 @@ void BtInfoDialog::initUI() m_checkPicture = new DCheckBox(this); m_checkPicture->setObjectName("checkPicture"); - m_checkPicture->setGeometry(185, 401, 95, 29); m_checkPicture->setText(tr("Pictures")); m_checkPicture->setFont(font); m_checkPicture->setChecked(true); @@ -193,7 +196,6 @@ void BtInfoDialog::initUI() m_checkAudio = new DCheckBox(this); m_checkAudio->setObjectName("checkAudio"); - m_checkAudio->setGeometry(270, 401, 95, 29); m_checkAudio->setText(tr("Music")); m_checkAudio->setFont(font); m_checkAudio->setChecked(true); @@ -201,22 +203,25 @@ void BtInfoDialog::initUI() m_checkOther = new DCheckBox(this); m_checkOther->setObjectName("checkOther"); - m_checkOther->setGeometry(355, 401, 95, 29); //Aria2cInterface::bytesFormat(this->info.totalLengthByets)try(375, 401, 95, 29); m_checkOther->setText(tr("Others")); m_checkOther->setFont(font); m_checkOther->setChecked(true); connect(m_checkOther, SIGNAL(clicked()), this, SLOT(onOtherCheck())); + QWidget *checkWidget = new QWidget(this); + QHBoxLayout *hlyt = new QHBoxLayout(); + checkWidget->setLayout(hlyt); + hlyt->addWidget(m_checkAll); + hlyt->addWidget(m_checkVideo); + hlyt->addWidget(m_checkPicture); + hlyt->addWidget(m_checkAudio); + hlyt->addWidget(m_checkOther); + hlyt->addWidget(m_checkAll); + addContent(checkWidget); //下载路径所在分区剩余磁盘容量 - m_labelCapacityFree = new DLabel(this); - m_labelCapacityFree->setGeometry(350, 363, 86, 23); - QString freeSize = Aria2RPCInterface::instance()->getCapacityFree(m_defaultDownloadDir); - m_labelCapacityFree->setPalette(pal); - m_labelCapacityFree->setFont(font2); // m_editDir = new DFileChooserEdit(this); - m_editDir->setGeometry(15, 435, 471, 36); m_editDir->setFont(font); // QString text = getFileEditText(m_defaultDownloadDir); QString flieEditText = tr("Available:") + Aria2RPCInterface::instance()->getCapacityFree(m_defaultDownloadDir); @@ -225,7 +230,6 @@ void BtInfoDialog::initUI() m_labelCapacityFree->setText(flieEditText); m_labelCapacityFree->setPalette(pal); m_labelCapacityFree->setFont(font2); - m_labelCapacityFree->move(348, 438); QString str = getFileEditText(m_defaultDownloadDir); m_editDir->setText(str); m_editDir->setClearButtonEnabled(false); @@ -236,12 +240,12 @@ void BtInfoDialog::initUI() for (int i = 0; i < btnList.size(); i++) { btnList[i]->setToolTip(tr("Change download folder")); } - + addContent(m_editDir); //确定按钮 m_btnOK = new DPushButton(this); + addContent(m_btnOK, Qt::AlignHCenter); m_btnOK->setObjectName("sureBtn"); //this->btnOK->setFixedWidth(190); - m_btnOK->setGeometry(160, 480, 191, 35); m_btnOK->setText(tr("Download Now")); m_btnOK->setFont(font); m_btnOK->setAccessibleName("downloadNow"); @@ -254,15 +258,29 @@ void BtInfoDialog::initUI() m_tableView->setAlternatingRowColors(true); m_tableView->setFrameShape(QAbstractItemView::NoFrame); -// QFont font; - font.setPixelSize(13); m_tableView->setFont(font); m_tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); m_tableView->horizontalHeader()->setHighlightSections(false); m_tableView->horizontalHeader()->setFont(font); m_tableView->verticalHeader()->hide(); - m_tableView->verticalHeader()->setDefaultSectionSize(46); +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::NormalMode) { + m_tableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + } else { + m_tableView->verticalHeader()->setDefaultSectionSize(Global::tableView_CompactMode_Width); + } + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + if (sizeMode == DGuiApplicationHelper::NormalMode) { + m_tableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + } else { + m_tableView->verticalHeader()->setDefaultSectionSize(Global::tableView_CompactMode_Width); + } + }); +#else + m_tableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); +#endif + m_delegate = new BtInfoDelegate(this); m_tableView->setItemDelegate(m_delegate); @@ -597,7 +615,6 @@ void BtInfoDialog::onFilechoosed(const QString &filename) QPalette pal; pal.setColor(QPalette::WindowText, QColor("#8AA1B4")); QFont font; - font.setPixelSize(12); m_labelCapacityFree->setText(QString(tr("Available:") + freeSize)); m_labelCapacityFree->setPalette(pal); m_labelCapacityFree->setFont(font); diff --git a/src/src/ui/createTask/btinfotableview.cpp b/src/src/ui/createTask/btinfotableview.cpp index 28c3b487..1b050db9 100644 --- a/src/src/ui/createTask/btinfotableview.cpp +++ b/src/src/ui/createTask/btinfotableview.cpp @@ -38,7 +38,6 @@ BtInfoTableView::BtInfoTableView(QWidget *parent) connect(this, &QAbstractItemView::doubleClicked, this, &BtInfoTableView::onDoubleClicked); QFont font; font.setFamily("Source Han Sans"); - font.setPixelSize(13); setFont(font); } diff --git a/src/src/ui/createTask/createtaskwidget.cpp b/src/src/ui/createTask/createtaskwidget.cpp index 9e3f0295..d3d5ab52 100644 --- a/src/src/ui/createTask/createtaskwidget.cpp +++ b/src/src/ui/createTask/createtaskwidget.cpp @@ -102,7 +102,6 @@ void CreateTaskWidget::initUi() QFont font; font.setFamily("Source Han Sans"); - font.setPixelSize(13); DLabel *msgTitle = new DLabel(this); QString titleMsg = tr("New Task"); @@ -130,7 +129,7 @@ void CreateTaskWidget::initUi() } m_texturl->setPlaceholderText(tr("Enter download links or drag a torrent file here")); - m_texturl->setFixedSize(QSize(500, 154)); + m_texturl->setMinimumSize(QSize(500, 154)); m_texturl->setFont(font); m_texturl->setWordWrapMode(QTextOption::NoWrap); // m_texturl->document()->setMaximumBlockCount(60); @@ -153,27 +152,32 @@ void CreateTaskWidget::initUi() m_tableView->setSelectionBehavior(QAbstractItemView::SelectRows); m_tableView->setEditTriggers(QAbstractItemView::EditKeyPressed); m_tableView->setAlternatingRowColors(true); - -// DPalette tableviewPalette; -// QBrush brush(QColor(0,0,0,1)); - -// tableviewPalette.setBrush(DPalette::Base, brush); -// m_tableView->setPalette(tableviewPalette); -// brush.setColor(QColor(0,0,0,2)); -// tableviewPalette.setBrush(DPalette::Base, brush); -// m_tableView->horizontalHeader()->setPalette(tableviewPalette); - - -// QFont font; - font.setPixelSize(13); m_tableView->setFont(font); headerView *header = new headerView(Qt::Horizontal, m_tableView); - // header->setStyleSheet("QHeaderView::section stop: 70 #ffffff, stop"); m_tableView->setHorizontalHeader(header); header->setDefaultAlignment(Qt::AlignLeft); header->setHighlightSections(false); m_tableView->verticalHeader()->hide(); - m_tableView->verticalHeader()->setDefaultSectionSize(46); +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::NormalMode) { + m_tableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + m_texturl->setMinimumHeight(154); + } else { + m_tableView->verticalHeader()->setDefaultSectionSize(Global::tableView_CompactMode_Width); + m_texturl->setMinimumHeight(184); + } + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + if (sizeMode == DGuiApplicationHelper::NormalMode) { + m_tableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + m_texturl->setMinimumHeight(154); + } else { + m_tableView->verticalHeader()->setDefaultSectionSize(Global::tableView_CompactMode_Width); + m_texturl->setMinimumHeight(184); + } + }); +#else + m_tableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); +#endif m_delegate = new TaskDelegate(this); m_delegate->setObjectName("taskDelegate"); m_tableView->setItemDelegate(m_delegate); @@ -197,7 +201,6 @@ void CreateTaskWidget::initUi() QHBoxLayout *hllyt = new QHBoxLayout(labelWidget); //总大小标签 QFont font2; - font2.setPixelSize(12); QPalette pal2; pal2.setColor(QPalette::WindowText, QColor("#8AA1B4")); m_labelFileSize = new DLabel(this); @@ -282,7 +285,6 @@ void CreateTaskWidget::initUi() QPalette palFree; palFree.setColor(QPalette::WindowText, QColor("#8AA1B4")); QFont fontFree; - fontFree.setPixelSize(12); m_labelCapacityFree = new DLabel(); QString freeSize = Aria2RPCInterface::instance()->getCapacityFree(m_defaultDownloadDir); m_labelCapacityFree->setPalette(palFree); @@ -335,8 +337,6 @@ void CreateTaskWidget::initUi() iconBtn->setAccessibleName("bticonBtn"); // QIcon tryIcon1(QIcon::fromTheme("dcc_bt")); iconBtn->setIcon(QIcon::fromTheme("dcc_bt")); - iconBtn->setIconSize(QSize(18, 15)); - iconBtn->setFixedSize(QSize(36, 36)); connect(iconBtn, &DIconButton::clicked, this, &CreateTaskWidget::onFileDialogOpen); iconBtn->setToolTip(tr("Select file")); layout->addWidget(iconBtn); @@ -345,8 +345,6 @@ void CreateTaskWidget::initUi() iconBtn->setAccessibleName("mliconBtn"); // QIcon tryIcon1(QIcon::fromTheme("dcc_bt")); mlBtn->setIcon(QIcon::fromTheme("dcc_ml")); - mlBtn->setIconSize(QSize(18, 15)); - mlBtn->setFixedSize(QSize(36, 36)); connect(mlBtn, &DIconButton::clicked, this, &CreateTaskWidget::onMLFileDialogOpen); mlBtn->setToolTip(tr("Select file")); layout->addWidget(mlBtn); @@ -382,8 +380,8 @@ void CreateTaskWidget::initUi() layout->addWidget(rightBox); addContent(boxBtn); - setMaximumSize(521, 575); - setMinimumSize(521, 575); + setMaximumSize(541, 575); + setMinimumSize(541, 575); connect(m_analysisUrl, SIGNAL(sendFinishedUrl(LinkInfo *)), this, SLOT(updataTabel(LinkInfo *))); } @@ -692,7 +690,6 @@ void CreateTaskWidget::onFilechoosed(const QString &filename) QPalette pal; pal.setColor(QPalette::WindowText, QColor("#8AA1B4")); QFont font; - font.setPixelSize(12); m_labelCapacityFree->setText(QString(tr("Available:") + freeSize)); m_labelCapacityFree->setPalette(pal); m_labelCapacityFree->setFont(font); @@ -1157,8 +1154,8 @@ void CreateTaskWidget::hideTableWidget() m_labelFileSize->hide(); m_checkWidget->hide(); m_editDir->hide(); - setMaximumSize(521, 325); - setMinimumSize(521, 325); + setMaximumSize(541, 325); + setMinimumSize(541, 325); auto e = QProcessEnvironment::systemEnvironment(); QString XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE")); if (XDG_SESSION_TYPE == QLatin1String("wayland")) { @@ -1178,8 +1175,8 @@ void CreateTaskWidget::showTableWidget() m_labelFileSize->show(); m_checkWidget->show(); m_editDir->show(); - setMaximumSize(521, 575); - setMinimumSize(521, 575); + setMaximumSize(541, 575); + setMinimumSize(541, 575); QRect rect = geometry(); move(rect.x(), rect.y()); diff --git a/src/src/ui/createTask/taskdelegate.cpp b/src/src/ui/createTask/taskdelegate.cpp index 2479cac2..4f5fee58 100644 --- a/src/src/ui/createTask/taskdelegate.cpp +++ b/src/src/ui/createTask/taskdelegate.cpp @@ -89,7 +89,6 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->restore(); painter->save(); QFont font; - font.setPointSize(11); painter->setFont(font); if (index.column() == 0) { @@ -116,11 +115,10 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, icon = prov.icon(QFileIconProvider::File); } QPixmap pic = icon.pixmap(20, 20); - if(size.isEmpty()){ painter->setOpacity(0.4); } - painter->drawPixmap(option.rect.x() + 32, option.rect.y() + 13, pic); + painter->drawPixmap(option.rect.x() + 32, option.rect.y() + (option.rect.height() - 20)/2, pic); painter->setOpacity(1.0); painter->setPen(Qt::darkGray); @@ -133,7 +131,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, QString i = index.data(TaskModel::Name).toString(); QString text = painter->fontMetrics().elidedText(index.data(index.column()+1).toString(), Qt::ElideRight, option.rect.width() - 55); - painter->drawText(option.rect.x() + 55, option.rect.y() + 28, text); + painter->drawText(option.rect.marginsRemoved(QMargins(55, 2, 0, 2)), Qt::AlignVCenter | Qt::AlignLeft, text); } else if(index.column() == 1){ @@ -146,7 +144,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, } QString text = painter->fontMetrics().elidedText(index.data(index.column()).toString(), Qt::ElideRight, option.rect.width() - 25); - painter->drawText(option.rect.x() + 5, option.rect.y() + 28, text); + painter->drawText(option.rect.marginsRemoved(QMargins(5, 2, 0, 2)), Qt::AlignVCenter | Qt::AlignLeft, text); } painter->restore(); diff --git a/src/src/ui/mainFrame/headerView.cpp b/src/src/ui/mainFrame/headerView.cpp index e61815db..088d0524 100644 --- a/src/src/ui/mainFrame/headerView.cpp +++ b/src/src/ui/mainFrame/headerView.cpp @@ -52,7 +52,7 @@ DownloadHeaderView::DownloadHeaderView(Qt::Orientation orientation, QWidget *par this, &DownloadHeaderView::onPalettetypechanged); - m_headerCbx->setFixedSize(25, 25); + m_headerCbx->setFixedSize(20, 20); m_headerCbx->setVisible(true); //setSectionResizeMode(QHeaderView::ResizeToContents); // 设置resize模式自适应,不能由程序和用户更改 @@ -72,7 +72,8 @@ DownloadHeaderView::~DownloadHeaderView() void DownloadHeaderView::updateGeometries() { - m_headerCbx->move(sectionPosition(0) + 5, (this->height() - 25) / 2 + 2); + m_headerCbx->resize(this->height()-2, this->height()-2); + m_headerCbx->move(sectionPosition(0) + 5, 1); QHeaderView::updateGeometries(); } diff --git a/src/src/ui/mainFrame/itemDelegate.cpp b/src/src/ui/mainFrame/itemDelegate.cpp index da214dab..b39aa431 100644 --- a/src/src/ui/mainFrame/itemDelegate.cpp +++ b/src/src/ui/mainFrame/itemDelegate.cpp @@ -97,7 +97,6 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const bool isSelected = index.data(TableModel::Ischecked).toBool(); //option.state & QStyle::State_Selected; QFont font; - font.setPointSize(11); painter->setFont(font); painter->setRenderHint(QPainter::Antialiasing); @@ -128,9 +127,6 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, } QRect localRect = textRect; - - int x = localRect.x(); - int y = localRect.y() + 12; QString filetype = index.data(TableModel::FileName).toString(); QString fileSavePath = index.data(TableModel::SavePath).toString(); QFileInfo fileInfo(fileSavePath); @@ -148,13 +144,13 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, pic = icon.pixmap(20, 20); } - painter->drawPixmap(x, y, pic); + painter->drawPixmap(option.rect.x(), option.rect.y() + (option.rect.height() - 20)/2, pic); const QString path = index.data(TableModel::SavePath).toString(); int status = index.data(TableModel::Status).toInt(); if ((!QFileInfo::exists(path)) && (status == Global::DownloadTaskStatus::Complete || status == Global::DownloadTaskStatus::Removed)) { //文件不存在的任务,添加提示 QPixmap errorPic = QIcon(":icons/icon/error.svg").pixmap(12, 12); - painter->drawPixmap(x + 10, y + 10, errorPic); + painter->drawPixmap(option.rect.x() + 10, option.rect.y() + (option.rect.height() - 20)/2 + 8, errorPic); } const QRect rectText = localRect.marginsRemoved(QMargins(25, 2, 0, 5)); @@ -193,15 +189,15 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, } QFont font; - font.setPointSize(10); painter->setFont(font); - QRect sizeRect = textRect; - sizeRect.setTop(sizeRect.top() + 10); - sizeRect.setHeight(sizeRect.height() / 4 - 2); - QRect barRect = sizeRect; - barRect.setTop(barRect.bottom() + 10); + + QRect barRect = textRect; + barRect.setTop(textRect.top() + textRect.height() / 2); barRect.setWidth(barRect.width() - 10); - barRect.setHeight(20); + barRect.setHeight(textRect.height() / 2); + QRect sizeRect = barRect; + sizeRect.setTop(barRect.top() - 10); + sizeRect.setHeight(10); QStyleOptionViewItem viewOption(option); initStyleOption(&viewOption, index); @@ -209,7 +205,7 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, (index.data(TableModel::Status) == Global::Lastincomplete)) { const QString pauseText = painter->fontMetrics().elidedText(tr("Paused"), Qt::ElideRight, textRect.width() - 10); - painter->drawText(barRect, Qt::AlignBottom | Qt::AlignLeft, pauseText); + painter->drawText(barRect, Qt::AlignVCenter | Qt::AlignLeft, pauseText); } else if (index.data(TableModel::Status) == Global::Error) { QFont font; font.setPointSize(10); @@ -248,7 +244,7 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QString sizeText = painter->fontMetrics().elidedText(str, Qt::ElideRight, textRect.width() - 10); - painter->drawText(barRect, Qt::AlignBottom | Qt::AlignLeft, sizeText); + painter->drawText(barRect, Qt::AlignVCenter | Qt::AlignLeft, sizeText); } QRect s1(0, 0, 3, m_bgImage->height()); diff --git a/src/src/ui/mainFrame/mainframe.cpp b/src/src/ui/mainFrame/mainframe.cpp index f19c44d4..3474bbc3 100644 --- a/src/src/ui/mainFrame/mainframe.cpp +++ b/src/src/ui/mainFrame/mainframe.cpp @@ -143,12 +143,10 @@ void MainFrame::init() m_DownLoadingTableView = new TableView(tableviewFlag::downloading); m_DownLoadingTableView->setObjectName("downloadTableView"); - m_DownLoadingTableView->verticalHeader()->setDefaultSectionSize(48); m_DownLoadingTableView->setColumnHidden(4, true); m_RecycleTableView = new TableView(tableviewFlag::recycle); m_RecycleTableView->setObjectName("recycleTableView"); - m_RecycleTableView->verticalHeader()->setDefaultSectionSize(48); m_RecycleTableView->setColumnHidden(3, true); m_DownLoadingTableView->getTableControl()->setRecycleTable(m_RecycleTableView); m_LeftWidget = new QWidget; @@ -167,7 +165,6 @@ void MainFrame::init() pNotaskWidgetlayout->setContentsMargins(10, 0, 0, 0); QFont lableFont; - lableFont.setPixelSize(17); lableFont.setWeight(QFont::DemiBold); m_NotaskLabel = new Dtk::Widget::DLabel(); @@ -182,7 +179,6 @@ void MainFrame::init() m_NotaskTipLabel = new DLabel(); QFont notaskTipLabelFont; - notaskTipLabelFont.setPixelSize(14); m_NotaskTipLabel->setFont(notaskTipLabelFont); m_NotaskTipLabel->setText(tr("Click + to create new task")); m_NotaskTipLabel->setAlignment(Qt::AlignHCenter); @@ -225,7 +221,28 @@ void MainFrame::init() //m_LeftList->setFrameShape(QFrame::Shape::NoFrame); QFont font; font.setFamily("Source Han Sans"); - font.setPixelSize(14); + QSize itemsize = m_LeftList->itemSize(); +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::NormalMode) { + font.setPixelSize(15); + m_DownLoadingTableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + m_RecycleTableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + itemsize.setHeight(40); + m_LeftList->setItemSize(itemsize); + } else { + font.setPixelSize(12); + m_DownLoadingTableView->verticalHeader()->setDefaultSectionSize(Global::tableView_CompactMode_Width); + m_RecycleTableView->verticalHeader()->setDefaultSectionSize(Global::tableView_CompactMode_Width); + itemsize.setHeight(40 * Global::compactMode_ratio); + m_LeftList->setItemSize(itemsize); + } +#else + font.setPixelSize(15); + m_DownLoadingTableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + m_RecycleTableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + itemsize.setHeight(40); + m_LeftList->setItemSize(itemsize); +#endif m_LeftList->setFont(font); QPalette pal = m_LeftList->palette(); pal.setColor(QPalette::Window, Qt::white); @@ -241,6 +258,31 @@ void MainFrame::init() m_RecycleItem = new DStandardItem(QIcon::fromTheme("dcc_list_delete"), tr("Trash")); m_RecycleItem->setAccessibleText("Trash"); m_RecycleItem->setFont(font); +#ifdef DTKWIDGET_CLASS_DSizeMode + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + QSize itemsize = m_LeftList->itemSize(); + QFont font; + font.setFamily("Source Han Sans"); + if (sizeMode == DGuiApplicationHelper::NormalMode) { + font.setPixelSize(15); + m_DownLoadingTableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + m_RecycleTableView->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + m_LeftList->setItemSize(QSize(Global::tableView_NormalMode_Width, Global::tableView_NormalMode_Width)); + itemsize.setHeight(40); + m_LeftList->setItemSize(itemsize); + } else { + font.setPixelSize(12); + m_DownLoadingTableView->verticalHeader()->setDefaultSectionSize(Global::tableView_CompactMode_Width); + m_RecycleTableView->verticalHeader()->setDefaultSectionSize(Global::tableView_CompactMode_Width); + m_LeftList->setItemSize(QSize(Global::tableView_CompactMode_Width, Global::tableView_CompactMode_Width)); + itemsize.setHeight(40 * Global::compactMode_ratio); + m_LeftList->setItemSize(itemsize); + } + m_DownloadingItem->setFont(font); + m_DownloadFinishItem->setFont(font); + m_RecycleItem->setFont(font); + }); +#endif m_DownloadingItem->setEditable(false); m_DownloadFinishItem->setEditable(false); m_RecycleItem->setEditable(false); @@ -561,6 +603,7 @@ void MainFrame::onTrayQuitClick(bool force) if (rs != DDialog::Accepted) { return; } + msgBox.setParent(NULL); } m_DownLoadingTableView->getTableControl()->saveDataBeforeClose(); m_RecycleTableView->getTableControl()->saveDataBeforeClose(); @@ -699,9 +742,9 @@ void MainFrame::setPaletteType() palette.setColor(DPalette::Background, c); m_TaskNumWidget->setPalette(palette); m_NotaskLabel->setWindowOpacity(0.2); - m_DownloadingItem->setIcon(QIcon::fromTheme("dcc_list_downloading_dark")); - m_DownloadFinishItem->setIcon(QIcon::fromTheme("dcc_print_done_dark")); - m_RecycleItem->setIcon(QIcon::fromTheme("dcc_list_delete_dark")); + m_DownloadingItem->setIcon(QIcon::fromTheme("dcc_list_downloading_dark", QIcon(":/icons/deepin/builtin/dark/actions/dcc_list_downloading_dark_11px.svg"))); + m_DownloadFinishItem->setIcon(QIcon::fromTheme("dcc_print_done_dark", QIcon(":/icons/deepin/builtin/dark/actions/dcc_print_done_dark_11px.svg"))); + m_RecycleItem->setIcon(QIcon::fromTheme("dcc_list_delete_dark", QIcon(":/icons/deepin/builtin/dark/actions/dcc_list_delete_dark_11px.svg"))); DPalette notaskTipLabelP; notaskTipLabelP.setBrush(DPalette::WindowText, DGuiApplicationHelper::instance()->applicationPalette().textTips()); @@ -722,9 +765,9 @@ void MainFrame::setPaletteType() palette.setColor(DPalette::Background, c); m_TaskNumWidget->setPalette(palette); m_NotaskLabel->setWindowOpacity(0.2); - m_DownloadingItem->setIcon(QIcon::fromTheme("dcc_list_downloading")); - m_DownloadFinishItem->setIcon(QIcon::fromTheme("dcc_print_done")); - m_RecycleItem->setIcon(QIcon::fromTheme("dcc_list_delete")); + m_DownloadingItem->setIcon(QIcon::fromTheme("dcc_list_downloading", QIcon(":/icons/deepin/builtin/dark/actions/dcc_list_downloading_dark_11px.svg"))); + m_DownloadFinishItem->setIcon(QIcon::fromTheme("dcc_print_done", QIcon(":/icons/deepin/builtin/light/actions/dcc_print_done_11px.svg"))); + m_RecycleItem->setIcon(QIcon::fromTheme("dcc_list_delete", QIcon(":/icons/deepin/builtin/light/actions/dcc_list_delete_11px.svg"))); //m_pdownloadingItem->setBackground(DGuiApplicationHelper::instance()->applicationPalette().base()); //m_pdownloadfinishItem->setBackground(DGuiApplicationHelper::instance()->applicationPalette().base()); //m_precycleItem->setBackground(DGuiApplicationHelper::instance()->applicationPalette().base()); @@ -738,6 +781,7 @@ void MainFrame::setPaletteType() void MainFrame::onSettingsMenuClicked() { DSettingsDialog settingsDialog(this); + settingsDialog.setFixedWidth(795); settingsDialog.setAccessibleName("DSettingsDialog"); settingsDialog.setObjectName("DSettingsDialog"); @@ -1552,7 +1596,7 @@ void MainFrame::onSearchEditTextChanged(QString text) flag = 0; } QPoint p = m_ToolBar->getSearchEditPosition(); - QPoint pp = QPoint(p.x() + 250, p.y() + 10); + QPoint pp = QPoint(p.x(), p.y()); searchWidget->move(pp); m_SearchContent = text; QList taskIDList; diff --git a/src/src/ui/mainFrame/searchresoultwidget.cpp b/src/src/ui/mainFrame/searchresoultwidget.cpp index 2d95fe0b..95d869d2 100644 --- a/src/src/ui/mainFrame/searchresoultwidget.cpp +++ b/src/src/ui/mainFrame/searchresoultwidget.cpp @@ -36,6 +36,7 @@ #include #include #include "global.h" +#include SearchResoultWidget::SearchResoultWidget(QWidget *parent) : QListWidget(parent) @@ -44,7 +45,7 @@ SearchResoultWidget::SearchResoultWidget(QWidget *parent) setFixedHeight(280); DPlatformWindowHandle handle(this); handle.setWindowRadius(18); - setIconSize(QSize(16, 16)); + setIconSize(QSize(12, 12)); setSpacing(2); } @@ -57,15 +58,27 @@ void SearchResoultWidget::setData(QList &taskIDList, QListWidgetItem *item = new QListWidgetItem; QString text = " "; if(taskStatusList.at(i) == Global::Complete) { - item->setIcon(QIcon::fromTheme("dcc_print_done")); + if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) { + item->setIcon(QIcon::fromTheme("dcc_print_done", QIcon(":/icons/deepin/builtin/dark/actions/dcc_print_done_dark_11px.svg"))); + } else if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) { + item->setIcon(QIcon::fromTheme("dcc_print_done", QIcon(":/icons/deepin/builtin/light/actions/dcc_print_done_11px.svg"))); + } text += tr("Completed"); item->setData(Qt::UserRole, "Completed"); } else if(taskStatusList.at(i) == Global::Removed) { - item->setIcon(QIcon::fromTheme("dcc_list_delete")); + if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) { + item->setIcon(QIcon::fromTheme("dcc_list_delete", QIcon(":/icons/deepin/builtin/dark/actions/dcc_list_delete_dark_11px.svg"))); + } else if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) { + item->setIcon(QIcon::fromTheme("dcc_list_delete", QIcon(":/icons/deepin/builtin/light/actions/dcc_list_delete_11px.svg"))); + } text += tr("Trash"); item->setData(Qt::UserRole, "Trash"); } else { - item->setIcon(QIcon::fromTheme("dcc_list_downloading")); + if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) { + item->setIcon(QIcon::fromTheme("dcc_list_downloading", QIcon(":/icons/deepin/builtin/dark/actions/dcc_list_downloading_dark_11px.svg"))); + } else if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) { + item->setIcon(QIcon::fromTheme("dcc_list_downloading", QIcon(":/icons/deepin/builtin/light/actions/dcc_list_downloading_11px.svg"))); + } text += tr("Downloading"); item->setData(Qt::UserRole, "Downloading"); } diff --git a/src/src/ui/mainFrame/tableView.cpp b/src/src/ui/mainFrame/tableView.cpp index 1c3549cb..36d96cbe 100644 --- a/src/src/ui/mainFrame/tableView.cpp +++ b/src/src/ui/mainFrame/tableView.cpp @@ -101,16 +101,16 @@ void TableView::initUI() setHorizontalHeader(m_HeaderView); m_HeaderView->setStretchLastSection(true); m_HeaderView->setDefaultAlignment(Qt::AlignVCenter | Qt::AlignLeft); - setColumnWidth(0, 20); + setColumnWidth(0, 30); setColumnWidth(1, 248); m_HeaderView->setSectionResizeMode(1, QHeaderView::Interactive); + m_HeaderView->setSectionResizeMode(0, QHeaderView::Fixed); setColumnWidth(2, 110); setColumnWidth(3, QHeaderView::Interactive); setColumnWidth(4, QHeaderView::Interactive); setTabKeyNavigation(true); QFont font; font.setFamily("Source Han Sans"); - font.setPixelSize(14); setFont(font); } diff --git a/src/src/ui/mainFrame/topButton.cpp b/src/src/ui/mainFrame/topButton.cpp index 4617ba53..20b34fef 100644 --- a/src/src/ui/mainFrame/topButton.cpp +++ b/src/src/ui/mainFrame/topButton.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include "global.h" DWIDGET_USE_NAMESPACE @@ -50,36 +52,47 @@ TopButton::TopButton(QWidget *parent) QPoint TopButton::getSearchEditPosition() { - return mapFromParent(m_searchEdit->rect().bottomLeft()); + return m_searchEdit->geometry().bottomLeft(); } void TopButton::Init() { QHBoxLayout *mainHlayout = new QHBoxLayout(this); - mainHlayout->setContentsMargins(0, 6, 0, 10); + mainHlayout->setContentsMargins(0, 5, 0, 5); mainHlayout->setSpacing(10); m_iconLable = new DLabel; QIcon logo_icon = QIcon(":icons/icon/downloader5.svg"); +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::NormalMode) { + m_iconLable->setPixmap(logo_icon.pixmap(32, 32)); + } else { + m_iconLable->setPixmap(logo_icon.pixmap(32*Global::compactMode_ratio, 32*Global::compactMode_ratio)); + } + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + if (sizeMode == DGuiApplicationHelper::NormalMode) { + m_iconLable->setPixmap(logo_icon.pixmap(32, 32)); + } else { + m_iconLable->setPixmap(logo_icon.pixmap(32*Global::compactMode_ratio, 32*Global::compactMode_ratio)); + } + }); +#else m_iconLable->setPixmap(logo_icon.pixmap(32, 32)); - m_iconLable->setFixedSize(36, 36); +#endif m_searchEdit = new SearchWidget(); - m_searchEdit->setMinimumWidth(350); - m_searchEdit->setFixedHeight(36); + m_searchEdit->setMinimumWidth(380); m_searchEdit->lineEdit()->setMaxLength(256); // searchEdit->setFixedSize(350,36); m_newDownloadBtn = new DIconButton(this); m_newDownloadBtn->setObjectName("newTaskBtn"); m_newDownloadBtn->setAccessibleName("newTaskBtn"); - m_newDownloadBtn->setFixedSize(36, 36); m_newDownloadBtn->setIcon(QIcon::fromTheme("dcc_newdownload")); m_newDownloadBtn->setToolTip(tr("New task")); m_pauseDownloadBtn = new DIconButton(this); m_pauseDownloadBtn->setObjectName("pauseDownloadBtn"); m_pauseDownloadBtn->setAccessibleName("pauseDownloadBtn"); - m_pauseDownloadBtn->setFixedSize(36, 36); m_pauseDownloadBtn->setIcon(QIcon::fromTheme("dcc_list_icon_pause")); m_pauseDownloadBtn->setEnabled(false); m_pauseDownloadBtn->setToolTip(tr("Pause")); @@ -87,7 +100,6 @@ void TopButton::Init() m_startDownloadBtn = new DIconButton(this); m_startDownloadBtn->setObjectName("startDownloadBtn"); m_startDownloadBtn->setAccessibleName("startDownloadBtn"); - m_startDownloadBtn->setFixedSize(36, 36); m_startDownloadBtn->setIcon(QIcon::fromTheme("dcc_icon_start")); m_startDownloadBtn->setEnabled(false); m_startDownloadBtn->setToolTip(tr("Resume")); @@ -95,12 +107,11 @@ void TopButton::Init() m_deleteDownloadBtn = new DIconButton(this); m_deleteDownloadBtn->setObjectName("deleteBtn"); m_deleteDownloadBtn->setAccessibleName("deleteBtn"); - m_deleteDownloadBtn->setFixedSize(36, 36); m_deleteDownloadBtn->setIcon(QIcon::fromTheme("dcc_list_icon_delete")); m_deleteDownloadBtn->setEnabled(false); m_deleteDownloadBtn->setToolTip(tr("Delete")); - mainHlayout->addSpacing(5); + mainHlayout->addSpacing(10); mainHlayout->addWidget(m_iconLable); mainHlayout->addSpacing(7); mainHlayout->addWidget(m_pauseDownloadBtn); @@ -108,8 +119,9 @@ void TopButton::Init() mainHlayout->addWidget(m_deleteDownloadBtn); mainHlayout->addWidget(m_newDownloadBtn); - + mainHlayout->addStretch(); mainHlayout->addWidget(m_searchEdit); + mainHlayout->addStretch(); // mainHlayout->addStretch(); qDebug() << "asdwasdw"; diff --git a/src/src/ui/settings/diagnostictool.cpp b/src/src/ui/settings/diagnostictool.cpp index 49cfb762..102cbe57 100644 --- a/src/src/ui/settings/diagnostictool.cpp +++ b/src/src/ui/settings/diagnostictool.cpp @@ -41,7 +41,8 @@ #include #include #include - +#include +#include "global.h" #include "func.h" #include "aria2rpcinterface.h" @@ -50,7 +51,6 @@ DiagnosticTool::DiagnosticTool(QWidget *parent) , m_Tableview(new QTableView) , m_Model(new DiagnosticModel) { - setFixedSize(453, 431); initUI(); QTimer::singleShot(500, this, SLOT(startDiagnostic())); setAccessibleName("DiagnosticTool"); @@ -72,9 +72,9 @@ void DiagnosticTool::initUI() tryIcon.pixmap(QSize(30, 30)); setIcon(tryIcon); QLabel *mainLabel = new QLabel(this); - mainLabel->setFixedSize(440, 360); + mainLabel->setMinimumSize(440, 380); BaseWidget *pWidget = new BaseWidget(""); - pWidget->setFixedSize(420, 290); + pWidget->setMinimumSize(420, 380); // QPalette p; // p.setColor(QPalette::Background, QColor(255, 255, 255)); // pWidget->setPalette(p); @@ -82,50 +82,77 @@ void DiagnosticTool::initUI() //setPalette(p); QFont f; - f.setPixelSize(17); f.setBold(true); QLabel *pLabel = new QLabel(tr("Result:")); - pLabel->setFixedSize(202, 25); pLabel->setFont(f); m_Button = new QPushButton(tr("Diagnose Again"), this); m_Button->setAccessibleName("diagnoseBtn"); - m_Button->setFixedSize(202, 36); + m_Button->setFixedWidth(202); connect(m_Button, &QPushButton::clicked, this, [=]() { m_Model->clearData(); QTimer::singleShot(500, this, [=]() { startDiagnostic(); }); }); - QHBoxLayout *pHLayout = new QHBoxLayout(); - pHLayout->addStretch(); - pHLayout->addWidget(m_Button); - pHLayout->addStretch(); QVBoxLayout *pLayout = new QVBoxLayout(); + pLayout->setContentsMargins(10, 10, 10, 10); + pLayout->addSpacing(10); pLayout->addWidget(pLabel); + pLayout->addSpacing(10); pLayout->addWidget(m_Tableview); pLayout->addStretch(); - //pLayout->addLayout(pHLayout); pWidget->setLayout(pLayout); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(pWidget); mainLayout->addStretch(); - mainLayout->addLayout(pHLayout); mainLabel->setLayout(mainLayout); addContent(mainLabel, Qt::AlignHCenter | Qt::AlignTop); + addSpacing(10); + addContent(m_Button, Qt::AlignHCenter); m_delegate = new DiagnosticDelegate(this); m_Tableview->setModel(m_Model); m_Tableview->setItemDelegate(m_delegate); m_Tableview->horizontalHeader()->hide(); m_Tableview->verticalHeader()->hide(); - m_Tableview->verticalHeader()->setDefaultSectionSize(40); - m_Tableview->setFixedSize(404, 245); +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::NormalMode) { + m_Tableview->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + m_Tableview->setMinimumHeight(Global::tableView_NormalMode_Width * 6); + pWidget->setMinimumHeight(Global::tableView_NormalMode_Width * 6 + 80); + mainLabel->setMinimumHeight(Global::tableView_NormalMode_Width * 6 + 100); + } else { + m_Tableview->verticalHeader()->setDefaultSectionSize(Global::tableView_CompactMode_Width); + m_Tableview->setMinimumHeight(Global::tableView_CompactMode_Width * 6); + pWidget->setMinimumHeight(Global::tableView_CompactMode_Width * 6 + 80); + mainLabel->setMinimumHeight(Global::tableView_CompactMode_Width * 6 + 100); + } + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + if (sizeMode == DGuiApplicationHelper::NormalMode) { + m_Tableview->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + m_Tableview->setMinimumHeight(Global::tableView_NormalMode_Width * 6); + pWidget->setMinimumHeight(Global::tableView_NormalMode_Width * 6 + 80); + mainLabel->setMinimumHeight(Global::tableView_NormalMode_Width * 6 + 100); + } else { + m_Tableview->verticalHeader()->setDefaultSectionSize(Global::tableView_CompactMode_Width); + m_Tableview->setMinimumHeight(Global::tableView_CompactMode_Width * 6); + pWidget->setMinimumHeight(Global::tableView_CompactMode_Width * 6 + 80); + mainLabel->setMinimumHeight(Global::tableView_CompactMode_Width * 6 + 100); + } + }); +#else + m_Tableview->verticalHeader()->setDefaultSectionSize(Global::tableView_NormalMode_Width); + m_Tableview->setMinimumHeight(Global::tableView_NormalMode_Width * 6); + pWidget->setMinimumHeight(Global::tableView_NormalMode_Width * 6 + 80); + mainLabel->setMinimumHeight(Global::tableView_NormalMode_Width * 6 + 100); +#endif + m_Tableview->setFixedWidth(404); m_Tableview->setShowGrid(false); m_Tableview->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive); m_Tableview->setColumnWidth(0, 42); m_Tableview->setColumnWidth(1, 290); - m_Tableview->setColumnWidth(2, 75); + m_Tableview->setColumnWidth(2, 72); m_Tableview->setAlternatingRowColors(true); m_Tableview->setEnabled(false); m_Tableview->verticalScrollBar()->setHidden(true); @@ -323,16 +350,16 @@ void DiagnosticDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op switch (index.column()) { case 0: { QPixmap pic = index.data(Qt::DisplayRole).toString(); - QRect rect = QRect(option.rect.x() + 10, option.rect.y() + 10, 25, 25); + QRect rect = QRect(option.rect.x() + 10, option.rect.y() + 2 + (option.rect.height() - pic.height())/2.f, pic.width(), pic.height()); painter->drawPixmap(rect, pic); } break; case 1: { - QRect rect = QRect(option.rect.x(), option.rect.y() + 10, option.rect.width(), option.rect.height()); - painter->drawText(rect, index.data(Qt::DisplayRole).toString()); + QRect rect = option.rect; + painter->drawText(rect, Qt::AlignVCenter | Qt::AlignLeft, index.data(Qt::DisplayRole).toString()); } break; case 2: { - QRect rect = QRect(option.rect.x(), option.rect.y() + 10, option.rect.width(), option.rect.height()); - painter->drawText(rect, index.data(Qt::DisplayRole).toString()); + QRect rect = option.rect; + painter->drawText(rect, Qt::AlignVCenter | Qt::AlignLeft, index.data(Qt::DisplayRole).toString()); } break; default: break; diff --git a/src/src/ui/settings/httpadvancedsettingwidget.cpp b/src/src/ui/settings/httpadvancedsettingwidget.cpp index a969265c..437150ac 100644 --- a/src/src/ui/settings/httpadvancedsettingwidget.cpp +++ b/src/src/ui/settings/httpadvancedsettingwidget.cpp @@ -66,7 +66,6 @@ void HttpAdvancedSettingWidget::initUI() QList list; QFont font; font.setFamily("Source Han Sans"); - font.setPixelSize(13); DButtonBoxButton *suffixBtn =new DButtonBoxButton(tr("Edit File Extensions")); //编辑下载文件扩展名 suffixBtn->setAccessibleName("EditFileExtensions"); suffixBtn->setFont(font); @@ -80,22 +79,19 @@ void HttpAdvancedSettingWidget::initUI() m_btnBox->setId(webBtn, 1); list<setButtonList(list,true); - m_btnBox->setFixedSize(280,36); addContent(m_btnBox, Qt::AlignHCenter); addSpacing(10); m_textEdit = new DTextEdit(this); - m_textEdit->setFixedSize(454,168); m_textEdit->setFont(font); - addContent(m_textEdit, Qt::AlignHCenter); + addContent(m_textEdit); addSpacing(8); m_defaultBtn = new DCommandLinkButton(tr("Restore"), this); m_defaultBtn->setAccessibleName("httpadvanceRestore"); connect(m_defaultBtn,&DCommandLinkButton::clicked, this, &HttpAdvancedSettingWidget::onRstoreDefaultClicked); m_defaultBtn->setFont(font); - m_defaultBtn->setGeometry(418,272,56,20); - // addContent(m_defaultBtn, Qt::AlignRight); + addContent(m_defaultBtn, Qt::AlignRight); addSpacing(20); QWidget *w = new QWidget(this); @@ -105,23 +101,20 @@ void HttpAdvancedSettingWidget::initUI() connect(cancel,&DPushButton::clicked, this, &HttpAdvancedSettingWidget::onCancelClicked); cancel->setText(tr("Cancel")); cancel->setFont(font); - cancel->setFixedSize(216,36); DPushButton * sure = new DPushButton(this); sure->setAccessibleName("httpadvanceSure"); connect(sure,&DPushButton::clicked, this, &HttpAdvancedSettingWidget::onSureClicked); - sure->setFixedSize(216,36); sure->setText(tr("Confirm", "button")); sure->setFont(font); QHBoxLayout * hblyt = new QHBoxLayout(w); hblyt->setContentsMargins(0,0,0,0); - w->setFixedSize(454, 44); hblyt->addWidget(cancel); hblyt->addSpacing(20); hblyt->addWidget(sure); w->setLayout(hblyt); - addContent(w, Qt::AlignHCenter); + addContent(w); QFile file(m_configPath); diff --git a/src/src/ui/settings/notificationssettiingwidget.cpp b/src/src/ui/settings/notificationssettiingwidget.cpp index 5becf1f6..671a4cee 100644 --- a/src/src/ui/settings/notificationssettiingwidget.cpp +++ b/src/src/ui/settings/notificationssettiingwidget.cpp @@ -41,13 +41,11 @@ NotificationsSettiingWidget::NotificationsSettiingWidget(QWidget *parent) : QWidget(parent) { QFont lableFont; - lableFont.setPixelSize(14); //lableFont.setBold(QFont::DemiBold); lableFont.setFamily("T5"); DLabel *pTextLabel = new DLabel(tr("Notify me when downloading finished or failed"), this); pTextLabel->setFont(lableFont); QFont tipFont; - tipFont.setPixelSize(12); tipFont.setFamily("T6"); DPalette palette; QColor fontColor("#6d7c88"); @@ -57,7 +55,6 @@ NotificationsSettiingWidget::NotificationsSettiingWidget(QWidget *parent) pTipLabel->setPalette(palette); pTipLabel->setWindowOpacity(0.7); QFont btnFont; - btnFont.setPixelSize(14); btnFont.setFamily("T6"); QPushButton *btn = new QPushButton(tr("Settings"), this); btn->setFont(btnFont); diff --git a/src/src/ui/settings/settings.cpp b/src/src/ui/settings/settings.cpp index 1c0ed721..02477823 100644 --- a/src/src/ui/settings/settings.cpp +++ b/src/src/ui/settings/settings.cpp @@ -941,7 +941,6 @@ QWidget *Settings::createDiskCacheSettiingLabelHandle(QObject *obj) settingsLabel->setLabelText(diskCacheInfo); QFont font; - font.setPointSize(10); // 设置字号 settingsLabel->setLabelFont(font); DPalette palette; diff --git a/src/src/ui/settings/settingswidget.cpp b/src/src/ui/settings/settingswidget.cpp index 5a1375bd..cdbf8c99 100644 --- a/src/src/ui/settings/settingswidget.cpp +++ b/src/src/ui/settings/settingswidget.cpp @@ -54,7 +54,6 @@ SettingsControlWidget::SettingsControlWidget(QWidget *parent) bool SettingsControlWidget::initUI(QString label, QString text, bool isLineEdit) { QFont font; - font.setPixelSize(15); QHBoxLayout *layout = new QHBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); DLabel *pLabel = new DLabel(label); @@ -69,7 +68,6 @@ bool SettingsControlWidget::initUI(QString label, QString text, bool isLineEdit) m_Edit = new DLineEdit(); //m_Edit->setAccessibleName(text.remove(QRegExp("\\s"))); m_Edit->setEnabled(false); - m_Edit->setMinimumWidth(100); QSharedPointer validator = QSharedPointer(new QIntValidator(1, 9999), &QObject::deleteLater); m_Edit->lineEdit()->setValidator(validator.data()); @@ -84,7 +82,6 @@ bool SettingsControlWidget::initUI(QString label, QString text, bool isLineEdit) m_ComboBox = new DComboBox(); //m_ComboBox->setAccessibleName(text.remove(QRegExp("\\s"))); m_ComboBox->setEnabled(false); - m_ComboBox->setFixedWidth(80); QStringList strList; strList << "5" << "10" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 54671665..bee19986 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -86,7 +86,7 @@ add_executable(${PROJECT_NAME_TEST} ${SRC_LIST} ${ALL_HEADERS} ${ALL_SOURCES} ${ #添加gtest库,Qt库,dtk库 target_link_libraries(${PROJECT_NAME_TEST} gmock gmock_main gtest gtest_main pthread - Qt5::Core Qt5::Network Qt5::Widgets Qt5::Svg Qt5::DBus Qt5::Sql Qt5::Test Dtk::Widget Dtk::Gui Dtk::Core Qt5::WebChannel Qt5::WebSockets) + Qt5::Core Qt5::Network Qt5::Widgets Qt5::Svg Qt5::DBus Qt5::Sql Qt5::Test ${DtkWidget_LIBRARIES} ${DtkGui_LIBRARIES} ${DtkCore_LIBRARIES} Qt5::WebChannel Qt5::WebSockets) # 添加 QTest 测试 add_test(${PROJECT_NAME_TEST} COMMAND ${PROJECT_NAME_TEST})