Skip to content

Commit

Permalink
fix: adapt compact mode
Browse files Browse the repository at this point in the history
  adapt compact mode

Log: adapt compact mode
Bug: https://pms.uniontech.com/bug-view-279797.html
  • Loading branch information
starhcq committed Nov 14, 2024
1 parent ef0ee7b commit e485333
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 56 deletions.
14 changes: 7 additions & 7 deletions 3rdparty/interface/queries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void OverwriteQuery::autoFeed(DLabel *label1, DLabel *label2, CustomDDialog *dia
NewStr newstr = autoCutText(m_strDesText, label2);
label2->setText(newstr.resultStr);
int height_lable = newstr.strList.size() * newstr.fontHeifht;
label2->setFixedHeight(height_lable);
label2->setMinimumHeight(height_lable);

// 字符串太长的情况下用中间使用...
QFont font;
Expand All @@ -304,7 +304,7 @@ void OverwriteQuery::autoFeed(DLabel *label1, DLabel *label2, CustomDDialog *dia
if (0 == m_iLabelOldHeight) { // 第一次exec自动调整
dialog->adjustSize();
} else {
dialog->setFixedHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iLabelOld1Height - m_iCheckboxOld1Height + height_lable + 2 * newstr.fontHeifht); //字号变化后自适应调整
dialog->setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iLabelOld1Height - m_iCheckboxOld1Height + height_lable + 2 * newstr.fontHeifht); //字号变化后自适应调整
}
m_iLabelOldHeight = height_lable;
m_iLabelOld1Height = newstr.fontHeifht;
Expand Down Expand Up @@ -384,7 +384,7 @@ void PasswordNeededQuery::execute()
DPasswordEdit *passwordedit = new DPasswordEdit(dialog);
passwordedit->lineEdit()->setAttribute(Qt::WA_InputMethodEnabled, false); //隐藏密码时不能输入中文
passwordedit->setFocusPolicy(Qt::StrongFocus);
passwordedit->setFixedHeight(36);
passwordedit->setMinimumHeight(36);
passwordedit->setFixedWidth(280);

