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 14, 2024
1 parent b403db3 commit 4057cf3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
32 changes: 29 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,16 +414,36 @@ 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:"<<m_baseTime;
}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;
}

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()
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 4057cf3

Please sign in to comment.