Changeset View
Changeset View
Standalone View
Standalone View
lookandfeel/contents/components/Clock.qml
Show All 13 Lines | |||||
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.8 | 20 | import QtQuick 2.8 | ||
21 | import QtQuick.Layouts 1.1 | 21 | import QtQuick.Layouts 1.1 | ||
22 | import QtGraphicalEffects 1.0 | | |||
23 | 22 | | |||
24 | import org.kde.plasma.core 2.0 | 23 | import org.kde.plasma.core 2.0 | ||
25 | import org.kde.plasma.components 2.0 | 24 | import org.kde.plasma.components 2.0 | ||
26 | 25 | | |||
27 | Item { | 26 | ColumnLayout { | ||
28 | // If we're using software rendering, draw outlines instead of shadows | | |||
29 | // See https://bugs.kde.org/show_bug.cgi?id=398317 | | |||
30 | readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software | 27 | readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software | ||
31 | 28 | | |||
32 | width: clock.implicitWidth | | |||
33 | height: clock.implicitHeight | | |||
34 | | ||||
35 | DropShadow { | | |||
36 | id: clockShadow | | |||
37 | visible: !softwareRendering | | |||
38 | anchors.fill: clock | | |||
39 | source: clock | | |||
40 | horizontalOffset: 1 | | |||
41 | verticalOffset: 1 | | |||
42 | radius: 6 | | |||
43 | samples: 14 | | |||
44 | spread: 0.3 | | |||
45 | color: "black" // matches Breeze window decoration and desktopcontainment | | |||
46 | } | | |||
47 | | ||||
48 | ColumnLayout { | | |||
49 | id: clock | | |||
50 | Label { | 29 | Label { | ||
51 | text: Qt.formatTime(timeSource.data["Local"]["DateTime"]) | 30 | text: Qt.formatTime(timeSource.data["Local"]["DateTime"]) | ||
52 | style: softwareRendering ? Text.Outline : undefined | 31 | style: softwareRendering ? Text.Outline : undefined | ||
53 | styleColor: softwareRendering ? ColorScope.backgroundColor : undefined | 32 | styleColor: softwareRendering ? ColorScope.backgroundColor : undefined | ||
54 | font.pointSize: 48 | 33 | font.pointSize: 48 | ||
55 | Layout.alignment: Qt.AlignHCenter | 34 | Layout.alignment: Qt.AlignHCenter | ||
56 | } | 35 | } | ||
36 | | ||||
57 | Label { | 37 | Label { | ||
58 | text: Qt.formatDate(timeSource.data["Local"]["DateTime"], Qt.DefaultLocaleLongDate) | 38 | text: Qt.formatDate(timeSource.data["Local"]["DateTime"], Qt.DefaultLocaleLongDate) | ||
59 | style: softwareRendering ? Text.Outline : undefined | 39 | style: softwareRendering ? Text.Outline : undefined | ||
60 | styleColor: softwareRendering ? ColorScope.backgroundColor : undefined | 40 | styleColor: softwareRendering ? ColorScope.backgroundColor : undefined | ||
61 | font.pointSize: 24 | 41 | font.pointSize: 24 | ||
62 | Layout.alignment: Qt.AlignHCenter | 42 | Layout.alignment: Qt.AlignHCenter | ||
63 | } | 43 | } | ||
44 | | ||||
64 | DataSource { | 45 | DataSource { | ||
65 | id: timeSource | 46 | id: timeSource | ||
66 | engine: "time" | 47 | engine: "time" | ||
67 | connectedSources: ["Local"] | 48 | connectedSources: ["Local"] | ||
68 | interval: 1000 | 49 | interval: 1000 | ||
69 | } | 50 | } | ||
70 | } | 51 | } | ||
71 | } | |