From f65176a68e61c72785fee0b9355595930fae0ca5 Mon Sep 17 00:00:00 2001 From: fengli Date: Mon, 13 Nov 2023 16:08:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B4=A7=E5=87=91=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复紧凑模式显示问题 Log: 修复紧凑模式显示问题 Bug: https://pms.uniontech.com/bug-view-225047.html --- deepin-font-manager/globaldef.h | 1 + .../interfaces/dfontbasedialog.cpp | 24 ++ .../interfaces/dfontbasedialog.h | 6 + deepin-font-manager/utils.cpp | 5 + deepin-font-manager/utils.h | 3 + deepin-font-manager/views/dfdeletedialog.cpp | 88 +++----- deepin-font-manager/views/dfdeletedialog.h | 7 +- .../views/dfinstallerrordialog.cpp | 210 ++++++------------ .../views/dfinstallerrordialog.h | 19 +- .../views/dfinstallerrorlistview.cpp | 6 +- .../views/dfinstallnormalwindow.cpp | 2 +- .../views/dfontmgrmainwindow.cpp | 24 +- libdeepin-font-manager/dfontpreviewitemdef.h | 2 +- 13 files changed, 155 insertions(+), 242 deletions(-) diff --git a/deepin-font-manager/globaldef.h b/deepin-font-manager/globaldef.h index 969792ab..e526875b 100644 --- a/deepin-font-manager/globaldef.h +++ b/deepin-font-manager/globaldef.h @@ -19,6 +19,7 @@ #define FTM_LEFT_SIDE_BAR_WIDTH 160 // State bar #define FTM_SBAR_HEIGHT 56 +#define FTM_SBAR_COMPACT_HEIGHT 40 //Alt+M rightMenuPositionParam //SP3--Alt+M右键菜单--位置参数 #define POSITION_PARAM_X 158 diff --git a/deepin-font-manager/interfaces/dfontbasedialog.cpp b/deepin-font-manager/interfaces/dfontbasedialog.cpp index e47866c8..c56d54ef 100644 --- a/deepin-font-manager/interfaces/dfontbasedialog.cpp +++ b/deepin-font-manager/interfaces/dfontbasedialog.cpp @@ -20,6 +20,9 @@ DFontBaseDialog::DFontBaseDialog(QWidget *parent) setAttribute(Qt::WA_DeleteOnClose); initUI(); InitConnections(); +#ifdef DTKWIDGET_CLASS_DSizeMode + slotSizeModeChanged(DGuiApplicationHelper::instance()->sizeMode()); +#endif } DFontBaseDialog::~DFontBaseDialog() @@ -102,6 +105,9 @@ void DFontBaseDialog::InitConnections() Q_EMIT closeBtnClicked(); this->close(); }); +#ifdef DTKWIDGET_CLASS_DSizeMode + connect(DGuiApplicationHelper::instance(),&DGuiApplicationHelper::sizeModeChanged,this, &DFontBaseDialog::slotSizeModeChanged); +#endif } /************************************************************************* @@ -193,6 +199,24 @@ void DFontBaseDialog::closeEvent(QCloseEvent *event) Q_EMIT closed(); } + +#ifdef DTKWIDGET_CLASS_DSizeMode +void DFontBaseDialog::slotSizeModeChanged(DGuiApplicationHelper::SizeMode sizeMode) +{ + if (sizeMode == DGuiApplicationHelper::SizeMode::CompactMode) { + m_titleBar->setFixedHeight(40); + m_logoIcon->setFixedSize(QSize(25, 25)); + m_logoIcon->setPixmap(QIcon::fromTheme("deepin-font-manager").pixmap(QSize(25, 25))); + m_closeButton->setIconSize(QSize(40, 40)); + } else { + m_titleBar->setFixedHeight(50); + m_logoIcon->setFixedSize(QSize(32, 32)); + m_logoIcon->setPixmap(QIcon::fromTheme("deepin-font-manager").pixmap(QSize(32, 32))); + m_closeButton->setIconSize(QSize(50, 50)); + } +} +#endif + /************************************************************************* getCloseButton 获取右上角的关闭按钮 diff --git a/deepin-font-manager/interfaces/dfontbasedialog.h b/deepin-font-manager/interfaces/dfontbasedialog.h index 738107b2..7e5685b5 100644 --- a/deepin-font-manager/interfaces/dfontbasedialog.h +++ b/deepin-font-manager/interfaces/dfontbasedialog.h @@ -10,6 +10,7 @@ #include #include +#include DWIDGET_USE_NAMESPACE @@ -65,6 +66,11 @@ class DFontBaseDialog : public DAbstractDialog void closeBtnClicked(); public slots: +#ifdef DTKWIDGET_CLASS_DSizeMode + //紧凑模式切换 + void slotSizeModeChanged(DGuiApplicationHelper::SizeMode sizeMode); +#endif + private: QWidget *m_titleBar {nullptr}; DLabel *m_logoIcon {nullptr}; diff --git a/deepin-font-manager/utils.cpp b/deepin-font-manager/utils.cpp index 36f6ea53..90a1991e 100644 --- a/deepin-font-manager/utils.cpp +++ b/deepin-font-manager/utils.cpp @@ -160,3 +160,8 @@ bool Utils::isWayland() return false; } } + +void Utils::clearImgCache() +{ + m_imgCacheHash.clear(); +} diff --git a/deepin-font-manager/utils.h b/deepin-font-manager/utils.h index 291ad144..0f2388a1 100644 --- a/deepin-font-manager/utils.h +++ b/deepin-font-manager/utils.h @@ -34,6 +34,9 @@ class Utils : public QObject //判断是否wayland环境 static bool isWayland(); + + //清除图像缓存 + static void clearImgCache(); }; #endif diff --git a/deepin-font-manager/views/dfdeletedialog.cpp b/deepin-font-manager/views/dfdeletedialog.cpp index 19bafcb8..a50a3927 100644 --- a/deepin-font-manager/views/dfdeletedialog.cpp +++ b/deepin-font-manager/views/dfdeletedialog.cpp @@ -77,7 +77,7 @@ NewStr autoCutText(const QString &text, DLabel *pDesLbl) null *************************************************************************/ DFDeleteDialog::DFDeleteDialog(DFontMgrMainWindow *win, int deleteCnt, int systemCnt, bool hasCurrent, QWidget *parent) - : DFontBaseDialog(parent) + : DDialog(parent) , m_mainWindow(win) , m_deleteCnt(deleteCnt) , m_systemCnt(systemCnt) @@ -100,10 +100,10 @@ DFDeleteDialog::DFDeleteDialog(DFontMgrMainWindow *win, int deleteCnt, int syste void DFDeleteDialog::initUI() { setFixedWidth(DEFAULT_WINDOW_W); + setIcon(QIcon::fromTheme("deepin-font-manager")); initMessageTitle(); initMessageDetail(); - QLayout *buttonsLayout = initBottomButtons(); QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->setSpacing(0); @@ -111,8 +111,6 @@ void DFDeleteDialog::initUI() mainLayout->addWidget(messageTitle, 0, Qt::AlignCenter); mainLayout->addSpacing(6); mainLayout->addWidget(messageDetail, 0, Qt::AlignCenter); - mainLayout->addSpacing(16); - mainLayout->addLayout(buttonsLayout); QWidget *mainFrame = new QWidget(this); mainFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -124,6 +122,9 @@ void DFDeleteDialog::initUI() messageDetail->setMinimumWidth(DEFAULT_WINDOW_W - 20); addContent(mainFrame); + + insertButton(0, DApplication::translate("DFDeleteDialog", "Cancel", "button"), false, ButtonNormal); + insertButton(1, DApplication::translate("DeleteConfirmDailog", "Delete", "button"), true, ButtonWarning); } /************************************************************************* @@ -136,19 +137,6 @@ void DFDeleteDialog::initUI() *************************************************************************/ void DFDeleteDialog::initConnections() { - connect(m_cancelBtn, &DPushButton::clicked, this, [ = ]() { - reject(); - close(); - emit m_signalManager->cancelDel(); - }); - connect(m_confirmBtn, &DPushButton::clicked, this, [ = ]() { - if (m_deleting) - return; - m_deleting = true; - accept(); - close(); - }); - //关闭删除确认对话框并且没有点击"确认"按钮时,取消删除操作 connect(this, &DFDeleteDialog::closed, this, [ = ]() { if (m_mainWindow != nullptr && !m_deleting) { @@ -157,6 +145,28 @@ void DFDeleteDialog::initConnections() emit m_signalManager->clearRecoverList(); } }); + + connect(this, &DFDeleteDialog::buttonClicked, this, [=](int index, const QString &text){ + switch (index) { + case 0: + reject(); + close(); + emit m_signalManager->cancelDel(); + break; + + case 1: + if (m_deleting) + return; + m_deleting = true; + accept(); + close(); + break; + + default: + break; + } + }); + connect(qApp, &DApplication::fontChanged, this, &DFDeleteDialog::onFontChanged); connect(DApplicationHelper::instance(), &DApplicationHelper::themeTypeChanged, this, &DFDeleteDialog::setTheme); @@ -223,46 +233,6 @@ void DFDeleteDialog::initMessageDetail() DFontSizeManager::instance()->bind(messageDetail, DFontSizeManager::T6, QFont::Medium); } -/************************************************************************* - initBottomButtons - 初始化页面按钮 - - null - null Description:null - null -*************************************************************************/ -QLayout *DFDeleteDialog::initBottomButtons() -{ - QHBoxLayout *layout = new QHBoxLayout(); - layout->setSpacing(0); - layout->setContentsMargins(0, 0, 0, 0); - - m_cancelBtn = new DPushButton(this); - m_cancelBtn->setFixedWidth(170); - m_cancelBtn->setText(DApplication::translate("DFDeleteDialog", "Cancel", "button")); - - m_confirmBtn = new DWarningButton(this); - m_confirmBtn->setFixedWidth(170); - m_confirmBtn->setText(DApplication::translate("DeleteConfirmDailog", "Delete", "button")); - - DVerticalLine *verticalSplite = new DVerticalLine(this); - DPalette pa = DApplicationHelper::instance()->palette(verticalSplite); - QColor splitColor = pa.color(DPalette::ItemBackground); - pa.setBrush(DPalette::Background, splitColor); - verticalSplite->setPalette(pa); - verticalSplite->setBackgroundRole(QPalette::Background); - verticalSplite->setAutoFillBackground(true); - verticalSplite->setFixedSize(3, 28); - - layout->addWidget(m_cancelBtn); - layout->addSpacing(9); - layout->addWidget(verticalSplite); - layout->addSpacing(9); - layout->addWidget(m_confirmBtn); - - return layout; -} - /************************************************************************* onFontChanged 适应系统字体变化 @@ -300,8 +270,8 @@ void DFDeleteDialog::keyPressEvent(QKeyEvent *event) received = true; } if (event->key() == Qt::Key_Return) { - if (!getCloseButton()->hasFocus() && !m_cancelBtn->hasFocus()) { - m_confirmBtn->click(); + if (!getButton(0)->hasFocus() && !getButton(1)->hasFocus()) { + getButton(1)->click(); received = true; } } diff --git a/deepin-font-manager/views/dfdeletedialog.h b/deepin-font-manager/views/dfdeletedialog.h index 9d9c5575..e2ff1c6a 100644 --- a/deepin-font-manager/views/dfdeletedialog.h +++ b/deepin-font-manager/views/dfdeletedialog.h @@ -9,6 +9,7 @@ #include "dfontbasedialog.h" #include "signalmanager.h" +#include #include #include #include @@ -23,7 +24,7 @@ class DFontMgrMainWindow; null *************************************************************************/ -class DFDeleteDialog : public DFontBaseDialog +class DFDeleteDialog : public DDialog { Q_OBJECT public: @@ -53,14 +54,10 @@ private slots: void initMessageTitle(); //初始化页面提示信息内容 void initMessageDetail(); - //初始化页面按钮 - QLayout *initBottomButtons(); DLabel *messageTitle; DLabel *messageDetail; - DPushButton *m_cancelBtn; - DWarningButton *m_confirmBtn; DFontMgrMainWindow *m_mainWindow; SignalManager *m_signalManager = SignalManager::instance(); int m_deleteCnt; diff --git a/deepin-font-manager/views/dfinstallerrordialog.cpp b/deepin-font-manager/views/dfinstallerrordialog.cpp index adb87e17..3b521580 100644 --- a/deepin-font-manager/views/dfinstallerrordialog.cpp +++ b/deepin-font-manager/views/dfinstallerrordialog.cpp @@ -16,7 +16,7 @@ #include DWIDGET_USE_NAMESPACE -#define LISTVIEW_LEFT_SPACING 2 +#define LISTVIEW_LEFT_SPACING 10 /************************************************************************* DFInstallErrorDialog @@ -31,7 +31,7 @@ DWIDGET_USE_NAMESPACE null *************************************************************************/ DFInstallErrorDialog::DFInstallErrorDialog(QWidget *parent, const QStringList &errorInstallFontFileList) - : DFontBaseDialog(parent) + : DDialog(parent) , m_parent(qobject_cast(parent)) , m_signalManager(SignalManager::instance()) , m_errorInstallFiles(errorInstallFontFileList) @@ -43,7 +43,13 @@ DFInstallErrorDialog::DFInstallErrorDialog(QWidget *parent, const QStringList &e emit m_signalManager->popInstallErrorDialog(); connect(m_signalManager, &SignalManager::updateInstallErrorListview, this, &DFInstallErrorDialog::addData); resetContinueInstallBtnStatus(); -// m_installErrorListView->setFocus(); + + connect(this, &DFInstallErrorDialog::buttonClicked, this, &DFInstallErrorDialog::onControlButtonClicked); + +#ifdef DTKWIDGET_CLASS_DSizeMode + slotSizeModeChanged(DGuiApplicationHelper::instance()->sizeMode()); + connect(DGuiApplicationHelper::instance(),&DGuiApplicationHelper::sizeModeChanged,this, &DFInstallErrorDialog::slotSizeModeChanged); +#endif } /************************************************************************* @@ -130,66 +136,44 @@ void DFInstallErrorDialog::initData() *************************************************************************/ void DFInstallErrorDialog::initUI() { - initMainFrame(); - initTitleBar(); - initInstallErrorFontViews(); - - connect(this, &DFInstallErrorDialog::closeBtnClicked, this, &DFInstallErrorDialog::onCancelInstall); -} - -/************************************************************************* - resizeEvent - 字体验证框大小重绘页面 - - - event Description:事件对象 - null Description:null - null -*************************************************************************/ -void DFInstallErrorDialog::resizeEvent(QResizeEvent *event) -{ - DFontBaseDialog::resizeEvent(event); - m_mainFrame->resize(event->size().width(), event->size().height()); -} + setContentsMargins(0, 0, 0, 0); + setIconPixmap(Utils::renderSVG("://exception-logo.svg", QSize(32, 32))); + setWindowTitle(DApplication::translate("ExceptionWindow", "Font Verification")); -/************************************************************************* - initMainFrame - 初始化字体验证框页面框架 - - null - null Description:null - null -*************************************************************************/ -void DFInstallErrorDialog::initMainFrame() -{ this->setFixedSize(448, 302); m_mainLayout = new QVBoxLayout; - m_mainLayout->setMargin(0); m_mainLayout->setSpacing(0); m_mainLayout->setContentsMargins(0, 0, 0, 0); m_mainFrame = new QWidget(this); m_mainFrame->setContentsMargins(0, 0, 0, 0); m_mainFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - m_mainFrame->setLayout(m_mainLayout); + addContent(m_mainFrame, Qt::AlignHCenter); - addContent(m_mainFrame); -} + DVerticalLine *verticalSplit = new DVerticalLine; + verticalSplit->setFixedWidth(1); + verticalSplit->setFixedHeight(28); + DPalette pa = DApplicationHelper::instance()->palette(verticalSplit); + QBrush splitBrush = pa.brush(DPalette::ItemBackground); + pa.setBrush(DPalette::Background, splitBrush); + verticalSplit->setPalette(pa); + verticalSplit->setBackgroundRole(QPalette::Background); + verticalSplit->setAutoFillBackground(true); -/************************************************************************* - initTitleBar - 初始化标题栏信息 - - null - null Description:null - null -*************************************************************************/ -void DFInstallErrorDialog::initTitleBar() -{ - setIconPixmap(Utils::renderSVG("://exception-logo.svg", QSize(32, 32))); - setTitle(DApplication::translate("ExceptionWindow", "Font Verification")); + m_installErrorListView = new DFInstallErrorListView(m_installErrorFontModelList, this); + m_installErrorListView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_installErrorListView->setFixedWidth(width() - LISTVIEW_LEFT_SPACING * 2); + m_installErrorListView->setEditTriggers(QAbstractItemView::NoEditTriggers); + m_installErrorListView->setSelectionMode(QAbstractItemView::ExtendedSelection); + m_mainLayout->addWidget(m_installErrorListView); + + insertButton(0, DApplication::translate("ExceptionWindow", "Exit"), false, ButtonNormal); + insertButton(1, DApplication::translate("ExceptionWindow", "Continue"), true, ButtonRecommend); + + connect(m_installErrorListView, SIGNAL(clickedErrorListItem(QModelIndex)), this, + SLOT(onListItemClicked(QModelIndex))); } /************************************************************************* @@ -238,86 +222,6 @@ int DFInstallErrorDialog::getErrorFontSelectableCount() return checkedCount; } -/************************************************************************* - initInstallErrorFontViews - 初始化字体验证列表视图布局 - - null - null Description:null - null -*************************************************************************/ -void DFInstallErrorDialog::initInstallErrorFontViews() -{ - //contentFrame = new QWidget(this); - //contentFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - m_mainLayout->setMargin(0); - m_mainLayout->setSpacing(0); - m_mainLayout->setContentsMargins(0, 0, 0, 0); - - QHBoxLayout *buttonLayout = new QHBoxLayout; - buttonLayout->setMargin(0); - buttonLayout->setSpacing(0); - buttonLayout->setContentsMargins(10, 0, 10, 0); - - int btnHeight = 38; - QWidget *btnFrame = new QWidget; - btnFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - btnFrame->setFixedHeight(btnHeight + 15); - btnFrame->setLayout(buttonLayout); - - QButtonGroup *btnGroup = new QButtonGroup(this); - - btnGroup->setExclusive(true); - - QFont btnFont = font(); - //btnFont.setPixelSize(14); - - m_quitInstallBtn = new DPushButton(this); - m_quitInstallBtn->setFont(btnFont); - m_quitInstallBtn->setMinimumWidth(204); - m_quitInstallBtn->setText(DApplication::translate("ExceptionWindow", "Exit", "button")); - - m_continueInstallBtn = new DSuggestButton(this); - m_continueInstallBtn->setMinimumWidth(204); - m_continueInstallBtn->setFont(btnFont); - m_continueInstallBtn->setText(DApplication::translate("ExceptionWindow", "Continue", "button")); - - btnGroup->addButton(m_quitInstallBtn, 0); - btnGroup->addButton(m_continueInstallBtn, 1); - - connect(btnGroup, SIGNAL(buttonClicked(int)), this, SLOT(onControlButtonClicked(int))); - - DVerticalLine *verticalSplit = new DVerticalLine; - verticalSplit->setFixedWidth(1); - verticalSplit->setFixedHeight(28); - DPalette pa = DApplicationHelper::instance()->palette(verticalSplit); - QBrush splitBrush = pa.brush(DPalette::ItemBackground); - pa.setBrush(DPalette::Background, splitBrush); - verticalSplit->setPalette(pa); - verticalSplit->setBackgroundRole(QPalette::Background); - verticalSplit->setAutoFillBackground(true); - - buttonLayout->addWidget(m_quitInstallBtn); - buttonLayout->addSpacing(10); - buttonLayout->addWidget(verticalSplit); - buttonLayout->addSpacing(9); - buttonLayout->addWidget(m_continueInstallBtn); - - m_installErrorListView = new DFInstallErrorListView(m_installErrorFontModelList, this); - m_installErrorListView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - m_installErrorListView->setFixedWidth(width() - LISTVIEW_LEFT_SPACING); - m_installErrorListView->setEditTriggers(QAbstractItemView::NoEditTriggers); - m_installErrorListView->setSelectionMode(QAbstractItemView::ExtendedSelection); - - m_mainLayout->addWidget(m_installErrorListView); - m_mainLayout->addWidget(btnFrame); - m_mainLayout->addStretch(); - - connect(m_installErrorListView, SIGNAL(clickedErrorListItem(QModelIndex)), this, - SLOT(onListItemClicked(QModelIndex))); -} - /************************************************************************* resetContinueInstallBtnStatus 刷新继续按钮的状态-选中数量大于1时,继续按钮可用 @@ -331,14 +235,13 @@ void DFInstallErrorDialog::resetContinueInstallBtnStatus() //所有字体都未勾选时,禁止点击"继续安装" if (0 == getErrorFontCheckedCount()) { if (m_errorInstallFiles.count() > 0) { - m_continueInstallBtn->setToolTip(DApplication::translate("ExceptionWindow", "No fonts to be installed")); + getButton(1)->setToolTip(DApplication::translate("ExceptionWindow", "No fonts to be installed")); } - - m_continueInstallBtn->setDisabled(true); - m_continueInstallBtn->setFocusPolicy(Qt::NoFocus); + getButton(1)->setDisabled(true); + getButton(1)->setFocusPolicy(Qt::NoFocus); } else { - m_continueInstallBtn->setEnabled(true); - m_continueInstallBtn->setFocusPolicy(Qt::TabFocus); + getButton(1)->setEnabled(true); + getButton(1)->setFocusPolicy(Qt::TabFocus); } if (getErrorFontSelectableCount() > 0) { @@ -361,9 +264,8 @@ void DFInstallErrorDialog::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Escape) { this->close(); - } - //SP3--安装验证页面,回车取消/选中 - else if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) { + } else if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) { + //SP3--安装验证页面,回车取消/选中 if (m_installErrorListView->hasFocus()) { if (m_installErrorListView->selectionModel()->selectedIndexes().count() == 1) { onListItemClicked(m_installErrorListView->selectionModel()->selectedIndexes().first()); @@ -371,13 +273,12 @@ void DFInstallErrorDialog::keyPressEvent(QKeyEvent *event) } else if (m_installErrorListView->selectionModel()->selectedIndexes().count() > 1) { onListItemsClicked(m_installErrorListView->selectionModel()->selectedIndexes()); } - } - //默认字体列表无焦点情况下,回车执行“继续”或“取消”按钮 - else { - if (m_continueInstallBtn->isEnabled()) - emit m_continueInstallBtn->click(); - else { - m_quitInstallBtn->click(); + } else { + //默认字体列表无焦点情况下,回车执行“继续”或“取消”按钮 + if (getButton(1)->isEnabled()) { + emit getButton(1)->click(); + } else { + emit getButton(0)->click(); } } } else if (event->key() == Qt::Key_Home && event->modifiers() == Qt::NoModifier) { @@ -409,6 +310,8 @@ void DFInstallErrorDialog::closeEvent(QCloseEvent *event) //关闭窗口时发送取消安装信号 emit onCancelInstall(); + + DDialog::closeEvent(event); } /************************************************************************* @@ -576,7 +479,20 @@ void DFInstallErrorDialog::onControlButtonClicked(int btnIndex) } emit onContinueInstall(continueInstallFontFileList); -// this->close(); this->reject(); } } + +#ifdef DTKWIDGET_CLASS_DSizeMode +void DFInstallErrorDialog::slotSizeModeChanged(DGuiApplicationHelper::SizeMode sizeMode) +{ + Utils::clearImgCache(); + if (sizeMode == DGuiApplicationHelper::SizeMode::CompactMode) { + this->setFixedSize(448, 259); + setIconPixmap(Utils::renderSVG("://exception-logo.svg", QSize(25, 25))); + } else { + this->setFixedSize(448, 302); + setIconPixmap(Utils::renderSVG("://exception-logo.svg", QSize(32, 32))); + } +} +#endif diff --git a/deepin-font-manager/views/dfinstallerrordialog.h b/deepin-font-manager/views/dfinstallerrordialog.h index e868e710..b66307a3 100644 --- a/deepin-font-manager/views/dfinstallerrordialog.h +++ b/deepin-font-manager/views/dfinstallerrordialog.h @@ -12,6 +12,7 @@ #include #include +#include #include @@ -26,7 +27,7 @@ class DFInstallErrorListView; null *************************************************************************/ -class DFInstallErrorDialog : public DFontBaseDialog +class DFInstallErrorDialog : public DDialog { Q_OBJECT @@ -38,14 +39,6 @@ class DFInstallErrorDialog : public DFontBaseDialog void initData(); //字体验证框主页面 void initUI(); - //字体验证框大小重绘页面 - void resizeEvent(QResizeEvent *event)Q_DECL_OVERRIDE; - //初始化字体验证框页面框架 - void initMainFrame(); - //初始化标题栏信息 - void initTitleBar(); - //初始化字体验证列表视图布局 - void initInstallErrorFontViews(); //获取已勾选继续安装项个数 int getErrorFontCheckedCount(); //获取可勾选项个数 @@ -77,6 +70,11 @@ public slots: //按钮点击事件 void onControlButtonClicked(int btnIndex); +#ifdef DTKWIDGET_CLASS_DSizeMode + //紧凑模式切换 + void slotSizeModeChanged(DGuiApplicationHelper::SizeMode sizeMode); +#endif + private: DFInstallNormalWindow *m_parent; QWidget *m_mainFrame; @@ -84,9 +82,6 @@ public slots: DFInstallErrorListView *m_installErrorListView; - DPushButton *m_quitInstallBtn; - DSuggestButton *m_continueInstallBtn; - SignalManager *m_signalManager; QStringList m_errorInstallFiles; diff --git a/deepin-font-manager/views/dfinstallerrorlistview.cpp b/deepin-font-manager/views/dfinstallerrorlistview.cpp index a5ca6a83..53b497c4 100644 --- a/deepin-font-manager/views/dfinstallerrorlistview.cpp +++ b/deepin-font-manager/views/dfinstallerrorlistview.cpp @@ -231,7 +231,7 @@ void DFInstallErrorListDelegate::drawSelectStatus(QPainter *painter, const QStyl QPainterPath path; const int radius = 8; - setPaintPath(bgRect, path, 3, 0, radius); + setPaintPath(bgRect, path, 0, 0, radius); if (option.state & QStyle::State_Selected) { // DPalette pa = DApplicationHelper::instance()->palette(m_parentView);//dtk库接口不稳定,更换palette获取方式 @@ -403,7 +403,7 @@ void DFInstallErrorListDelegate::paint(QPainter *painter, const QStyleOptionView rect.setWidth(option.rect.width()); rect.setHeight(option.rect.height()); - QRect bgRect = QRect(rect.left() + 10, rect.top(), rect.width() - 18, rect.height()); + QRect bgRect = QRect(rect.left(), rect.top(), rect.width(), rect.height()); if (itemModel.bSelectable) { drawSelectStatus(painter, option, bgRect); @@ -438,7 +438,7 @@ QSize DFInstallErrorListDelegate::sizeHint(const QStyleOptionViewItem &option, Q_UNUSED(index) #ifdef DTKWIDGET_CLASS_DSizeMode if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::SizeMode::CompactMode) { - return QSize(option.rect.width(), 40); + return QSize(option.rect.width(), 38); } #endif return QSize(option.rect.width(), 48); diff --git a/deepin-font-manager/views/dfinstallnormalwindow.cpp b/deepin-font-manager/views/dfinstallnormalwindow.cpp index 8e29e414..d81ff340 100644 --- a/deepin-font-manager/views/dfinstallnormalwindow.cpp +++ b/deepin-font-manager/views/dfinstallnormalwindow.cpp @@ -791,7 +791,7 @@ void DFInstallNormalWindow::showInstallErrDlg() connect(m_pexceptionDlg, &DFInstallErrorDialog::onContinueInstall, this, &DFInstallNormalWindow::onContinueInstall); - connect(m_pexceptionDlg, &DFInstallErrorDialog::destroyed, this, [ = ]() { + connect(m_pexceptionDlg, &DFInstallErrorDialog::closed, this, [ = ]() { if (!m_errCancelInstall) return; qDebug() << " DFInstallErrorDialog cancel called"; diff --git a/deepin-font-manager/views/dfontmgrmainwindow.cpp b/deepin-font-manager/views/dfontmgrmainwindow.cpp index eadbd2ac..a6cae8d2 100644 --- a/deepin-font-manager/views/dfontmgrmainwindow.cpp +++ b/deepin-font-manager/views/dfontmgrmainwindow.cpp @@ -151,6 +151,10 @@ void DFontMgrMainWindow::initUI() initTileBar(); initRightKeyMenu(); initMainVeiws(); + +#ifdef DTKWIDGET_CLASS_DSizeMode + slotSizeModeChanged(DGuiApplicationHelper::instance()->sizeMode()); +#endif } /************************************************************************* @@ -870,15 +874,10 @@ void DFontMgrMainWindow::initStateBar() stateBarLayout->setSpacing(0); d->stateBar = new QWidget(this); - //d->stateBar->setFrameShape(DFrame::NoFrame); d->stateBar->setFixedHeight(FTM_SBAR_HEIGHT); d->stateBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); d->textInputEdit = new DLineEdit(this); - // QFont searchFont; - // searchFont.setPixelSize(14); - // d->textInputEdit->setFont(searchFont); - //d->textInputEdit->setMinimumSize(QSize(FTM_SBAR_TXT_EDIT_W,FTM_SBAR_TXT_EDIT_H)); DFontSizeManager::instance()->bind(d->textInputEdit, DFontSizeManager::T6); d->textInputEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); d->textInputEdit->setClearButtonEnabled(true); @@ -886,10 +885,6 @@ void DFontMgrMainWindow::initStateBar() d->fontScaleSlider = new DSlider(Qt::Orientation::Horizontal, this); d->fontScaleSlider->setFixedSize(FTM_SBAR_SLIDER_W, FTM_SBAR_SLIDER_H); - // d->fontScaleSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - // d->fontScaleSlider->setTracking(true); - // d->fontScaleSlider->setTickPosition(QSlider::NoTicks); - // d->fontScaleSlider->setRange(MIN_FONT_SIZE, MAX_FONT_SIZE); d->fontScaleSlider->setMinimum(MIN_FONT_SIZE); d->fontScaleSlider->setMaximum(MAX_FONT_SIZE); //设置初始显示字体大小 @@ -903,17 +898,12 @@ void DFontMgrMainWindow::initStateBar() d->fontSizeLabel->setFixedSize(FTM_SBAR_FSIZE_LABEL_W, FTM_SBAR_FSIZE_LABEL_H); d->fontSizeLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); - // QFont fontSize; - // fontSize.setPixelSize(14); - // d->fontSizeLabel->setFont(fontSize); DFontSizeManager::instance()->bind(d->fontSizeLabel, DFontSizeManager::T6); - // d->fontSizeLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); // Init the default font size QString defaultFontSize = QString(FMT_FONT_SIZE).arg(DEFAULT_FONT_SIZE); //调节右下角字体大小显示label显示内容/*UT000539*/ autoLabelWidth(defaultFontSize, d->fontSizeLabel, d->fontSizeLabel->fontMetrics()); - // d->fontSizeLabel->setText(defaultFontSize); stateBarLayout->addSpacing(10); stateBarLayout->addWidget(d->textInputEdit, 1); @@ -2002,6 +1992,12 @@ void DFontMgrMainWindow::slotSizeModeChanged(DGuiApplicationHelper::SizeMode siz point.setX(x); point.setY((titlebar()->height() - d->searchFontEdit->height()) / 2); d->searchFontEdit->move(point); + + if (sizeMode == DGuiApplicationHelper::SizeMode::CompactMode) { + d->stateBar->setFixedHeight(FTM_SBAR_COMPACT_HEIGHT); + } else { + d->stateBar->setFixedHeight(FTM_SBAR_HEIGHT); + } } #endif diff --git a/libdeepin-font-manager/dfontpreviewitemdef.h b/libdeepin-font-manager/dfontpreviewitemdef.h index fb776471..4f6803fa 100644 --- a/libdeepin-font-manager/dfontpreviewitemdef.h +++ b/libdeepin-font-manager/dfontpreviewitemdef.h @@ -20,7 +20,7 @@ #define FTM_DEFAULT_PREVIEW_DIGIT_TEXT QString("0123456789") #define FTM_DEFAULT_PREVIEW_FONTSIZE 30 #define FTM_PREVIEW_ITEM_HEIGHT (72+2+10) -#define FTM_PREVIEW_ITEM_COMPACT_HEIGHT (48+2+10) +#define FTM_PREVIEW_ITEM_COMPACT_HEIGHT (50+2+10) #define FONT_TTF QString("TrueType") #define FONT_OTF QString("OpenType")