diff --git a/src/deepin-draw/widgets/dzoommenucombobox.cpp b/src/deepin-draw/widgets/dzoommenucombobox.cpp index 7bcf0f507..888cfd125 100644 --- a/src/deepin-draw/widgets/dzoommenucombobox.cpp +++ b/src/deepin-draw/widgets/dzoommenucombobox.cpp @@ -16,9 +16,15 @@ #include #include + const int FLOATING_SIZE = 32; + const int FLOATING_SIZE_COMPACT = 22; + const int ICON_SIZE = 24; + const int ICON_SIZE_COMPACT = 18; + const int BTN_HEIGHT = 36; + const int BTN_HEIGHT_COMPACT = 24; DZoomMenuComboBox::DZoomMenuComboBox(DWidget *parent): DWidget(parent) - , m_floatingSize(32) + , m_floatingSize(FLOATING_SIZE) , m_currentIndex(-1) { initUI(); @@ -163,6 +169,36 @@ void DZoomMenuComboBox::slotActionToggled(QAction *action) } } +void DZoomMenuComboBox::updateSizeMode() +{ + int nIconSize = ICON_SIZE; + int nBtnHeight = BTN_HEIGHT; +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::isCompactMode()) { + m_floatingSize = FLOATING_SIZE_COMPACT; + nIconSize = ICON_SIZE_COMPACT; + nBtnHeight = BTN_HEIGHT_COMPACT; + } else { + m_floatingSize = FLOATING_SIZE; + nIconSize = ICON_SIZE; + nBtnHeight = BTN_HEIGHT; + } +#else + m_floatingSize = FLOATING_SIZE; +#endif + + if (m_increaseBtn) { + m_increaseBtn->setFixedSize(QSize(m_floatingSize, m_floatingSize)); + } + if (m_reduceBtn) { + m_reduceBtn->setFixedSize(QSize(m_floatingSize, m_floatingSize)); + } + if (m_btn) { + m_btn->setIconSize(QSize(nIconSize, nIconSize)); + m_btn->setFixedSize(QSize(nBtnHeight, nBtnHeight)); + } +} + bool DZoomMenuComboBox::eventFilter(QObject *o, QEvent *e) { if (o == m_menu) { @@ -220,7 +256,7 @@ void DZoomMenuComboBox::initUI() m_reduceBtn->setIconSize(QSize(16, 16)); m_increaseBtn->setIconSize(QSize(16, 16)); m_btn->setIconSize(QSize(24, 24)); - m_label->setFixedSize(QSize(50, 24)); + m_label->setFixedSize(QSize(40, 24)); connect(m_reduceBtn, &DFloatingButton::clicked, this, [ = ]() { emit signalLeftBtnClicked(); @@ -244,4 +280,9 @@ void DZoomMenuComboBox::initConnection() connect(m_menu, &QMenu::aboutToHide, this, [ = ]() { this->setFocus(); }); +#ifdef DTKWIDGET_CLASS_DSizeMode + // 紧凑模式信号处理 + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, &DZoomMenuComboBox::updateSizeMode); + updateSizeMode(); +#endif } diff --git a/src/deepin-draw/widgets/dzoommenucombobox.h b/src/deepin-draw/widgets/dzoommenucombobox.h index aac446f48..cb331091c 100644 --- a/src/deepin-draw/widgets/dzoommenucombobox.h +++ b/src/deepin-draw/widgets/dzoommenucombobox.h @@ -90,6 +90,11 @@ protected slots: * @bref: slotActionToggled 处理子选项点击事件 */ void slotActionToggled(QAction *action); +private slots: + /** + * @brief 根据布局模式(紧凑)变更更新界面布局 + */ + void updateSizeMode(); protected: bool eventFilter(QObject *o, QEvent *e) override; private: diff --git a/src/deepin-draw/widgets/toptoolbar.cpp b/src/deepin-draw/widgets/toptoolbar.cpp index 25fcf6296..f201f097d 100644 --- a/src/deepin-draw/widgets/toptoolbar.cpp +++ b/src/deepin-draw/widgets/toptoolbar.cpp @@ -24,7 +24,6 @@ #include const int MINHEIGHT = 38; const int Text_Size = 14; - TopTilte::TopTilte(DWidget *parent) : DFrame(parent) { @@ -46,7 +45,7 @@ void TopTilte::initUI() m_editDrawBorad->setCheckable(true); m_editDrawBorad->setIcon(QIcon::fromTheme("editdrawboard")); m_editDrawBorad->setIconSize(QSize(40, 40)); - m_editDrawBorad->setFixedSize(QSize(35, 35)); + m_editDrawBorad->resize(QSize(35, 35)); m_editDrawBorad->setToolTip(tr("Crop canvas (C)")); m_editDrawBorad->setShortcut(QKeySequence(QKeySequence(Qt::Key_C))); diff --git a/src/drawboard/drawboard/widgets/colorWidget/private/ccolorpanel.cpp b/src/drawboard/drawboard/widgets/colorWidget/private/ccolorpanel.cpp index 21b60ecdb..ad7a0511d 100644 --- a/src/drawboard/drawboard/widgets/colorWidget/private/ccolorpanel.cpp +++ b/src/drawboard/drawboard/widgets/colorWidget/private/ccolorpanel.cpp @@ -40,7 +40,7 @@ const int PANEL_WIDTH = 334; const int ORIGIN_HEIGHT = 56; const int EXPAND_HEIGHT = 475; const int RADIUS = 8; -const QSize COLOR_BORDER_SIZE = QSize(24, 24); +const QSize COLOR_BORDER_SIZE = QSize(36, 36); const QColor PANEL_TITLE_COLOR = QColor(0, 0, 0); const qreal PANEL_TITLE_COLOR_ALPHA = 0.4; const QColor PANEL_BACK_GROUND = QColor("#000000"); @@ -364,7 +364,7 @@ CColorButton::CColorButton(const QColor &color, QWidget *parent) : QPushButton(parent) , m_color(color) { - resize(COLOR_BORDER_SIZE); + setFixedSize(COLOR_BORDER_SIZE); setCheckable(true); connect(this, &CColorButton::clicked, this, [ = ]() { diff --git a/src/drawboard/drawboard/widgets/colorWidget/private/cpickcolorwidget.cpp b/src/drawboard/drawboard/widgets/colorWidget/private/cpickcolorwidget.cpp index e7f91d79f..472be2427 100644 --- a/src/drawboard/drawboard/widgets/colorWidget/private/cpickcolorwidget.cpp +++ b/src/drawboard/drawboard/widgets/colorWidget/private/cpickcolorwidget.cpp @@ -28,8 +28,11 @@ const QColor PICK_TITLE_COLOR = QColor(0, 0, 0); const qreal PICK_TITLE_COLOR_ALPHA = 0.4; const int CONST_LABEL_HEIGHT = 36; const int OFFSET_EXPEND_HEADER = 15; +const int BUTTON_SIZE = 36; +const int BUTTON_SIZE_COMPACT = 24; PickColorWidget::PickColorWidget(QWidget *parent, bool bUseOldUi) : QWidget(parent) + , m_bUseOldUI(bUseOldUi) { if (bUseOldUi) { initOldUi(); @@ -211,6 +214,12 @@ void PickColorWidget::initConnects() } } }); + +#ifdef DTKWIDGET_CLASS_DSizeMode + // 紧凑模式信号处理 + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, &PickColorWidget::updateSizeMode); + updateSizeMode(); +#endif } void PickColorWidget::initOldUi() @@ -387,3 +396,24 @@ void PickColorWidget::hideEvent(QHideEvent *event) QWidget::hideEvent(event); } +void PickColorWidget::updateSizeMode() +{ + int nBtnSize = BUTTON_SIZE; +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::isCompactMode()) + nBtnSize = BUTTON_SIZE_COMPACT; + else + nBtnSize = BUTTON_SIZE; +#else + nBtnSize = BUTTON_SIZE; +#endif + + if (m_picker) { + m_picker->setFixedSize(QSize(55, nBtnSize)); + if (m_bUseOldUI) + m_picker->setIconSize(QSize(15,15)); + else + m_picker->setIconSize(QSize(nBtnSize, nBtnSize)); + } +} + diff --git a/src/drawboard/drawboard/widgets/colorWidget/private/cpickcolorwidget.h b/src/drawboard/drawboard/widgets/colorWidget/private/cpickcolorwidget.h index 9df5177a4..aaa8c1afe 100644 --- a/src/drawboard/drawboard/widgets/colorWidget/private/cpickcolorwidget.h +++ b/src/drawboard/drawboard/widgets/colorWidget/private/cpickcolorwidget.h @@ -66,6 +66,11 @@ class DRAWLIB_EXPORT PickColorWidget : public QWidget void previewedColorChanged(const QColor &color); void heightChanged(); +private slots: + /** + * @brief 根据布局模式(紧凑)变更更新界面布局 + */ + void updateSizeMode(); private: /** * @brief updateColor 更新颜色 @@ -86,6 +91,7 @@ class DRAWLIB_EXPORT PickColorWidget : public QWidget ColorPickerInterface *m_cp; CAlphaControlWidget *m_alphaControlWidget; QColor curColor; + bool m_bUseOldUI = false; }; #endif // CPICKCOLORWIDGET_H diff --git a/src/drawboard/drawboard/widgets/dialog/cexportimagedialog.cpp b/src/drawboard/drawboard/widgets/dialog/cexportimagedialog.cpp index 26a6f31d5..414e08fab 100644 --- a/src/drawboard/drawboard/widgets/dialog/cexportimagedialog.cpp +++ b/src/drawboard/drawboard/widgets/dialog/cexportimagedialog.cpp @@ -22,9 +22,15 @@ #include #include +#ifdef USE_DTK +#include +DGUI_USE_NAMESPACE +#endif + #define NAME_MAX 255 const QSize DIALOG_SIZE = QSize(380, 280); const QSize LINE_EDIT_SIZE = QSize(250, 35); +const QSize LINE_EDIT_SIZE_COMPACT = QSize(250, 23); const QSize TIP_LABEL_MAXSIZE = QSize(103, 12); const int MAX_PERCENT_VALUE = 100; const int MIN_PERCENT_VALUE = 0; @@ -261,6 +267,11 @@ void CExportImageDialog::initConnection() }); #endif +#ifdef DTKWIDGET_CLASS_DSizeMode + // 紧凑模式信号处理 + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, &CExportImageDialog::updateSizeMode); + updateSizeMode(); +#endif } void CExportImageDialog::slotOnSavePathChange(int index) @@ -342,6 +353,23 @@ void CExportImageDialog::slotOnQualityChanged(int value) m_quality = value; } +void CExportImageDialog::updateSizeMode() +{ + int nHeight= LINE_EDIT_SIZE.height(); +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::isCompactMode()) + nHeight = LINE_EDIT_SIZE_COMPACT.height(); + else + nHeight = LINE_EDIT_SIZE.height(); +#else + nHeight = LINE_EDIT_SIZE.height(); +#endif + + if (m_fileNameEdit) { + m_fileNameEdit->setFixedHeight(nHeight); + } +} + void CExportImageDialog::showDirChoseDialog() { QFileDialog dialog(this); diff --git a/src/drawboard/drawboard/widgets/dialog/cexportimagedialog.h b/src/drawboard/drawboard/widgets/dialog/cexportimagedialog.h index cfd3ca299..ffc68406c 100644 --- a/src/drawboard/drawboard/widgets/dialog/cexportimagedialog.h +++ b/src/drawboard/drawboard/widgets/dialog/cexportimagedialog.h @@ -51,6 +51,10 @@ private slots: void slotOnFormatChange(int index); int execCheckFile(const QString &text); void slotOnQualityChanged(int value); + /** + * @brief 根据布局模式(紧凑)变更更新界面布局 + */ + void updateSizeMode(); signals: void signalDoSave(QString);