Skip to content

Commit

Permalink
update v1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
tonquer committed Apr 18, 2021
1 parent 551b1da commit ff26982
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 42 deletions.
4 changes: 3 additions & 1 deletion conf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
IsLoadingPicture = True

UpdateUrl = "https://github.com/tonquer/picacg-windows/releases/latest"
UpdateVersion = "v1.1.3"
UpdateUrl2 = "https://github.com/tonquer/picacg-windows/releases"
UpdateVersion = "v1.1.4"

# waifu2x
CanWaifu2x = True
ErrorMsg = ""

Encode = 0
Waifu2xThread = 2
Expand Down
18 changes: 11 additions & 7 deletions src/index/book.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self):
self.categories = [] # 分类
self.tags = [] # tag
self.eps = [] # 章节列表BookEps
self.epsDict = {}

@property
def id(self):
Expand Down Expand Up @@ -89,21 +90,24 @@ def AddBookEpsInfoBack(self, backData):
limit = r.data['eps']["limit"]
# 优化,如果分页已经加载好了,只需要重新加载更新最后一页即可

for i, data in enumerate(r.data['eps']['docs']):
index = (page -1) * limit + i
if len(info.eps) > index:
epsInfo = info.eps[index]
for i, data2 in enumerate(r.data['eps']['docs']):
# index = (page -1) * limit + i
epsId = data2.get('id')
if epsId in info.epsDict:
epsInfo = info.epsDict[epsId]
else:
epsInfo = BookEps()
info.eps.append(epsInfo)
ToolUtil.ParseFromData(epsInfo, data)
info.epsDict[epsId] = epsInfo
# info.eps.append(epsInfo)
ToolUtil.ParseFromData(epsInfo, data2)

loadPage = int((len(info.eps)-1) / limit + 1)
loadPage = int((len(info.epsDict)-1) / limit + 1)
nextPage = page + 1
# 如果已经有了,则从最后那一页加载起就可以了
if loadPage > nextPage:
nextPage = loadPage

info.eps = list(info.epsDict.values())
info.eps.sort(key=lambda a: a.order)

if nextPage <= pages:
Expand Down
2 changes: 1 addition & 1 deletion src/qt/chat/qtchatroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _RecvBroadcastMsg(self, data):
if not os.path.isdir(path):
os.makedirs(path)
f = open(saveName, "wb")
f.write(audio)
f.write(audio.encode("utf-8"))
f.close()
except Exception as es:
Log.Error(es)
Expand Down
6 changes: 2 additions & 4 deletions src/qt/chat/qtchatroommsg.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from PySide2 import QtWidgets
from PySide2.QtCore import QEvent, QUrl, QProcess
from PySide2.QtGui import QPixmap, Qt, QIcon, QCursor, QDesktopServices
from PySide2.QtWebSockets import QWebSocket
from PySide2.QtCore import QEvent, QProcess
from PySide2.QtGui import QPixmap, Qt, QIcon, QCursor
from PySide2.QtWidgets import QMenu, QApplication

from resources.resources import DataMgr
from src.qt.com.qtimg import QtImgMgr
from src.util import Log
from ui.chatrootmsg import Ui_ChatRoomMsg


Expand Down
16 changes: 10 additions & 6 deletions src/qt/com/qtimg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from PySide2.QtGui import QColor, QPainter, QPixmap, QImage
from PySide2.QtWidgets import QFrame, QGraphicsPixmapItem, QGraphicsScene, QApplication, QFileDialog

from conf import config
from src.qt.com.qtbubblelabel import QtBubbleLabel
from src.qt.util.qttask import QtTask
from src.util import Singleton, ToolUtil, Log
Expand All @@ -23,18 +24,21 @@ def ShowImg(self, data):
self.data = data
self.waifu2xData = None
QtTask().CancelConver("QtImg")
self.obj.comboBox.setEnabled(True)
self.obj.changeButton.setEnabled(True)
if config.CanWaifu2x:
self.obj.comboBox.setEnabled(True)
self.obj.changeButton.setEnabled(True)
self.obj.changeButton.setText("转换")
self.obj.ShowImg(data)
elif self.data:
self.obj.comboBox.setEnabled(True)
self.obj.changeButton.setEnabled(True)
if config.CanWaifu2x:
self.obj.comboBox.setEnabled(True)
self.obj.changeButton.setEnabled(True)
self.obj.changeButton.setText("转换")
self.obj.ShowImg(self.data)
else:
self.obj.comboBox.setEnabled(True)
self.obj.changeButton.setEnabled(True)
if config.CanWaifu2x:
self.obj.comboBox.setEnabled(True)
self.obj.changeButton.setEnabled(True)
self.obj.changeButton.setText("转换")
self.obj.show()

