Cute Chess 0.1
chessclock.h
1/*
2 This file is part of Cute Chess.
3 Copyright (C) 2008-2018 Cute Chess authors
4
5 Cute Chess is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Cute Chess is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef CHESSCLOCK_H
20#define CHESSCLOCK_H
21
22#include <QWidget>
23#include <QTime>
24
25class QTimerEvent;
26class QLabel;
27
28class ChessClock: public QWidget
29{
30 Q_OBJECT
31
32 public:
33 ChessClock(QWidget* parent = nullptr);
34
35 public slots:
36 void setPlayerName(const QString& name);
37 void setInfiniteTime(bool infinite);
38 void setTime(int totalTime);
39 void start(int totalTime);
40 void stop();
41
42 protected:
43 virtual void timerEvent(QTimerEvent* event);
44
45 private:
46 void stopTimer();
47
48 int m_totalTime;
49 int m_timerId;
50 bool m_infiniteTime;
51 QTime m_time;
52 QLabel* m_nameLabel;
53 QLabel* m_timeLabel;
54 QPalette m_defaultPalette;
55};
56
57#endif // CHESSCLOCK