Skip to content

Commit

Permalink
fix: 紧凑模式问题修复
Browse files Browse the repository at this point in the history
修复紧凑模式显示问题

Log: 修复紧凑模式显示问题

Bug: https://pms.uniontech.com/bug-view-225047.html
  • Loading branch information
feeengli committed Nov 13, 2023
1 parent fbd4427 commit 33917bb
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 42 deletions.
1 change: 1 addition & 0 deletions deepin-font-manager/globaldef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions deepin-font-manager/interfaces/dfontbasedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
}

/*************************************************************************
Expand Down Expand Up @@ -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

/*************************************************************************
<Function> getCloseButton
<Description> 获取右上角的关闭按钮
Expand Down
6 changes: 6 additions & 0 deletions deepin-font-manager/interfaces/dfontbasedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <DLabel>
#include <DWindowCloseButton>
#include <DGuiApplicationHelper>

DWIDGET_USE_NAMESPACE

Expand Down Expand Up @@ -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};
Expand Down
5 changes: 5 additions & 0 deletions deepin-font-manager/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,8 @@ bool Utils::isWayland()
return false;
}
}

void Utils::clearImgCache()
{
m_imgCacheHash.clear();
}
3 changes: 3 additions & 0 deletions deepin-font-manager/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class Utils : public QObject

//判断是否wayland环境
static bool isWayland();

//清除图像缓存
static void clearImgCache();
};

#endif
46 changes: 21 additions & 25 deletions deepin-font-manager/views/dfinstallerrordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/*************************************************************************
Expand Down Expand Up @@ -137,21 +142,6 @@ void DFInstallErrorDialog::initUI()
connect(this, &DFInstallErrorDialog::closeBtnClicked, this, &DFInstallErrorDialog::onCancelInstall);
}

/*************************************************************************
<Function> resizeEvent
<Description> 字体验证框大小重绘页面
<Author>
<Input>
<param1> event Description:事件对象
<Return> null Description:null
<Note> null
*************************************************************************/
void DFInstallErrorDialog::resizeEvent(QResizeEvent *event)
{
DFontBaseDialog::resizeEvent(event);
m_mainFrame->resize(event->size().width(), event->size().height());
}

/*************************************************************************
<Function> initMainFrame
<Description> 初始化字体验证框页面框架
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -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
7 changes: 5 additions & 2 deletions deepin-font-manager/views/dfinstallerrordialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class DFInstallErrorDialog : public DFontBaseDialog
void initData();
//字体验证框主页面
void initUI();
//字体验证框大小重绘页面
void resizeEvent(QResizeEvent *event)Q_DECL_OVERRIDE;
//初始化字体验证框页面框架
void initMainFrame();
//初始化标题栏信息
Expand Down Expand Up @@ -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;
Expand Down
24 changes: 10 additions & 14 deletions deepin-font-manager/views/dfontmgrmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ void DFontMgrMainWindow::initUI()
initTileBar();
initRightKeyMenu();
initMainVeiws();

#ifdef DTKWIDGET_CLASS_DSizeMode
slotSizeModeChanged(DGuiApplicationHelper::instance()->sizeMode());
#endif
}

/*************************************************************************
Expand Down Expand Up @@ -870,26 +874,17 @@ 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);
d->textInputEdit->lineEdit()->setPlaceholderText(DApplication::translate("StateBar", "Input preview text"));

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);
//设置初始显示字体大小
Expand All @@ -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);
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion libdeepin-font-manager/dfontpreviewitemdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 33917bb

Please sign in to comment.