mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +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
|
QT += widgets svg
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += plugin c++11 link_pkgconfig
|
CONFIG += plugin c++11 link_pkgconfig
|
||||||
PKGCONFIG += dtkwidget dtkbase
|
PKGCONFIG +=
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(datetime)
|
TARGET = $$qtLibraryTarget(datetime)
|
||||||
DESTDIR = $$_PRO_FILE_PWD_/../
|
DESTDIR = $$_PRO_FILE_PWD_/../
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
#include "datetimeplugin.h"
|
#include "datetimeplugin.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
DatetimePlugin::DatetimePlugin(QObject *parent)
|
DatetimePlugin::DatetimePlugin(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
|
|
||||||
m_calendar(new DCalendar(nullptr)),
|
m_dateTipsLabel(new QLabel),
|
||||||
|
|
||||||
m_refershTimer(new QTimer(this))
|
m_refershTimer(new QTimer(this))
|
||||||
{
|
{
|
||||||
m_calendar->setFixedSize(300, 300);
|
m_dateTipsLabel->setStyleSheet("color:white;"
|
||||||
m_calendar->setDateInfoVisible(true);
|
"padding:6px 10px;");
|
||||||
m_calendar->setControlPanelVisible(false);
|
|
||||||
m_calendar->setSolarDisplayFormat(tr("MM/dd/yyyy"));
|
|
||||||
m_calendar->setLunarVisible(QLocale::system().name().startsWith("zh_"));
|
|
||||||
|
|
||||||
m_refershTimer->setInterval(1000);
|
m_refershTimer->setInterval(1000);
|
||||||
m_refershTimer->start();
|
m_refershTimer->start();
|
||||||
@ -24,7 +23,7 @@ DatetimePlugin::DatetimePlugin(QObject *parent)
|
|||||||
DatetimePlugin::~DatetimePlugin()
|
DatetimePlugin::~DatetimePlugin()
|
||||||
{
|
{
|
||||||
delete m_centeralWidget;
|
delete m_centeralWidget;
|
||||||
delete m_calendar;
|
delete m_dateTipsLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString DatetimePlugin::pluginName() const
|
const QString DatetimePlugin::pluginName() const
|
||||||
@ -70,14 +69,23 @@ QWidget *DatetimePlugin::itemTipsWidget(const QString &itemKey)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(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()
|
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)
|
if (currentString == m_currentTimeString)
|
||||||
return;
|
return;
|
||||||
|
@ -5,10 +5,7 @@
|
|||||||
#include "datetimewidget.h"
|
#include "datetimewidget.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QLabel>
|
||||||
#include <dcalendar.h>
|
|
||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
|
||||||
|
|
||||||
class DatetimePlugin : public QObject, PluginsItemInterface
|
class DatetimePlugin : public QObject, PluginsItemInterface
|
||||||
{
|
{
|
||||||
@ -30,12 +27,14 @@ public:
|
|||||||
QWidget *itemWidget(const QString &itemKey);
|
QWidget *itemWidget(const QString &itemKey);
|
||||||
QWidget *itemTipsWidget(const QString &itemKey);
|
QWidget *itemTipsWidget(const QString &itemKey);
|
||||||
|
|
||||||
|
const QString itemCommand(const QString &itemKey);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateCurrentTimeString();
|
void updateCurrentTimeString();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DatetimeWidget *m_centeralWidget;
|
DatetimeWidget *m_centeralWidget;
|
||||||
DCalendar *m_calendar;
|
QLabel *m_dateTipsLabel;
|
||||||
|
|
||||||
QTimer *m_refershTimer;
|
QTimer *m_refershTimer;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user