mirror of https://github.com/procxx/kepka.git
Fix build in GCC.
GCC doesn't allow using scoped enums in bitfields without warnings. So we use "unsigned" bitfield and a couple of get/set methods.
This commit is contained in:
parent
38f94c63e9
commit
cd3c5e4ade
|
@ -33,8 +33,8 @@ QObject *TimersAdjuster() {
|
||||||
Timer::Timer(base::lambda<void()> callback) : QObject(nullptr)
|
Timer::Timer(base::lambda<void()> callback) : QObject(nullptr)
|
||||||
, _callback(std::move(callback))
|
, _callback(std::move(callback))
|
||||||
, _type(Qt::PreciseTimer)
|
, _type(Qt::PreciseTimer)
|
||||||
, _adjusted(false)
|
, _adjusted(false) {
|
||||||
, _repeat(Repeat::Interval) {
|
setRepeat(Repeat::Interval);
|
||||||
connect(TimersAdjuster(), &QObject::destroyed, this, [this] { adjust(); }, Qt::QueuedConnection);
|
connect(TimersAdjuster(), &QObject::destroyed, this, [this] { adjust(); }, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ void Timer::start(TimeMs timeout, Qt::TimerType type, Repeat repeat) {
|
||||||
cancel();
|
cancel();
|
||||||
|
|
||||||
_type = type;
|
_type = type;
|
||||||
_repeat = repeat;
|
setRepeat(repeat);
|
||||||
_adjusted = false;
|
_adjusted = false;
|
||||||
setTimeout(timeout);
|
setTimeout(timeout);
|
||||||
_timerId = startTimer(_timeout, _type);
|
_timerId = startTimer(_timeout, _type);
|
||||||
|
@ -91,9 +91,9 @@ int Timer::timeout() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer::timerEvent(QTimerEvent *e) {
|
void Timer::timerEvent(QTimerEvent *e) {
|
||||||
if (_repeat == Repeat::Interval) {
|
if (repeat() == Repeat::Interval) {
|
||||||
if (_adjusted) {
|
if (_adjusted) {
|
||||||
start(_timeout, _type, _repeat);
|
start(_timeout, _type, repeat());
|
||||||
} else {
|
} else {
|
||||||
_next = getms(true) + _timeout;
|
_next = getms(true) + _timeout;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ protected:
|
||||||
void timerEvent(QTimerEvent *e) override;
|
void timerEvent(QTimerEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class Repeat {
|
enum class Repeat : unsigned {
|
||||||
Interval = 0,
|
Interval = 0,
|
||||||
SingleShot = 1,
|
SingleShot = 1,
|
||||||
};
|
};
|
||||||
|
@ -77,6 +77,13 @@ private:
|
||||||
void setTimeout(TimeMs timeout);
|
void setTimeout(TimeMs timeout);
|
||||||
int timeout() const;
|
int timeout() const;
|
||||||
|
|
||||||
|
void setRepeat(Repeat repeat) {
|
||||||
|
_repeat = static_cast<unsigned>(repeat);
|
||||||
|
}
|
||||||
|
Repeat repeat() const {
|
||||||
|
return static_cast<Repeat>(_repeat);
|
||||||
|
}
|
||||||
|
|
||||||
base::lambda<void()> _callback;
|
base::lambda<void()> _callback;
|
||||||
TimeMs _next = 0;
|
TimeMs _next = 0;
|
||||||
int _timeout = 0;
|
int _timeout = 0;
|
||||||
|
@ -84,7 +91,7 @@ private:
|
||||||
|
|
||||||
Qt::TimerType _type : 2;
|
Qt::TimerType _type : 2;
|
||||||
bool _adjusted : 1;
|
bool _adjusted : 1;
|
||||||
Repeat _repeat : 1;
|
unsigned _repeat : 1;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,4 +112,4 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
Loading…
Reference in New Issue