KDEGames

kgameclock.h
1 /*
2  This file is part of the KDE games library
3  SPDX-FileCopyrightText: 2007 Mauricio Piacentini <[email protected]>
4  Portions reused from KGameLCDClock
5  SPDX-FileCopyrightText: 2001, 2002, 2003 Nicolas Hadacek <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-only
8 */
9 
10 #ifndef __KGAMECLOCK_H
11 #define __KGAMECLOCK_H
12 
13 // own
14 #include <libkdegames_export.h>
15 // Qt
16 #include <QObject>
17 // Std
18 #include <memory>
19 
20 class KGameClockPrivate;
21 
22 /**
23  * \class KGameClock kgameclock.h <KGameClock>
24  *
25  * Class representing a game clock, wraps after 24 hours
26  */
27 class KDEGAMES_EXPORT KGameClock : public QObject
28 {
29  Q_OBJECT
30 public:
31  enum ClockType { HourMinSec = 0, MinSecOnly };
32 
33  /**
34  * @return Constructor
35  */
36  explicit KGameClock(QObject *parent = nullptr, ClockType clocktype = HourMinSec);
37 
38  ~KGameClock() override;
39 
40  /**
41  * @return the total number of seconds elapsed.
42  */
43  uint seconds() const;
44 
45  /**
46  * @return the time as a string to be displayed: "mm:ss" or "hh:mm:ss" depending on clock type.
47  */
48  QString timeString() const;
49 
50  /**
51  * Set the time.
52  */
53  void setTime(uint seconds);
54 
55  /**
56  * Set the time (format should be "hh:mm:ss").
57  */
58  void setTime(const QString &s);
59 
60  /**
61  * Refresh
62  */
63  void showTime();
64 
65 Q_SIGNALS:
66  void timeChanged(const QString &);
67 
68 public Q_SLOTS:
69  /**
70  * Reset the clock and start again from zero
71  */
72  virtual void restart();
73 
74  /**
75  * Pause the clock
76  */
77  virtual void pause();
78 
79  /**
80  * Resume counting time from the current position
81  */
82  virtual void resume();
83 
84 protected Q_SLOTS:
85  virtual void timeoutClock();
86 
87 private:
88  friend class KGameClockPrivate;
89  std::unique_ptr<KGameClockPrivate> const d;
90 
92 };
93 
94 #endif
Q_DISABLE_COPY(Class)
Class representing a game clock, wraps after 24 hours.
Definition: kgameclock.h:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Dec 7 2021 22:34:14 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.