From 1beb40009c1379e8f92f7d3cbb26434bbfc363ac Mon Sep 17 00:00:00 2001 From: houchengqiu Date: Wed, 20 Sep 2023 17:40:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=80=90UI=E3=80=91=20Adapt=20compact?= =?UTF-8?q?=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【UI】 Adapt compact mode Log: 【UI】 Adapt compact mode Task: https://pms.uniontech.com/task-view-292059.html --- src/drawshape/drawTools/cpentool.cpp | 6 +- src/drawshape/drawTools/cpicturetool.cpp | 31 +++++++-- .../AttributesWidgets/private/blurwidget.cpp | 12 +--- .../AttributesWidgets/private/ccutwidget.cpp | 67 +++++++++++++------ src/frame/ccentralwidget.cpp | 2 + src/frame/clefttoolbar.cpp | 53 ++++++++++++++- src/frame/clefttoolbar.h | 2 + src/frame/cmultiptabbarwidget.cpp | 43 +++++++++++- src/widgets/cspinbox.cpp | 23 ++++++- src/widgets/dialog/cexportimagedialog.cpp | 6 +- 10 files changed, 195 insertions(+), 50 deletions(-) diff --git a/src/drawshape/drawTools/cpentool.cpp b/src/drawshape/drawTools/cpentool.cpp index 25c94132c..313f51750 100644 --- a/src/drawshape/drawTools/cpentool.cpp +++ b/src/drawshape/drawTools/cpentool.cpp @@ -79,7 +79,7 @@ void CPenTool::registerAttributionWidgets() auto streakBeginStyle = new CComBoxSettingWgt(tr("Start")); auto pStreakStartComboBox = new QComboBox; setWgtAccesibleName(pStreakStartComboBox, "Line start style combox"); - pStreakStartComboBox->setFixedSize(QSize(90, 36)); + pStreakStartComboBox->setFixedWidth(90); pStreakStartComboBox->setIconSize(QSize(34, 20)); pStreakStartComboBox->setFocusPolicy(Qt::NoFocus); @@ -108,7 +108,7 @@ void CPenTool::registerAttributionWidgets() streakEndStyle->setAttribution(EStreakEndStyle); auto pStreakEndComboBox = new QComboBox; setWgtAccesibleName(pStreakEndComboBox, "Line end style combox"); - pStreakEndComboBox->setFixedSize(QSize(90, 36)); + pStreakEndComboBox->setFixedWidth(90); pStreakEndComboBox->setIconSize(QSize(34, 20)); pStreakEndComboBox->setFocusPolicy(Qt::NoFocus); @@ -143,7 +143,7 @@ void CPenTool::registerAttributionWidgets() m_pPenStyleComboBox->view()->installEventFilter(this); - m_pPenStyleComboBox->setFixedSize(QSize(230, 36)); + m_pPenStyleComboBox->setFixedWidth(230);; m_pPenStyleComboBox->setIconSize(QSize(24, 20)); m_pPenStyleComboBox->setFocusPolicy(Qt::NoFocus); diff --git a/src/drawshape/drawTools/cpicturetool.cpp b/src/drawshape/drawTools/cpicturetool.cpp index c93bff8c2..b75c76782 100644 --- a/src/drawshape/drawTools/cpicturetool.cpp +++ b/src/drawshape/drawTools/cpicturetool.cpp @@ -28,6 +28,8 @@ #include "cgraphicslayer.h" #include "filehander.h" +const int BUTTON_NORMAL = 38; +const int BUTTON_COMPACT = 26; class CPictureTool::CPictureTool_private { @@ -90,7 +92,6 @@ void CPictureTool::registerAttributionWidgets() auto m_rightRotateBtn = new QPushButton; m_rightRotateBtn->setObjectName("PicRightRotateBtn"); - m_rightRotateBtn->setMaximumSize(QSize(38, 38)); m_rightRotateBtn->setIcon(QIcon::fromTheme("ddc_clockwise rotation_normal")); m_rightRotateBtn->setIconSize(QSize(48, 48)); m_rightRotateBtn->setToolTip(tr("Rotate 90° CW")); @@ -107,7 +108,6 @@ void CPictureTool::registerAttributionWidgets() auto m_flipHBtn = new QPushButton; m_flipHBtn->setObjectName("PicFlipHBtn"); - m_flipHBtn->setMaximumSize(QSize(38, 38)); m_flipHBtn->setIcon(QIcon::fromTheme("ddc_flip horizontal_normal")); m_flipHBtn->setIconSize(QSize(48, 48)); m_flipHBtn->setToolTip(tr("Flip horizontally")); @@ -127,7 +127,6 @@ void CPictureTool::registerAttributionWidgets() auto m_flipVBtn = new QPushButton; m_flipVBtn->setObjectName("PicFlipVBtn"); - m_flipVBtn->setMaximumSize(QSize(38, 38)); m_flipVBtn->setIcon(QIcon::fromTheme("ddc_flip vertical_normal")); m_flipVBtn->setIconSize(QSize(48, 48)); m_flipVBtn->setToolTip(tr("Flip vertically")); @@ -146,7 +145,6 @@ void CPictureTool::registerAttributionWidgets() auto m_flipAdjustment = new QPushButton; m_flipAdjustment->setObjectName("PicFlipAdjustmentBtn"); - m_flipAdjustment->setMaximumSize(QSize(38, 38)); m_flipAdjustment->setIcon(QIcon::fromTheme("ddc_flip_adjustment_normal")); m_flipAdjustment->setIconSize(QSize(48, 48)); m_flipAdjustment->setToolTip(tr("Auto fit")); @@ -175,6 +173,31 @@ void CPictureTool::registerAttributionWidgets() } }); + + int btnSize = BUTTON_NORMAL; +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) + btnSize = BUTTON_COMPACT; + + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + int nBtnSize = 0; + if (sizeMode == DGuiApplicationHelper::NormalMode) + nBtnSize = BUTTON_NORMAL; + else + nBtnSize = BUTTON_COMPACT; + m_leftRotateBtn->setMaximumSize(QSize(nBtnSize, nBtnSize)); + m_rightRotateBtn->setMaximumSize(QSize(nBtnSize, nBtnSize)); + m_flipHBtn->setMaximumSize(QSize(nBtnSize, nBtnSize)); + m_flipVBtn->setMaximumSize(QSize(nBtnSize, nBtnSize)); + m_flipAdjustment->setMaximumSize(QSize(nBtnSize, nBtnSize)); + }); +#endif + m_leftRotateBtn->setMaximumSize(QSize(btnSize, btnSize)); + m_rightRotateBtn->setMaximumSize(QSize(btnSize, btnSize)); + m_flipHBtn->setMaximumSize(QSize(btnSize, btnSize)); + m_flipVBtn->setMaximumSize(QSize(btnSize, btnSize)); + m_flipAdjustment->setMaximumSize(QSize(btnSize, btnSize)); + drawBoard()->attributionWidget()->installComAttributeWgt(EImageAdaptScene, m_flipAdjustment, true); } CPictureTool::~CPictureTool() diff --git a/src/frame/AttributesWidgets/private/blurwidget.cpp b/src/frame/AttributesWidgets/private/blurwidget.cpp index 730c36b81..c9c1e4cc7 100644 --- a/src/frame/AttributesWidgets/private/blurwidget.cpp +++ b/src/frame/AttributesWidgets/private/blurwidget.cpp @@ -83,13 +83,8 @@ void BlurWidget::initUI() penLabel->setText(tr("Type")); - QFont ft; - ft.setPixelSize(TEXT_SIZE); - penLabel->setFont(ft); - auto m_blurBtn = new DToolButton(this); setWgtAccesibleName(m_blurBtn, "Blur type button"); - m_blurBtn->setMaximumSize(QSize(38, 38)); m_blurBtn->setIconSize(QSize(38, 38)); m_blurBtn->setToolTip(tr("Blur")); m_blurBtn->setCheckable(true); @@ -102,7 +97,6 @@ void BlurWidget::initUI() auto m_masicBtn = new DToolButton(this); setWgtAccesibleName(m_masicBtn, "Masic type button"); - m_masicBtn->setMaximumSize(QSize(38, 38)); m_masicBtn->setIconSize(QSize(38, 38)); m_masicBtn->setToolTip(tr("Mosaic")); m_masicBtn->setCheckable(true); @@ -120,7 +114,6 @@ void BlurWidget::initUI() connect(m_TypeButtons, QOverload::of(&QButtonGroup::buttonToggled), this, [ = ](int tp, bool checked) { if (checked) { -// emit blurTypeChanged(EBlurEffect(tp)); emit blurEffectChanged(getEffect()); } }); @@ -128,7 +121,6 @@ void BlurWidget::initUI() DLabel *penWidthLabel = new DLabel(this); penWidthLabel->setObjectName("Width"); penWidthLabel->setText(tr("Width")); - penWidthLabel->setFont(ft); m_spinboxForLineWidth = new CSpinBox(this); m_spinboxForLineWidth->setObjectName("BlurPenWidth"); @@ -140,14 +132,13 @@ void BlurWidget::initUI() if (!Application::isTabletSystemEnvir()) m_spinboxForLineWidth->setFixedWidth(90); - m_spinboxForLineWidth->setMaximumHeight(36); m_spinboxForLineWidth->setSuffix("px"); m_spinboxForLineWidth->lineEdit()->setClearButtonEnabled(false); - m_spinboxForLineWidth->setFont(ft); QWidget *groupWidget = new QWidget(this); QHBoxLayout *groupLayout = new QHBoxLayout(this); groupLayout->addWidget(penWidthLabel); + groupLayout->setSpacing(10); groupLayout->addWidget(m_spinboxForLineWidth); groupWidget->setLayout(groupLayout); @@ -155,7 +146,6 @@ void BlurWidget::initUI() m_pLineWidthLabel = new DLabel(this); m_pLineWidthLabel->setObjectName("Width Label"); m_pLineWidthLabel->setText(QString("%1px").arg(m_spinboxForLineWidth->value())); - m_pLineWidthLabel->setFont(ft); m_pLineWidthLabel->setFixedWidth(60); m_pLineWidthLabel->hide(); diff --git a/src/frame/AttributesWidgets/private/ccutwidget.cpp b/src/frame/AttributesWidgets/private/ccutwidget.cpp index edc0635f2..262b6bc32 100644 --- a/src/frame/AttributesWidgets/private/ccutwidget.cpp +++ b/src/frame/AttributesWidgets/private/ccutwidget.cpp @@ -25,11 +25,12 @@ DGUI_USE_NAMESPACE -const int BTN_SPACING = 6; -const int SEPARATE_SPACING = 5; const int PUSHBUTTON_FONT_SIZE = 12; const int TEXT_SIZE = 12; - +const int TOOL_BUTTON_NORMAL = 38; +const int TOOL_BUTTON_COMPACT = 26; +const int ICON_SIZE_NORMAL = 48; +const int ICON_SIZE_COMPACT = 36; CCutWidget::CCutWidget(DWidget *parent) : DrawAttribution::CAttriBaseOverallWgt(parent) { @@ -345,15 +346,6 @@ void CCutWidget::initUI() m_originalBtn->setFont(pushBtnFont); _allWgts << m_originalBtn; - //修复切换维语和藏语后,裁剪模式按钮大小不一致 - int unifyHeight = m_originalBtn->height() + 8; - m_scaleBtn1_1->setFixedHeight(unifyHeight); - m_scaleBtn2_3->setFixedHeight(unifyHeight); - m_scaleBtn8_5->setFixedHeight(unifyHeight); - m_scaleBtn16_9->setFixedHeight(unifyHeight); - m_freeBtn->setFixedHeight(unifyHeight); - m_originalBtn->setFixedHeight(unifyHeight); - m_scaleBtn1_1->setCheckable(true); m_scaleBtn2_3->setCheckable(true); m_scaleBtn8_5->setCheckable(true); @@ -368,23 +360,60 @@ void CCutWidget::initUI() m_doneBtn = new ToolButton(this, BUTTON_STYLE); qobject_cast(m_doneBtn)->setShowText(false); setWgtAccesibleName(m_doneBtn, "Cut done pushbutton"); - //m_doneBtn->setFixedSize(QSize(38, 38)); - m_doneBtn->setMaximumHeight(unifyHeight); m_doneBtn->setIcon(QIcon::fromTheme("ddc_cutting_normal")); - m_doneBtn->setIconSize(QSize(48, 48)); m_doneBtn->setText(QObject::tr("OK")); - //m_cancelBtn = new QPushButton(this); m_cancelBtn = new ToolButton(this, BUTTON_STYLE); qobject_cast(m_cancelBtn)->setShowText(false); setWgtAccesibleName(m_cancelBtn, "Cut cancel pushbutton"); - //m_cancelBtn->setFixedSize(QSize(38, 38)); - m_cancelBtn->setMaximumHeight(unifyHeight); m_cancelBtn->setIcon(QIcon::fromTheme("ddc_cancel_normal")); - m_cancelBtn->setIconSize(QSize(48, 48)); m_cancelBtn->setText(QObject::tr("Cancel")); + + //修复切换维语和藏语后,裁剪模式按钮大小不一致 + int unifyHeight = TOOL_BUTTON_NORMAL; + int iconSize = ICON_SIZE_NORMAL; +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) { + unifyHeight = TOOL_BUTTON_COMPACT; + iconSize = ICON_SIZE_COMPACT; + } + + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + int nHeight = 0; + int nIconSize = 0; + if (sizeMode == DGuiApplicationHelper::NormalMode) { + nHeight = TOOL_BUTTON_NORMAL; + nIconSize = ICON_SIZE_NORMAL; + } else { + nHeight = TOOL_BUTTON_COMPACT; + nIconSize = ICON_SIZE_COMPACT; + } + + m_scaleBtn1_1->setFixedHeight(nHeight); + m_scaleBtn2_3->setFixedHeight(nHeight); + m_scaleBtn8_5->setFixedHeight(nHeight); + m_scaleBtn16_9->setFixedHeight(nHeight); + m_freeBtn->setFixedHeight(nHeight); + m_originalBtn->setFixedHeight(nHeight); + m_doneBtn->setFixedHeight(nHeight); + m_cancelBtn->setFixedHeight(nHeight ); + m_doneBtn->setIconSize(QSize(nIconSize, nIconSize)); + m_cancelBtn->setIconSize(QSize(nIconSize, nIconSize)); + }); +#endif + m_scaleBtn1_1->setFixedHeight(unifyHeight); + m_scaleBtn2_3->setFixedHeight(unifyHeight); + m_scaleBtn8_5->setFixedHeight(unifyHeight); + m_scaleBtn16_9->setFixedHeight(unifyHeight); + m_freeBtn->setFixedHeight(unifyHeight); + m_originalBtn->setFixedHeight(unifyHeight); + m_doneBtn->setFixedHeight(unifyHeight); + m_cancelBtn->setFixedHeight(unifyHeight); + m_doneBtn->setIconSize(QSize(iconSize, iconSize)); + m_cancelBtn->setIconSize(QSize(iconSize, iconSize)); + m_sizeWidget->setProperty(AttriWidgetReWidth, QSize(210, unifyHeight)); m_scaleBtn1_1->setProperty(WidgetAlignInVerWindow, 0); m_scaleBtn2_3->setProperty(WidgetAlignInVerWindow, 0); diff --git a/src/frame/ccentralwidget.cpp b/src/frame/ccentralwidget.cpp index 72d3bae0f..8857dc57b 100644 --- a/src/frame/ccentralwidget.cpp +++ b/src/frame/ccentralwidget.cpp @@ -135,6 +135,8 @@ class DrawBoard::DrawBoard_private //_borad->installEventFilter(_leftScrollArea); _leftScrollArea->installEventFilter(_borad); + _toolManager->setScrollArea(_leftScrollArea); + QVBoxLayout *subVLay = new QVBoxLayout; subVLay->setContentsMargins(0, 0, 0, 0); subVLay->setSpacing(0); diff --git a/src/frame/clefttoolbar.cpp b/src/frame/clefttoolbar.cpp index bb81fb103..ebdda290d 100644 --- a/src/frame/clefttoolbar.cpp +++ b/src/frame/clefttoolbar.cpp @@ -31,7 +31,10 @@ DGUI_USE_NAMESPACE const int BTN_SPACING = 12; bool blocked = false; -const int TOOL_MANAGER_WIDTH = 68; +const int TOOL_MANAGER_WIDTH_NORMAL = 68; +const int TOOL_MANAGER_WIDTH_COMPACT = 48; +const int TOOL_BTN_SIZE_NORMAL = 37; +const int TOOL_BTN_SIZE_COMPACT = 28; DrawToolManager::DrawToolManager(DrawBoard *parent) : DFrame(parent), m_drawBoard(parent) @@ -53,6 +56,11 @@ DrawToolManager::~DrawToolManager() } +void DrawToolManager::setScrollArea(DScrollArea *area) +{ + m_scrollArea = area; +} + bool DrawToolManager::setCurrentTool(int tool, bool force) { return setCurrentTool(this->tool(tool), force); @@ -145,6 +153,13 @@ void DrawToolManager::installTool(IDrawTool *pTool) pTool->setParent(this); pTool->setDrawBoard(drawBoard()); _tools.insert(pTool->getDrawToolMode(), pTool); + +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) + button->setFixedSize(QSize(TOOL_BTN_SIZE_COMPACT, TOOL_BTN_SIZE_COMPACT)); + else + button->setFixedSize(QSize(TOOL_BTN_SIZE_NORMAL, TOOL_BTN_SIZE_NORMAL)); +#endif } } @@ -189,7 +204,7 @@ void DrawToolManager::initUI() this->setAutoFillBackground(true); setMinimumHeight(460);//设置最小高度保证最小化显示正常 - setFixedWidth(TOOL_MANAGER_WIDTH); + setFixedWidth(TOOL_MANAGER_WIDTH_NORMAL); auto mainLayout = new QVBoxLayout(this); mainLayout->setContentsMargins(0, 0, 0, 0); @@ -198,9 +213,41 @@ void DrawToolManager::initUI() m_layout = new QVBoxLayout; m_layout->setSpacing(BTN_SPACING); m_layout->setMargin(0); - m_layout->setContentsMargins(10, 24, 0, 24); + m_layout->setContentsMargins(14, 24, 0, 24); mainLayout->addLayout(m_layout); mainLayout->addStretch(); + +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) { + setFixedWidth(TOOL_MANAGER_WIDTH_COMPACT); + m_layout->setContentsMargins(9, 24, 0, 24); + } + + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) { + this->setFixedWidth(TOOL_MANAGER_WIDTH_COMPACT); + if (m_scrollArea) + m_scrollArea->setFixedWidth(TOOL_MANAGER_WIDTH_COMPACT); + m_layout->setContentsMargins(9, 24, 0, 24); + + if (toolButtonGroup) { + for (int i = 0; i < toolButtonGroup->buttons().size(); i++) + toolButtonGroup->buttons().at(i)->setFixedSize(QSize(TOOL_BTN_SIZE_COMPACT, TOOL_BTN_SIZE_COMPACT)); + } + } else { + this->setFixedWidth(TOOL_MANAGER_WIDTH_NORMAL); + if (m_scrollArea) + m_scrollArea->setFixedWidth(TOOL_MANAGER_WIDTH_NORMAL); + m_layout->setContentsMargins(14, 24, 0, 24); + + if (toolButtonGroup) { + for (int i = 0; i < toolButtonGroup->buttons().size(); i++) + toolButtonGroup->buttons().at(i)->setFixedSize(QSize(TOOL_BTN_SIZE_NORMAL, TOOL_BTN_SIZE_NORMAL)); + } + } + }); + +#endif } void DrawToolManager::initDrawTools() diff --git a/src/frame/clefttoolbar.h b/src/frame/clefttoolbar.h index 6101366b1..168f16b3d 100644 --- a/src/frame/clefttoolbar.h +++ b/src/frame/clefttoolbar.h @@ -29,6 +29,7 @@ class DrawToolManager : public DFrame explicit DrawToolManager(DrawBoard *parent = nullptr); ~DrawToolManager(); + void setScrollArea(DScrollArea* area); bool setCurrentTool(int tool, bool force = false); bool setCurrentTool(IDrawTool *tool, bool force = false); @@ -71,6 +72,7 @@ class DrawToolManager : public DFrame CDrawToolFactory::CDrawToolsMap _tools; DrawBoard *m_drawBoard = nullptr; + DScrollArea *m_scrollArea = nullptr; }; #endif // RIGHTTOOLBAR_H diff --git a/src/frame/cmultiptabbarwidget.cpp b/src/frame/cmultiptabbarwidget.cpp index 232f74404..e82684ee5 100644 --- a/src/frame/cmultiptabbarwidget.cpp +++ b/src/frame/cmultiptabbarwidget.cpp @@ -17,7 +17,10 @@ #include "ccentralwidget.h" #include "filehander.h" -const QSize TabBarMiniSize = QSize(220, 36); +const QSize TabBar_Size_Normal = QSize(220, 36); +const QSize TabBar_Size_Compact = QSize(220, 24); +const int AddBtn_Size_Normal = 24; +const int AddBtn_Size_Compact = 20; TabBarWgt::TabBarWgt(DrawBoard *parent) : DTabBar(parent) @@ -31,6 +34,35 @@ TabBarWgt::TabBarWgt(DrawBoard *parent) this->setExpanding(true); this->setEnabledEmbedStyle(true); +#ifdef DTKWIDGET_CLASS_DSizeMode + DIconButton* addBtn = this->findChild("AddButton");; + if (addBtn) { + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) + addBtn->setMaximumSize(QSize(AddBtn_Size_Compact, AddBtn_Size_Compact)); + else + addBtn->setMaximumSize(QSize(AddBtn_Size_Normal, AddBtn_Size_Normal)); + } + + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + QSize tabSize; + int addBtnSize = 0; + if (sizeMode == DGuiApplicationHelper::CompactMode) { + tabSize = TabBar_Size_Compact; + addBtnSize = AddBtn_Size_Compact; + } else { + tabSize = TabBar_Size_Normal; + addBtnSize = AddBtn_Size_Normal; + } + + for (int i = 0; i < count(); i++) { + this->setTabMinimumSize(i, tabSize); + } + + if (addBtn) + addBtn->setMaximumSize(QSize(addBtnSize, addBtnSize)); + }); +#endif + connect(this, &TabBarWgt::tabAddRequested, this, [ = ]() { pageManager()->addPage(); }); @@ -67,7 +99,14 @@ void TabBarWgt::addItem(const QString &name, const QString &key) setTabData(index, key); // 对标签页名称做长度限制 - this->setTabMinimumSize(index, QSize(220, 36)); +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) + this->setTabMinimumSize(index, TabBar_Size_Compact); + else + this->setTabMinimumSize(index, TabBar_Size_Normal); +#else + this->setTabMinimumSize(index, TabBar_Size_Normal); +#endif } void TabBarWgt::removeItem(const QString &key) diff --git a/src/widgets/cspinbox.cpp b/src/widgets/cspinbox.cpp index 2cdb01229..a90abe2ef 100644 --- a/src/widgets/cspinbox.cpp +++ b/src/widgets/cspinbox.cpp @@ -13,6 +13,9 @@ #include "frame/cgraphicsview.h" #include "application.h" +const int NormalMode_Height = 36; +const int CompactMode_Height = 24; + CSpinBox::CSpinBox(DWidget *parent) : DSpinBox(parent) { @@ -21,11 +24,10 @@ CSpinBox::CSpinBox(DWidget *parent) lineEdit()->setReadOnly(true); setEnabledEmbedStyle(false); setButtonSymbols(PlusMinus); - setMaximumHeight(36); } else { setEnabledEmbedStyle(true); setButtonSymbols(UpDownArrows); - setMaximumSize(86, 36); + setMaximumWidth(86); } connect(this, QOverload::of(&DSpinBox::valueChanged), this, [ = ](int value) { @@ -40,7 +42,22 @@ CSpinBox::CSpinBox(DWidget *parent) }, Qt::QueuedConnection); - //setValueChangedKeepFocus(true); +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::NormalMode) + setMaximumHeight(NormalMode_Height); + else + setMaximumHeight(CompactMode_Height); + + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + if (sizeMode == DGuiApplicationHelper::NormalMode) { + setMaximumHeight(NormalMode_Height); + } else { + setMaximumHeight(CompactMode_Height); + } + }); +#else + setMaximumHeight(36); +#endif setKeyboardTracking(false); diff --git a/src/widgets/dialog/cexportimagedialog.cpp b/src/widgets/dialog/cexportimagedialog.cpp index 0ccbd076d..d313299ac 100644 --- a/src/widgets/dialog/cexportimagedialog.cpp +++ b/src/widgets/dialog/cexportimagedialog.cpp @@ -150,7 +150,6 @@ void CExportImageDialog::initUI() } m_fileNameEdit = new DLineEdit(this); setWgtAccesibleName(m_fileNameEdit, "Export name line editor"); - m_fileNameEdit->setFixedHeight(LINE_EDIT_SIZE.height()); m_fileNameEdit->setClearButtonEnabled(false); //编译器会对反斜杠进行转换,要想在正则表达式中包括一个\,需要输入两次,例如\\s。要想匹配反斜杠本身,需要输入4次,比如\\\\。 m_fileNameEdit->lineEdit()->setValidator(new QRegExpValidator(QRegExp("[^\\\\ /:*?\"<>|]+"), m_fileNameEdit->lineEdit())); @@ -175,7 +174,7 @@ void CExportImageDialog::initUI() m_pathEditor->setClearButtonEnabled(false); m_pathEditor->lineEdit()->setReadOnly(true); m_pathChosenButton = new PathActiveButton(this); - m_pathChosenButton->setFixedSize(40, 36); + m_pathChosenButton->setFixedWidth(40); m_pathChosenButton->setToolTip(tr("Select other directories")); connect(m_pathChosenButton, &PathActiveButton::clicked, this, [ = ]() { DFileDialog dialog(this); @@ -202,14 +201,11 @@ void CExportImageDialog::initUI() writeableFormats.removeAt(0); m_formatCombox->addItems(writeableFormats); - m_formatCombox->setFixedHeight(LINE_EDIT_SIZE.height()); - m_qualitySlider = new DSlider(Qt::Horizontal, this); setWgtAccesibleName(m_qualitySlider, "Export quality slider"); m_qualitySlider->setMinimum(1); m_qualitySlider->setMaximum(100); m_qualitySlider->setValue(100); - m_qualitySlider->setFixedSize(QSize(120, LINE_EDIT_SIZE.height())); m_qualityLabel = new DLabel(this);