dialog->addButton(QObject::tr("Cancel", "button"), true, DDialog::ButtonNormal);
Expand Down Expand Up @@ -449,7 +449,7 @@ void PasswordNeededQuery::autoFeed(DLabel *label1, DLabel *label2, CustomDDialog
NewStr newstr = autoCutText(m_strDesText, label2);
label2->setText(newstr.resultStr);
int height_lable = newstr.strList.size() * newstr.fontHeifht;
label2->setFixedHeight(height_lable);
label2->setMinimumHeight(height_lable);

// 字符串太长的情况下用中间使用...
QFont font;
Expand All @@ -459,7 +459,7 @@ void PasswordNeededQuery::autoFeed(DLabel *label1, DLabel *label2, CustomDDialog
if (0 == m_iLabelOldHeight) { // 第一次exec自动调整
dialog->adjustSize();
} else {
dialog->setFixedHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iLabelOld1Height + height_lable + newstr.fontHeifht); //字号变化后自适应调整
dialog->setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iLabelOld1Height + height_lable + newstr.fontHeifht); //字号变化后自适应调整
}
m_iLabelOldHeight = height_lable;
m_iLabelOld1Height = newstr.fontHeifht;
Expand Down Expand Up @@ -543,11 +543,11 @@ void LoadCorruptQuery::autoFeed(DLabel *label, CustomDDialog *dialog)
NewStr newstr = autoCutText(m_strDesText, label);
label->setText(newstr.resultStr);
int height_lable = newstr.strList.size() * newstr.fontHeifht;
label->setFixedHeight(height_lable);
label->setMinimumHeight(height_lable);
if (0 == m_iLabelOldHeight) { // 第一次exec自动调整
dialog->adjustSize();
} else {
dialog->setFixedHeight(m_iDialogOldHeight - m_iLabelOldHeight + height_lable); //字号变化后自适应调整
dialog->setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight + height_lable); //字号变化后自适应调整
}
m_iLabelOldHeight = height_lable;
m_iDialogOldHeight = dialog->height();
Expand Down
20 changes: 10 additions & 10 deletions src/source/dialog/popupdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ void TipDialog::autoFeed(DLabel *label)
NewStr newstr = autoCutText(m_strDesText, label);
label->setText(newstr.resultStr);
int height_lable = newstr.strList.size() * newstr.fontHeifht;
label->setFixedHeight(height_lable);
label->setMinimumHeight(height_lable);
if (0 == m_iLabelOldHeight) { // 第一次exec自动调整
adjustSize();
} else {
setFixedHeight(m_iDialogOldHeight - m_iLabelOldHeight + height_lable); //字号变化后自适应调整
setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight + height_lable); //字号变化后自适应调整
}
m_iLabelOldHeight = height_lable;
m_iDialogOldHeight = height();
Expand Down Expand Up @@ -133,11 +133,11 @@ void SimpleQueryDialog::autoFeed(DLabel *label)
NewStr newstr = autoCutText(m_strDesText, label);
label->setText(newstr.resultStr);
int height_lable = newstr.strList.size() * newstr.fontHeifht;
label->setFixedHeight(height_lable);
label->setMinimumHeight(height_lable);
if (0 == m_iLabelOldHeight) { // 第一次exec自动调整
adjustSize();
} else {
setFixedHeight(m_iDialogOldHeight - m_iLabelOldHeight + height_lable); //字号变化后自适应调整
setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight + height_lable); //字号变化后自适应调整
}
m_iLabelOldHeight = height_lable;
m_iDialogOldHeight = height();
Expand Down Expand Up @@ -240,7 +240,7 @@ void OverwriteQueryDialog::autoFeed(DLabel *label1, DLabel *label2)
NewStr newstr = autoCutText(m_strDesText, label2);
label2->setText(newstr.resultStr);
int height_lable = newstr.strList.size() * newstr.fontHeifht;
label2->setFixedHeight(height_lable);
label2->setMinimumHeight(height_lable);

// 字符串太长的情况下用中间使用...
QFont font;
Expand All @@ -250,7 +250,7 @@ void OverwriteQueryDialog::autoFeed(DLabel *label1, DLabel *label2)
if (0 == m_iLabelOldHeight) { // 第一次exec自动调整
adjustSize();
} else {
setFixedHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iLabelOld1Height - m_iCheckboxOld1Height + height_lable + 2 * newstr.fontHeifht); //字号变化后自适应调整
setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iLabelOld1Height - m_iCheckboxOld1Height + height_lable + 2 * newstr.fontHeifht); //字号变化后自适应调整
}
m_iLabelOldHeight = height_lable;
m_iLabelOld1Height = newstr.fontHeifht;
Expand Down Expand Up @@ -372,11 +372,11 @@ void ConvertDialog::autoFeed(DLabel *label)
NewStr newstr = autoCutText(m_strDesText, label);
label->setText(newstr.resultStr);
int height_lable = newstr.strList.size() * newstr.fontHeifht;
label->setFixedHeight(height_lable);
label->setMinimumHeight(height_lable);
if (0 == m_iLabelOldHeight) { // 第一次exec自动调整
adjustSize();
} else {
setFixedHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iLabelOld1Height + height_lable + newstr.fontHeifht); //字号变化后自适应调整
setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iLabelOld1Height + height_lable + newstr.fontHeifht); //字号变化后自适应调整
}
m_iLabelOldHeight = height_lable;
m_iLabelOld1Height = newstr.fontHeifht;
Expand Down Expand Up @@ -490,11 +490,11 @@ void AppendDialog::autoFeed(DLabel *pLabel)
NewStr newstr = autoCutText(m_strDesText, pLabel);
pLabel->setText(newstr.resultStr);
int height_lable = newstr.strList.size() * newstr.fontHeifht;
pLabel->setFixedHeight(height_lable);
pLabel->setMinimumHeight(height_lable);
if (0 == m_iLabelOldHeight) { // 第一次exec自动调整
adjustSize();
} else {
setFixedHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iCheckboxOld1Height + height_lable + newstr.fontHeifht); //字号变化后自适应调整
setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iCheckboxOld1Height + height_lable + newstr.fontHeifht); //字号变化后自适应调整
}
m_iLabelOldHeight = height_lable;
m_iCheckboxOld1Height = newstr.fontHeifht;
Expand Down
6 changes: 3 additions & 3 deletions src/source/dialog/settingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ void SettingDialog::createSettingButton()
CustomPushButton *selectAllButton = new CustomPushButton(tr("Select All", "button"));
CustomPushButton *cancelSelectButton = new CustomPushButton(tr("Clear All"));
CustomSuggestButton *recommendedButton = new CustomSuggestButton(tr("Recommended"));
selectAllButton->setMinimumSize(153, 36);
cancelSelectButton->setMinimumSize(153, 36);
recommendedButton->setMinimumSize(153, 36);
selectAllButton->setMinimumWidth(153);
cancelSelectButton->setMinimumWidth(153);
recommendedButton->setMinimumWidth(153);
layout->addStretch();
layout->addWidget(selectAllButton);
layout->addStretch();
Expand Down
4 changes: 1 addition & 3 deletions src/source/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ void MainWindow::initUI()
m_pProgressdialog = new ProgressDialog(this); //进度弹窗
m_commentProgressDialog = new CommentProgressDialog(this); // 更新注释进度弹窗
m_pSettingDlg = new SettingDialog(this);
m_pSettingDlg->setMinimumWidth(750);

