Skip to content

Commit

Permalink
更新1.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
tonquer committed May 16, 2021
1 parent e9fa777 commit 6ffa028
Show file tree
Hide file tree
Showing 26 changed files with 279 additions and 120 deletions.
2 changes: 1 addition & 1 deletion conf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

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

# waifu2x
CanWaifu2x = True
Expand Down
Binary file modified data/book.db
Binary file not shown.
Binary file modified lib/waifu2x.pyd
Binary file not shown.
Binary file modified lib/waifu2x.so
Binary file not shown.
3 changes: 2 additions & 1 deletion src/qt/com/qtbubblelabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def OpenPicture(self, path="."):
elif baseName[-3:] == "gif":
picFormat = "gif"
else:
return
return None, None, None

if os.path.isfile(name):
self.cachePath = os.path.dirname(name)
Expand All @@ -145,6 +145,7 @@ def OpenPicture(self, path="."):
data = f.read()
f.close()
return data, name, picFormat
return None, None, None
except Exception as ex:
Log.Error(ex)
return None, None, None
20 changes: 20 additions & 0 deletions src/qt/com/qtimg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import time
import weakref

from PySide2 import QtWidgets, QtGui, QtCore
from PySide2.QtCore import Qt, QRectF, QPointF, QSizeF, QEvent, QTextCodec, QRegExp
Expand All @@ -19,6 +20,14 @@ def __init__(self):
self.obj = QtImg()
self.data = None
self.waifu2xData = None
self._owner = None

@property
def owner(self):
return self._owner()

def SetOwner(self, owner):
self._owner = weakref.ref(owner)

def ShowImg(self, data):
if data:
Expand All @@ -43,6 +52,9 @@ def ShowImg(self, data):
self.obj.changeButton.setText("转换")
self.obj.show()

def SetHeadStatus(self, isSet):
self.obj.headButton.setEnabled(isSet)


class QtImg(QtWidgets.QWidget, Ui_Img):
def __init__(self):
Expand Down Expand Up @@ -360,3 +372,11 @@ def CheckScaleRadio(self):
else:
self.changeButton.setEnabled(False)
self.changeButton.setText("转换")

def SetHead(self):
data = QtImgMgr().waifu2xData if QtImgMgr().waifu2xData else QtImgMgr().data
if not data:
return
QtImgMgr().owner.userForm.UpdatePictureData(data)
QtBubbleLabel.ShowMsgEx(self, "头像上传中......")
return
13 changes: 11 additions & 2 deletions src/qt/main/qtsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def __init__(self, owner):
layouy.addWidget(QLabel("屏蔽:"))
layouy.addWidget(self.categoryList)
self.bookLayout.addLayout(layouy, 1, 0)
for name in ["耽美", "偽娘", "禁書", "扶她", "重口", "生肉", "純愛", "WEBTOON"]:
self.categoryList.AddItem(name)
self.categoryList.itemClicked.connect(self.ClickCategoryListItem)

self.keywordList = QtCategoryList(self)
Expand All @@ -45,6 +43,16 @@ def __init__(self, owner):
layouy.addWidget(self.keywordList)
self.bookLayout.addLayout(layouy, 2, 0)
self.keywordList.itemClicked.connect(self.ClickKeywordListItem)
self.SetSearch()

def InitCategoryList(self):
self.categoryList.clear()
if not self.localBox.isChecked():
for name in ["耽美", "偽娘", "禁書", "扶她", "重口", "生肉", "純愛", "WEBTOON"]:
self.categoryList.AddItem(name)
else:
for name in ["耽美", "伪娘", "禁书", "扶她", "重口", "生肉", "纯爱", "WEBTOON"]:
self.categoryList.AddItem(name)

def SwitchCurrent(self):
pass
Expand Down Expand Up @@ -94,6 +102,7 @@ def Search(self, categories=None):

def SetSearch(self):
# self.localBox.setChecked(not self.localBox.isChecked())
self.InitCategoryList()
if self.localBox.isChecked():
self.authorBox.setEnabled(True)
self.desBox.setEnabled(True)
Expand Down
37 changes: 26 additions & 11 deletions src/qt/main/qtsearch_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,32 @@ def InitUpdateInfo(self):
time = query.value(2)
return nums, time