Expand Down
7 changes: 3 additions & 4 deletions src/qt/com/qtlistwidget.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import weakref

from PySide2.QtCore import Qt, QSize
from PySide2.QtGui import QPixmap, QColor, QIntValidator, QImage, QFont, QCursor
from PySide2.QtGui import QPixmap, QColor, QIntValidator, QFont, QCursor
from PySide2.QtWidgets import QListWidget, QLabel, QWidget, QVBoxLayout, QHBoxLayout, QListWidgetItem, QAbstractSlider, \
QScroller, QGridLayout, QSpacerItem, QSizePolicy, QMenu, QApplication
QScroller, QMenu, QApplication

from conf import config
from resources import resources
from src.qt.com.qtcomment import QtComment
from src.qt.com.qtimg import QtImg, QtImgMgr
from src.qt.com.qtimg import QtImgMgr
from src.qt.util.qttask import QtTask
from src.util import ToolUtil
from src.util.status import Status
Expand Down
5 changes: 2 additions & 3 deletions src/qt/com/qtloading.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import weakref

from PySide2 import QtWidgets, QtCore, QtGui
from PySide2.QtCore import QPoint, QTimer
from PySide2 import QtWidgets, QtCore
from PySide2.QtCore import QTimer
from PySide2.QtGui import QPixmap, QImage
from PySide2.QtWidgets import QDesktopWidget

from resources import resources
from ui.loading import Ui_Loading
Expand Down
2 changes: 1 addition & 1 deletion src/qt/main/qtindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from resources.resources import DataMgr
from src.qt.com.qtlistwidget import QtBookList
from src.server import Server, req, Status, Log
from src.server import Server, req, Log
from src.user.user import User
from ui.index import Ui_Index

Expand Down
2 changes: 1 addition & 1 deletion src/qt/menu/qtsetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ def SetGpuInfos(self, gpuInfo):

def GetGpuName(self):
index = config.Encode
if index >= len(self.gpuInfos):
if index >= len(self.gpuInfos) or index < 0:
return "GPU"
return self.gpuInfos[index]
13 changes: 6 additions & 7 deletions src/qt/qtmain.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import re


from PySide2 import QtWidgets, QtGui # 导入PySide2部件
from PySide2.QtCore import QTimer, QUrl
Expand All @@ -9,7 +8,7 @@
from conf import config
from resources import resources
from src.qt.chat.qtchat import QtChat
from src.qt.com.qtimg import QtImg, QtImgMgr
from src.qt.com.qtimg import QtImgMgr
from src.qt.main.qtindex import QtIndex
from src.qt.menu.qtabout import QtAbout
from src.qt.read.qtbookinfo import QtBookInfo
Expand Down Expand Up @@ -138,14 +137,14 @@ def Init(self):
self.settingForm.SetGpuInfos(gpuInfo)
Log.Info("waifu2x初始化: " + str(stat) + " encode: " + str(config.Encode))
else:
self.msgForm.ShowError("waifu2x无法启用")
self.msgForm.ShowError("waifu2x无法启用, "+config.ErrorMsg)
self.settingForm.checkBox.setEnabled(False)
self.qtReadImg.frame.qtTool.checkBox.setEnabled(False)
self.downloadForm.autoConvert = False
self.downloadForm.radioButton.setChecked(False)
QtImgMgr().obj.radioButton.setChecked(False)
self.downloadForm.radioButton.setEnabled(False)
QtImgMgr().obj.radioButton.setEnabled(False)
QtImgMgr().obj.changeButton.setEnabled(False)
QtImgMgr().obj.changeButton.setEnabled(False)
QtImgMgr().obj.comboBox.setEnabled(False)
config.IsOpenWaifu = 0

