mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +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();
|
||||
}
|
||||
|
||||
QWidget *DockItem::popupTips() const
|
||||
QWidget *DockItem::popupTips()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ protected:
|
||||
void showPopupTips();
|
||||
virtual void invokedMenuItem(const QString &itemId, const bool checked);
|
||||
virtual const QString contextMenu() const;
|
||||
virtual QWidget *popupTips() const;
|
||||
virtual QWidget *popupTips();
|
||||
|
||||
private:
|
||||
const QPoint popupMarkPoint();
|
||||
|
@ -17,13 +17,18 @@ PluginsItem::PluginsItem(PluginsItemInterface* const pluginInter, const QString
|
||||
: DockItem(Plugins, parent),
|
||||
m_pluginInter(pluginInter),
|
||||
m_itemKey(itemKey),
|
||||
m_draging(false)
|
||||
m_draging(false),
|
||||
m_simpleTips(new QLabel(this))
|
||||
{
|
||||
m_pluginType = pluginInter->pluginType(itemKey);
|
||||
|
||||
if (m_pluginType == PluginsItemInterface::Simple)
|
||||
return;
|
||||
|
||||
m_simpleTips->setAlignment(Qt::AlignCenter);
|
||||
m_simpleTips->setStyleSheet("color:white;"
|
||||
"font-size:12px;");
|
||||
|
||||
// construct complex widget layout
|
||||
QWidget *centeralWidget = m_pluginInter->itemWidget(itemKey);
|
||||
Q_ASSERT(centeralWidget);
|
||||
@ -133,6 +138,19 @@ QSize PluginsItem::sizeHint() const
|
||||
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()
|
||||
{
|
||||
QPixmap pixmap;
|
||||
|
@ -23,6 +23,8 @@ private:
|
||||
bool eventFilter(QObject *o, QEvent *e);
|
||||
QSize sizeHint() const;
|
||||
|
||||
QWidget *popupTips();
|
||||
|
||||
private:
|
||||
void startDrag();
|
||||
void mouseClicked();
|
||||
@ -33,6 +35,7 @@ private:
|
||||
PluginsItemInterface::ItemType m_pluginType;
|
||||
|
||||
bool m_draging;
|
||||
QLabel *m_simpleTips;
|
||||
|
||||
static QPoint MousePressPoint;
|
||||
};
|
||||
|
@ -38,8 +38,10 @@ public:
|
||||
|
||||
// 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 *itemTipsWidget(const QString &itemKey) {Q_UNUSED(itemKey); return nullptr;}
|
||||
// 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 QString itemTipsString(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
|
||||
|
@ -4,7 +4,7 @@ include(../../interfaces/interfaces.pri)
|
||||
QT += widgets svg
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin c++11 link_pkgconfig
|
||||
PKGCONFIG +=
|
||||
PKGCONFIG += dtkwidget dtkbase
|
||||
|
||||
TARGET = $$qtLibraryTarget(datetime)
|
||||
DESTDIR = $$_PRO_FILE_PWD_/../
|
||||
|
@ -2,8 +2,13 @@
|
||||
|
||||
DatetimePlugin::DatetimePlugin(QObject *parent)
|
||||
: QObject(parent),
|
||||
|
||||
m_calendar(new DCalendar(nullptr)),
|
||||
|
||||
m_refershTimer(new QTimer(this))
|
||||
{
|
||||
m_calendar->setFixedSize(300, 300);
|
||||
|
||||
m_refershTimer->setInterval(1000);
|
||||
m_refershTimer->start();
|
||||
|
||||
@ -29,6 +34,13 @@ PluginsItemInterface::ItemType DatetimePlugin::pluginType(const QString &itemKey
|
||||
return Complex;
|
||||
}
|
||||
|
||||
PluginsItemInterface::ItemType DatetimePlugin::tipsType(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
return Complex;
|
||||
}
|
||||
|
||||
void DatetimePlugin::init(PluginProxyInterface *proxyInter)
|
||||
{
|
||||
m_proxyInter = proxyInter;
|
||||
@ -49,6 +61,13 @@ QWidget *DatetimePlugin::itemWidget(const QString &itemKey)
|
||||
return m_centeralWidget;
|
||||
}
|
||||
|
||||
QWidget *DatetimePlugin::itemTipsWidget(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
return m_calendar;
|
||||
}
|
||||
|
||||
void DatetimePlugin::updateCurrentTimeString()
|
||||
{
|
||||
const QString currentString = QTime::currentTime().toString("mm");
|
||||
|
@ -6,6 +6,10 @@
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <dcalendar.h>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
class DatetimePlugin : public QObject, PluginsItemInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -18,17 +22,21 @@ public:
|
||||
|
||||
const QString pluginName() const;
|
||||
ItemType pluginType(const QString &itemKey);
|
||||
ItemType tipsType(const QString &itemKey);
|
||||
void init(PluginProxyInterface *proxyInter);
|
||||
|
||||
int itemSortKey(const QString &itemKey) const;
|
||||
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
QWidget *itemTipsWidget(const QString &itemKey);
|
||||
|
||||
private slots:
|
||||
void updateCurrentTimeString();
|
||||
|
||||
private:
|
||||
DatetimeWidget *m_centeralWidget;
|
||||
DCalendar *m_calendar;
|
||||
|
||||
QTimer *m_refershTimer;
|
||||
|
||||
QString m_currentTimeString;
|
||||
|
Loading…
x
Reference in New Issue
Block a user