def Search(self, word, isTitle, isAutor, isDes, isTag, isCategory, page, sortKey=0, sortId=0):
def Search(self, wordList, isTitle, isAutor, isDes, isTag, isCategory, page, sortKey=0, sortId=0):
query = QSqlQuery(self.db)
data = ""
if isTitle:
data += " or title2 like '%{}%' ".format(word)
if isAutor:
data += " or author like '%{}%' ".format(word)
if isDes:
data += " or description like '%{}%' ".format(word)
if isTag:
data += " or tags like '%{}%' ".format(word)
if isCategory:
data += " or categories like '%{}%' ".format(word)
wordList2 = wordList.split("|")
for words in wordList2:
data2 = ""
for word in words.split("&"):
if not word:
continue
data3 = ""
if isTitle:
data3 += " title2 like '%{}%' or ".format(word)
if isAutor:
data3 += " author like '%{}%' or ".format(word)
if isDes:
data3 += " description like '%{}%' or ".format(word)
if isTag:
data3 += " tags like '%{}%' or ".format(word)
if isCategory:
data3 += " categories like '%{}%' or ".format(word)
data3 = data3.strip("or ")
data2 += "({}) and ".format(data3)
data2 = data2.strip("and ")
if data2:
data += " or ({})".format(data2)

sql = "SELECT * FROM book WHERE 0 {}".format(data)
if sortKey == 0:
sql += "ORDER BY updated_at "
Expand Down Expand Up @@ -117,6 +130,8 @@ def Search(self, word, isTitle, isAutor, isDes, isTag, isCategory, page, sortKey
info.pages = query.value(7)
info.finished = query.value(8)
info.likesCount = query.value(9)
info.categories = query.value(10)
info.tags = query.value(11)
info.created_at = query.value(12)
info.updated_at = query.value(13)
info.path = query.value(14)
Expand Down
4 changes: 2 additions & 2 deletions src/qt/qtmain.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(self):

self.menusetting.triggered.connect(self.OpenSetting)
self.menuabout.triggered.connect(self.OpenAbout)

QtImgMgr().SetOwner(self)
# def ClearExpiredCache(self):
# try:
# toPath = os.path.join(config.SavePath, config.CachePathDir)
Expand Down Expand Up @@ -166,7 +166,7 @@ def OpenSetting(self):
def OpenAbout(self, action):
if action.text() == "about":
self.aboutForm.show()
elif action.text() == "img convert":
elif action.text() == "waifu2x":
QtImgMgr().ShowImg("")
pass

Expand Down
6 changes: 6 additions & 0 deletions src/qt/read/qtbookinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,3 +574,9 @@ def eventFilter(self, obj, event):
return False
else:
return super(self.__class__, self).eventFilter(obj, event)

def keyPressEvent(self, ev):
key = ev.key()
if Qt.Key_Escape == key:
self.close()
return super(self.__class__, self).keyPressEvent(ev)
2 changes: 1 addition & 1 deletion src/qt/user/qtlogin.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def InitUser(self):
return

def UpdateUserBack(self, msg):
self.owner().userForm.UpdateLabel(User().name, User().level, User().exp, User().isPunched)
self.owner().userForm.UpdateLabel(User().name, User().level, User().exp, User().title, User().isPunched)
if not User().avatar:
return

Expand Down
19 changes: 13 additions & 6 deletions src/qt/user/qtuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(self, owner):
self.stackedWidget.addWidget(self.owner().downloadForm)
self.stackedWidget.addWidget(self.owner().leaveMsgForm)
self.stackedWidget.addWidget(self.owner().chatForm)
self.isHeadUp = False

def SetPicture(self, data):
a = QPixmap()
Expand Down Expand Up @@ -83,34 +84,40 @@ def SignBack(self, msg):
self.update()
return

def UpdateLabel(self, name, level, exp, sign):
def UpdateLabel(self, name, level, exp, title, sign):
self.name.setText(name)
self.level.setText("level: "+str(level))
self.title.setText(title)
self.level.setText("LV"+str(level))
self.exp.setText("exp: " + str(exp))
if not sign:
self.signButton.setEnabled(True)
self.signButton.setText("签到")
self.update()

def UpdatePictureData(self):
data, name, picFormat = QtBubbleLabel.OpenPicture(self)
def UpdatePictureData(self, data):
if not data:
return
self.icon.setPixmap(None)
self.icon.setText("头像上传中......")
self.owner().qtTask.AddHttpTask(lambda x: Server().Send(req.SetAvatarInfoReq(data, picFormat), bakParam=x), self.UpdatePictureDataBack)
self.isHeadUp = True
QtImgMgr().SetHeadStatus(not self.isHeadUp)
self.owner().qtTask.AddHttpTask(lambda x: Server().Send(req.SetAvatarInfoReq(data), bakParam=x), self.UpdatePictureDataBack)
return

def UpdatePictureDataBack(self, msg):
self.isHeadUp = False
QtImgMgr().SetHeadStatus(not self.isHeadUp)
if msg == Status.Ok:
self.owner().loginForm.InitUser()
else:
QtBubbleLabel().ShowMsg(msg)
self.owner().msgForm.ShowError(msg)

def eventFilter(self, obj, event):
if event.type() == QEvent.MouseButtonPress:
if event.button() == Qt.LeftButton:
self.UpdatePictureData()
QtImgMgr().ShowImg(self.pictureData)
# self.UpdatePictureData()
return True
else:
return False
Expand Down
2 changes: 1 addition & 1 deletion src/server/req.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self):


