2017-09-18 14:33:44 +08:00
|
|
|
/*
|
2018-02-07 11:52:47 +08:00
|
|
|
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
2017-09-18 14:33:44 +08:00
|
|
|
*
|
|
|
|
* Author: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* Maintainer: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2016-06-27 14:33:21 +08:00
|
|
|
#ifndef DATETIMEWIDGET_H
|
|
|
|
#define DATETIMEWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
2017-03-30 16:48:34 +08:00
|
|
|
#include <QSettings>
|
2016-06-27 14:33:21 +08:00
|
|
|
|
|
|
|
class DatetimeWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit DatetimeWidget(QWidget *parent = 0);
|
|
|
|
|
2017-03-30 16:48:34 +08:00
|
|
|
bool is24HourFormat() const { return m_24HourFormat; }
|
2017-10-23 13:36:16 +08:00
|
|
|
bool enabled();
|
|
|
|
void setEnabled(const bool b);
|
2017-03-30 16:48:34 +08:00
|
|
|
|
2016-09-21 10:24:42 +08:00
|
|
|
signals:
|
2017-06-26 15:20:16 +08:00
|
|
|
void requestUpdateGeometry() const;
|
2016-09-21 10:24:42 +08:00
|
|
|
void requestContextMenu() const;
|
|
|
|
|
2017-03-30 16:48:34 +08:00
|
|
|
public slots:
|
|
|
|
void toggleHourFormat();
|
|
|
|
|
2016-06-27 14:33:21 +08:00
|
|
|
private:
|
|
|
|
QSize sizeHint() const;
|
2016-08-19 10:19:38 +08:00
|
|
|
void resizeEvent(QResizeEvent *e);
|
2016-06-27 14:33:21 +08:00
|
|
|
void paintEvent(QPaintEvent *e);
|
2016-08-15 09:26:45 +08:00
|
|
|
void mousePressEvent(QMouseEvent *e);
|
2016-06-30 20:44:13 +08:00
|
|
|
|
|
|
|
const QPixmap loadSvg(const QString &fileName, const QSize size);
|
2016-08-19 10:19:38 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
QPixmap m_cachedIcon;
|
|
|
|
QString m_cachedTime;
|
2017-03-30 16:48:34 +08:00
|
|
|
QSettings m_settings;
|
|
|
|
bool m_24HourFormat;
|
2016-06-27 14:33:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DATETIMEWIDGET_H
|