Skip to content

Commit

Permalink
fix: the status bar display error time
Browse files Browse the repository at this point in the history
fix the status bar display error time

Log: fix the status bar display error time
Bug: https://pms.uniontech.com/bug-view-262791.html
  • Loading branch information
add-uos committed Aug 15, 2024
1 parent b403db3 commit 3fe2b9e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/dde-dock-plugins/recordtime/recordtimeplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ void RecordTimePlugin::clear()
m_checkTimer->deleteLater();
m_checkTimer = nullptr;
}

QString tmpPath = QString("/home/%1/.cache/deepin/deepin-screen-recorder/tmpStart.txt")
.arg(QDir::homePath().section("/", -1, -1));
QFile tmpFile(tmpPath);
if(QFile::exists(tmpPath)) {
tmpFile.remove();
}
}

void RecordTimePlugin::onStart()
Expand Down
28 changes: 25 additions & 3 deletions src/dde-dock-plugins/recordtime/timewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ TimeWidget::TimeWidget(DWidget *parent):
m_hover(false),
m_pressed(false),
m_systemVersion(0),
m_timerCount(0)
m_timerCount(0),
m_useFileCount(false)
{
m_systemVersion = DSysInfo::minorVersion().toInt() ;
qInfo() << "Current system version: " << m_systemVersion;
Expand Down Expand Up @@ -142,7 +143,12 @@ void TimeWidget::onTimeout()
}
m_bRefresh = !m_bRefresh;
QTime showTime(0, 0, 0);
showTime = showTime.addMSecs(m_timerCount * 400);
if(m_useFileCount){
showTime = showTime.addSecs(m_baseTime.secsTo(QTime::currentTime()));
}else{
showTime = showTime.addMSecs(m_timerCount * 400);
}

m_showTimeStr = showTime.toString("hh:mm:ss");
update();
}
Expand Down Expand Up @@ -408,9 +414,25 @@ void TimeWidget::leaveEvent(QEvent *e)

void TimeWidget::start()
{
QString tmpPath = QString("/home/%1/.cache/deepin/deepin-screen-recorder/tmpStart.txt")
.arg(QDir::homePath().section("/", -1, -1));
QFile tmpFile(tmpPath);

if(tmpFile.open(QIODevice::WriteOnly)){
m_useFileCount = true;
tmpFile.flush();
tmpFile.close();

QFileInfo tmpFileInfo(tmpPath);
m_baseTime = tmpFileInfo.birthTime().time();
}else{
m_useFileCount = false;
m_baseTime = QTime::currentTime();
}

m_showTimeStr = QString("00:00:00");
connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimeout()));
m_baseTime = QTime::currentTime();

m_timer->start(400);
m_timerCount = 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/dde-dock-plugins/recordtime/timewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ private slots:
bool m_pressed;
int m_systemVersion;
int m_timerCount;
bool m_useFileCount;
/**
* @brief m_lightIcon1070 1070下录屏计时图标icon
*/
Expand Down

0 comments on commit 3fe2b9e

Please sign in to comment.