Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
tonquer committed Mar 2, 2024
1 parent 3394877 commit f22a701
Show file tree
Hide file tree
Showing 38 changed files with 5,085 additions and 229 deletions.
1 change: 1 addition & 0 deletions res/icon/no_sign.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions res/icon/sign.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions res/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
<file>icon/logo_round.png</file>
<file>icon/placeholder_avatar.png</file>
<file>icon/new.svg</file>
<file>icon/sign.svg</file>
<file>icon/no_sign.svg</file>
<file>icon/loading/loading_1.png</file>
<file>icon/loading/loading_2.png</file>
<file>icon/loading/loading_3.png</file>
Expand Down
6 changes: 4 additions & 2 deletions src/component/list/comic_list_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def AddBookByLocal(self, v, category=""):
widget.categoryLabel.setText(category)
widget.categoryLabel.setVisible(True)

widget.nameLable.setText(title)
widget.SetTitle(title)
item = QListWidgetItem(self)
item.setFlags(item.flags() & ~Qt.ItemIsSelectable)
item.setSizeHint(widget.sizeHint())
Expand All @@ -147,8 +147,10 @@ def AddBookItem(self, _id, title, categoryStr="", url=""):
widget.url = url
widget.index = index
widget.categoryLabel.setText(categoryStr)
widget.nameLable.setText(title)
widget.SetTitle(title)
widget.path = ToolUtil.GetRealPath(_id, "cover")
widget.starButton.setVisible(False)
widget.timeLabel.setVisible(False)
# if updated_at:
# dayStr = ToolUtil.GetUpdateStr(updated_at)
# updateStr = dayStr + Str.GetStr(Str.Update)
Expand Down
56 changes: 54 additions & 2 deletions src/component/widget/comic_item_widget.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PySide6.QtCore import Qt, QSize, Signal
from PySide6.QtGui import QPixmap, QIcon, QFont
from PySide6.QtGui import QPixmap, QIcon, QFont, QFontMetrics
from PySide6.QtWidgets import QWidget

from config import config
Expand Down Expand Up @@ -68,8 +68,60 @@ def __init__(self, isCategory=False):
self.isWaifu2xLoading = False
self.isLoadPicture = False

def SetTitle(self, title):
self.title = title
if Setting.NotCategoryShow.value:
self.categoryLabel.setVisible(False)

if Setting.TitleLine.value == 0:
self.nameLable.setVisible(False)
elif Setting.TitleLine.value == 1:
self.nameLable.setWordWrap(False)
self.nameLable.setText(title)
elif Setting.TitleLine.value > 3:
self.nameLable.setText(title)
else:
title2 = self.ElidedLineText()
self.nameLable.setText(title2)

def ElidedLineText(self):
line = Setting.TitleLine.value
if line <= 0 :
line = 2
f = QFontMetrics(self.nameLable.font())
if (line == 1):
return f.elidedText(self.title, Qt.ElideRight, self.nameLable.maximumWidth())

strList = []
start = 0
isEnd = False
for i in range(1, len(self.title)):
if f.boundingRect(self.title[start:i]).width() >= self.nameLable.maximumWidth()-10:
strList.append(self.title[start:i])
if len(strList) >= line:
isEnd = True
break
start = i

if not isEnd:
strList.append(self.title[start:])

if not strList:
strList.append(self.title)
hasElided = True
endIndex = len(strList) - 1
endString = strList[endIndex]
if f.boundingRect(endString).width() < self.nameLable.maximumWidth():
hasElided = False

if (hasElided):
if len(endString) > 4 :
endString = endString[0:len(endString) - 4] + "..."
strList[endIndex] = endString
return "".join(strList)

def GetTitle(self):
return self.nameLable.text()
return self.title

def SetPicture(self, data):
self.picData = data
Expand Down
56 changes: 54 additions & 2 deletions src/component/widget/navigation_widget.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import time
from datetime import datetime

from PySide6.QtCore import QPropertyAnimation, QRect, QEasingCurve, QFile, QEvent, QSize
from PySide6.QtGui import QPixmap, Qt, QIcon
from PySide6.QtWidgets import QWidget, QScroller, QScrollerProperties
from PySide6.QtWidgets import QWidget, QScroller, QScrollerProperties, QCalendarWidget

from config import config
from config.setting import Setting
from interface.ui_navigation import Ui_Navigation
from interface.ui_sign_widget import Ui_SignWidget
from qt_owner import QtOwner
from server import req
from task.qt_task import QtTaskBase
from tools.status import Status
from tools.str import Str
from tools.user import User
from view.user.login_view import LoginView
from view.user.sign_view import SignView


class NavigationWidget(QWidget, Ui_Navigation, QtTaskBase):
Expand All @@ -32,6 +37,11 @@ def __init__(self, parent=None):
self.picData = None
self.offlineButton.SetState(False)
self.offlineButton.Switch.connect(self.SwitchOffline)
# self.signButton.setEnabled(False)
self.signId = 0
self.signMap = {}
self.signButton.clicked.connect(self.OpenSign)
self.isDailySign = False

