optimize datetime plugin on fashion mode

Change-Id: I51389dcf35384964f5ecfbfbdc2390e797343c60
This commit is contained in:
石博文 2016-06-27 15:34:54 +08:00 committed by Hualet Wang
parent af16b0c136
commit 4145d6343e
35 changed files with 64 additions and 5 deletions

View File

@ -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);

View File

@ -19,3 +19,6 @@ SOURCES += \
target.path = $${PREFIX}/lib/dde-dock/plugins/
INSTALLS += target
RESOURCES += \
resources.qrc

View File

@ -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();
}

View File

@ -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

View File

@ -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());
}

View 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B