optimize datetime plugin on fashion mode
Change-Id: I51389dcf35384964f5ecfbfbdc2390e797343c60
@ -34,7 +34,9 @@ DockSettings::DockSettings(QObject *parent)
|
||||
m_iconSize = m_dockInter->iconSize();
|
||||
AppItem::setIconBaseSize(m_iconSize);
|
||||
DockItem::setDockPosition(m_position);
|
||||
qApp->setProperty(PROP_POSITION, QVariant::fromValue(m_position));
|
||||
DockItem::setDockDisplayMode(m_displayMode);
|
||||
qApp->setProperty(PROP_DISPLAY_MODE, QVariant::fromValue(m_displayMode));
|
||||
|
||||
m_fashionModeAct.setCheckable(true);
|
||||
m_efficientModeAct.setCheckable(true);
|
||||
|
@ -19,3 +19,6 @@ SOURCES += \
|
||||
|
||||
target.path = $${PREFIX}/lib/dde-dock/plugins/
|
||||
INSTALLS += target
|
||||
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
|
@ -9,7 +9,7 @@ DatetimePlugin::DatetimePlugin(QObject *parent)
|
||||
|
||||
m_centeralWidget = new DatetimeWidget;
|
||||
|
||||
connect(m_refershTimer, &QTimer::timeout, m_centeralWidget, static_cast<void (DatetimeWidget::*)()>(&DatetimeWidget::update));
|
||||
connect(m_refershTimer, &QTimer::timeout, this, &DatetimePlugin::updateCurrentTimeString);
|
||||
}
|
||||
|
||||
DatetimePlugin::~DatetimePlugin()
|
||||
@ -41,3 +41,14 @@ QWidget *DatetimePlugin::itemWidget(const QString &itemKey)
|
||||
|
||||
return m_centeralWidget;
|
||||
}
|
||||
|
||||
void DatetimePlugin::updateCurrentTimeString()
|
||||
{
|
||||
const QString currentString = QTime::currentTime().toString("mm");
|
||||
|
||||
if (currentString == m_currentTimeString)
|
||||
return;
|
||||
|
||||
m_currentTimeString = currentString;
|
||||
m_centeralWidget->update();
|
||||
}
|
||||
|
@ -22,9 +22,14 @@ public:
|
||||
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
|
||||
private slots:
|
||||
void updateCurrentTimeString();
|
||||
|
||||
private:
|
||||
DatetimeWidget *m_centeralWidget;
|
||||
QTimer *m_refershTimer;
|
||||
|
||||
QString m_currentTimeString;
|
||||
};
|
||||
|
||||
#endif // DATETIMEPLUGIN_H
|
||||
|
@ -23,16 +23,29 @@ void DatetimeWidget::paintEvent(QPaintEvent *e)
|
||||
Q_UNUSED(e);
|
||||
|
||||
const Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
|
||||
const QDateTime current = QDateTime::currentDateTime();
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
if (displayMode == Dock::Efficient)
|
||||
{
|
||||
painter.setPen(Qt::white);
|
||||
painter.drawText(rect(), Qt::AlignCenter, "88:88");
|
||||
painter.drawText(rect(), Qt::AlignCenter, current.toString(tr("HH:mm")));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
// draw fashion mode datetime plugin
|
||||
const int perfectIconSize = qMin(width(), height()) * 0.8;
|
||||
const QString currentTimeString = current.toString("HHmmss");
|
||||
|
||||
QPixmap pixmap(":/icons/resources/icons/panel.png");
|
||||
QPainter itemPainter(&pixmap);
|
||||
itemPainter.drawPixmap(8, 15, QPixmap(QString(":/icons/resources/icons/big%1.png").arg(currentTimeString[0])));
|
||||
itemPainter.drawPixmap(18, 15, QPixmap(QString(":/icons/resources/icons/big%1.png").arg(currentTimeString[1])));
|
||||
itemPainter.drawPixmap(28, 24, QPixmap(QString(":/icons/resources/icons/small%1.png").arg(currentTimeString[2])));
|
||||
itemPainter.drawPixmap(34, 24, QPixmap(QString(":/icons/resources/icons/small%1.png").arg(currentTimeString[3])));
|
||||
itemPainter.end();
|
||||
|
||||
pixmap = pixmap.scaled(perfectIconSize, perfectIconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
painter.drawPixmap(rect().center() - pixmap.rect().center(), pixmap, pixmap.rect());
|
||||
}
|
||||
|
25
plugins/datetime/resources.qrc
Normal file
@ -0,0 +1,25 @@
|
||||
<RCC>
|
||||
<qresource prefix="/icons">
|
||||
<file>resources/icons/panel.png</file>
|
||||
<file>resources/icons/big0.png</file>
|
||||
<file>resources/icons/big1.png</file>
|
||||
<file>resources/icons/big2.png</file>
|
||||
<file>resources/icons/big3.png</file>
|
||||
<file>resources/icons/big4.png</file>
|
||||
<file>resources/icons/big5.png</file>
|
||||
<file>resources/icons/big6.png</file>
|
||||
<file>resources/icons/big7.png</file>
|
||||
<file>resources/icons/big8.png</file>
|
||||
<file>resources/icons/big9.png</file>
|
||||
<file>resources/icons/small0.png</file>
|
||||
<file>resources/icons/small1.png</file>
|
||||
<file>resources/icons/small2.png</file>
|
||||
<file>resources/icons/small3.png</file>
|
||||
<file>resources/icons/small4.png</file>
|
||||
<file>resources/icons/small5.png</file>
|
||||
<file>resources/icons/small6.png</file>
|
||||
<file>resources/icons/small7.png</file>
|
||||
<file>resources/icons/small8.png</file>
|
||||
<file>resources/icons/small9.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
BIN
plugins/datetime/resources/icons/am.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/big0.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/big1.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/big2.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/big3.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/big4.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/big5.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/big6.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/big7.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/big8.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/big9.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/dail.png
Normal file
After Width: | Height: | Size: 243 B |
BIN
plugins/datetime/resources/icons/hour_hand.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/datetime/resources/icons/hour_hand_with_shadow.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
plugins/datetime/resources/icons/minute_hand.png
Normal file
After Width: | Height: | Size: 191 B |
BIN
plugins/datetime/resources/icons/minute_hand_with_shadow.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
plugins/datetime/resources/icons/panel.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
plugins/datetime/resources/icons/pm.png
Normal file
After Width: | Height: | Size: 164 B |
BIN
plugins/datetime/resources/icons/point.png
Normal file
After Width: | Height: | Size: 237 B |
BIN
plugins/datetime/resources/icons/small0.png
Normal file
After Width: | Height: | Size: 174 B |
BIN
plugins/datetime/resources/icons/small1.png
Normal file
After Width: | Height: | Size: 152 B |
BIN
plugins/datetime/resources/icons/small2.png
Normal file
After Width: | Height: | Size: 173 B |
BIN
plugins/datetime/resources/icons/small3.png
Normal file
After Width: | Height: | Size: 168 B |
BIN
plugins/datetime/resources/icons/small4.png
Normal file
After Width: | Height: | Size: 163 B |
BIN
plugins/datetime/resources/icons/small5.png
Normal file
After Width: | Height: | Size: 173 B |
BIN
plugins/datetime/resources/icons/small6.png
Normal file
After Width: | Height: | Size: 168 B |
BIN
plugins/datetime/resources/icons/small7.png
Normal file
After Width: | Height: | Size: 155 B |
BIN
plugins/datetime/resources/icons/small8.png
Normal file
After Width: | Height: | Size: 184 B |
BIN
plugins/datetime/resources/icons/small9.png
Normal file
After Width: | Height: | Size: 172 B |