Skip to content

Commit

Permalink
英化首页
Browse files Browse the repository at this point in the history
  • Loading branch information
XCWQW233 committed Aug 27, 2024
1 parent 921bba5 commit b5f06d8
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 30 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ English | <a href="README_zh.md">简体中文</a>

### Software Screenshots

![front_page](images/home.png)
![sidebar](images/home_tab.png)
![cfg_management](images/cfg.png)
![resource_management](images/resouces.png)
![server_list_management](images/server_list.png)
![setting](images/settings.png)
![front_page](images/zh/home.png)
![sidebar](images/zh/home_tab.png)
![cfg_management](images/zh/cfg.png)
![resource_management](images/zh/resouces.png)
![server_list_management](images/zh/server_list.png)
![setting](images/zh/settings.png)
12 changes: 6 additions & 6 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

### 软件截图

![首页](images/home.png)
![侧栏](images/home_tab.png)
![cfg管理](images/cfg.png)
![资源管理](images/resouces.png)
![服务器列表管理](images/server_list.png)
![设置](images/settings.png)
![首页](images/zh/home.png)
![侧栏](images/zh/home_tab.png)
![cfg管理](images/zh/cfg.png)
![资源管理](images/zh/resouces.png)
![服务器列表管理](images/zh/server_list.png)
![设置](images/zh/settings.png)
43 changes: 25 additions & 18 deletions app/view/home_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from app.config import cfg, base_path
from PyQt5.QtCore import Qt, QThread, pyqtSignal, QTimer
from PyQt5.QtWidgets import QVBoxLayout, QWidget, QHBoxLayout, QSpacerItem, QSizePolicy
from qfluentwidgets import ImageLabel, CardWidget, SubtitleLabel, BodyLabel, HeaderCardWidget, InfoBar, InfoBarPosition, CaptionLabel, FlowLayout, SingleDirectionScrollArea, setFont
from qfluentwidgets import ImageLabel, CardWidget, SubtitleLabel, BodyLabel, HeaderCardWidget, InfoBar, InfoBarPosition, \
CaptionLabel, FlowLayout, SingleDirectionScrollArea, setFont

from app.utils.network import ImageLoader

Expand Down Expand Up @@ -59,11 +60,11 @@ def __init__(self, name: str, parent=None):

self.labels = [
SubtitleLabel(name, self),
BodyLabel('全球排名:加载中...\n'
'游戏分数:加载中...\n'
'游玩时长:加载中...\n'
'最后完成:加载中...\n'
'入坑时间:加载中...', self),
BodyLabel(self.tr('全球排名:加载中...\n'
'游戏分数:加载中...\n'
'游玩时长:加载中...\n'
'最后完成:加载中...\n'
'入坑时间:加载中...'), self),
]

for label in self.labels:
Expand All @@ -88,21 +89,25 @@ def on_image_loaded(self, pixmap):

def on_data_loaded(self, json_data: dict):
if json_data == {}:
self.labels[1].setText(f'全球排名:NO.数据获取失败\n'
f'游戏分数:数据获取失败/数据获取失败 分\n'
f'游玩时长:数据获取失败 小时\n'
f'最后完成:数据获取失败\n'
f'入坑时间:数据获取失败')
self.labels[1].setText(self.tr('全球排名:NO.数据获取失败\n'
'游戏分数:数据获取失败/数据获取失败 分\n'
'游玩时长:数据获取失败 小时\n'
'最后完成:数据获取失败\n'
'入坑时间:数据获取失败'))
return
use_time = 0
for time in json_data['activity']:
use_time = use_time + time['hours_played']

self.labels[1].setText(f'全球排名:NO.{json_data["points"]["rank"]}\n'
f'游戏分数:{json_data["points"]["points"]}/{json_data["points"]["total"]}\n'
f'游玩时长:{use_time} 小时\n'
f'最后完成:{json_data["last_finishes"][0]["map"]}\n'
f'入坑时间:{datetime.datetime.fromtimestamp(json_data["first_finish"]["timestamp"])}')
self.labels[1].setText(self.tr('全球排名:NO.{}\n'
'游戏分数:{}/{} 分\n'
'游玩时长:{} 小时\n'
'最后完成:{}\n'
'入坑时间:{}').format(json_data["points"]["rank"], json_data["points"]["points"],
json_data["points"]["total"], use_time,
json_data["last_finishes"][0]["map"],
datetime.datetime.fromtimestamp(
json_data["first_finish"]["timestamp"])))


class FriendCard(CardWidget):
Expand Down Expand Up @@ -182,7 +187,8 @@ def __init__(self, parent=None):
self.hBoxLayout = QHBoxLayout()

self.vBoxLayout.addLayout(self.hBoxLayout, Qt.AlignTop)
self.TEECARD(GlobalsVal.ddnet_setting_config.get("player_name", "nameless tee"), GlobalsVal.ddnet_setting_config.get("dummy_name", "[D] nameless te"))
self.TEECARD(GlobalsVal.ddnet_setting_config.get("player_name", "nameless tee"),
GlobalsVal.ddnet_setting_config.get("dummy_name", "[D] nameless te"))
self.vBoxLayout.addWidget(FriendList(), Qt.AlignCenter)

if cfg.get(cfg.DDNetCheckUpdate):
Expand All @@ -205,7 +211,8 @@ def on_check_update_loaded(self, json_data: list):
if GlobalsVal.ddnet_info['version'] != json_data[0]["version"]:
InfoBar.warning(
title=self.tr('DDNet 版本检测'),
content=self.tr("您当前的DDNet版本为 {} 最新版本为 {} 请及时更新").format(GlobalsVal.ddnet_info['version'], json_data[0]["version"]),
content=self.tr("您当前的DDNet版本为 {} 最新版本为 {} 请及时更新").format(
GlobalsVal.ddnet_info['version'], json_data[0]["version"]),
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.BOTTOM_RIGHT,
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit b5f06d8

Please sign in to comment.