[packaging] dde-shell-weather-plugin 任务栏天气插件龙芯版
Tofloor
poster avatar
lon
deepin
5 hours ago
Author

最近用旧的服务器顶对了台X86的台式机,老E5的机子,一些大点的活,用它试试

发现 X86 的版本有一个不错的小插件,任务栏天气插件,于是尝试在龙芯下编译,居然成功了,功能正常

改了少许代码,分横竖两版,任务栏上下,左右用不同的布局显示,因为我习惯左边任务栏,不同的任务栏方向,采用不同的布局

下面是改动的代码:

diff --git a/package/main.qml b/package/main.qml
index b552760..eac4dc8 100644
--- a/package/main.qml
+++ b/package/main.qml
@@ -444,100 +444,133 @@ AppletItem {
         readonly property int textColumnMaxWidth: Math.max(0,
                                                            root.horizontalAppletMaxWidth
                                                            - horizontalPadding
-                                                           - iconSlot.width
+                                                           - iconSlotH.width
                                                            - contentSpacing)
-        implicitWidth: horizontalPadding + iconSlot.width + contentSpacing
-                       + textColumn.implicitWidth
+        implicitWidth: root.useColumnLayout ? dockSize 
+                       : (horizontalPadding + iconSlotH.width + contentSpacing + textColumnH.implicitWidth)
   
-        // Left: Weather icon
-        Item {
-            id: iconSlot
-            anchors.left: parent.left
-            anchors.verticalCenter: parent.verticalCenter
-            width: Math.max(20, dockSize - 26)
-            height: parent.height
-
-            WeatherIcon {
-                id: weatherIcon
-                anchors.centerIn: parent
-                width: Math.min(parent.height, parent.width)
-                height: width
-                weatherCode: Applet.weather.weatherCode
-                iconNameOverride: Applet.weather.iconName
-                animationTrigger: Applet.weather.updateSerial
-                iconColor: themeColors.icon
-                loading: Applet.weather.isLoading
+        // 横向布局:上下任务栏 (图标 + 双行文本)
+        Row {
+            id: horizontalLayout
+            anchors.fill: parent
+            spacing: weatherSummary.contentSpacing
+            visible: !root.useColumnLayout
+
+            Item {
+                id: iconSlotH
+                anchors.verticalCenter: parent.verticalCenter
+                width: Math.max(20, dockSize - 26)
+                height: parent.height
+
+                WeatherIcon {
+                    anchors.centerIn: parent
+                    width: Math.min(parent.height, parent.width)
+                    height: width
+                    weatherCode: Applet.weather.weatherCode
+                    iconNameOverride: Applet.weather.iconName
+                    animationTrigger: Applet.weather.updateSerial
+                    iconColor: themeColors.icon
+                    loading: Applet.weather.isLoading
+                }
             }
-        }
-  
-        // Right: Two rows
-        ColumnLayout {
-            id: textColumn
-            anchors.left: iconSlot.right
-            // Keep a fixed visual gap from the icon's visible edge instead of
-            // relying on RowLayout spacing against the icon canvas width.
-            anchors.leftMargin: weatherSummary.contentSpacing
-            anchors.verticalCenter: parent.verticalCenter
-            spacing: 0
-      
-            // Row 1: Location + High/Low temp
-            RowLayout {
-                id: topRow
-                spacing: 4
-          
-                Text {
-                    id: cityLabel
-                    text: Applet.weather.city
-                    width: Math.min(implicitWidth,
-                                    Math.max(0,
-                                             weatherSummary.textColumnMaxWidth
-                                             - (tempRangeLabel.visible
-                                                    ? topRow.spacing + tempRangeLabel.implicitWidth
-                                                    : 0)))
-                    font.pixelSize: 10
-                    color: themeColors.secondaryText
-                    elide: Text.ElideRight
-                    visible: text.length > 0
+
+            ColumnLayout {
+                id: textColumnH
+                anchors.verticalCenter: parent.verticalCenter
+                spacing: 0
+
+                RowLayout {
+                    id: topRow
+                    spacing: 4
+
+                    Text {
+                        id: cityLabel
+                        text: Applet.weather.city
+                        width: Math.min(implicitWidth,
+                                        Math.max(0,
+                                                 weatherSummary.textColumnMaxWidth
+                                                 - (tempRangeLabel.visible
+                                                        ? topRow.spacing + tempRangeLabel.implicitWidth
+                                                        : 0)))
+                        font.pixelSize: 10
+                        color: themeColors.secondaryText
+                        elide: Text.ElideRight
+                        visible: text.length > 0
+                    }
+
+                    Text {
+                        id: tempRangeLabel
+                        text: Applet.weather.formattedTemperatureRange
+                        font.pixelSize: 10
+                        color: themeColors.secondaryText
+                    }
                 }
-          
-                Text {
-                    id: tempRangeLabel
-                    text: Applet.weather.formattedTemperatureRange
-                    font.pixelSize: 10
-                    color: themeColors.secondaryText
+
+                RowLayout {
+                    id: bottomRow
+                    spacing: 4
+
+                    Text {
+                        id: tempLabel
+                        text: Applet.weather.formattedTemperature
+                        font.pixelSize: 14
+                        font.bold: false
+                        color: themeColors.primaryText
+                    }
+
+                    Text {
+                        id: descLabel
+                        text: Applet.weather.weatherDescription
+                        width: Math.min(implicitWidth,
+                                        Math.max(0,
+                                                 weatherSummary.textColumnMaxWidth
+                                                 - (tempLabel.visible
+                                                        ? bottomRow.spacing + tempLabel.implicitWidth
+                                                        : 0)))
+                        font.pixelSize: 10
+                        color: themeColors.secondaryText
+                        elide: Text.ElideRight
+                        visible: text.length > 0
+                    }
                 }
             }
-      
-            // Row 2: Current temp + Weather description
-            RowLayout {
-                id: bottomRow
-                spacing: 4
-          
-                Text {
-                    id: tempLabel
-                    text: Applet.weather.formattedTemperature
-                    font.pixelSize: 14
-                    font.bold: false
-                    color: themeColors.primaryText
-                }
-          
-                Text {
-                    id: descLabel
-                    text: Applet.weather.weatherDescription
-                    width: Math.min(implicitWidth,
-                                    Math.max(0,
-                                             weatherSummary.textColumnMaxWidth
-                                             - (tempLabel.visible
-                                                    ? bottomRow.spacing + tempLabel.implicitWidth
-                                                    : 0)))
-                    font.pixelSize: 10
-                    color: themeColors.secondaryText
-                    elide: Text.ElideRight
-                    visible: text.length > 0
+        }
+
+        // 纵向布局:左右任务栏 (图标在上 + 当前温度在下)
+        Column {
+            id: verticalLayout
+            anchors.fill: parent
+            spacing: 2
+            visible: root.useColumnLayout
+
+            Item {
+                width: parent.width
+                height: parent.height * 0.6
+
+                WeatherIcon {
+                    anchors.centerIn: parent
+                    width: Math.min(parent.height, parent.width)
+                    height: width
+                    weatherCode: Applet.weather.weatherCode
+                    iconNameOverride: Applet.weather.iconName
+                    animationTrigger: Applet.weather.updateSerial
+                    iconColor: themeColors.icon
+                    loading: Applet.weather.isLoading
                 }
             }
+
+            Text {
+                text: Applet.weather.formattedTemperature
+                font.pixelSize: 10
+                font.bold: true
+                color: themeColors.primaryText
+                anchors.horizontalCenter: parent.horizontalCenter
+                verticalAlignment: Text.AlignTop
+            }
         }
     }
+
+
   
     // Theme colors
     QtObject {
diff --git a/src/weatherprovider.cpp b/src/weatherprovider.cpp
index 179f32a..67d4c68 100644
--- a/src/weatherprovider.cpp
+++ b/src/weatherprovider.cpp
@@ -2666,8 +2666,10 @@ WeatherProvider::tooltipText () const
             ? tr ("Unknown")
             : m_weatherData.weatherDescription.trimmed ();
 
-  return tr ("Location: %1\nWeather: %2\nUpdated: %3")
-      .arg (displayCity, displayDescription, formattedUpdatedAt ());
+  //  增加温度范围显示    
+  const QString tempRange = formattedTemperatureRange();
+  return tr ("Location: %1\nWeather: %2  %3\nUpdated: %4")
+      .arg (displayCity, displayDescription, tempRange, formattedUpdatedAt ());
 }
 
 QString
diff --git a/translations/org.deepin.ds.weather_zh_CN.ts b/translations/org.deepin.ds.weather_zh_CN.ts
index e2128cb..b7fca4e 100644
--- a/translations/org.deepin.ds.weather_zh_CN.ts
+++ b/translations/org.deepin.ds.weather_zh_CN.ts
@@ -302,11 +302,11 @@
     
         
         Location: %1
-Weather: %2
-Updated: %3
+Weather: %2  %3
+Updated: %4
         地区:%1
-天气:%2
-更新时间:%3
+天气:%2  %3
+更新时间:%4
     
 
 

效果:

未命名.png

未命名1.png

插件下载:

dde-shell-weather-plugin_1.6.3-2lon_loong64.zip

这个不知是论坛那位大佬开发的,下次发布带上龙吧,没硬件不要紧,论坛有好几位龙芯用户可以帮你编译

另外这个插件的作者最近也不在论坛活动,https://bbs.deepin.org/zh/post/296954 龙芯版的我想投递应用商店,联系不上他

Reply Favorite View the author
All Replies
avatar
deepin流云
Super Moderator
Community OP
3 hours ago
#1

@HualetWang 作者在此kissing_heart

Reply View the author
avatar
HualetWang
deepin
3 hours ago
#2

长期在论坛潜水😂 代码我抽空合一下,龙架构的包看来得薅点公司的资源😊

Reply View the author