Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 紧凑模式问题修复 #109

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
88 changes: 29 additions & 59 deletions deepin-font-manager/views/dfdeletedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ NewStr autoCutText(const QString &text, DLabel *pDesLbl)
<Note> 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)
Expand All @@ -100,19 +100,17 @@ 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);
mainLayout->setContentsMargins(10, 0, 10, 10);
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);
Expand All @@ -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);
}

/*************************************************************************
Expand All @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -223,46 +233,6 @@ void DFDeleteDialog::initMessageDetail()
DFontSizeManager::instance()->bind(messageDetail, DFontSizeManager::T6, QFont::Medium);
}

/*************************************************************************
<Function> initBottomButtons
<Description> 初始化页面按钮
<Author>
<Input> null
<Return> null Description:null
<Note> 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;
}

/*************************************************************************
<Function> onFontChanged
<Description> 适应系统字体变化
Expand Down Expand Up @@ -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;
}
}
Expand Down
7 changes: 2 additions & 5 deletions deepin-font-manager/views/dfdeletedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "dfontbasedialog.h"
#include "signalmanager.h"

#include <DDialog>
#include <DLabel>
#include <DPushButton>
#include <DWarningButton>
Expand All @@ -23,7 +24,7 @@ class DFontMgrMainWindow;
<Author>
<Note> null
*************************************************************************/
class DFDeleteDialog : public DFontBaseDialog
class DFDeleteDialog : public DDialog
{
Q_OBJECT
public:
Expand Down Expand Up @@ -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;
Expand Down
Loading