forked from sonichy/dde-dock-datetime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
datetimewidget.h
61 lines (50 loc) · 1.53 KB
/
datetimewidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
*
* Author: sbw <[email protected]>
*
* Maintainer: sbw <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DATETIMEWIDGET_H
#define DATETIMEWIDGET_H
#include <QWidget>
#include <QSettings>
class DatetimeWidget : public QWidget
{
Q_OBJECT
public:
explicit DatetimeWidget(QWidget *parent = 0);
bool is24HourFormat() const { return m_24HourFormat; }
bool enabled();
void setEnabled(const bool b);
signals:
void requestUpdateGeometry() const;
void requestContextMenu() const;
public slots:
void toggleHourFormat();
void toggleClock();
private:
QSize sizeHint() const;
void resizeEvent(QResizeEvent *e);
void paintEvent(QPaintEvent *e);
const QPixmap loadSvg(const QString &fileName, const QSize size);
private:
QPixmap m_cachedIcon;
QString m_cachedTime;
QSettings m_settings;
bool m_24HourFormat;
};
#endif // DATETIMEWIDGET_H