// 添加界面至主界面
m_pMainWidget->addWidget(m_pCompressPage);
Expand Down Expand Up @@ -167,7 +168,6 @@ void MainWindow::initTitleBar()

// 初始化标题栏菜单
titlebar()->setMenu(menu);
titlebar()->setFixedHeight(50);
titlebar()->setTitle("");

// 设置应用程序图标
Expand Down Expand Up @@ -3386,15 +3386,13 @@ void TitleWidget::initUI()
{
// 添加左上角按钮
m_pTitleButton = new DIconButton(DStyle::SP_IncreaseElement, this);
m_pTitleButton->setFixedSize(36, 36);
// m_pTitleButton->setVisible(false);
m_pTitleButton->setObjectName("TitleButton");
m_pTitleButton->setAccessibleName("Title_btn");
m_pTitleButton->setToolTip(tr("Open file"));

// 左上角注释信息
m_pTitleCommentButton = new DIconButton(this);
m_pTitleCommentButton->setFixedSize(36, 36);
m_pTitleCommentButton->setToolTip(tr("File info"));
slotThemeChanged();

Expand Down
6 changes: 3 additions & 3 deletions src/source/page/compresspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void CompressPage::initUI()
// 初始化相关变量
m_pCompressView = new CompressView(this);
m_pNextBtn = new CustomPushButton(tr("Next"), this);
m_pNextBtn->setMinimumSize(340, 36);
m_pNextBtn->setMinimumWidth(340);

// 按钮布局
QHBoxLayout *pBtnLayout = new QHBoxLayout;
Expand All @@ -78,7 +78,7 @@ void CompressPage::initUI()
pMainLayout->addLayout(pBtnLayout);
pMainLayout->setStretchFactor(m_pCompressView, 10);
pMainLayout->setStretchFactor(pBtnLayout, 1);
pMainLayout->setContentsMargins(20, 1, 20, 20);
pMainLayout->setContentsMargins(10, 1, 10, 20);

// 设置快捷键
auto openkey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_O), this);
Expand All @@ -98,7 +98,7 @@ void CompressPage::initConnections()

