forked from quickshell/quickshell
core/clock: fix instability causing timer to fire multiple times
If the signal was fired slightly before the scheduled time, it would schedule itself again a couple ms in the future.
This commit is contained in:
parent
a4903eaefc
commit
9555b201fe
2 changed files with 58 additions and 30 deletions
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <qdatetime.h>
|
||||
#include <qobject.h>
|
||||
#include <qqmlintegration.h>
|
||||
#include <qtimer.h>
|
||||
|
@ -49,7 +50,7 @@ signals:
|
|||
void secondsChanged();
|
||||
|
||||
private slots:
|
||||
void update();
|
||||
void onTimeout();
|
||||
|
||||
private:
|
||||
bool mEnabled = true;
|
||||
|
@ -58,6 +59,11 @@ private:
|
|||
quint32 mMinutes = 0;
|
||||
quint32 mSeconds = 0;
|
||||
QTimer timer;
|
||||
QTime nextTime;
|
||||
|
||||
void update();
|
||||
void setTime(QTime time);
|
||||
void schedule(QTime floor);
|
||||
|
||||
DECLARE_PRIVATE_MEMBER(SystemClock, hours, setHours, mHours, hoursChanged);
|
||||
DECLARE_PRIVATE_MEMBER(SystemClock, minutes, setMinutes, mMinutes, minutesChanged);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue