From 5b1d58f9f747a21831e3551582186c855ddb4476 Mon Sep 17 00:00:00 2001 From: shenmo Date: Wed, 11 Jun 2025 08:09:16 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!88=20:?= =?UTF-8?q?=20feat:=20=E8=B0=83=E6=95=B4=E5=B8=83=E5=B1=80'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.github.ccc-app-manager.desktop | 3 +- resources/icons.qrc | 2 +- src/appmanagerwidget.cpp | 12 ++--- src/dlg/pkgdownloaddlg.cpp | 2 +- src/job/appmanagerjob.cpp | 3 -- src/main.cpp | 4 +- src/mainwindow.cpp | 70 +++++++++++++----------------- src/mainwindow.h | 3 +- 8 files changed, 41 insertions(+), 58 deletions(-) mode change 100755 => 100644 com.github.ccc-app-manager.desktop diff --git a/com.github.ccc-app-manager.desktop b/com.github.ccc-app-manager.desktop old mode 100755 new mode 100644 index 19fd04e..275172b --- a/com.github.ccc-app-manager.desktop +++ b/com.github.ccc-app-manager.desktop @@ -1,11 +1,10 @@ -#!/usr/bin/env xdg-open [Desktop Entry] Name=app-manager Name[zh_CN]=应用管理器 Categories=Utility; Comment=app manager,app,system Encoding=UTF-8 -Exec=/opt/apps/com.github.ccc-app-manager/files//ccc-app-manager +Exec=/opt/apps/com.github.ccc-app-manager/files/start.sh "%F" Icon=/opt/apps/com.github.ccc-app-manager/files/ccc-app-manager_56px.svg StartupNotify=true Terminal=false diff --git a/resources/icons.qrc b/resources/icons.qrc index 8c00ef4..49fdd84 100644 --- a/resources/icons.qrc +++ b/resources/icons.qrc @@ -1,5 +1,5 @@ - + icons/ccc-app-manager_56px.svg icons/app-manager_bak_64px.svg icons/distributor-logo-deepin_64px.svg diff --git a/src/appmanagerwidget.cpp b/src/appmanagerwidget.cpp index a781c06..c8d7650 100644 --- a/src/appmanagerwidget.cpp +++ b/src/appmanagerwidget.cpp @@ -107,7 +107,7 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) QPushButton *reloadBtn = new QPushButton(this); reloadBtn->setFlat(true); reloadBtn->setToolTip("重载所有应用信息"); - reloadBtn->setIcon(QIcon(":/actions/rotate_48px.svg")); + reloadBtn->setIcon(QIcon::fromTheme("rotate")); reloadBtn->setIconSize(QSize(30, 30)); reloadBtn->setFixedSize(QSize(30, 30)); guideOperatingLayout->addWidget(reloadBtn); @@ -119,7 +119,7 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) QPushButton *filterBtn = new QPushButton(this); filterBtn->setToolTip("展示类别"); - filterBtn->setIcon(QIcon(":/actions/filter_48px.svg")); + filterBtn->setIcon(QIcon::fromTheme("filter")); filterBtn->setFixedWidth(30); guideOperatingLayout->addWidget(filterBtn); @@ -142,7 +142,7 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) QPushButton *sorterBtn = new QPushButton(this); sorterBtn->setToolTip("排序"); - sorterBtn->setIcon(QIcon(":/actions/sorter_48px.svg")); + sorterBtn->setIcon(QIcon::fromTheme("sorter")); sorterBtn->setFixedWidth(30); guideOperatingLayout->addWidget(sorterBtn); @@ -270,7 +270,7 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) // 查找下一个按钮 DIconButton *findNextContentBtn = new DIconButton(this); findNextContentBtn->setToolTip("查找下一个"); - findNextContentBtn->setIcon(QIcon(":/actions/chevron-down_48px.svg")); + findNextContentBtn->setIcon(QIcon::fromTheme("chevron-down")); findNextContentBtn->setFixedSize(30, 30); findNextContentBtn->setIconSize(QSize(30, 30)); findNextContentBtn->setEnabledCircle(true); @@ -315,10 +315,10 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) firstLineBottomLayout->addSpacing(10); // 跳转到应用商店菜单 QAction *gotoDeepinAppStoreAction = new QAction("深度", this); - gotoDeepinAppStoreAction->setIcon(QIcon(":/icons/distributor-logo-deepin_64px.svg")); + gotoDeepinAppStoreAction->setIcon(QIcon::fromTheme("distributor-logo-deepin")); gotoDeepinAppStoreAction->setCheckable(false); QAction *gotoSparkAppStoreAction = new QAction("星火", this); - gotoSparkAppStoreAction->setIcon(QIcon(":/icons/spark-store_64px.svg")); + gotoSparkAppStoreAction->setIcon(QIcon::fromTheme("spark-store")); gotoSparkAppStoreAction->setCheckable(false); QMenu *gotoAppStoreBtnMenu = new QMenu(this); gotoAppStoreBtnMenu->addAction(gotoDeepinAppStoreAction); diff --git a/src/dlg/pkgdownloaddlg.cpp b/src/dlg/pkgdownloaddlg.cpp index c3f4289..6243b50 100644 --- a/src/dlg/pkgdownloaddlg.cpp +++ b/src/dlg/pkgdownloaddlg.cpp @@ -51,7 +51,7 @@ PkgDownloadDlg::PkgDownloadDlg(const AM::AppInfo &appInfo, AppManagerModel *mode setLayout(mainLayout); m_titlebar = new DTitlebar(this); - m_titlebar->setIcon(QIcon(":/icons/ccc-app-manager_56px.svg")); + m_titlebar->setIcon(QIcon::fromTheme("ccc-app-manager")); m_titlebar->setTitle("应用管理器"); m_titlebar->setFixedHeight(40); m_titlebar->setBackgroundTransparent(true); diff --git a/src/job/appmanagerjob.cpp b/src/job/appmanagerjob.cpp index de386ac..4c42af6 100644 --- a/src/job/appmanagerjob.cpp +++ b/src/job/appmanagerjob.cpp @@ -301,7 +301,6 @@ void AppManagerJob::init() void AppManagerJob::reloadAppInfos() { - setRunningStatus(AM::Busy); m_mutex.lock(); // m_appInfosMap为成员变量,加锁 m_appInfosMap.clear(); m_mutex.unlock(); // 解锁 @@ -329,8 +328,6 @@ void AppManagerJob::reloadAppInfos() loadAllPkgInstalledAppInfos(); Q_EMIT loadAppInfosFinished(); - - setRunningStatus(AM::Normal); } void AppManagerJob::downloadPkg(const QString &pkgName) diff --git a/src/main.cpp b/src/main.cpp index f22f6f6..3f99190 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,8 +19,8 @@ int main(int argc, char *argv[]) a.loadTranslator(); a.setApplicationDisplayName(QObject::tr("App Manager")); a.setStyle("chameleon"); - a.setWindowIcon(QIcon(":/icons/ccc-app-manager_56px.svg")); - a.setProductIcon(QIcon(":/icons/ccc-app-manager_56px.svg")); + a.setWindowIcon(QIcon::fromTheme("ccc-app-manager")); + a.setProductIcon(QIcon::fromTheme("ccc-app-manager")); a.setApplicationDescription("ccc-app-manager是一款方便的第三方应用管理工具\n支持应用的安装,卸载,安装包提取等功能\n感谢yzzi开发了好用的oh-my-dde系统配置工具,我把工具的启动入口加到了本项目中"); a.setQuitOnLastWindowClosed(true);//关闭主窗口后关闭关于 // 单例运行 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a410c1b..b6abeb9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -6,9 +6,8 @@ #include #include #include - -#include #include + #include #include #include @@ -16,8 +15,7 @@ #include MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , m_mainMenu(nullptr) + : DMainWindow(parent) , m_centralWidgetBlurBg(nullptr) , m_isDeepin(false) , m_appManagerModel(nullptr) @@ -29,25 +27,28 @@ MainWindow::MainWindow(QWidget *parent) int resizedHeight = int(resizedWidth * 3 / 5); resize(resizedWidth, resizedHeight); // 设置背景 - // setTitlebarShadowEnabled(false); + setTitlebarShadowEnabled(false); setFocusPolicy(Qt::FocusPolicy::ClickFocus); - QMenuBar *menuBar = this->menuBar(); - m_mainMenu = new QMenu(this); - m_mainMenu->setTitle("打开"); - menuBar->addMenu(m_mainMenu); + titlebar()->setIcon(QIcon::fromTheme("ccc-app-manager")); + titlebar()->setTitle("应用管理器"); + titlebar()->setFixedHeight(40); + titlebar()->setBackgroundTransparent(true); + + QMenu *menu = new QMenu(this); + titlebar()->setMenu(menu); QAction *watchGuiAppListAction = new QAction(this); watchGuiAppListAction->setText("复制启动器中所有应用包名"); - m_mainMenu->addAction(watchGuiAppListAction); + menu->addAction(watchGuiAppListAction); QAction *openOhMyDDEAction = new QAction(this); openOhMyDDEAction->setText("打开oh-my-dde"); - m_mainMenu->addAction(openOhMyDDEAction); + menu->addAction(openOhMyDDEAction); QAction *openProInfoWindowAction = new QAction(this); openProInfoWindowAction->setText("打开进程信息窗口"); - m_mainMenu->addAction(openProInfoWindowAction); + menu->addAction(openProInfoWindowAction); m_centralWidgetBlurBg = new DBlurEffectWidget(this); m_centralWidgetBlurBg->setBlendMode(DBlurEffectWidget::BlendMode::BehindWindowBlend); @@ -59,32 +60,25 @@ MainWindow::MainWindow(QWidget *parent) m_isDeepin = DSysInfo::isDeepin(); DFrame *centralWidget = new DFrame(this); - QPalette pa = centralWidget->palette(); - pa.setColor(QPalette::ColorRole::Base, Qt::transparent); - centralWidget->setPalette(pa); + int dtkWindowRadius = 8; + if (QGSettings::isSchemaInstalled("com.deepin.xsettings")) { + QGSettings deepinSettings("com.deepin.xsettings"); + if (AM::isQGSettingsContainsKey(deepinSettings, "dtk-window-radius")) { + dtkWindowRadius = deepinSettings.get("dtk-window-radius").toInt(); + } + } + int internalPix = dtkWindowRadius < 9 ? 0 : (dtkWindowRadius - 8) / 2; + centralWidget->setContentsMargins(4 + internalPix, 0, 4 + internalPix, 4 + internalPix); setCentralWidget(centralWidget); - QVBoxLayout *mainLayout = new QVBoxLayout; + QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->setContentsMargins(0, 0, 0, 0); - mainLayout->setSpacing(0); centralWidget->setLayout(mainLayout); - DTitlebar *titleBar = new DTitlebar(this); - titleBar->setIcon(QIcon(":/icons/ccc-app-manager_56px.svg")); - titleBar->setTitle("应用管理器"); - // titleBar->setFixedHeight(40); - titleBar->setBackgroundTransparent(true); - titleBar->setMenu(m_mainMenu); - mainLayout->addWidget(titleBar, 0, Qt::AlignTop); - - QHBoxLayout *contentLayout = new QHBoxLayout; - contentLayout->setContentsMargins(0, 0, 0, 0); - mainLayout->addLayout(contentLayout, 1); - // 应用管理 m_appManagerModel = new AppManagerModel(this); m_appManagerWidget = new AppManagerWidget(m_appManagerModel, this); - contentLayout->addWidget(m_appManagerWidget); + mainLayout->addWidget(m_appManagerWidget); // init connection // 运行状态改变 @@ -176,19 +170,13 @@ MainWindow::MainWindow(QWidget *parent) // post init if (m_isDeepin) { - menuBar->setVisible(false); setAttribute(Qt::WA_TranslucentBackground, true); m_centralWidgetBlurBg->setVisible(true); - titleBar->setBackgroundTransparent(true); - setWindowFlag(Qt::WindowType::FramelessWindowHint, true); + titlebar()->setBackgroundTransparent(true); } else { setAttribute(Qt::WA_TranslucentBackground, false); m_centralWidgetBlurBg->setVisible(false); - titleBar->setBackgroundTransparent(false); - titleBar->setVisible(false); - - mainLayout->removeWidget(titleBar); - titleBar->deleteLater(); + titlebar()->setBackgroundTransparent(false); } updateUIByRunningStatus(); @@ -200,13 +188,13 @@ MainWindow::~MainWindow() void MainWindow::resizeEvent(QResizeEvent *event) { - QMainWindow::resizeEvent(event); + DMainWindow::resizeEvent(event); m_centralWidgetBlurBg->setFixedSize(size()); } void MainWindow::closeEvent(QCloseEvent *event) { - QMainWindow::closeEvent(event); + DMainWindow::closeEvent(event); qApp->exit(); } @@ -255,6 +243,6 @@ void MainWindow::openSparkStoreNeedBeInstallDlg() void MainWindow::updateUIByRunningStatus() { bool enable = (RunningStatus::Normal == m_appManagerModel->getRunningStatus()); - m_mainMenu->setEnabled(enable); + titlebar()->menu()->setEnabled(enable); m_appManagerWidget->setEnabled(enable); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 93bf3e6..d73da5f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -10,7 +10,7 @@ DWIDGET_END_NAMESPACE DWIDGET_USE_NAMESPACE DCORE_USE_NAMESPACE -class MainWindow : public QMainWindow +class MainWindow : public DMainWindow { Q_OBJECT public: @@ -30,7 +30,6 @@ private: void updateUIByRunningStatus(); private: - QMenu *m_mainMenu; DBlurEffectWidget *m_barBlurBg; DBlurEffectWidget *m_centralWidgetBlurBg; bool m_isDeepin; -- Gitee