class SetAvatarInfoReq(ServerReq):
def __init__(self, data, picFormat="png"):
def __init__(self, data, picFormat="jpg"):
url = config.Url + "users/avatar"
method = "PUT"
if picFormat[-3:] == "png":
Expand Down
2 changes: 1 addition & 1 deletion src/util/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class Status(object):
RegisterError = "注册失败"
NotFoundBook = "未找到书籍"
UnderReviewBook = "本子审核中"
SetHeadError = "头像设置出错了,"
SetHeadError = "头像设置出错了, 请尽量选择500kb以下的图片,"

2 changes: 1 addition & 1 deletion start.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

from conf import config
sys.path.append("lib")
sys.path.insert(0, "lib")
try:
import waifu2x
config.CanWaifu2x = True
Expand Down
23 changes: 18 additions & 5 deletions ui/completelineedit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import json
import re

from PySide2.QtCore import Qt, QStringListModel, QPoint, QEvent
from PySide2.QtWidgets import QApplication, QLineEdit, QListView, QCompleter, QWidget, QHBoxLayout

Expand Down Expand Up @@ -26,21 +28,23 @@ def keyPressEvent(self, ev):
count = self.listView.model().rowCount()
currentIndex = self.listView.currentIndex()
if Qt.Key_Down == key:
if currentIndex.row() <= 0 and self.text() != currentIndex.data():
curText = re.split('&|\|', self.text())
curText = curText.pop() if len(curText) > 0 else ""
if currentIndex.row() <= 0 and curText != currentIndex.data():
row = 0
else:
row = currentIndex.row() + 1 if currentIndex.row() + 1 < count else 0
index = self.listView.model().index(row, 0)
self.listView.setCurrentIndex(index)
if self.listView.currentIndex().isValid():
self.completeText2(self.listView.currentIndex())
self.completeText2(self.listView.currentIndex(), False)
return
elif Qt.Key_Up == key:
row = currentIndex.row() - 1 if currentIndex.row() > 0 else 0
index = self.listView.model().index(row, 0)
self.listView.setCurrentIndex(index)
if self.listView.currentIndex().isValid():
self.completeText2(self.listView.currentIndex())
self.completeText2(self.listView.currentIndex(), False)
return
elif Qt.Key_Escape == key:
self.listView.hide()
Expand All @@ -58,6 +62,9 @@ def setCompleter(self, strings):
return
datas = []
strings = strings.upper()

strings2 = re.split('&|\|', strings)
strings = strings2.pop() if len(strings2) > 0 else ""
isSelf = False
for data in self.words:
assert isinstance(data, str)
Expand Down Expand Up @@ -87,11 +94,17 @@ def completeText(self, modelIndex):
self.completeText2(modelIndex)
self.listView.hide()

def completeText2(self, modelIndex):
def completeText2(self, modelIndex, isNext=True):
text = modelIndex.data()
data = text.split("|")
self.isNotReload = True
self.setText(data[0])
oldData = re.split('&|\|', self.text())
print(self.text())
if len(oldData) > 0:
text = self.text().replace(oldData[len(oldData)-1], data[0])
if data[0] and isNext:
text = text + "|"
self.setText(text)
self.isNotReload = False

def focusOutEvent(self, ev):
Expand Down
8 changes: 8 additions & 0 deletions ui/img.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ def setupUi(self, Img):

self.verticalLayout_3.addWidget(self.saveButton)

self.headButton = QPushButton(Img)
self.headButton.setObjectName(u"headButton")
self.headButton.setMaximumSize(QSize(100, 16777215))

self.verticalLayout_3.addWidget(self.headButton)


self.verticalLayout.addLayout(self.verticalLayout_3)

Expand Down Expand Up @@ -304,6 +310,7 @@ def setupUi(self, Img):
self.comboBox.currentIndexChanged.connect(Img.ChangeModel)
self.changeButton.clicked.connect(Img.StartWaifu2x)
self.noiseCombox.currentIndexChanged.connect(Img.CheckScaleRadio)
self.headButton.clicked.connect(Img.SetHead)

QMetaObject.connectSlotsByName(Img)
# setupUi
Expand Down Expand Up @@ -342,5 +349,6 @@ def retranslateUi(self, Img):
self.pushButton_3.setText(QCoreApplication.translate("Img", u"\u7f29\u5c0f", None))
self.pushButton.setText(QCoreApplication.translate("Img", u"\u653e\u5927", None))
self.saveButton.setText(QCoreApplication.translate("Img", u"\u4fdd\u5b58\u56fe\u7247", None))
self.headButton.setText(QCoreApplication.translate("Img", u"\u8bbe\u7f6e\u4e3a\u5934\u50cf", None))
# retranslateUi

Loading

0 comments on commit 6ffa028

Please sign in to comment.