Skip to content

Commit e78b248

Browse files
fix: update schedule dialog icon and scroll behavior
Update the schedule detail dialog to keep the icon consistent after theme changes and avoid unnecessary scrolling. The dialog now refreshes the icon when the theme changes, hides the scrollbar when content fits, and keeps scrolling available only when the content exceeds the visible area.
1 parent 0eee8e8 commit e78b248

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

src/calendar-client/src/dialog/myscheduleview.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,21 @@ void CMyScheduleView::slotAutoFeed(const QFont &font)
9595
resultStr += str;
9696
}
9797

98-
if (strList.count() * h > 100) {
98+
const int scheduleContentH = strList.count() * h;
99+
const bool needScroll = scheduleContentH > 100;
100+
if (needScroll) {
99101
m_scheduleLabelH = 100;
100102
} else {
101103
int minH = 17;
102-
m_scheduleLabelH = strList.count() * h;
104+
m_scheduleLabelH = scheduleContentH;
103105
m_scheduleLabelH = m_scheduleLabelH >= minH ? m_scheduleLabelH : minH;
104106
}
105107
//更新控件高度
106108
area->setFixedHeight(m_scheduleLabelH);
109+
area->setVerticalScrollBarPolicy(needScroll ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff);
110+
area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
107111
m_scheduleLabel->setText(resultStr);
112+
m_scheduleLabel->setFixedHeight(needScroll ? scheduleContentH : m_scheduleLabelH);
108113

109114
m_timeLabelH = 26;
110115
if (m_scheduleInfo->lunnar()) {
@@ -185,6 +190,11 @@ void CMyScheduleView::setLabelTextColor(const int type)
185190
setPaletteTextColor(m_timeLabel, timeColor);
186191
}
187192

193+
void CMyScheduleView::updateDialogIcon()
194+
{
195+
setIcon(QIcon::fromTheme("dde-calendar"));
196+
}
197+
188198
/**
189199
* @brief setPaletteTextColor 设置调色板颜色
190200
* @param widget 需要设置的widget
@@ -301,8 +311,7 @@ void CMyScheduleView::initUI()
301311
m_Title->setAlignment(Qt::AlignCenter);
302312
DFontSizeManager::instance()->bind(m_Title, DFontSizeManager::T5, QFont::DemiBold);
303313
//设置日期图标
304-
QIcon t_icon(CDynamicIcon::getInstance()->getPixmap());
305-
setIcon(t_icon);
314+
updateDialogIcon();
306315
m_Title->setText(tr("My Event"));
307316
m_Title->move(90, 0); // center x: (400-220)/2
308317

@@ -315,6 +324,8 @@ void CMyScheduleView::initUI()
315324
area->setFocusPolicy(Qt::FocusPolicy::NoFocus);
316325
area->setFrameShape(QFrame::NoFrame);
317326
area->setFixedWidth(363);
327+
area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
328+
area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
318329
area->setBackgroundRole(QPalette::Window);
319330
area->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
320331
area->setWidgetResizable(true);
@@ -379,6 +390,9 @@ void CMyScheduleView::initConnection()
379390
QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged,
380391
this,
381392
&CMyScheduleView::setLabelTextColor);
393+
QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged,
394+
this,
395+
&CMyScheduleView::updateDialogIcon);
382396
//如果为节假日日程
383397
if (CScheduleOperation::isFestival(m_scheduleInfo)) {
384398
qCDebug(ClientLogger) << "Adding close button for festival schedule";

src/calendar-client/src/dialog/myscheduleview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public slots:
4949
//界面初始化
5050
void initUI();
5151
void initConnection();
52+
void updateDialogIcon();
5253
//设置label文字颜色
5354
void setLabelTextColor(const int type);
5455
//设置调色板颜色

0 commit comments

Comments
 (0)