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/dfinstallerrordialog.cpp b/deepin-font-manager/views/dfinstallerrordialog.cpp index adb87e17..f2ec6f1b 100644 --- a/deepin-font-manager/views/dfinstallerrordialog.cpp +++ b/deepin-font-manager/views/dfinstallerrordialog.cpp @@ -44,6 +44,11 @@ DFInstallErrorDialog::DFInstallErrorDialog(QWidget *parent, const QStringList &e connect(m_signalManager, &SignalManager::updateInstallErrorListview, this, &DFInstallErrorDialog::addData); resetContinueInstallBtnStatus(); // m_installErrorListView->setFocus(); + +#ifdef DTKWIDGET_CLASS_DSizeMode + slotSizeModeChanged(DGuiApplicationHelper::instance()->sizeMode()); + connect(DGuiApplicationHelper::instance(),&DGuiApplicationHelper::sizeModeChanged,this, &DFInstallErrorDialog::slotSizeModeChanged); +#endif } /************************************************************************* @@ -137,21 +142,6 @@ void DFInstallErrorDialog::initUI() 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()); -} - /************************************************************************* initMainFrame 初始化字体验证框页面框架 @@ -258,16 +248,9 @@ void DFInstallErrorDialog::initInstallErrorFontViews() 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); + buttonLayout->setContentsMargins(10, 0, 10, 10); QButtonGroup *btnGroup = new QButtonGroup(this); - btnGroup->setExclusive(true); QFont btnFont = font(); @@ -311,8 +294,7 @@ void DFInstallErrorDialog::initInstallErrorFontViews() m_installErrorListView->setSelectionMode(QAbstractItemView::ExtendedSelection); m_mainLayout->addWidget(m_installErrorListView); - m_mainLayout->addWidget(btnFrame); - m_mainLayout->addStretch(); + m_mainLayout->addLayout(buttonLayout); connect(m_installErrorListView, SIGNAL(clickedErrorListItem(QModelIndex)), this, SLOT(onListItemClicked(QModelIndex))); @@ -580,3 +562,17 @@ void DFInstallErrorDialog::onControlButtonClicked(int btnIndex) 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..b223c659 100644 --- a/deepin-font-manager/views/dfinstallerrordialog.h +++ b/deepin-font-manager/views/dfinstallerrordialog.h @@ -38,8 +38,6 @@ class DFInstallErrorDialog : public DFontBaseDialog void initData(); //字体验证框主页面 void initUI(); - //字体验证框大小重绘页面 - void resizeEvent(QResizeEvent *event)Q_DECL_OVERRIDE; //初始化字体验证框页面框架 void initMainFrame(); //初始化标题栏信息 @@ -77,6 +75,11 @@ public slots: //按钮点击事件 void onControlButtonClicked(int btnIndex); +#ifdef DTKWIDGET_CLASS_DSizeMode + //紧凑模式切换 + void slotSizeModeChanged(DGuiApplicationHelper::SizeMode sizeMode); +#endif + private: DFInstallNormalWindow *m_parent; QWidget *m_mainFrame; 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")