void CompressPage::slotCompressNextClicked()
{
qDebug() << "点击了压缩下一步按钮";
qInfo() << "点击了压缩下一步按钮";

// 如果没有待压缩文件,弹出提示框
if (m_pCompressView->getCompressFiles().isEmpty()) {
Expand Down
17 changes: 9 additions & 8 deletions src/source/page/compresssettingpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,13 @@ void CompressSettingPage::initUI()
m_pCompressTypeLbl = new DLabel(this);
pArrowPixmapLbl = new DLabel(this);

m_pClickLbl->setMinimumSize(125, 40);
m_pClickLbl->setMinimumWidth(125);
m_pClickLbl->setObjectName("ClickTypeLabel");
m_pClickLbl->setFocusPolicy(Qt::TabFocus);
m_pClickLbl->installEventFilter(this);

DStyle style; // 设置菜单箭头
QPixmap pixmap = style.standardIcon(DStyle::StandardPixmap::SP_ReduceElement).pixmap(QSize(10, 10));
pArrowPixmapLbl->setMinimumHeight(25);
pArrowPixmapLbl->setPixmap(pixmap);

DFontSizeManager::instance()->bind(m_pCompressTypeLbl, DFontSizeManager::T5, QFont::DemiBold);
Expand All @@ -213,20 +212,20 @@ void CompressSettingPage::initUI()
m_pCommentEdt = new DTextEdit(this);
m_pCompressBtn = new CustomPushButton(tr("Compress", "button"), this);

m_pFileNameEdt->setMinimumSize(260, 36); // 配置文件名属性
m_pFileNameEdt->setMinimumWidth(260); // 配置文件名属性
QLineEdit *pNameEdt = m_pFileNameEdt->lineEdit();
pNameEdt->setMaxLength(70);
m_pFileNameEdt->setText(tr("New Archive"));

m_pSavePathEdt->setFileMode(DFileDialog::Directory); // 配置保存路径
m_pSavePathEdt->setText(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
m_pSavePathEdt->setMinimumSize(260, 36);
m_pSavePathEdt->setMinimumWidth(260);

m_pCompressLevelCmb->setMinimumSize(260, 36); // 设置压缩方式尺寸
m_pCompressLevelCmb->setMinimumWidth(260); // 设置压缩方式尺寸
m_pCompressLevelCmb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); // 跟随界面缩放


m_pCpuCmb->setMinimumSize(260, 36); // 设置压缩方式尺寸
m_pCpuCmb->setMinimumWidth(260); // 设置压缩方式尺寸
m_pCpuCmb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); // 跟随界面缩放

// 设置压缩方式选项
Expand Down Expand Up @@ -254,7 +253,7 @@ void CompressSettingPage::initUI()
m_pListEncryptionLbl->setEnabled(false);

// 待确认
m_pSplitValueEdt->setMinimumSize(260, 36);
m_pSplitValueEdt->setMinimumWidth(260);
m_pSplitValueEdt->setSuffix("MB");
m_pSplitValueEdt->setRange(0.0, 1000000);
m_pSplitValueEdt->setSingleStep(0.1);
Expand All @@ -265,7 +264,7 @@ void CompressSettingPage::initUI()
m_pCommentEdt->setPlaceholderText(tr("Enter up to %1 characters").arg(MAXCOMMENTLEN));
m_pCommentEdt->setTabChangesFocus(true); // DTextEdit中Tab键切换焦点

m_pCompressBtn->setMinimumSize(340, 36); // 设置压缩按钮最小尺寸
m_pCompressBtn->setMinimumWidth(340); // 设置压缩按钮最小尺寸

// 左侧布局
QHBoxLayout *pTypeLayout = new QHBoxLayout; // 类型布局
Expand Down Expand Up @@ -295,8 +294,10 @@ void CompressSettingPage::initUI()

// 右侧内容布局
QVBoxLayout *pRightLayout = new QVBoxLayout;
pRightLayout->setSpacing(5);
pRightLayout->addWidget(pLabName);
pRightLayout->addWidget(m_pFileNameEdt);
pRightLayout->addSpacing(7);
pRightLayout->addWidget(pLabSave);
pRightLayout->addWidget(m_pSavePathEdt);
pRightLayout->addWidget(m_pCompressLevelLbl);
Expand Down
2 changes: 1 addition & 1 deletion src/source/page/failurepage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void FailurePage::initUI()

//重试按钮
m_pRetrybutton = new CustomPushButton(this);
m_pRetrybutton->setMinimumSize(340, 36);
m_pRetrybutton->setMinimumWidth(340);
m_pRetrybutton->setText(tr("Retry", "button"));

//返回按钮
Expand Down
4 changes: 2 additions & 2 deletions src/source/page/progresspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ void ProgressPage::initUI()
DFontSizeManager::instance()->bind(m_pRemainingTimeLbl, DFontSizeManager::T8);

// 设置取消按钮样式
m_pCancelBtn->setMinimumSize(200, 36);
m_pCancelBtn->setMinimumWidth(200);

// 设置暂停继续按钮样式
m_pPauseContinueButton->setMinimumSize(200, 36);
m_pPauseContinueButton->setMinimumWidth(200);
m_pPauseContinueButton->setCheckable(true);

// 速度和剩余时间布局
Expand Down
2 changes: 1 addition & 1 deletion src/source/page/successpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void SuccessPage::initUI()

//查看文件按钮
m_pShowFileBtn = new CustomPushButton(this);
m_pShowFileBtn->setMinimumSize(340, 36);
m_pShowFileBtn->setMinimumWidth(340);
m_pShowFileBtn->setText(tr("View"));

//返回按钮
Expand Down
12 changes: 12 additions & 0 deletions src/source/tree/datamodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include <QCollator>
#include <QElapsedTimer>
#include <QItemSelection>
#include <DApplicationHelper>
#include <DGuiApplicationHelper>

DGUI_USE_NAMESPACE

DataModel::DataModel(QObject *parent)
: QAbstractTableModel(parent)
Expand Down Expand Up @@ -99,7 +103,15 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
icon = QIcon::fromTheme("empty").pixmap(24, 24);
}

