From 4057cf365502ab5a343d9d895ba8b60b96bb5be0 Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Wed, 14 Aug 2024 11:00:02 +0800 Subject: [PATCH] fix: the status bar display error time fix the status bar display error time Log: fix the status bar display error time Bug: https://pms.uniontech.com/bug-view-262791.html --- .../recordtime/timewidget.cpp | 32 +++++++++++++++++-- src/dde-dock-plugins/recordtime/timewidget.h | 1 + 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/dde-dock-plugins/recordtime/timewidget.cpp b/src/dde-dock-plugins/recordtime/timewidget.cpp index 342d4f54..93cf8a21 100755 --- a/src/dde-dock-plugins/recordtime/timewidget.cpp +++ b/src/dde-dock-plugins/recordtime/timewidget.cpp @@ -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; @@ -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(); } @@ -408,9 +414,26 @@ void TimeWidget::leaveEvent(QEvent *e) void TimeWidget::start() { + QString userName = QDir::homePath().section("/", -1, -1); + QString tmpPath = "/home/" + userName + "/.cache/deepin/deepin-screen-recorder/tmpStart.txt"; + QFile tmpFile(tmpPath); + + if(tmpFile.open(QIODevice::WriteOnly)){ + m_useFileCount = true; + tmpFile.flush(); + tmpFile.close(); + + QFileInfo tmpfile(tmpPath); + m_baseTime = tmpfile.birthTime().time(); + qDebug()<<"here time:"<start(400); m_timerCount = 0; } @@ -418,6 +441,9 @@ void TimeWidget::start() void TimeWidget::stop() { disconnect(m_timer, SIGNAL(timeout()), this, SLOT(onTimeout())); + QString userName = QDir::homePath().section("/", -1, -1); + QFile tmpFile("/home/" + userName + "/.cache/deepin/deepin-screen-recorder/tmpStart.txt"); + tmpFile.remove(); } //判断是否是wayland协议 bool TimeWidget::isWaylandProtocol() diff --git a/src/dde-dock-plugins/recordtime/timewidget.h b/src/dde-dock-plugins/recordtime/timewidget.h index 317e9e6f..6874c205 100755 --- a/src/dde-dock-plugins/recordtime/timewidget.h +++ b/src/dde-dock-plugins/recordtime/timewidget.h @@ -107,6 +107,7 @@ private slots: bool m_pressed; int m_systemVersion; int m_timerCount; + bool m_useFileCount; /** * @brief m_lightIcon1070 1070下录屏计时图标icon */