KGameClock Class
Class representing a game clock. More...
| Header: | #include <KGameClock> |
| Inherits: | QObject |
Public Types
| enum | ClockType { HourMinSec, MinSecOnly, FlexibleHourMinSec, LongMinSec } |
Public Functions
| KGameClock(QObject *parent = nullptr, KGameClock::ClockType clocktype = HourMinSec) | |
| uint | seconds() const |
| void | setTime(const QString &s) |
| void | setTime(uint seconds) |
| void | showTime() |
| QString | timeString() const |
Public Slots
Signals
| void | timeChanged(const QString &) |
Protected Slots
| virtual void | timeoutClock() |
Detailed Description
This class represents a game clock.
Member Type Documentation
enum KGameClock::ClockType
Controls the format of the return value of timeString().
| Format | Example1 | Example2 |
|---|---|---|
| HourMinSec | 00:04:05 | 01:02:03 |
| MinSecOnly | 04:05 | 02:03 |
| FlexibleHourMinSec | 04:05 | 01:02:03 |
| LongMinSec | 04:05 | 62:03 |
| Constant | Value | Description |
|---|---|---|
KGameClock::HourMinSec | 0 | Time in hours, minutes, and seconds. |
KGameClock::MinSecOnly | 1 | Time in minutes and seconds, minus any hours. |
KGameClock::FlexibleHourMinSec (since 22.04) | 2 | Time in minutes and seconds, with hours if necessary. |
KGameClock::LongMinSec (since 22.04) | 3 | Time in total minutes and seconds. |
Member Function Documentation
[explicit] KGameClock::KGameClock(QObject *parent = nullptr, KGameClock::ClockType clocktype = HourMinSec)
Constructs a KGameClock with parent, clocktype.
[virtual slot] void KGameClock::pause()
Pauses the clock.
[virtual slot] void KGameClock::restart()
Resets the clock and starts again from zero.
[virtual slot] void KGameClock::resume()
Resumes counting time from the current position.
uint KGameClock::seconds() const
Returns the total number of seconds elapsed.
void KGameClock::setTime(const QString &s)
Sets the time to s, format should be "hh:mm:ss" (or "mm:ss" since 22.04).
void KGameClock::setTime(uint seconds)
Sets the time to seconds.
void KGameClock::showTime()
Refreshes the time by emitting timeChanged.
[signal] void KGameClock::timeChanged(const QString &)
When showTime() is called, emits the value of timeString().
QString KGameClock::timeString() const
Returns the time as a string to be displayed: "mm:ss" or "hh:mm:ss" depending on clock type.