mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
modify datetime plugin
Change-Id: Id37812646bcaf307d98e80ac75567fe013ee886a
This commit is contained in:
parent
0cb6de3926
commit
352a7cc426
@ -4,7 +4,7 @@ include(../../interfaces/interfaces.pri)
|
||||
QT += widgets svg
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin c++11 link_pkgconfig
|
||||
PKGCONFIG += dtkwidget dtkbase
|
||||
PKGCONFIG +=
|
||||
|
||||
TARGET = $$qtLibraryTarget(datetime)
|
||||
DESTDIR = $$_PRO_FILE_PWD_/../
|
||||
|
@ -1,17 +1,16 @@
|
||||
#include "datetimeplugin.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
DatetimePlugin::DatetimePlugin(QObject *parent)
|
||||
: QObject(parent),
|
||||
|
||||
m_calendar(new DCalendar(nullptr)),
|
||||
m_dateTipsLabel(new QLabel),
|
||||
|
||||
m_refershTimer(new QTimer(this))
|
||||
{
|
||||
m_calendar->setFixedSize(300, 300);
|
||||
m_calendar->setDateInfoVisible(true);
|
||||
m_calendar->setControlPanelVisible(false);
|
||||
m_calendar->setSolarDisplayFormat(tr("MM/dd/yyyy"));
|
||||
m_calendar->setLunarVisible(QLocale::system().name().startsWith("zh_"));
|
||||
m_dateTipsLabel->setStyleSheet("color:white;"
|
||||
"padding:6px 10px;");
|
||||
|
||||
m_refershTimer->setInterval(1000);
|
||||
m_refershTimer->start();
|
||||
@ -24,7 +23,7 @@ DatetimePlugin::DatetimePlugin(QObject *parent)
|
||||
DatetimePlugin::~DatetimePlugin()
|
||||
{
|
||||
delete m_centeralWidget;
|
||||
delete m_calendar;
|
||||
delete m_dateTipsLabel;
|
||||
}
|
||||
|
||||
const QString DatetimePlugin::pluginName() const
|
||||
@ -70,14 +69,23 @@ QWidget *DatetimePlugin::itemTipsWidget(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
m_calendar->setCurrentDate(QDate::currentDate());
|
||||
return m_dateTipsLabel;
|
||||
}
|
||||
|
||||
return m_calendar;
|
||||
const QString DatetimePlugin::itemCommand(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
return "dde-calendar";
|
||||
}
|
||||
|
||||
void DatetimePlugin::updateCurrentTimeString()
|
||||
{
|
||||
const QString currentString = QTime::currentTime().toString("mm");
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
|
||||
m_dateTipsLabel->setText(currentDateTime.toString(tr("MM/dd/yyyy ddd HH:mm:ss")));
|
||||
|
||||
const QString currentString = currentDateTime.toString("mm");
|
||||
|
||||
if (currentString == m_currentTimeString)
|
||||
return;
|
||||
|
@ -5,10 +5,7 @@
|
||||
#include "datetimewidget.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <dcalendar.h>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
#include <QLabel>
|
||||
|
||||
class DatetimePlugin : public QObject, PluginsItemInterface
|
||||
{
|
||||
@ -30,12 +27,14 @@ public:
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
QWidget *itemTipsWidget(const QString &itemKey);
|
||||
|
||||
const QString itemCommand(const QString &itemKey);
|
||||
|
||||
private slots:
|
||||
void updateCurrentTimeString();
|
||||
|
||||
private:
|
||||
DatetimeWidget *m_centeralWidget;
|
||||
DCalendar *m_calendar;
|
||||
QLabel *m_dateTipsLabel;
|
||||
|
||||
QTimer *m_refershTimer;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user