mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add calendar
Change-Id: Ic50f6cfb7efdb5b424d9c0b4a04beb682b2737bc
This commit is contained in:
parent
38f6fc0818
commit
dd20d77e3f
@ -172,7 +172,7 @@ const QString DockItem::contextMenu() const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *DockItem::popupTips() const
|
QWidget *DockItem::popupTips()
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ protected:
|
|||||||
void showPopupTips();
|
void showPopupTips();
|
||||||
virtual void invokedMenuItem(const QString &itemId, const bool checked);
|
virtual void invokedMenuItem(const QString &itemId, const bool checked);
|
||||||
virtual const QString contextMenu() const;
|
virtual const QString contextMenu() const;
|
||||||
virtual QWidget *popupTips() const;
|
virtual QWidget *popupTips();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QPoint popupMarkPoint();
|
const QPoint popupMarkPoint();
|
||||||
|
@ -17,13 +17,18 @@ PluginsItem::PluginsItem(PluginsItemInterface* const pluginInter, const QString
|
|||||||
: DockItem(Plugins, parent),
|
: DockItem(Plugins, parent),
|
||||||
m_pluginInter(pluginInter),
|
m_pluginInter(pluginInter),
|
||||||
m_itemKey(itemKey),
|
m_itemKey(itemKey),
|
||||||
m_draging(false)
|
m_draging(false),
|
||||||
|
m_simpleTips(new QLabel(this))
|
||||||
{
|
{
|
||||||
m_pluginType = pluginInter->pluginType(itemKey);
|
m_pluginType = pluginInter->pluginType(itemKey);
|
||||||
|
|
||||||
if (m_pluginType == PluginsItemInterface::Simple)
|
if (m_pluginType == PluginsItemInterface::Simple)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_simpleTips->setAlignment(Qt::AlignCenter);
|
||||||
|
m_simpleTips->setStyleSheet("color:white;"
|
||||||
|
"font-size:12px;");
|
||||||
|
|
||||||
// construct complex widget layout
|
// construct complex widget layout
|
||||||
QWidget *centeralWidget = m_pluginInter->itemWidget(itemKey);
|
QWidget *centeralWidget = m_pluginInter->itemWidget(itemKey);
|
||||||
Q_ASSERT(centeralWidget);
|
Q_ASSERT(centeralWidget);
|
||||||
@ -133,6 +138,19 @@ QSize PluginsItem::sizeHint() const
|
|||||||
return QSize(24, 24);
|
return QSize(24, 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget *PluginsItem::popupTips()
|
||||||
|
{
|
||||||
|
if (m_pluginInter->tipsType(m_itemKey) == PluginsItemInterface::Complex)
|
||||||
|
return m_pluginInter->itemTipsWidget(m_itemKey);
|
||||||
|
|
||||||
|
const QString tips = m_pluginInter->itemTipsString(m_itemKey);
|
||||||
|
if (tips.isEmpty())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
m_simpleTips->setText(tips);
|
||||||
|
return m_simpleTips;
|
||||||
|
}
|
||||||
|
|
||||||
void PluginsItem::startDrag()
|
void PluginsItem::startDrag()
|
||||||
{
|
{
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
|
@ -23,6 +23,8 @@ private:
|
|||||||
bool eventFilter(QObject *o, QEvent *e);
|
bool eventFilter(QObject *o, QEvent *e);
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
|
|
||||||
|
QWidget *popupTips();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startDrag();
|
void startDrag();
|
||||||
void mouseClicked();
|
void mouseClicked();
|
||||||
@ -33,6 +35,7 @@ private:
|
|||||||
PluginsItemInterface::ItemType m_pluginType;
|
PluginsItemInterface::ItemType m_pluginType;
|
||||||
|
|
||||||
bool m_draging;
|
bool m_draging;
|
||||||
|
QLabel *m_simpleTips;
|
||||||
|
|
||||||
static QPoint MousePressPoint;
|
static QPoint MousePressPoint;
|
||||||
};
|
};
|
||||||
|
@ -38,8 +38,10 @@ public:
|
|||||||
|
|
||||||
// if pluginType is complex widget mode, return a widget to plugins item
|
// if pluginType is complex widget mode, return a widget to plugins item
|
||||||
virtual QWidget *itemWidget(const QString &itemKey) {Q_UNUSED(itemKey); return nullptr;}
|
virtual QWidget *itemWidget(const QString &itemKey) {Q_UNUSED(itemKey); return nullptr;}
|
||||||
|
virtual QWidget *itemTipsWidget(const QString &itemKey) {Q_UNUSED(itemKey); return nullptr;}
|
||||||
// if pluginType is simple icon mode, plugins need to implements these data source functions
|
// if pluginType is simple icon mode, plugins need to implements these data source functions
|
||||||
virtual const QIcon itemIcon(const QString &itemKey) {Q_UNUSED(itemKey); return QIcon();}
|
virtual const QIcon itemIcon(const QString &itemKey) {Q_UNUSED(itemKey); return QIcon();}
|
||||||
|
virtual const QString itemTipsString(const QString &itemKey) {Q_UNUSED(itemKey); return QString();}
|
||||||
virtual const QString itemCommand(const QString &itemKey) {Q_UNUSED(itemKey); return QString();}
|
virtual const QString itemCommand(const QString &itemKey) {Q_UNUSED(itemKey); return QString();}
|
||||||
|
|
||||||
// return simple string tips, call this function when tips type is Simple
|
// return simple string tips, call this function when tips type is Simple
|
||||||
|
@ -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 +=
|
PKGCONFIG += dtkwidget dtkbase
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(datetime)
|
TARGET = $$qtLibraryTarget(datetime)
|
||||||
DESTDIR = $$_PRO_FILE_PWD_/../
|
DESTDIR = $$_PRO_FILE_PWD_/../
|
||||||
|
@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
DatetimePlugin::DatetimePlugin(QObject *parent)
|
DatetimePlugin::DatetimePlugin(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
|
|
||||||
|
m_calendar(new DCalendar(nullptr)),
|
||||||
|
|
||||||
m_refershTimer(new QTimer(this))
|
m_refershTimer(new QTimer(this))
|
||||||
{
|
{
|
||||||
|
m_calendar->setFixedSize(300, 300);
|
||||||
|
|
||||||
m_refershTimer->setInterval(1000);
|
m_refershTimer->setInterval(1000);
|
||||||
m_refershTimer->start();
|
m_refershTimer->start();
|
||||||
|
|
||||||
@ -29,6 +34,13 @@ PluginsItemInterface::ItemType DatetimePlugin::pluginType(const QString &itemKey
|
|||||||
return Complex;
|
return Complex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PluginsItemInterface::ItemType DatetimePlugin::tipsType(const QString &itemKey)
|
||||||
|
{
|
||||||
|
Q_UNUSED(itemKey);
|
||||||
|
|
||||||
|
return Complex;
|
||||||
|
}
|
||||||
|
|
||||||
void DatetimePlugin::init(PluginProxyInterface *proxyInter)
|
void DatetimePlugin::init(PluginProxyInterface *proxyInter)
|
||||||
{
|
{
|
||||||
m_proxyInter = proxyInter;
|
m_proxyInter = proxyInter;
|
||||||
@ -49,6 +61,13 @@ QWidget *DatetimePlugin::itemWidget(const QString &itemKey)
|
|||||||
return m_centeralWidget;
|
return m_centeralWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget *DatetimePlugin::itemTipsWidget(const QString &itemKey)
|
||||||
|
{
|
||||||
|
Q_UNUSED(itemKey);
|
||||||
|
|
||||||
|
return m_calendar;
|
||||||
|
}
|
||||||
|
|
||||||
void DatetimePlugin::updateCurrentTimeString()
|
void DatetimePlugin::updateCurrentTimeString()
|
||||||
{
|
{
|
||||||
const QString currentString = QTime::currentTime().toString("mm");
|
const QString currentString = QTime::currentTime().toString("mm");
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <dcalendar.h>
|
||||||
|
|
||||||
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
class DatetimePlugin : public QObject, PluginsItemInterface
|
class DatetimePlugin : public QObject, PluginsItemInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -18,17 +22,21 @@ public:
|
|||||||
|
|
||||||
const QString pluginName() const;
|
const QString pluginName() const;
|
||||||
ItemType pluginType(const QString &itemKey);
|
ItemType pluginType(const QString &itemKey);
|
||||||
|
ItemType tipsType(const QString &itemKey);
|
||||||
void init(PluginProxyInterface *proxyInter);
|
void init(PluginProxyInterface *proxyInter);
|
||||||
|
|
||||||
int itemSortKey(const QString &itemKey) const;
|
int itemSortKey(const QString &itemKey) const;
|
||||||
|
|
||||||
QWidget *itemWidget(const QString &itemKey);
|
QWidget *itemWidget(const QString &itemKey);
|
||||||
|
QWidget *itemTipsWidget(const QString &itemKey);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateCurrentTimeString();
|
void updateCurrentTimeString();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DatetimeWidget *m_centeralWidget;
|
DatetimeWidget *m_centeralWidget;
|
||||||
|
DCalendar *m_calendar;
|
||||||
|
|
||||||
QTimer *m_refershTimer;
|
QTimer *m_refershTimer;
|
||||||
|
|
||||||
QString m_currentTimeString;
|
QString m_currentTimeString;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user