Skip to content

Commit

Permalink
fix: UI error on collapse mode
Browse files Browse the repository at this point in the history
modify UI on collapse mode

Issue: linuxdeepin/developer-center#4642
  • Loading branch information
FeiWang1119 committed Aug 23, 2023
1 parent 29dd4e5 commit 692851b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
29 changes: 25 additions & 4 deletions notification/notifycenterwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void NotifyCenterWidget::initUI()
m_toggleNotificationFolding = new CicleIconButton(nullptr);
m_toggleNotificationFolding->setAccessibleName("ToggleNotificationFolding");
m_toggleNotificationFolding->setFixedSize(UI::Panel::buttonSize);
m_toggleNotificationFolding->setIcon(DDciIcon::fromTheme("arrow_ordinary_up"));
connect(m_toggleNotificationFolding, &CicleIconButton::clicked, this, &NotifyCenterWidget::toggleNotificationFolding);

m_settingBtn = new CicleIconButton(nullptr);
Expand Down Expand Up @@ -164,12 +165,15 @@ void NotifyCenterWidget::updateDisplayOfRemainingNotification()
} else {
const int rowCount = m_notifyWidget->model()->remainNotificationCount();
if (rowCount > 0) {
if (m_bottomTipLayout->parentWidget()->isHidden())
if (m_bottomTipLayout->parentWidget()->isHidden()) {
m_bottomTipLayout->parentWidget()->show();
collapesNotificationFoldingImpl(false);
}
m_expandRemaining->setText(tr("%1 more notifications").arg(QString::number(rowCount)));
m_bottomTipLayout->setCurrentWidget(m_expandRemaining);
} else {
m_bottomTipLayout->parentWidget()->hide();
expandNotificationFoldingImpl(false);
}
}
}
Expand All @@ -191,20 +195,31 @@ void NotifyCenterWidget::updateTabFocus()
}

void NotifyCenterWidget::expandNotificationFolding()
{
expandNotificationFoldingImpl(true);
}

void NotifyCenterWidget::expandNotificationFoldingImpl(const bool refreshData)
{
m_isCollapesNotificationFolding = false;
m_notifyWidget->model()->expandData();
if (refreshData)
m_notifyWidget->model()->expandData();
m_toggleNotificationFolding->setIcon(DDciIcon::fromTheme("arrow_ordinary_up"));
Q_EMIT notificationFoldingChanged(m_isCollapesNotificationFolding);
m_expandRemaining->hide();
m_toggleNotificationFolding->show();
}

void NotifyCenterWidget::collapesNotificationFolding()
{
collapesNotificationFoldingImpl(true);
}

void NotifyCenterWidget::collapesNotificationFoldingImpl(const bool refreshData)
{
m_isCollapesNotificationFolding = true;
m_notifyWidget->model()->collapseData();
m_toggleNotificationFolding->setIcon(DDciIcon::fromTheme("arrow_ordinary_down"));
if (refreshData)
m_notifyWidget->model()->collapseData();
Q_EMIT notificationFoldingChanged(m_isCollapesNotificationFolding);
m_expandRemaining->show();
m_toggleNotificationFolding->hide();
Expand Down Expand Up @@ -236,6 +251,12 @@ bool NotifyCenterWidget::hasAppNotification() const
return m_notifyWidget->model()->rowCount() > 0;
}

void NotifyCenterWidget::showEvent(QShowEvent *event)
{
// toggleNotificationFolding();
DBlurEffectWidget::showEvent(event);
}

void NotifyCenterWidget::showSettingMenu()
{
QMenu *menu = new QMenu(this);
Expand Down
6 changes: 6 additions & 0 deletions notification/notifycenterwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ private Q_SLOTS:
void updateDisplayOfRemainingNotification();
void updateTabFocus();
void expandNotificationFolding();
void expandNotificationFoldingImpl(const bool refreshData);
void collapesNotificationFolding();
void collapesNotificationFoldingImpl(const bool refreshData);
void toggleNotificationFolding();
void showSettingMenu();
void showNotificationModuleOfControlCenter();
Expand All @@ -77,6 +79,10 @@ private Q_SLOTS:
QTimer *m_refreshTimer = nullptr;
QTime m_tickTime;
qreal m_scale = 1;

// QWidget interface
protected:
void showEvent(QShowEvent *event);
};

#endif // NotifyCenterWidget_H

0 comments on commit 692851b

Please sign in to comment.