Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion applets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
# SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -7,3 +7,4 @@ add_subdirectory(dde-appearance)
add_subdirectory(dde-apps)
add_subdirectory(dde-key-notify)
add_subdirectory(dde-shutdown)
add_subdirectory(dde-weather)
27 changes: 27 additions & 0 deletions applets/dde-weather/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Network)

add_library(dde-weather SHARED
weatherapplet.h
weatherapplet.cpp
weathermodel.h
weathermodel.cpp
weatherhelper.h
weatherhelper.cpp
)

target_link_libraries(dde-weather PRIVATE
dde-shell-frame
Qt${QT_VERSION_MAJOR}::Network
)

find_package(Dtk${DTK_VERSION_MAJOR}DConfig REQUIRED)

dtk_add_config_meta_files(APPID "org.deepin.dde.shell" FILES configs/org.deepin.ds.weather.json)

ds_install_package(PACKAGE org.deepin.ds.weather TARGET dde-weather)

ds_handle_package_translation(PACKAGE org.deepin.ds.weather)
42 changes: 42 additions & 0 deletions applets/dde-weather/configs/org.deepin.ds.weather.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"city": {
"value": "auto",
"serial": 0,
"flags": [],
"name": "city name or 'auto' for auto detection",
"name[zh_CN]": "城市名称或'auto'自动检测",
"permissions": "readwrite",
"visibility": "public"
},
"refreshInterval": {
"value": 30,
"serial": 0,
"flags": [],
"name": "weather refresh interval in minutes",
"name[zh_CN]": "天气刷新间隔(分钟)",
"permissions": "readwrite",
"visibility": "public"
},
"temperatureUnit": {
"value": "celsius",
"serial": 0,
"flags": [],
"name": "temperature unit: celsius or fahrenheit",
"name[zh_CN]": "温度单位:摄氏度或华氏度",
"permissions": "readwrite",
"visibility": "public"
},
"showInDock": {
"value": true,
"serial": 0,
"flags": [],
"name": "show weather widget in dock",
"name[zh_CN]": "在任务栏显示天气小组件",
"permissions": "readwrite",
"visibility": "public"
}
}
}
120 changes: 120 additions & 0 deletions applets/dde-weather/package/WeatherDetail.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

import org.deepin.ds 1.0

Rectangle {
id: detail
color: Qt.rgba(0.15, 0.15, 0.15, 0.95)
radius: 12

ColumnLayout {
anchors.fill: parent
anchors.margins: 16
spacing: 12

RowLayout {
Layout.fillWidth: true
spacing: 12

Text {
text: Applet.weatherIcon || "☀"
font.pixelSize: 48
color: "white"
}

ColumnLayout {
Layout.fillWidth: true
spacing: 4

Text {
text: Applet.currentCity || qsTr("Unknown")
font.pixelSize: 18
font.bold: true
color: "white"
}

Text {
text: Applet.temperature + "°C"
font.pixelSize: 28
font.bold: true
color: "white"
}

Text {
text: Applet.weatherDesc || ""
font.pixelSize: 14
color: Qt.rgba(1, 1, 1, 0.7)
}
}
}

Rectangle {
Layout.fillWidth: true
height: 1
color: Qt.rgba(1, 1, 1, 0.1)
}

ListView {
Layout.fillWidth: true
Layout.fillHeight: true
model: Applet.model
spacing: 8
clip: true

delegate: RowLayout {
width: ListView.view.width
spacing: 12

Text {
text: model.icon || "☀"
font.pixelSize: 20
color: "white"
}

Text {
text: model.city || ""
font.pixelSize: 14
color: "white"
Layout.fillWidth: true
}

Text {
text: model.temperature + "°C"
font.pixelSize: 14
font.bold: true
color: "white"
}

Text {
text: model.description || ""
font.pixelSize: 12
color: Qt.rgba(1, 1, 1, 0.6)
}
}
}

RowLayout {
Layout.fillWidth: true
spacing: 8

Button {
text: qsTr("Refresh")
onClicked: Applet.refresh()
}

Item { Layout.fillWidth: true }

Text {
text: qsTr("Last update: --:--")
font.pixelSize: 11
color: Qt.rgba(1, 1, 1, 0.5)
}
}
}
}
84 changes: 84 additions & 0 deletions applets/dde-weather/package/main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

import org.deepin.ds 1.0

AppletItem {
id: root
objectName: "weather-applet"
implicitWidth: 200
implicitHeight: 100

property bool expanded: false

Rectangle {
anchors.fill: parent
radius: 8
color: Qt.rgba(1, 1, 1, 0.1)

ColumnLayout {
anchors.centerIn: parent
spacing: 4

Text {
Layout.alignment: Qt.AlignHCenter
text: Applet.weatherIcon || "☀"
font.pixelSize: 32
color: "white"
}

Text {
Layout.alignment: Qt.AlignHCenter
text: Applet.temperature + "°C"
font.pixelSize: 16
font.bold: true
color: "white"
}

Text {
Layout.alignment: Qt.AlignHCenter
text: Applet.currentCity || qsTr("Loading...")
font.pixelSize: 11
color: Qt.rgba(1, 1, 1, 0.7)
}
}

MouseArea {
anchors.fill: parent
onClicked: {
if (popup.visible) {
popup.close()
} else {
popup.open()
}
}
}
}

PanelPopup {
id: popup
x: -50
y: -320
width: 300
height: 300

WeatherDetail {
anchors.fill: parent
}
}

PanelToolTip {
id: toolTip
text: Applet.currentCity + " " + Applet.weatherDesc + " " + Applet.temperature + "°C"
visible: false
}

Component.onCompleted: {
Applet.refresh()
}
}
8 changes: 8 additions & 0 deletions applets/dde-weather/package/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Plugin": {
"Version": "1.0",
"Id": "org.deepin.ds.weather",
"Url": "main.qml",
"Category": "DDE"
}
}
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_ar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_az.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_bo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_ca.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_de.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_es.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_fi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_fr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_hu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_it.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_ja.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_ko.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_lo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_pl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_ru.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_sq.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
3 changes: 3 additions & 0 deletions applets/dde-weather/translations/org.deepin.ds.weather_uk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1"/>
Loading
Loading