if Setting.IsGrabGesture.value:
QScroller.grabGesture(self.scrollArea, QScroller.LeftMouseButtonGesture)
Expand All @@ -41,6 +51,14 @@ def __init__(self, parent=None):
propertiesOne.setScrollMetric(QScrollerProperties.HorizontalOvershootPolicy, QScrollerProperties.OvershootAlwaysOff)
QScroller.scroller(self.scrollArea).setScrollerProperties(propertiesOne)

def OpenSign(self):
if self.isDailySign:
signView = SignView(QtOwner().owner, self.signMap)
signView.show()
else:
self.AddHttpTask(req.SignDailyReq2(QtOwner().user.uid, self.signId), self.GetSignBack)
return

def SwitchOffline(self, state):
QtOwner().isOfflineModel = state
return
Expand Down Expand Up @@ -69,16 +87,50 @@ def LoginSucBack(self):
return
# self.pushButton.hide()
user = QtOwner().user
self.levelLabel.setText("LV" + str(user.level))
self.levelLabel.setText("LV" + str(user.level) + "(" + str(user.exp) + "/" + str(user.nex_exp) + ")")
self.favorite.setText("(" + str(user.favorites) + "/" + str(user.canFavorites) + ")")
self.coins.setText(str(user.coin))
self.titleLabel.setText(str(user.title))
self.nameLabel.setText(str(user.name))
config.LoginUserName = user.name.replace("@", "")
if user.imgUrl and config.IsLoadingPicture:
self.AddDownloadTask(user.imgUrl, "", completeCallBack=self.ShowUserImg)

self.pushButton.setText(Str.GetStr(Str.LoginOut))
self.AddHttpTask(req.GetDailyReq2(user.uid), self.GetSignDailyBack)
# self.AddHttpTask(req.GetUserInfoReq(), self.UpdateUserBack)

def GetSignDailyBack(self, raw):
st = raw["st"]
curDate = datetime.today().day
if st == Status.Ok:
data = raw.get("data", {})
self.signId = data.get("daily_id", 0)
self.signMap.clear()
for v in data.get('record', []):
for v2 in v:
signDate = int(v2["date"])
self.signMap[signDate] = v2.get('signed')
if signDate == curDate:
self.isDailySign = v2.get('signed')
if self.isDailySign:
self.signButton.setText(Str.GetStr(Str.AlreadySign))
else:
self.signButton.setText(Str.GetStr(Str.Sign))
if Setting.AutoSign.value:
QtOwner().ShowMsg("已自动打卡")
self.signButton.click()
pass

def GetSignBack(self, raw):
st = raw.get("st")
msg = raw.get("data", {}).get("msg", "")
if st == Status.Ok:
self.isDailySign = True
self.signButton.setText(Str.GetStr(Str.AlreadySign))
QtOwner().ShowError(msg if msg else Str.GetStr(st))


def UpdateProxyName(self):
if Setting.ProxySelectIndex.value == 5:
self.proxyName.setText("CDN_{}".format(str(Setting.PreferCDNIP.value)))
Expand Down
6 changes: 3 additions & 3 deletions src/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
UpdateUrl2Back = "https://hub.ggo.icu/tonquer/JMComic-qt/"
UpdateUrl3Back = "https://hub.fastgit.xyz/tonquer/JMComic-qt"

UpdateVersion = "v1.2.0"
RealVersion = "v1.2.0"
VersionTime = "2024-2-23"
UpdateVersion = "v1.2.1"
RealVersion = "v1.2.1"
VersionTime = "2024-3-2"

Waifu2xVersion = "1.1.6"
LoginUserName = ""
Expand Down
3 changes: 3 additions & 0 deletions src/config/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class Setting:
ThemeIndex = SettingValue("GeneraSetting", 0, False, ["Auto", "light", "dark"]) #
LogIndex = SettingValue("GeneraSetting", 0, False, ["warn", "info", "debug"]) # Warn Info Debug
CoverSize = SettingValue("GeneraSetting", 100, False) #
TitleLine = SettingValue("GeneraSetting", 2, False) #
NotCategoryShow = SettingValue("GeneraSetting", 0, False) #
CategorySize = SettingValue("GeneraSetting", 80, False) #
ScaleLevel = SettingValue("GeneraSetting", 0, True, ["Auto", 100, 125, 150, 175, 200])
IsUseTitleBar = SettingValue("GeneraSetting", 1, True)
Expand Down Expand Up @@ -152,6 +154,7 @@ class Setting:
ChatSendAction = SettingValue("Other", 0, False, ["CtrlEnter", "Enter"])
ScreenIndex = SettingValue("Other", 0, False)
AutoLogin = SettingValue("Other", 0, False)
AutoSign = SettingValue("Other", 1, False)
SavePassword = SettingValue("Other", 1, False)
IsShowCmd = SettingValue("Other", 0, False)
IsGrabGesture = SettingValue("Other", 0, True)
Expand Down
Loading

0 comments on commit f22a701

Please sign in to comment.