#ifdef DTKWIDGET_CLASS_DSizeMode
if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::NormalMode) {
return icon;
} else {
return icon.pixmap(16, 16);
}
#else
return icon;
#endif
}

return QVariant();
Expand Down
5 changes: 0 additions & 5 deletions src/source/tree/datamodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@

#include "commonstruct.h"

#include <DGuiApplicationHelper>
#include <dtkwidget_global.h>
#include <QAbstractTableModel>
#include <QFileInfoList>
#include <QDir>

DWIDGET_USE_NAMESPACE
DGUI_USE_NAMESPACE

class MimeTypeDisplayManager;
class QItemSelection;

Expand Down
19 changes: 16 additions & 3 deletions src/source/tree/datatreeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ QSize StyleTreeViewDelegate::sizeHint(const QStyleOptionViewItem &option, const
{
Q_UNUSED(index);

return QSize(option.rect.width(), 36);
#ifdef DTKWIDGET_CLASS_DSizeMode
if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::NormalMode) {
return QSize(option.rect.width(), TABLE_HEIGHT_NormalMode);
} else {
return QSize(option.rect.width(), TABLE_HEIGHT_CompactMode);
}
#else
return QSize(option.rect.width(), TABLE_HEIGHT_NormalMode);
#endif
}

void StyleTreeViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Expand Down Expand Up @@ -234,8 +242,13 @@ void DataTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option
//根据实际情况设置颜色,奇数行为灰色
auto palette = options.palette;
QBrush background;
if (!(index.row() & 1)) {
background = palette.color(cg, DPalette::AlternateBase);
bool bVis = m_pHeaderView->getpreLbl()->isVisible();
if (bVis ? (index.row() & 1) : !(index.row() & 1)) {
if(DGuiApplicationHelper::DarkType == DGuiApplicationHelper::instance()->themeType()) {
background = QColor(255, 255, 255, 12);
} else {
background = palette.color(cg, DPalette::AlternateBase);
}
} else {
background = palette.color(cg, DPalette::Base);
}
Expand Down
Loading

0 comments on commit e485333

Please sign in to comment.