diff --git a/src/common/mainwindow.cpp b/src/common/mainwindow.cpp index e11475f6..899a0eea 100644 --- a/src/common/mainwindow.cpp +++ b/src/common/mainwindow.cpp @@ -856,6 +856,7 @@ MainWindow::MainWindow(QWidget *parent) }); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + m_pToolbox->dSizeModeChanged(); if (m_bMiniMode) return; m_pCommHintWid->hide(); if (m_pPlaylist && m_pPlaylist->state() == PlaylistWidget::State::Opened) diff --git a/src/common/platform/platform_mainwindow.cpp b/src/common/platform/platform_mainwindow.cpp index 14ef0637..95f3193f 100644 --- a/src/common/platform/platform_mainwindow.cpp +++ b/src/common/platform/platform_mainwindow.cpp @@ -882,6 +882,7 @@ Platform_MainWindow::Platform_MainWindow(QWidget *parent) }); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { + m_pToolbox->dSizeModeChanged(); if (m_bMiniMode) return; m_pCommHintWid->hide(); if (m_pPlaylist && m_pPlaylist->state() == Platform_PlaylistWidget::State::Opened) diff --git a/src/widgets/platform/platform_playlist_widget.cpp b/src/widgets/platform/platform_playlist_widget.cpp index 23ce196f..bea0c70c 100644 --- a/src/widgets/platform/platform_playlist_widget.cpp +++ b/src/widgets/platform/platform_playlist_widget.cpp @@ -1349,6 +1349,13 @@ void Platform_PlaylistWidget::togglePopup(bool isShortcut) fixed.setRect(10, (view_rect.height() - (TOOLBOX_SPACE_HEIGHT + TOOLBOX_HEIGHT + 10) + 5), view_rect.width() - 20, TOOLBOX_SPACE_HEIGHT + 10); +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) { + fixed.setRect(10, (view_rect.height() - (TOOLBOX_SPACE_HEIGHT + TOOLBOX_DSIZEMODE_HEIGHT + 10) + 5), + view_rect.width() - 20, TOOLBOX_SPACE_HEIGHT + 10); + } +#endif + QRect shrunk = fixed; shrunk.setHeight(0); shrunk.moveBottom(fixed.bottom()); diff --git a/src/widgets/platform/platform_toolbox_proxy.cpp b/src/widgets/platform/platform_toolbox_proxy.cpp index 7f80524b..354ba6d5 100644 --- a/src/widgets/platform/platform_toolbox_proxy.cpp +++ b/src/widgets/platform/platform_toolbox_proxy.cpp @@ -1383,6 +1383,7 @@ void Platform_ToolboxProxy::initMember() m_bAnimationFinash = true; m_bCanPlay = false; m_bSetListBtnFocus = false; + m_bDsizeModeChanged = false; } /** @@ -1763,6 +1764,7 @@ void Platform_ToolboxProxy::slotPlayListStateChange(bool isShortcut) closeAnyPopup(); if (m_pPlaylist->state() == Platform_PlaylistWidget::State::Opened) { + m_bDsizeModeChanged = false; //窗口绑定渲染不展示动画,故按键状态不做限制 Q_UNUSED(isShortcut); QRect rcBegin = this->geometry(); @@ -1780,11 +1782,18 @@ void Platform_ToolboxProxy::slotPlayListStateChange(bool isShortcut) QRect rcEnd = rcBegin; rcEnd.setY(rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 7); #ifdef DTKWIDGET_CLASS_DSizeMode - if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) - rcEnd.setY(rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 37); + constexpr int8_t height_diff = static_cast(TOOLBOX_HEIGHT - TOOLBOX_DSIZEMODE_HEIGHT); + int y = 0; + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode){ + y= m_bDsizeModeChanged ? (rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 7 + height_diff) : (rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 37); + } else { + y= m_bDsizeModeChanged ? (rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 37 - height_diff) : (rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 7); + } + rcEnd.setY(y); #endif setGeometry(rcEnd); m_pListBtn->setChecked(false); + m_bDsizeModeChanged = false; } } diff --git a/src/widgets/platform/platform_toolbox_proxy.h b/src/widgets/platform/platform_toolbox_proxy.h index 1c6695a6..f2d46ef4 100644 --- a/src/widgets/platform/platform_toolbox_proxy.h +++ b/src/widgets/platform/platform_toolbox_proxy.h @@ -395,6 +395,12 @@ class Platform_ToolboxProxy: public DFloatingWidget ToolButton *fsBtn() {return m_pFullScreenBtn;} VolumeButton *volBtn() {return m_pVolBtn;} void setThumbnailmode(bool is_thumbnailmode) {m_bThumbnailmode = is_thumbnailmode;} + /** + * @brief 在紧凑模式正常模式之间切换的时候调用 + */ + inline void dSizeModeChanged() noexcept { + m_bDsizeModeChanged = !m_bDsizeModeChanged; + } public slots: /** @@ -658,6 +664,7 @@ private slots: bool m_bAnimationFinash; ///动画是否完成 bool m_bCanPlay; ///判断是否能进行曲目切换的标志位 bool m_bSetListBtnFocus; ///设置播放列表按钮焦点标志位 + bool m_bDsizeModeChanged; ///是否在正常模式和紧凑模式之间切换,主要用于播放列表的升降 float m_processAdd; }; @@ -751,6 +758,8 @@ public slots: #define TOOLBOX_TOP_EXTENT 0 #define TOOLBOX_SPACE_HEIGHT 314 #define TOOLBOX_HEIGHT 80 +/*紧凑模式下toolbox的高度*/ +#define TOOLBOX_DSIZEMODE_HEIGHT 50 #define TOOLBOX_HEIGHT_EXT (TOOLBOX_HEIGHT + TOOLBOX_TOP_EXTENT) #define TOOLBOX_BUTTON_WIDTH 50 #define TOOLBOX_BUTTON_HEIGHT 50 diff --git a/src/widgets/playlist_widget.cpp b/src/widgets/playlist_widget.cpp index 2d78668b..eccf9b9a 100644 --- a/src/widgets/playlist_widget.cpp +++ b/src/widgets/playlist_widget.cpp @@ -1344,15 +1344,21 @@ void PlaylistWidget::togglePopup(bool isShortcut) QRect view_rect = main_rect.marginsRemoved(QMargins(1, 1, 1, 1)); #endif + int toolbox_height=TOOLBOX_HEIGHT; +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) { + toolbox_height = TOOLBOX_DSIZEMODE_HEIGHT; + } +#endif + QRect fixed; if(CompositingManager::get().platform() == X86) { - fixed.setRect(10, (view_rect.height() - (TOOLBOX_SPACE_HEIGHT + TOOLBOX_HEIGHT + 10)), + fixed.setRect(10, (view_rect.height() - (TOOLBOX_SPACE_HEIGHT + toolbox_height + 10)), view_rect.width() - 20, TOOLBOX_SPACE_HEIGHT + 10); - } else { - fixed.setRect(10, (view_rect.height() - (TOOLBOX_SPACE_HEIGHT + TOOLBOX_HEIGHT + 10) + 5), - view_rect.width() - 20, TOOLBOX_SPACE_HEIGHT + 10); + fixed.setRect(10, (view_rect.height() - (TOOLBOX_SPACE_HEIGHT + toolbox_height + 10) + 5), + view_rect.width() - 20, TOOLBOX_SPACE_HEIGHT + 10); } QRect shrunk = fixed; diff --git a/src/widgets/toolbox_proxy.cpp b/src/widgets/toolbox_proxy.cpp index 7ffd9218..77d1128a 100644 --- a/src/widgets/toolbox_proxy.cpp +++ b/src/widgets/toolbox_proxy.cpp @@ -1499,6 +1499,7 @@ void ToolboxProxy::initMember() m_bAnimationFinash = true; m_bCanPlay = false; m_bSetListBtnFocus = false; + m_bDsizeModeChanged = false; } /** @@ -1825,7 +1826,7 @@ void ToolboxProxy::slotFileLoaded() if(nIndex == -1) return; if(nIndex < nNextIndex && !sNextVideoName.isNull()) { m_pMainWindow->play({sNextVideoName}); - } else{ + } else { bool isNext = true; for(int i = nIndex; i < lstItemInfo.count(); i++) { PlayItemInfo iteminfo = lstItemInfo.at(i); @@ -1881,6 +1882,7 @@ void ToolboxProxy::slotPlayListStateChange(bool isShortcut) closeAnyPopup(); if (m_pPlaylist->state() == PlaylistWidget::State::Opened) { + m_bDsizeModeChanged = false; //非x86平台播放列表切换不展示动画,故按键状态不做限制 if(CompositingManager::get().platform() == Platform::X86) { if (isShortcut && m_pListBtn->isChecked()) { @@ -1891,7 +1893,7 @@ void ToolboxProxy::slotPlayListStateChange(bool isShortcut) } QRect rcBegin = this->geometry(); QRect rcEnd = rcBegin; - rcEnd.setY(194); + rcEnd.setY(rcBegin.y() - TOOLBOX_SPACE_HEIGHT - 7); m_bAnimationFinash = false; m_pPaOpen = new QPropertyAnimation(this, "geometry"); m_pPaOpen->setEasingCurve(QEasingCurve::Linear); @@ -1904,16 +1906,11 @@ void ToolboxProxy::slotPlayListStateChange(bool isShortcut) Q_UNUSED(isShortcut); QRect rcBegin = this->geometry(); QRect rcEnd = rcBegin; - rcEnd.setY(194); + rcEnd.setY(rcBegin.y() - TOOLBOX_SPACE_HEIGHT - 7); setGeometry(rcEnd); m_pListBtn->setChecked(true); } } else { - int y = 515; -#ifdef DTKWIDGET_CLASS_DSizeMode - if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) - y = 543; -#endif if(CompositingManager::get().platform() == Platform::X86) { m_bAnimationFinash = false; @@ -1926,7 +1923,20 @@ void ToolboxProxy::slotPlayListStateChange(bool isShortcut) QRect rcBegin = this->geometry(); QRect rcEnd = rcBegin; - rcEnd.setY(y); + if(m_bDsizeModeChanged){ + constexpr int8_t height_diff = static_cast(TOOLBOX_HEIGHT - TOOLBOX_DSIZEMODE_HEIGHT); + int y = rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 7; +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) { + y = rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 7 + height_diff; + } else { + y = rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 7 - height_diff; + } +#endif + rcEnd.setY(y); + } else { + rcEnd.setY(rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 7); + } m_pPaClose = new QPropertyAnimation(this, "geometry"); m_pPaClose->setEasingCurve(QEasingCurve::Linear); m_pPaClose->setDuration(POPUP_DURATION); @@ -1938,10 +1948,21 @@ void ToolboxProxy::slotPlayListStateChange(bool isShortcut) Q_UNUSED(isShortcut); QRect rcBegin = this->geometry(); QRect rcEnd = rcBegin; - rcEnd.setY(y); + if(m_bDsizeModeChanged){ + int8_t height_diff = static_cast(TOOLBOX_HEIGHT - TOOLBOX_DSIZEMODE_HEIGHT); +#ifdef DTKWIDGET_CLASS_DSizeMode + if (DGuiApplicationHelper::instance()->sizeMode() != DGuiApplicationHelper::CompactMode) { + height_diff = -height_diff; + } +#endif + rcEnd.setY(rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 7 + height_diff); + } else { + rcEnd.setY(rcBegin.y() + TOOLBOX_SPACE_HEIGHT + 7); + } setGeometry(rcEnd); m_pListBtn->setChecked(false); } + m_bDsizeModeChanged = false; } } diff --git a/src/widgets/toolbox_proxy.h b/src/widgets/toolbox_proxy.h index 2de2fdc3..e980b0ce 100644 --- a/src/widgets/toolbox_proxy.h +++ b/src/widgets/toolbox_proxy.h @@ -396,6 +396,12 @@ class ToolboxProxy: public DFloatingWidget VolumeButton *volBtn() {return m_pVolBtn;} void setThumbnailmode(bool is_thumbnailmode) {m_bThumbnailmode = is_thumbnailmode;} MircastWidget *getMircastWidget() {return m_mircastWidget;} + /** + * @brief 在紧凑模式正常模式之间切换的时候调用 + */ + inline void dSizeModeChanged() noexcept { + m_bDsizeModeChanged = !m_bDsizeModeChanged; + } public slots: /** @@ -656,6 +662,7 @@ private slots: bool m_bAnimationFinash; ///动画是否完成 bool m_bCanPlay; ///判断是否能进行曲目切换的标志位 bool m_bSetListBtnFocus; ///设置播放列表按钮焦点标志位 + bool m_bDsizeModeChanged; ///是否在正常模式和紧凑模式之间切换,主要用于播放列表的升降 float m_processAdd; }; @@ -749,6 +756,8 @@ public slots: #define TOOLBOX_TOP_EXTENT 0 #define TOOLBOX_SPACE_HEIGHT 314 #define TOOLBOX_HEIGHT 80 +/*紧凑模式下toolbox的高度*/ +#define TOOLBOX_DSIZEMODE_HEIGHT 50 #define TOOLBOX_HEIGHT_EXT (TOOLBOX_HEIGHT + TOOLBOX_TOP_EXTENT) #define TOOLBOX_BUTTON_WIDTH 50 #define TOOLBOX_BUTTON_HEIGHT 50