Expand Down Expand Up @@ -173,6 +172,6 @@ def InitUpdateBack(self, data):
data),
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
if r == QMessageBox.Yes:
QDesktopServices.openUrl(QUrl("https://github.com/tonquer/picacg-windows/releases"))
QDesktopServices.openUrl(QUrl(config.UpdateUrl2))
except Exception as es:
Log.Error(es)
8 changes: 5 additions & 3 deletions src/qt/read/qtbookinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def __init__(self, owner):

self.msgForm = QtBubbleLabel(self)
self.picture.installEventFilter(self)
self.title.setGeometry(QRect(328, 240, 329, 27 * 4))
# self.title.setGeometry(QRect(328, 240, 329, 27 * 4))
self.title.setWordWrap(True)
self.title.setAlignment(Qt.AlignTop)
# self.title.setAlignment(Qt.AlignLeft)
self.title.setContextMenuPolicy(Qt.CustomContextMenu)
self.title.customContextMenuRequested.connect(self.CopyTitle)

Expand Down Expand Up @@ -307,13 +307,15 @@ def UpdateEpsData(self):
downloadIds = self.owner().downloadForm.GetDownloadCompleteEpsId(self.bookId)
for index, epsInfo in enumerate(info.eps):
label = QLabel(epsInfo.title)
# label.setWordWrap(True)
label.setContentsMargins(20, 10, 20, 10)
item = QListWidgetItem(self.epsListWidget)
if index in downloadIds:
item.setBackground(QColor(18, 161, 130))
else:
item.setBackground(QColor(0,0,0,0))
item.setSizeHint(label.sizeHint())
item.setSizeHint(label.sizeHint() + QSize(2, 0))
item.setToolTip(epsInfo.title)
self.epsListWidget.setItemWidget(item, label)
self.tabWidget.setTabText(0, "章节({})".format(str(len(info.eps))))
return
Expand Down
4 changes: 3 additions & 1 deletion src/qt/read/qtreadimg.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def OpenPage(self, bookId, epsId, name):
info = BookMgr().books.get(bookId)
if info:
self.category = info.tags[:]
self.category.extend(info.categories)
self.qtTool.checkBox.setChecked(config.IsOpenWaifu)
self.qtTool.SetData(isInit=True)
self.graphicsItem.setPixmap(QPixmap())
Expand Down Expand Up @@ -196,7 +197,8 @@ def ShowImg(self, isShowWaifu=True):
self.graphicsItem.setPixmap(QPixmap())
self.qtTool.modelBox.setEnabled(False)
return
self.qtTool.modelBox.setEnabled(True)
if config.CanWaifu2x:
self.qtTool.modelBox.setEnabled(True)
assert isinstance(p, QtFileData)
if not isShowWaifu:
p2 = p.data
Expand Down
3 changes: 2 additions & 1 deletion src/qt/read/qtreadimg_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def SetData(self, pSize=None, dataLen=0, state="", waifuSize=None, waifuDataLen=
self.stateWaifu.setStyleSheet("color:red;")
else:
self.stateWaifu.setStyleSheet("color:dark;")
self.stateWaifu.setText("状态:" + waifuState)
if config.CanWaifu2x:
self.stateWaifu.setText("状态:" + waifuState)
if waifuTick or isInit:
self.tickLabel.setText("耗时:" + str(waifuTick) + "s")

Expand Down
4 changes: 2 additions & 2 deletions src/qt/user/qtuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from PySide2 import QtWidgets, QtGui
from PySide2.QtCore import Qt, QSize, QEvent
from PySide2.QtGui import QIcon, QPixmap
from PySide2.QtWidgets import QListWidget, QListWidgetItem
from PySide2.QtGui import QPixmap
from PySide2.QtWidgets import QListWidgetItem

from resources import resources
from src.qt.com.qtimg import QtImgMgr
Expand Down
1 change: 1 addition & 0 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
config.CanWaifu2x = True
except Exception as es:
config.CanWaifu2x = False
config.ErrorMsg = es.msg

from PySide2 import QtWidgets # 导入PySide2部件
from src.qt.qtmain import BikaQtMainWindow
Expand Down

0 comments on commit ff26982

Please sign in to comment.