diff --git a/data/book.db b/data/book.db
index c0b3bfa..a762236 100644
Binary files a/data/book.db and b/data/book.db differ
diff --git a/resources/icon_64x64.png b/resources/icon_64x64.png
deleted file mode 100644
index 85ef57b..0000000
Binary files a/resources/icon_64x64.png and /dev/null differ
diff --git a/src/qt/com/qt_scroll.py b/src/qt/com/qt_scroll.py
index cca830d..468bc1e 100644
--- a/src/qt/com/qt_scroll.py
+++ b/src/qt/com/qt_scroll.py
@@ -2,10 +2,12 @@
from enum import Enum
from math import cos, pi
-from PySide2.QtCore import QTimer, QDateTime, Qt, QPropertyAnimation, QEasingCurve, QAbstractAnimation
+from PySide2.QtCore import QTimer, QDateTime, Qt, QPropertyAnimation, QEasingCurve, QAbstractAnimation, QPoint
from PySide2.QtGui import QWheelEvent
from PySide2.QtWidgets import QApplication, QGraphicsView, QScrollBar
+from src.qt.qtmain import QtOwner
+
class SmoothMode(Enum):
""" 滚动模式 """
@@ -24,11 +26,12 @@ def __init__(self):
self.animation.setPropertyName(b"value")
self.scrollTime = 500
self.animation.setDuration(self.scrollTime)
- self.animation.setEasingCurve(QEasingCurve.Linear)
+ self.animation.setEasingCurve(QEasingCurve.InOutQuad)
self.animationValue = self.value()
self.backTick = 0
self.laveValue = 0
self.lastV = 0
+ self.animation.finished.connect(self.Finished)
# def setValue(self, value):
# self.animation.stop()
@@ -38,59 +41,36 @@ def __init__(self):
# self.animation.start()
# return
- def UpdateCurrentValue(self, value):
- print(value)
+ def Finished(self):
+ print("Finished")
+ QtOwner().readForm.frame.UpdateScrollBar(self.value())
def StopScroll(self):
self.backTick = 0
self.animation.stop()
- def ResetScroll(self):
- if self.animation.state() == QAbstractAnimation.State.Running:
- startValue = self.animation.startValue()
- endValue = self.animation.endValue()
- time = self.animation.currentTime()
- value = self.animation.currentValue()
- laveTime = self.animation.duration() - time
- if laveTime > 0:
- self.backTick = laveTime
- self.laveValue = endValue - value
- else:
- self.backTick = 0
- else:
- self.backTick = 0
-
- self.animation.stop()
- return
-
- def RestartScroll(self):
- if self.backTick == 0 or self.laveValue == 0:
- return
- print(self.backTick, self.laveValue)
- self.animation.stop()
- oldValue = self.value()
- # print(self.animation.duration())
- self.animation.setStartValue(oldValue)
- self.animation.setEndValue(oldValue + self.laveValue)
- self.animation.setDuration(self.backTick)
- self.animation.start()
-
def Scroll(self, value):
if value * self.lastV < 0:
if self.animation.state() == QAbstractAnimation.State.Running:
self.lastV = value
self.animation.stop()
return
+ value = min(self.maximum(), value)
+ value = max(self.minimum(), value)
self.lastV = value
self.animation.stop()
oldValue = self.value()
+ if oldValue == value:
+ return
+
# print(self.animation.duration())
self.animation.setStartValue(oldValue)
self.animation.setDuration(self.scrollTime)
self.animation.setEndValue(oldValue - value)
self.animation.start()
+
class QtComGraphicsView(QGraphicsView):
def __init__(self, parent):
super(self.__class__, self).__init__(parent)
@@ -117,8 +97,52 @@ def __init__(self, parent):
self.scrollSize = 500
self.scrollTime = 500
+ # def wheelEvent(self, e) -> None:
+ # from src.qt.read.qtreadimg import ReadMode
+ # if self.parent().qtTool.stripModel not in [ReadMode.UpDown, ReadMode.RightLeftScroll, ReadMode.LeftRightScroll]:
+ # if e.angleDelta().y() < 0:
+ # self.parent().qtTool.NextPage()
+ # else:
+ # self.parent().qtTool.LastPage()
+ # return
+ #
+ # if self.smoothMode == SmoothMode.NO_SMOOTH:
+ # super().wheelEvent(e)
+ # return
+ # if self.parent().qtTool.stripModel == ReadMode.UpDown:
+ # scrollBar = self.vScrollBar
+ # else:
+ # scrollBar = self.hScrollBar
+ #
+ # if e.angleDelta().y() > 0:
+ # scrollBar.Scroll(self.scrollSize)
+ # else:
+ # scrollBar.Scroll(-self.scrollSize)
+ # # return super().wheelEvent(e)
+ #
+ # def SetScrollValue(self, size, time):
+ # if size == self.scrollSize and time == self.scrollTime:
+ # return
+ # self.StopScroll()
+ # self.scrollSize = size
+ # self.scrollTime = time
+ # self.vScrollBar.scrollTime = time
+ # self.hScrollBar.scrollTime = time
+ # self.vScrollBar.animation.setDuration(self.scrollTime)
+ # self.hScrollBar.animation.setDuration(self.scrollTime)
+ #
+ # def StopScroll(self):
+ # self.hScrollBar.StopScroll()
+ # self.vScrollBar.StopScroll()
+ #
+ def Scroll(self, value):
+ from src.qt.read.qtreadimg import ReadMode
+ if self.parent().qtTool.stripModel == ReadMode.UpDown:
+ self.vScrollBar.Scroll(self.vScrollBar.value()+value)
+ else:
+ self.hScrollBar.Scroll(self.hScrollBar.value()+value)
- def wheelEvent(self, e) -> None:
+ def wheelEvent(self, e):
from src.qt.read.qtreadimg import ReadMode
if self.parent().qtTool.stripModel not in [ReadMode.UpDown, ReadMode.RightLeftScroll, ReadMode.LeftRightScroll]:
if e.angleDelta().y() < 0:
@@ -130,71 +154,26 @@ def wheelEvent(self, e) -> None:
if self.smoothMode == SmoothMode.NO_SMOOTH:
super().wheelEvent(e)
return
- if self.parent().qtTool.stripModel == ReadMode.UpDown:
- scrollBar = self.vScrollBar
- else:
- scrollBar = self.hScrollBar
-
- if e.angleDelta().y() > 0:
- scrollBar.Scroll(self.scrollSize)
- else:
- scrollBar.Scroll(-self.scrollSize)
- # return super().wheelEvent(e)
-
- def SetScrollValue(self, size, time):
- if size == self.scrollSize and time == self.scrollTime:
- return
- self.StopScroll()
- self.scrollSize = size
- self.scrollTime = time
- self.vScrollBar.scrollTime = time
- self.hScrollBar.scrollTime = time
- self.vScrollBar.animation.setDuration(self.scrollTime)
- self.hScrollBar.animation.setDuration(self.scrollTime)
-
- def StopScroll(self):
- self.hScrollBar.StopScroll()
- self.vScrollBar.StopScroll()
- def Scroll(self, value):
- from src.qt.read.qtreadimg import ReadMode
- if self.parent().qtTool.stripModel == ReadMode.UpDown:
- self.vScrollBar.Scroll(value)
- else:
- self.hScrollBar.Scroll(value)
-
- # def wheelEvent(self, e):
- # from src.qt.read.qtreadimg import ReadMode
- # if self.parent().qtTool.stripModel not in [ReadMode.UpDown, ReadMode.RightLeftScroll, ReadMode.LeftRightScroll]:
- # if e.angleDelta().y() < 0:
- # self.parent().qtTool.NextPage()
- # else:
- # self.parent().qtTool.LastPage()
- # return
- #
- # if self.smoothMode == SmoothMode.NO_SMOOTH:
- # super().wheelEvent(e)
- # return
- #
- # # 将当前时间点插入队尾
- # now = QDateTime.currentDateTime().toMSecsSinceEpoch()
- # self.scrollStamps.append(now)
- # while now - self.scrollStamps[0] > 500:
- # self.scrollStamps.popleft()
- # # 根据未处理完的事件调整移动速率增益
- # accerationRatio = min(len(self.scrollStamps) / 15, 1)
- # self.qEventParam = (e.pos(), e.globalPos(), e.buttons())
- # # 计算步数
- # self.stepsTotal = self.fps * self.duration / 1000
- # # 计算每一个事件对应的移动距离
- # delta = e.angleDelta().y() * self.stepRatio
- # if self.acceleration > 0:
- # delta += delta * self.acceleration * accerationRatio
- # # 将移动距离和步数组成列表,插入队列等待处理
- # self.stepsLeftQueue.append([delta, self.stepsTotal])
- # # 定时器的溢出时间t=1000ms/帧数
- # self.smoothMoveTimer.start(1000 // self.fps)
- # # print(e)
+ # 将当前时间点插入队尾
+ now = QDateTime.currentDateTime().toMSecsSinceEpoch()
+ self.scrollStamps.append(now)
+ while now - self.scrollStamps[0] > 500:
+ self.scrollStamps.popleft()
+ # 根据未处理完的事件调整移动速率增益
+ accerationRatio = min(len(self.scrollStamps) / 15, 1)
+ self.qEventParam = (e.pos(), e.globalPos(), e.buttons())
+ # 计算步数
+ self.stepsTotal = self.fps * self.duration / 1000
+ # 计算每一个事件对应的移动距离
+ delta = e.angleDelta().y() * self.stepRatio
+ if self.acceleration > 0:
+ delta += delta * self.acceleration * accerationRatio
+ # 将移动距离和步数组成列表,插入队列等待处理
+ self.stepsLeftQueue.append([delta, self.stepsTotal])
+ # 定时器的溢出时间t=1000ms/帧数
+ self.smoothMoveTimer.start(1000 // self.fps)
+ # print(e)
def __smoothMove(self):
""" 计时器溢出时进行平滑滚动 """
@@ -206,18 +185,30 @@ def __smoothMove(self):
# 如果事件已处理完,就将其移出队列
while self.stepsLeftQueue and self.stepsLeftQueue[0][1] == 0:
self.stepsLeftQueue.popleft()
- # 构造滚轮事件
- e = QWheelEvent(self.qEventParam[0],
- self.qEventParam[1],
- round(totalDelta),
- self.qEventParam[2],
- Qt.NoModifier)
# print(e)
# 将构造出来的滚轮事件发送给app处理
from src.qt.read.qtreadimg import ReadMode
if self.parent().qtTool.stripModel in [ReadMode.UpDown]:
+ # 构造滚轮事件
+ e = QWheelEvent(self.qEventParam[0],
+ self.qEventParam[1],
+ QPoint(),
+ QPoint(0, totalDelta),
+ round(totalDelta),
+ Qt.Vertical,
+ self.qEventParam[2],
+ Qt.NoModifier)
QApplication.sendEvent(self.verticalScrollBar(), e)
else:
+ # 构造滚轮事件
+ e = QWheelEvent(self.qEventParam[0],
+ self.qEventParam[1],
+ QPoint(),
+ QPoint(0, totalDelta),
+ round(totalDelta),
+ Qt.Horizontal,
+ self.qEventParam[2],
+ Qt.NoModifier)
QApplication.sendEvent(self.horizontalScrollBar(), e)
# 如果队列已空,停止滚动
if not self.stepsLeftQueue:
diff --git a/src/qt/com/qtbubblelabel.py b/src/qt/com/qtbubblelabel.py
deleted file mode 100644
index 496243b..0000000
--- a/src/qt/com/qtbubblelabel.py
+++ /dev/null
@@ -1,170 +0,0 @@
-import os
-import time
-
-from PySide2.QtCore import Qt, QPoint, QPropertyAnimation, QEasingCurve, QParallelAnimationGroup, QRectF, Property
-from PySide2.QtGui import QPen, QPainterPath, QPainter, QColor
-from PySide2.QtWidgets import QWidget, QVBoxLayout, QLabel, QApplication, QFileDialog
-
-from src.util import Log
-
-
-class QtBubbleLabel(QWidget):
- BackgroundColor = QColor(195, 195, 195)
- BorderColor = QColor(150, 150, 150)
-
- ShowMsgTick = {}
-
- def __init__(self, *args, **kwargs):
- super(QtBubbleLabel, self).__init__(*args, **kwargs)
- self.setWindowFlags(
- Qt.Window | Qt.Tool | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagerHint)
- self.setMinimumWidth(200)
- self.setMinimumHeight(48)
- self.setAttribute(Qt.WA_TranslucentBackground, True)
- layout = QVBoxLayout(self)
- layout.setContentsMargins(8, 8, 8, 16)
- self.label = QLabel(self)
- layout.addWidget(self.label)
- self._desktop = QApplication.instance().desktop()
- self.animationGroup = QParallelAnimationGroup(self)
- self.opacityAnimation = None
- self.moveAnimation = None
-
- def setText(self, text):
- self.label.setText(text)
-
- def text(self):
- return self.label.text()
-
- def stop(self):
- self.hide()
- self.animationGroup.stop()
- self.animationGroup.clear()
- self.opacityAnimation = None
- self.moveAnimation = None
- self.close()
-
- def show(self):
- super(QtBubbleLabel, self).show()
- x = self.parent().geometry().x()
- y = self.parent().geometry().y()
- x2 = self.parent().size().width()
- y2 = self.parent().size().height()
- startPos = QPoint(x+int(x2/2)-int(self.width()/2), y+int(y2/2))
- endPos = QPoint(x+int(x2/2)-int(self.width()/2), y+int(y2/2)-self.height()*3-5)
- self.move(startPos)
- # 初始化动画
- self.initAnimation(startPos, endPos)
-
- def initAnimation(self, startPos, endPos):
- # 透明度动画
- opacityAnimation = QPropertyAnimation(self, b"opacity")
- opacityAnimation.setStartValue(1.0)
- opacityAnimation.setEndValue(0.0)
- # 设置动画曲线
- opacityAnimation.setEasingCurve(QEasingCurve.InQuad)
- opacityAnimation.setDuration(3000) # 在4秒的时间内完成
- # 往上移动动画
- moveAnimation = QPropertyAnimation(self, b"pos")
- moveAnimation.setStartValue(startPos)
- moveAnimation.setEndValue(endPos)
- moveAnimation.setEasingCurve(QEasingCurve.InQuad)
- moveAnimation.setDuration(4000) # 在5秒的时间内完成
- # 并行动画组(目的是让上面的两个动画同时进行)
- self.animationGroup.addAnimation(opacityAnimation)
- self.animationGroup.addAnimation(moveAnimation)
- self.animationGroup.finished.connect(self.close) # 动画结束时关闭窗口
- self.animationGroup.start()
- self.opacityAnimation = opacityAnimation
- self.moveAnimation = moveAnimation
-
- def paintEvent(self, event):
- super(QtBubbleLabel, self).paintEvent(event)
- painter = QPainter(self)
- painter.setRenderHint(QPainter.Antialiasing) # 抗锯齿
-
- rectPath = QPainterPath() # 圆角矩形
-
- height = self.height() - 8 # 往上偏移8
- rectPath.addRoundedRect(QRectF(0, 0, self.width(), height), 5, 5)
- x = self.width() / 5 * 4
- # 边框画笔
- painter.setPen(QPen(self.BorderColor, 1, Qt.SolidLine,
- Qt.RoundCap, Qt.RoundJoin))
- # 背景画刷
- painter.setBrush(self.BackgroundColor)
- # 绘制形状
- painter.drawPath(rectPath)
-
- def windowOpacity(self):
- return super(QtBubbleLabel, self).windowOpacity()
-
- def setWindowOpacity(self, opacity):
- super(QtBubbleLabel, self).setWindowOpacity(opacity)
-
- opacity = Property(float, windowOpacity, setWindowOpacity)
-
- def ShowMsg(self, text):
- self.stop()
- self.setText(text)
- self.setStyleSheet("color:black")
- self.show()
-
- @staticmethod
- def ShowMsgEx(owner, text):
- msgTick = QtBubbleLabel.ShowMsgTick.get(owner.__class__.__name__, 0)
- CurTick = int(time.time())
- if msgTick >= CurTick:
- return
- data = QtBubbleLabel(owner)
- data.setText(text)
- data.setStyleSheet("color:black")
- data.show()
- QtBubbleLabel.ShowMsgTick[owner.__class__.__name__] = CurTick
-
- def ShowError(self, text):
- self.stop()
- self.setText(text)
- self.setStyleSheet("color:red")
- self.show()
-
- @staticmethod
- def ShowErrorEx(owner, text):
- msgTick = QtBubbleLabel.ShowMsgTick.get(owner.__class__.__name__, 0)
- CurTick = int(time.time())
- if msgTick >= CurTick:
- return
- data = QtBubbleLabel(owner)
- data.setText(text)
- data.setStyleSheet("color:red")
- data.show()
- QtBubbleLabel.ShowMsgTick[owner.__class__.__name__] = CurTick
-
- @staticmethod
- def OpenPicture(self, path="."):
- try:
- filename = QFileDialog.getOpenFileName(self, "Open Image", path, "Image Files(*.jpg *.png)")
- if filename and len(filename) > 1:
- name = filename[0]
- picFormat = filename[1]
- baseName = os.path.basename(name)
- if baseName[-3:] == "png":
- picFormat = "png"
- elif baseName[-3:] == "jpg":
- picFormat = "jpeg"
- elif baseName[-3:] == "gif":
- picFormat = "gif"
- else:
- return None, None, None
-
- if os.path.isfile(name):
- self.cachePath = os.path.dirname(name)
-
- f = open(name, "rb")
- data = f.read()
- f.close()
- return data, name, picFormat
- return None, None, None
- except Exception as ex:
- Log.Error(ex)
- return None, None, None
diff --git a/src/qt/com/qtlistwidget.py b/src/qt/com/qtlistwidget.py
deleted file mode 100644
index 3ba25f1..0000000
--- a/src/qt/com/qtlistwidget.py
+++ /dev/null
@@ -1,381 +0,0 @@
-import weakref
-
-from PySide2.QtCore import Qt, QSize
-from PySide2.QtGui import QPixmap, QColor, QIntValidator, QFont, QCursor
-from PySide2.QtWidgets import QListWidget, QLabel, QWidget, QVBoxLayout, QHBoxLayout, QListWidgetItem, QAbstractSlider, \
- QScroller, QMenu, QApplication, QAbstractItemView
-
-from conf import config
-from src.qt.com.qtcomment import QtComment
-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
-
-
-class QtIntLimit(QIntValidator):
- def __init__(self, bottom, top, parent):
- super(self.__class__, self).__init__(bottom, top, parent)
-
- def fixup(self, input: str) -> str:
- return str(self.top())
-
-
-class ItemWidget(QWidget):
- def __init__(self, _id, title, index, info, param):
- super(ItemWidget, self).__init__()
- self.id = _id
- self.url = ""
- self.path = ""
- self.param = param
- self.setMaximumSize(220, 400)
- self.setMaximumSize(220, 400)
- layout = QVBoxLayout(self)
- layout.setContentsMargins(10, 20, 10, 0)
- # 图片label
- self.pictureData = None
- self.picIcon = QLabel(self)
- # self.picIcon.setCursor(Qt.PointingHandCursor)
- # self.picIcon.setScaledContents(True)
- self.picIcon.setMinimumSize(220, 320)
- self.picIcon.setMaximumSize(220, 320)
- self.picIcon.setToolTip(title)
- pic = QPixmap()
- self.picIcon.setPixmap(pic)
- layout.addWidget(self.picIcon)
- layout2 = QHBoxLayout()
-
- self.indexLabel = QLabel(index, self, styleSheet="color: #999999;")
- self.indexLabel.setMinimumSize(40, 20)
- self.indexLabel.setMaximumSize(40, 40)
- self.indexLabel.setAlignment(Qt.AlignLeft)
- layout2.addWidget(self.indexLabel)
-
- self.infoLabel = QLabel(info, self, styleSheet="color: #999999;")
- self.infoLabel.setMinimumSize(160, 20)
- self.infoLabel.setMaximumSize(160, 40)
- self.infoLabel.setAlignment(Qt.AlignRight)
- layout2.addWidget(self.infoLabel)
-
- layout.addLayout(layout2)
-
- self.label = QLabel(title, self, styleSheet="color: #999999;")
- self.label.setMinimumSize(220, 20)
- self.label.setMaximumSize(220, 50)
- self.label.setAlignment(Qt.AlignCenter)
- self.label.setFont(QFont("Microsoft YaHei", 12, 87))
- self.label.setWordWrap(True)
- layout.addWidget(self.label)
- # if self.info:
- # self.PaintInfo()
-
- # def PaintInfo(self):
- # painter = QPainter(self.picIcon)
- # rect = self.picIcon.rect()
- # painter.save()
- # fheight = self.picIcon.fontMetrics().height()
- # # 底部矩形框背景渐变颜色
- # bottomRectColor = QLinearGradient(
- # rect.width() / 2, rect.height() - 24 - fheight,
- # rect.width() / 2, rect.height())
- #
- # bottomRectColor.setSpread(QGradient.PadSpread)
- # bottomRectColor.setColorAt(0, QColor(255, 255, 255, 70))
- # bottomRectColor.setColorAt(1, QColor(0, 0, 0, 50))
- #
- # # 画半透明渐变矩形框
- # painter.setPen(Qt.NoPen)
- # painter.setBrush(QBrush(bottomRectColor))
- # painter.drawRect(rect.x(), rect.height() - 24 -
- # fheight, rect.width(), 24 + fheight)
- # painter.restore()
- # # 距离底部一定高度画文字
- # font = self.picIcon.font() or QFont()
- # font.setPointSize(8)
- # painter.setFont(font)
- # painter.setPen(Qt.white)
- # rect.setHeight(rect.height() - 12) # 底部减去一定高度
- # painter.drawText(rect, Qt.AlignHCenter |
- # Qt.AlignBottom, self.info)
-
- def SetPicture(self, data):
- if not data:
- return
- self.pictureData = data
- pic = QPixmap()
- pic.loadFromData(data)
- # maxW = self.picIcon.width()
- # maxH = self.picIcon.height()
- # picW = pic.width()
- # picH = pic.height()
- # if maxW / picW < maxH / picH:
- # toW = maxW
- # toH = (picH/(picW/maxW))
- # else:
- # toH = maxH
- # toW = (picW / (picH / maxH))
- newPic = pic.scaled(self.picIcon.width(), self.picIcon.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation)
-
- self.picIcon.setPixmap(newPic)
-
-
- def GetTitle(self):
- return self.label.text()
-
- def GetId(self):
- return self.id
-
-
-class QtBookList(QListWidget):
- def __init__(self, parent, name, owner):
- QListWidget.__init__(self, parent)
- self.page = 1
- self.pages = 1
- self.name = name
- self.verticalScrollBar().actionTriggered.connect(self.OnActionTriggered)
- self.isLoadingPage = False
- self.LoadCallBack = None
- self.parentId = -1
- self.popMenu = None
- self.owner = weakref.ref(owner)
-
- QScroller.grabGesture(self, QScroller.LeftMouseButtonGesture)
- self.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
-
- def GetName(self):
- return self.name + "-QtBookList"
-
- def InitBook(self, callBack=None):
- self.resize(800, 600)
- self.setMinimumHeight(400)
- self.setFrameShape(self.NoFrame) # 无边框
- self.setFlow(self.LeftToRight) # 从左到右
- self.setWrapping(True)
- self.setResizeMode(self.Adjust)
- self.LoadCallBack = callBack
-
- self.popMenu = QMenu(self)
- action = self.popMenu.addAction("打开")
- action.triggered.connect(self.OpenBookInfoHandler)
- action = self.popMenu.addAction("查看封面")
- action.triggered.connect(self.OpenPicture)
- action = self.popMenu.addAction("重下封面")
- action.triggered.connect(self.ReDownloadPicture)
- action = self.popMenu.addAction("复制标题")
- action.triggered.connect(self.CopyHandler)
- action = self.popMenu.addAction("下载")
- action.triggered.connect(self.DownloadHandler)
- self.setContextMenuPolicy(Qt.CustomContextMenu)
- self.doubleClicked.connect(self.OpenBookInfo)
- self.customContextMenuRequested.connect(self.SelectMenu)
- self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
-
- def InstallCategory(self):
- self.doubleClicked.disconnect(self.OpenBookInfo)
- self.popMenu = QMenu(self)
- action = self.popMenu.addAction("查看封面")
- action.triggered.connect(self.OpenPicture)
- self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
- return
-
- def InstallDel(self):
- action = self.popMenu.addAction("刪除")
- action.triggered.connect(self.DelHandler)
- self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
-
- def InitUser(self, callBack=None):
- self.setFrameShape(self.NoFrame) # 无边框
- self.LoadCallBack = callBack
- self.setStyleSheet("QListWidget::item { border-bottom: 1px solid black; }")
- self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
-
- def OnActionTriggered(self, action):
- if action != QAbstractSlider.SliderMove or self.isLoadingPage:
- return
- if self.page >= self.pages:
- return
- if self.verticalScrollBar().sliderPosition() == self.verticalScrollBar().maximum():
- self.isLoadingPage = True
- if self.LoadCallBack:
- self.LoadCallBack()
-
- def UpdatePage(self, page, pages):
- self.page = page
- self.pages = pages
-
- def UpdateState(self, isLoading=False):
- self.isLoadingPage = isLoading
-
- def AddBookItem(self, _id, title, info="", url="", path="", param="", originalName=""):
- index = self.count()
- iwidget = ItemWidget(_id, title, str(index+1), info, param)
- iwidget.url = url
- iwidget.path = path
- item = QListWidgetItem(self)
- item.setSizeHint(iwidget.sizeHint())
- self.setItemWidget(item, iwidget)
- iwidget.picIcon.setText("图片加载中...")
- if url and path and config.IsLoadingPicture:
- QtTask().AddDownloadTask(url, path, None, self.LoadingPictureComplete, True, index, True, self.GetName())
- pass
-
- def AddUserItem(self, commnetId, commentsCount, likesCount, content, name, createdTime, floor, url="", path="", originalName="", title="", level=1):
- index = self.count()
- iwidget = QtComment(self)
- iwidget.id = commnetId
- iwidget.commentLabel.setText(content)
- iwidget.nameLabel.setText(name)
- iwidget.numLabel.setText("({})".format(commentsCount))
- iwidget.starLabel.setText("({})".format(likesCount))
- iwidget.levelLabel.setText(" LV" + str(level) + " ")
- iwidget.titleLabel.setText(" " + title + " ")
- iwidget.url = url
- iwidget.path = path
- if createdTime:
- timeArray, day = ToolUtil.GetDateStr(createdTime)
- if day >= 1:
- iwidget.dateLabel.setText("{}天前".format(str(day)))
- else:
- strTime = "{}:{}:{}".format(timeArray.tm_hour, timeArray.tm_min, timeArray.tm_sec)
- iwidget.dateLabel.setText("{}".format(strTime))
-
- iwidget.indexLabel.setText("{}楼".format(str(floor)))
-
- item = QListWidgetItem(self)
- item.setSizeHint(iwidget.sizeHint())
- self.setItemWidget(item, iwidget)
- if url and config.IsLoadingPicture:
- QtTask().AddDownloadTask(url, path, None, self.LoadingPictureComplete, True, index, True, self.GetName())
- pass
-
- def LoadingPictureComplete(self, data, status, index):
- if status == Status.Ok:
- item = self.item(index)
- widget = self.itemWidget(item)
- widget.SetPicture(data)
- pass
- else:
- item = self.item(index)
- widget = self.itemWidget(item)
- widget.picIcon.setText("图片加载失败")
- return
-
- def clear(self) -> None:
- QListWidget.clear(self)
-
- # 防止异步加载时,信息错乱
- QtTask().CancelTasks(self.GetName())
-
- def SelectMenu(self, pos):
- index = self.indexAt(pos)
- if index.isValid():
- self.popMenu.exec_(QCursor.pos())
- pass
-
- def DownloadHandler(self):
- selected = self.selectedItems()
- for item in selected:
- widget = self.itemWidget(item)
- self.owner().epsInfoForm.OpenEpsInfo(widget.GetId())
- pass
-
- def OpenBookInfoHandler(self):
- selected = self.selectedItems()
- for item in selected:
- widget = self.itemWidget(item)
- self.owner().bookInfoForm.OpenBook(widget.GetId())
- return
-
- def CopyHandler(self):
- selected = self.selectedItems()
- if not selected:
- return
-
- data = ''
- for item in selected:
- widget = self.itemWidget(item)
- data += widget.GetTitle() + str("\r\n")
- clipboard = QApplication.clipboard()
- data = data.strip("\r\n")
- clipboard.setText(data)
- pass
-
- def DelHandler(self):
- bookIds = set()
- selected = self.selectedItems()
- for item in selected:
- widget = self.itemWidget(item)
- bookIds.add(widget.GetId())
- if not bookIds:
- return
- self.parent().DelCallBack(bookIds)
-
- def OpenBookInfo(self, modelIndex):
- index = modelIndex.row()
- item = self.item(index)
- if not item:
- return
- widget = self.itemWidget(item)
- if not widget:
- return
- bookId = widget.id
- if not bookId:
- return
- self.owner().bookInfoForm.OpenBook(bookId)
-
- def OpenPicture(self):
- selected = self.selectedItems()
- for item in selected:
- widget = self.itemWidget(item)
- QtImgMgr().ShowImg(widget.pictureData)
- return
-
- def ReDownloadPicture(self):
- selected = self.selectedItems()
- for item in selected:
- widget = self.itemWidget(item)
- index = self.row(item)
- if widget.url and config.IsLoadingPicture:
- widget.picIcon.setPixmap(None)
- widget.picIcon.setText("图片加载中")
- QtTask().AddDownloadTask(widget.url, widget.path, None, self.LoadingPictureComplete, True, index, False,
- self.GetName())
- pass
-
-class QtCategoryList(QListWidget):
- def __init__(self, parent):
- QListWidget.__init__(self, parent)
- self.setViewMode(self.ListMode)
- self.setFlow(self.LeftToRight)
- self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
- self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
- self.setHorizontalScrollMode(self.ScrollPerItem)
- QScroller.grabGesture(self, QScroller.LeftMouseButtonGesture)
- self.setMaximumHeight(30)
- self.setFocusPolicy(Qt.NoFocus)
-
- def AddItem(self, name):
- item = QListWidgetItem(name)
- item.setTextAlignment(Qt.AlignCenter)
- # item.setBackground(QColor(87, 195, 194))
- item.setBackground(QColor(0, 0, 0, 0))
- item.setSizeHint(QSize(90, 30))
- item.setFlags(item.flags() & (~Qt.ItemIsSelectable))
-
- self.addItem(item)
-
- def ClickItem(self, item):
- if item.background().color() == QColor(0, 0, 0, 0):
- item.setBackground(QColor(87, 195, 194))
- return True
- else:
- item.setBackground(QColor(0, 0, 0, 0))
- return False
-
- def GetAllSelectItem(self):
- data = set()
- for i in range(self.count()):
- item = self.item(i)
- if item.background().color() == QColor(87, 195, 194):
- data.add(item.text())
- return data
diff --git a/src/qt/com/qtmenu.py b/src/qt/com/qtmenu.py
deleted file mode 100644
index 39f4d68..0000000
--- a/src/qt/com/qtmenu.py
+++ /dev/null
@@ -1,79 +0,0 @@
-from PySide2.QtGui import QCursor, Qt
-from PySide2.QtWidgets import QMenu, QApplication
-
-from src.qt.qtmain import QtOwner
-
-
-class QtBookListMenu(object):
- def __init__(self):
- self.popMenu = QMenu(self.bookList)
- action = self.popMenu.addAction("打开")
- action.triggered.connect(self.OpenBookInfoHandler)
- action = self.popMenu.addAction("复制标题")
- action.triggered.connect(self.CopyHandler)
- action = self.popMenu.addAction("刪除")
- action.triggered.connect(self.DelHandler)
- action = self.popMenu.addAction("下载")
- action.triggered.connect(self.DownloadHandler)
-
- self.bookList.setContextMenuPolicy(Qt.CustomContextMenu)
-
- self.bookList.doubleClicked.connect(self.OpenBookInfo)
- self.bookList.customContextMenuRequested.connect(self.SelectMenu)
-
- def SelectMenu(self, pos):
- index = self.bookList.indexAt(pos)
- if index.isValid():
- self.popMenu.exec_(QCursor.pos())
- pass
-
- def DownloadHandler(self):
- selected = self.bookList.selectedItems()
- for item in selected:
- widget = self.bookList.itemWidget(item)
- QtOwner().owner.epsInfoForm.OpenEpsInfo(widget.GetId())
- pass
-
- def OpenBookInfoHandler(self):
- selected = self.bookList.selectedItems()
- for item in selected:
- widget = self.bookList.itemWidget(item)
- QtOwner().owner.bookInfoForm.OpenBook(widget.GetId())
- return
-
- def CopyHandler(self):
- selected = self.bookList.selectedItems()
- if not selected:
- return
-
- data = ''
- for item in selected:
- widget = self.bookList.itemWidget(item)
- data += widget.GetTitle() + str("\r\n")
- clipboard = QApplication.clipboard()
- data = data.strip("\r\n")
- clipboard.setText(data)
- pass
-
- def DelHandler(self):
- bookIds = set()
- selected = self.bookList.selectedItems()
- for item in selected:
- widget = self.bookList.itemWidget(item)
- bookIds.add(widget.GetId())
- if not bookIds:
- return
- self.DelCallBack(bookIds)
-
- def OpenBookInfo(self, modelIndex):
- index = modelIndex.row()
- item = self.bookList.item(index)
- if not item:
- return
- widget = self.bookList.itemWidget(item)
- if not widget:
- return
- bookId = widget.id
- if not bookId:
- return
- QtOwner().owner.bookInfoForm.OpenBook(bookId)
diff --git a/src/qt/download/download_info.py b/src/qt/download/download_info.py
index cfa185a..8e4b25b 100644
--- a/src/qt/download/download_info.py
+++ b/src/qt/download/download_info.py
@@ -161,12 +161,14 @@ def AddBookInfosBack(self, msg=""):
else:
book = BookMgr().books.get(self.bookId)
self.title = book.title
- self.savePath = os.path.join(os.path.join(config.SavePath, config.SavePathDir),
+ if not self.savePath:
+ self.savePath = os.path.join(os.path.join(config.SavePath, config.SavePathDir),
+ ToolUtil.GetCanSaveName(self.title))
+ self.savePath = os.path.join(self.savePath, "original")
+ elif not self.convertPath:
+ self.convertPath = os.path.join(os.path.join(config.SavePath, config.SavePathDir),
ToolUtil.GetCanSaveName(self.title))
- self.savePath = os.path.join(self.savePath, "原图")
- self.convertPath = os.path.join(os.path.join(config.SavePath, config.SavePathDir),
- ToolUtil.GetCanSaveName(self.title))
- self.convertPath = os.path.join(self.convertPath, "waifu2x")
+ self.convertPath = os.path.join(self.convertPath, "waifu2x")
self.AddBookEpsInfos()
return
diff --git a/src/qt/main/qtsearch_db.py b/src/qt/main/qtsearch_db.py
deleted file mode 100644
index 3322935..0000000
--- a/src/qt/main/qtsearch_db.py
+++ /dev/null
@@ -1,215 +0,0 @@
-import time
-
-from PySide2.QtSql import QSqlQuery, QSqlDatabase
-
-from conf import config
-from src.util import Log
-
-
-# 一本书
-class DbBook(object):
- def __init__(self):
- self.id = "" # 唯一标识
- self.title = "" # 标题
- self.title2 = "" # 标题
- self.author = "" # 作者
- self.chineseTeam = "" # 汉化组
- self.description = "" # 描述
- self.epsCount = 0 # 章节数
- self.pages = 0 # 页数
- self.finished = False # 是否完本
- self.categories = "" # 分类
- self.tags = "" # tag
- self.likesCount = 0 # 爱心数
- self.created_at = 0 # 创建时间
- self.updated_at = 0 # 更新时间
- self.path = "" # 路径
- self.fileServer = "" # 路径
- self.originalName = "" # 封面名
- self.totalLikes = 0 #
- self.totalViews = 0 #
-
-
-class QtSearchDb(object):
- def __init__(self):
- super(self.__class__, self).__init__()
- self.db = QSqlDatabase.addDatabase("QSQLITE", "book")
- self.db.setDatabaseName("data/book.db")
- if not self.db.open():
- Log.Warn(self.db.lastError().text())
-
- def InitWord(self):
- query = QSqlQuery(self.db)
- suc = query.exec_(
- """
- select * from words
- """
- )
- if not suc:
- a = query.lastError().text()
- Log.Warn(a)
- words = []
- while query.next():
- word = query.value(1)
- words.append(word)
- return words
-
- def InitUpdateInfo(self):
- query = QSqlQuery(self.db)
- suc = query.exec_(
- """
- select * from system
- """
- )
- if not suc:
- a = query.lastError().text()
- Log.Warn(a)
- nums = 0
- time = ""
- version = 0
- while query.next():
- if config.UpdateVersion == query.value(0):
- nums = query.value(1)
- time = query.value(2)
- version = query.value(3)
- return nums, time, version
-
- def Search(self, wordList, isTitle, isAutor, isDes, isTag, isCategory, page, sortKey=0, sortId=0):
- query = QSqlQuery(self.db)
- data = ""
- 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)
- data3 += " chineseTeam 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)
- if data:
- sql = "SELECT * FROM book WHERE 0 {}".format(data)
- else:
- sql = "SELECT * FROM book WHERE 1 "
- if sortKey == 0:
- sql += "ORDER BY updated_at "
- elif sortKey == 1:
- sql += "ORDER BY created_at "
- elif sortKey == 2:
- sql += "ORDER BY totalLikes "
- elif sortKey == 3:
- sql += "ORDER BY totalViews "
- elif sortKey == 4:
- sql += "ORDER BY epsCount "
- elif sortKey == 5:
- sql += "ORDER BY pages "
-
- if sortId == 0:
- sql += "DESC"
- else:
- sql += "ASC"
- sql += " limit {},{};".format((page-1)*20, 20)
- suc = query.exec_(sql)
- if not suc:
- a = query.lastError().text()
- Log.Warn(a)
- books = []
- while query.next():
- info = DbBook()
- info.id = query.value(0)
- info.title = query.value(1)
- info.title2 = query.value(2)
- info.author = query.value(3)
- info.chineseTeam = query.value(4)
- info.description = query.value(5)
- info.epsCount = query.value(6)
- 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)
- info.fileServer = query.value(15)
- info.originalName = query.value(16)
- info.totalLikes = query.value(17)
- info.totalViews = query.value(18)
- books.append(info)
- return books
-
- def Select(self, bookId):
- query = QSqlQuery(self.db)
- sql = "select * from book where id='{}'".format(bookId)
- suc = query.exec_(sql)
- if not suc:
- a = query.lastError().text()
- Log.Warn(a)
- return None
- while query.next():
- info = DbBook()
- info.id = query.value(0)
- info.title = query.value(1)
- info.title2 = query.value(2)
- info.author = query.value(3)
- info.chineseTeam = query.value(4)
- info.description = query.value(5)
- info.epsCount = query.value(6)
- 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)
- info.fileServer = query.value(15)
- info.originalName = query.value(16)
- return info
- return None
-
- def Update(self, addData, tick, version):
- timeArray = time.localtime(tick)
- strTime = "{}-{}-{} {}:{}:{}".format(timeArray.tm_year, timeArray.tm_mon, timeArray.tm_mday, timeArray.tm_hour, timeArray.tm_min, timeArray.tm_sec)
- sql = "update system set sub_version={}, time='{}' where id='{}'".format(version, strTime, config.UpdateVersion)
-
- self.db.transaction()
- query = QSqlQuery(self.db)
- suc = query.exec_(sql)
- if not suc:
- a = query.lastError().text()
- Log.Warn(a)
- for book in addData:
- try:
- if not book:
- continue
- sql = "replace INTO book(id, title, title2, author, chineseTeam, description, epsCount, pages, finished, likesCount, categories, tags," \
- "created_at, updated_at, path, fileServer, originalName, totalLikes, totalViews) " \
- "VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', {6}, {7}, {8}, {9}, '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', {17}, {18}); " \
- .format(book.id, book.title, book.title2, book.author, book.chineseTeam, book.description,
- book.epsCount, book.pages, int(book.finished), book.likesCount,
- book.categories, book.tags, book.created_at, book.updated_at, book.path, book.fileServer,
- book.originalName, book.totalLikes, book.totalViews)
- sql = sql.replace("\0", "")
- suc = query.exec_(sql)
- if not suc:
- a = query.lastError().text()
- Log.Warn(a)
- except Exception as ex:
- Log.Error(ex)
-
- self.db.commit()
- Log.Info("db: update database, len:{}, version:{}, tick:{} ".format(len(addData), tick, version))
diff --git a/src/qt/menu/qtsetting.py b/src/qt/menu/qtsetting.py
index 992e7c7..c4a23fe 100644
--- a/src/qt/menu/qtsetting.py
+++ b/src/qt/menu/qtsetting.py
@@ -104,7 +104,7 @@ def LoadSetting(self):
self.logBox.setCurrentIndex(config.LogIndex)
Log.UpdateLoggingLevel()
- config.IsTips = self.GetSettingV("Waifu2x/IsTips", config.IsTips)
+ # config.IsTips = self.GetSettingV("Waifu2x/IsTips", config.IsTips)
config.ChatSendAction = self.GetSettingV("Waifu2x/ChatSendAction", config.ChatSendAction)
config.IsOpenWaifu = self.GetSettingV("Waifu2x/IsOpen2", config.IsOpenWaifu)
self.checkBox.setChecked(config.IsOpenWaifu)
@@ -156,7 +156,7 @@ def ExitSaveSetting(self, mainQsize, bookQsize, imgQsize, userId, passwd):
self.settings.setValue("Passwd", base64.b64encode(passwd.encode("utf-8")))
self.settings.setValue("Passwd2", base64.b64encode(passwd.encode("utf-8")))
self.settings.setValue("Waifu2x/IsOpen2", int(config.IsOpenWaifu))
- self.settings.setValue("Waifu2x/IsTips", int(config.IsTips))
+ # self.settings.setValue("Waifu2x/IsTips", int(config.IsTips))
self.settings.setValue("Waifu2x/ChatSendAction", config.ChatSendAction)
def SetTheme(self):
diff --git a/src/qt/qtmain.py b/src/qt/qtmain.py
index 1e7b31b..bcf5c57 100644
--- a/src/qt/qtmain.py
+++ b/src/qt/qtmain.py
@@ -26,6 +26,13 @@ def owner(self):
assert isinstance(self._owner(), BikaQtMainWindow)
return self._owner()
+ @property
+ def readForm(self):
+ form = self._owner().qtReadImg
+ from src.qt.read.qtreadimg import QtReadImg
+ assert isinstance(form, QtReadImg)
+ return form
+
def SetOwner(self, owner):
self._owner = weakref.ref(owner)
@@ -280,7 +287,8 @@ def loadTrans(self, app, ui, lang, isInstall):
def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
super().closeEvent(a0)
- reply = QtOwner().ShowMsgBox(QMessageBox.Question, self.tr('提示'), self.tr('确定要退出吗?'))
+ # reply = QtOwner().ShowMsgBox(QMessageBox.Question, self.tr('提示'), self.tr('确定要退出吗?'))
+ reply = 0
if reply == 0:
a0.accept()
userId = self.loginForm.userIdEdit.text()
diff --git a/src/qt/read/qtbookinfo.py b/src/qt/read/qtbookinfo.py
index 7c99a97..bfa3b76 100644
--- a/src/qt/read/qtbookinfo.py
+++ b/src/qt/read/qtbookinfo.py
@@ -382,6 +382,7 @@ def keyPressEvent(self, ev):
def ChangeTab(self, index):
if index == 1:
- self.commentWidget.loadingForm2.show()
- self.commentWidget.LoadComment()
+ if not self.commentWidget.listWidget.count():
+ self.commentWidget.loadingForm2.show()
+ self.commentWidget.LoadComment()
return
\ No newline at end of file
diff --git a/src/qt/read/qtreadimg.py b/src/qt/read/qtreadimg.py
index 4abe4b1..bd956e7 100644
--- a/src/qt/read/qtreadimg.py
+++ b/src/qt/read/qtreadimg.py
@@ -59,6 +59,7 @@ def __init__(self):
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.SelectMenu)
+ self.isShowMenu = False
def LoadSetting(self):
self.stripModel = ReadMode(config.LookReadMode)
@@ -74,18 +75,39 @@ def SelectMenu(self):
action.triggered.connect(self.qtTool.FullScreen)
menu2 = popMenu.addMenu(self.tr("阅读模式"))
- action = menu2.addAction(self.tr("上下滚动"))
- action.triggered.connect(partial(self.ChangeReadMode, 0))
- action = menu2.addAction(self.tr("默认"))
- action.triggered.connect(partial(self.ChangeReadMode, 1))
- action = menu2.addAction(self.tr("左右双页"))
- action.triggered.connect(partial(self.ChangeReadMode, 2))
- action = menu2.addAction(self.tr("右左双页"))
- action.triggered.connect(partial(self.ChangeReadMode, 3))
- action = menu2.addAction(self.tr("左右滚动"))
- action.triggered.connect(partial(self.ChangeReadMode, 4))
- action = menu2.addAction(self.tr("右左滚动"))
- action.triggered.connect(partial(self.ChangeReadMode, 5))
+
+ def AddReadMode(name, value):
+ action = menu2.addAction(name)
+ action.triggered.connect(partial(self.ChangeReadMode, value))
+ if self.stripModel.value == value:
+ action.setCheckable(True)
+ action.setChecked(True)
+ AddReadMode(self.tr("上下滚动"), 0)
+ AddReadMode(self.tr("默认"), 1)
+ AddReadMode(self.tr("左右双页"), 2)
+ AddReadMode(self.tr("右左双页"), 3)
+ AddReadMode(self.tr("左右滚动"), 4)
+ AddReadMode(self.tr("右左滚动"), 5)
+
+ menu3 = popMenu.addMenu(self.tr("缩放"))
+
+ def AddScaleMode(name, value):
+ action = menu3.addAction(name)
+ action.triggered.connect(partial(self.qtTool.ScalePicture, value))
+ if (self.frame.scaleCnt+10) * 10 == value:
+ action.setCheckable(True)
+ action.setChecked(True)
+ AddScaleMode("50%", 50)
+ AddScaleMode("60%", 60)
+ AddScaleMode("70%", 70)
+ AddScaleMode("80%", 80)
+ AddScaleMode("90%", 90)
+ AddScaleMode("100%", 100)
+ AddScaleMode("120%", 120)
+ AddScaleMode("140%", 140)
+ AddScaleMode("160%", 160)
+ AddScaleMode("180%", 180)
+ AddScaleMode("200%", 200)
menu3 = popMenu.addMenu(self.tr("切页"))
action = menu3.addAction(self.tr("上一章"))
@@ -95,6 +117,7 @@ def SelectMenu(self):
action = popMenu.addAction(self.tr("退出"))
action.triggered.connect(self.close)
+ self.isShowMenu = True
popMenu.exec_(QCursor.pos())
@property
@@ -142,6 +165,7 @@ def OpenPage(self, bookId, epsId, name, isLastEps=False, pageIndex=-1):
if info:
self.category = info.tags[:]
self.category.extend(info.categories)
+
self.qtTool.checkBox.setChecked(config.IsOpenWaifu)
self.qtTool.SetData(isInit=True)
# self.graphicsGroup.setPixmap(QPixmap())
@@ -179,32 +203,7 @@ def OpenPage(self, bookId, epsId, name, isLastEps=False, pageIndex=-1):
if config.IsTips:
config.IsTips = 0
- msg = QMessageBox()
- if config.ThemeText == "flatblack":
- msg.setStyleSheet("QWidget{background-color:#2E2F30};QLabel{min-width: 300px;min-height: 300px;};")
- else:
- msg.setStyleSheet("QLabel{min-width: 300px;min-height: 300px;};")
- msg.setWindowTitle(self.tr("操作提示"))
- msg.setText(self.tr("""
- 操作提示:
- 下一页:
- 点击右下角区域
- 左滑图片
- 使用键盘→
- 上一页:
- 点击左下角区域
- 右滑图片
- 使用键盘←
- 打开菜单:
- 点击上方区域
- 点击右键
- 缩放:
- 按+,-
- 退出:
- 使用键盘ESC
- """))
- msg.setStandardButtons(QMessageBox.Ok)
- msg.exec()
+ self.frame.InitHelp()
def ReturnPage(self):
self.AddHistory()
@@ -460,30 +459,24 @@ def zoom(self, scaleV):
def keyReleaseEvent(self, ev):
if ev.modifiers() == Qt.ShiftModifier and ev.key() == Qt.Key_Left:
self.qtTool.OpenLastEps()
- return
+ return True
if ev.modifiers() == Qt.ShiftModifier and ev.key() == Qt.Key_Right:
self.qtTool.OpenNextEps()
- return
+ return True
# print(ev.modifiers, ev.key())
if ev.key() == Qt.Key_Plus or ev.key() == Qt.Key_Equal:
self.qtTool.zoomSlider.setValue(self.qtTool.zoomSlider.value()+10)
- return
+ return True
if ev.key() == Qt.Key_Minus:
self.qtTool.zoomSlider.setValue(self.qtTool.zoomSlider.value()-10)
- return
- if ev.key() == Qt.Key_Left:
- self.qtTool.LastPage()
- return
- elif ev.key() == Qt.Key_Right:
- self.qtTool.NextPage()
- return
- elif ev.key() == Qt.Key_Escape:
+ return True
+ if ev.key() == Qt.Key_Escape:
# if self.windowState() == Qt.WindowFullScreen:
# self.showNormal()
# self.frame.qtTool.fullButton.setText("全屏")
# return
self.qtTool.ReturnPage()
- return
+ return True
# elif ev.key() == Qt.Key_Up:
# point = self.graphicsItem.pos()
# self.graphicsItem.setPos(point.x(), point.y()+50)
@@ -492,7 +485,7 @@ def keyReleaseEvent(self, ev):
# point = self.graphicsItem.pos()
# self.graphicsItem.setPos(point.x(), point.y()-50)
# return
- super(self.__class__, self).keyReleaseEvent(ev)
+ return super(self.__class__, self).keyReleaseEvent(ev)
def AddHistory(self):
bookName = QtOwner().owner.bookInfoForm.bookName
diff --git a/src/qt/read/qtreadimg_frame.py b/src/qt/read/qtreadimg_frame.py
index 661567c..abbbc98 100644
--- a/src/qt/read/qtreadimg_frame.py
+++ b/src/qt/read/qtreadimg_frame.py
@@ -2,9 +2,9 @@
from PySide2 import QtWidgets
from PySide2.QtCore import Qt, QSizeF, QRectF, QEvent, QPoint, QSize, QRect
-from PySide2.QtGui import QPainter, QColor, QPixmap, QFont, QFontMetrics
+from PySide2.QtGui import QPainter, QColor, QPixmap, QFont, QFontMetrics, QPen, QBrush
from PySide2.QtWidgets import QGraphicsScene, QGraphicsPixmapItem, QFrame, QGraphicsItemGroup, QGraphicsItem, \
- QAbstractSlider, QAbstractItemView, QScroller
+ QAbstractSlider, QAbstractItemView, QScroller, QLabel
from conf import config
from resources.resources import DataMgr
@@ -27,6 +27,8 @@ def __init__(self, readImg):
self.graphicsView.setObjectName("graphicsView")
self.qtTool = QtImgTool(self)
self.qtTool.hide()
+ self.helpLabel = QLabel(self)
+ self.helpPixMap = QPixmap()
# self.graphicsView.setBackgroundBrush(QColor(Qt.white))
# self.graphicsView.setCursor(Qt.OpenHandCursor)
self.graphicsView.setResizeAnchor(self.graphicsView.AnchorViewCenter)
@@ -62,16 +64,17 @@ def __init__(self, readImg):
self.graphicsView.update()
self.graphicsScene.update()
-
+ self.helpLabel.installEventFilter(self)
self.graphicsScene.installEventFilter(self)
# self.graphicsView.installEventFilter(self)
# self.graphicsItem.installSceneEventFilter(self.graphicsItem)
+
self.graphicsView.setWindowFlag(Qt.FramelessWindowHint)
self.pixMapList = [QPixmap(), QPixmap(), QPixmap()]
self.graphicsItemList = [self.graphicsItem1, self.graphicsItem2, self.graphicsItem3]
- self.scaleCnt = 2
+ self.scaleCnt = 0
self.startPos = QPoint()
self.endPos = QPoint()
self.process = DWaterProgress(self)
@@ -89,43 +92,99 @@ def __init__(self, readImg):
# self.graphicsView.verticalScrollBar().setSingleStep(100)
# self.graphicsView.verticalScrollBar().setPageStep(100)
self.graphicsView.setSceneRect(0, 0, self.width(), self.height())
- self.graphicsView.verticalScrollBar().valueChanged.connect(self.OnValueChange)
- self.graphicsView.horizontalScrollBar().valueChanged.connect(self.OnValueChange)
@property
def readImg(self):
return self._readImg()
- def OnValueChange(self, value):
- self.UpdateScrollBar(value)
+ # def OnValueChange(self, value):
+ # self.UpdateScrollBar(value)
+ # return
+
+ def InitHelp(self):
+ label = self.helpLabel
+ font = QFont()
+ font.setPointSize(64)
+ fm = QFontMetrics(font)
+ label.resize(self.width(), self.height())
+ p = QPixmap(self.width(), self.height())
+ p.fill(Qt.transparent)
+ painter = QPainter(p)
+ # painter.setFont(font)
+ # painter.drawText(rect, text)
+ painter.setPen(QPen(QColor(255, 255, 255), 2))
+ painter.setBrush(QBrush(QColor(218, 84, 124, 100)))
+ painter.drawRect(QRect(0, self.height() // 2, self.width() // 3, self.height() // 2))
+ painter.drawRect(QRect(self.width() // 3 * 2, self.height() // 2, self.width() // 3, self.height() // 2))
+
+ painter.drawRect(QRect(self.width() // 3 * 1, 0, self.width() // 3, self.height() // 2))
+ painter.drawRect(QRect(self.width() // 3 * 1, self.height() // 2, self.width() // 3, self.height() // 2))
+
+ painter.setBrush(QBrush(QColor(51, 200, 255, 100)))
+ painter.drawRect(QRect(0, 0, self.width()//4, self.height() // 2))
+ painter.drawRect(QRect(0, 0, self.width()//3*4, self.height() // 2))
+
+ painter.setFont(font)
+ from src.qt.read.qtreadimg import ReadMode
+ if self.qtTool.stripModel in [ReadMode.RightLeftDouble, ReadMode.RightLeftScroll]:
+ nextPage = self.tr("上一页")
+ lastPage = self.tr("下一页")
+ else:
+ lastPage = self.tr("上一页")
+ nextPage = self.tr("下一页")
+ painter.drawText(QRect(0, self.height() // 4 * 3, self.width() // 3, self.height() // 2), lastPage)
+ painter.drawText(QRect(self.width() // 3 * 2, self.height() // 4 * 3, self.width() // 3, self.height() // 2),
+ nextPage)
+ painter.drawText(QRect(0, self.height() // 4 * 1, self.width(), self.height()), self.tr("菜单"))
+ painter.drawText(QRect(self.width()*2 // 3, self.height() // 4 * 1, self.width(), self.height()), self.tr("菜单"))
+
+ if self.qtTool.stripModel in [ReadMode.UpDown, ReadMode.LeftRight]:
+ painter.drawText(QRect(self.width() // 3, self.height() // 4 * 1, self.width(), self.height()), self.tr("上滑"))
+ painter.drawText(QRect(self.width() // 3, self.height() // 4 * 3, self.width(), self.height()), self.tr("下滑"))
+ self.helpPixMap = p
+ label.setPixmap(p)
+ label.setVisible(True)
+ # p = QPixmap()
+ # p.loadFromData(DataMgr().GetData("icon_picacg"))
+ # label.setPixmap(p)
return
def eventFilter(self, obj, ev):
# print(obj, ev)
- if obj == self.graphicsScene:
- if ev.type() == QEvent.GraphicsSceneMousePress:
+ if obj == self.graphicsScene or obj == self.helpLabel:
+ if ev.type() == QEvent.MouseButtonPress:
+ if not self.helpLabel.isHidden():
+ self.helpLabel.hide()
+ return True
+ elif ev.type() == QEvent.GraphicsSceneMousePress:
+ if not self.helpLabel.isHidden():
+ self.helpLabel.hide()
+ return True
# print(ev, ev.button())
self.startPos = ev.screenPos()
return False
elif ev.type() == QEvent.KeyPress:
+ if not self.helpLabel.isHidden():
+ self.helpLabel.hide()
+ return True
if ev.key() == Qt.Key_Down:
- point = self.graphicsGroup.pos()
- # if point.y() > 0:
- # return True
- # self.UpdatePos(point, -200)
- self.graphicsView.Scroll(-self.graphicsView.scrollSize)
+ from src.qt.read.qtreadimg import ReadMode
+ value = self.graphicsView.verticalScrollBar().value()
+ self.graphicsView.verticalScrollBar().setValue(value + 200)
+ self.UpdateScrollBar(self.graphicsView.verticalScrollBar().value(), -1)
elif ev.key() == Qt.Key_Up:
- point = self.graphicsGroup.pos()
- # if point.y() < 0:
- # return True
- # self.UpdatePos(point, 200)
- self.graphicsView.Scroll(self.graphicsView.scrollSize)
+ value = self.graphicsView.verticalScrollBar().value()
+ self.graphicsView.verticalScrollBar().setValue(value - 200)
+ self.UpdateScrollBar(self.graphicsView.verticalScrollBar().value(), 1)
+ elif ev.key() == Qt.Key_Left:
+ self.qtTool.LastPage()
+ elif ev.key() == Qt.Key_Right:
+ self.qtTool.NextPage()
return True
elif ev.type() == QEvent.GraphicsSceneMouseRelease:
# print(ev, self.width(), self.height(), self.readImg.pos())
self.endPos = ev.screenPos()
subPos = (self.endPos - self.startPos)
- self.graphicsView.StopScroll()
if ev.button() == Qt.MouseButton.LeftButton:
if abs(subPos.x()) >= 50:
if subPos.x() < 0:
@@ -134,15 +193,28 @@ def eventFilter(self, obj, ev):
self.qtTool.LastPage()
elif abs(subPos.x()) <= 20:
curPos = self.endPos - self.readImg.pos()
- if curPos.y() <= self.height() / 2:
- self.readImg.ShowAndCloseTool()
+ if curPos.x() <= self.width() // 3:
+ if curPos.y() <= self.height() // 2:
+ self.readImg.ShowAndCloseTool()
+ else:
+ self.qtTool.LastPage()
+ elif curPos.x() <= self.width() // 3 * 2:
+ if curPos.y() <= self.height() // 2:
+ value = self.graphicsView.verticalScrollBar().value()
+
+ self.graphicsView.verticalScrollBar().setValue(value - self.height())
+ self.UpdateScrollBar(self.graphicsView.verticalScrollBar().value(), -1)
+ else:
+ value = self.graphicsView.verticalScrollBar().value()
+
+ self.graphicsView.verticalScrollBar().setValue(value + self.height())
+ self.UpdateScrollBar(self.graphicsView.verticalScrollBar().value(), 1)
else:
- if curPos.x() >= self.width()/3*2:
+ if curPos.y() <= self.height() //2:
+ self.readImg.ShowAndCloseTool()
+ else:
self.qtTool.NextPage()
- elif curPos.x() <= self.width()/3:
- self.qtTool.LastPage()
- return False
return super(self.__class__, self).eventFilter(obj, ev)
def resizeEvent(self, event) -> None:
@@ -161,12 +233,17 @@ def OnActionTriggered(self, action):
value = self.graphicsView.horizontalScrollBar().value()
# print(value)
- self.UpdateScrollBar(value)
+ self.UpdateScrollBar(value, value-self.oldValue)
- def UpdateScrollBar(self, value):
- self.UpdatePos(value-self.oldValue)
+ def UpdateScrollBar(self, value, add):
+ self.UpdatePos(add)
self.ResetScrollBar()
- self.oldValue = value
+ from src.qt.read.qtreadimg import ReadMode
+ if self.qtTool.stripModel == ReadMode.UpDown:
+ self.oldValue = self.graphicsView.verticalScrollBar().value()
+ else:
+ self.oldValue = self.graphicsView.horizontalScrollBar().value()
+ return True
def ScaleFrame(self):
size = self.size()
@@ -197,25 +274,27 @@ def ResetScrollBar(self):
from src.qt.read.qtreadimg import ReadMode
if self.qtTool.stripModel == ReadMode.UpDown:
self.graphicsView.verticalScrollBar().setMinimum(-100)
- self.graphicsView.verticalScrollBar().setMaximum(width1 + width2 + 100)
+ self.graphicsView.verticalScrollBar().setMaximum(height1 + height2 + 100)
self.graphicsView.verticalScrollBar().setSingleStep(60)
self.graphicsView.verticalScrollBar().setPageStep(60)
self.graphicsView.horizontalScrollBar().setMinimum(0)
self.graphicsView.horizontalScrollBar().setMaximum(0)
elif self.qtTool.stripModel == ReadMode.LeftRightScroll:
self.graphicsView.horizontalScrollBar().setMinimum(-100)
- self.graphicsView.horizontalScrollBar().setMaximum(height1 + height2 + 100)
+ self.graphicsView.horizontalScrollBar().setMaximum(width1 + width2 + 100)
self.graphicsView.horizontalScrollBar().setSingleStep(60)
self.graphicsView.horizontalScrollBar().setPageStep(60)
self.graphicsView.verticalScrollBar().setMinimum(0)
self.graphicsView.verticalScrollBar().setMaximum(0)
elif self.qtTool.stripModel == ReadMode.RightLeftScroll:
- self.graphicsView.horizontalScrollBar().setMinimum(-(height1 + height2 + 100))
+ self.graphicsView.horizontalScrollBar().setMinimum(-(width1 + width2 + 100))
self.graphicsView.horizontalScrollBar().setMaximum(100)
self.graphicsView.horizontalScrollBar().setSingleStep(60)
self.graphicsView.horizontalScrollBar().setPageStep(60)
self.graphicsView.verticalScrollBar().setMinimum(0)
self.graphicsView.verticalScrollBar().setMaximum(0)
+ else:
+ self.graphicsView.verticalScrollBar().setMaximum(max(0, height1-self.height()))
def MakePixItem(self, index):
text = str(index+1)
@@ -223,8 +302,8 @@ def MakePixItem(self, index):
font.setPointSize(64)
fm = QFontMetrics(font)
- p = QPixmap(self.width()//2, self.height()//2)
- rect = QRect(self.width()//4-fm.width(text)//2, self.height()//4 - fm.height()//2, self.width()//2+fm.width(text)//2, self.height()//4+fm.height()//2)
+ p = QPixmap(self.width(), self.height())
+ rect = QRect(self.width()//2-fm.width(text)//2, self.height()//2 - fm.height()//2, self.width()//2+fm.width(text)//2, self.height()//2+fm.height()//2)
p.fill(Qt.transparent)
painter = QPainter(p)
painter.setFont(font)
@@ -271,9 +350,9 @@ def ScaleGraphicsItem(self):
from src.qt.read.qtreadimg import ReadMode
if self.qtTool.stripModel == ReadMode.LeftRight:
scale = (1 + self.scaleCnt * 0.1)
- self.graphicsItem1.setPixmap(
- self.pixMapList[0].scaled(min(self.width(), self.width() * scale), self.height() * scale,
- Qt.KeepAspectRatio, Qt.SmoothTransformation))
+ wight = min(self.width(), self.width() * scale)
+ height = self.height() * scale
+ self.graphicsItem1.setPixmap(self.pixMapList[0].scaled(wight, height, Qt.KeepAspectRatio, Qt.SmoothTransformation))
height1 = self.graphicsItem1.pixmap().size().height()
width1 = self.graphicsItem1.pixmap().size().width()
width2 = self.graphicsItem2.pixmap().size().width()
@@ -302,13 +381,13 @@ def ScaleGraphicsItem(self):
elif self.qtTool.stripModel in [ReadMode.LeftRightScroll]:
scale = (1 + self.scaleCnt * 0.1)
self.graphicsItem1.setPixmap(
- self.pixMapList[0].scaled(self.width() * scale, min(self.height(), self.height() * scale),
+ self.pixMapList[0].scaled(self.width() * scale*10, min(self.height(), self.height() * scale),
Qt.KeepAspectRatio, Qt.SmoothTransformation))
self.graphicsItem2.setPixmap(
- self.pixMapList[1].scaled(self.width() * scale, min(self.height(), self.height() * scale),
+ self.pixMapList[1].scaled(self.width() * scale*10, min(self.height(), self.height() * scale),
Qt.KeepAspectRatio, Qt.SmoothTransformation))
self.graphicsItem3.setPixmap(
- self.pixMapList[2].scaled(self.width() * scale, min(self.height(), self.height() * scale),
+ self.pixMapList[2].scaled(self.width() * scale*10, min(self.height(), self.height() * scale),
Qt.KeepAspectRatio, Qt.SmoothTransformation))
height1 = self.graphicsItem1.pixmap().size().height()
width1 = self.graphicsItem1.pixmap().size().width()
@@ -322,13 +401,13 @@ def ScaleGraphicsItem(self):
elif self.qtTool.stripModel in [ReadMode.RightLeftScroll]:
scale = (1 + self.scaleCnt * 0.1)
self.graphicsItem1.setPixmap(
- self.pixMapList[0].scaled(self.width() * scale, min(self.height(), self.height() * scale),
+ self.pixMapList[0].scaled(self.width() * scale*10, min(self.height(), self.height() * scale),
Qt.KeepAspectRatio, Qt.SmoothTransformation))
self.graphicsItem2.setPixmap(
- self.pixMapList[1].scaled(self.width() * scale, min(self.height(), self.height() * scale),
+ self.pixMapList[1].scaled(self.width() * scale*10, min(self.height(), self.height() * scale),
Qt.KeepAspectRatio, Qt.SmoothTransformation))
self.graphicsItem3.setPixmap(
- self.pixMapList[2].scaled(self.width() * scale, min(self.height(), self.height() * scale),
+ self.pixMapList[2].scaled(self.width() * scale*10, min(self.height(), self.height() * scale),
Qt.KeepAspectRatio, Qt.SmoothTransformation))
height1 = self.graphicsItem1.pixmap().size().height()
width1 = self.graphicsItem1.pixmap().size().width()
@@ -339,17 +418,17 @@ def ScaleGraphicsItem(self):
self.graphicsItem1.setPos(self.width()-width1, (self.height()-height1)/2)
self.graphicsItem2.setPos(self.width()-width1-width1, (self.height()-height2)/2)
self.graphicsItem3.setPos(self.width()-width1-width1-width2, (self.height()-height3)/2)
- else:
- scale = (1 + self.scaleCnt * 0.1)
+ elif self.qtTool.stripModel in [ReadMode.UpDown]:
+ scale = (0.5 + self.scaleCnt * 0.1)
+ minWidth = min(self.width(), self.width() * scale)
+ minHeight = self.height() * scale * 10
+
self.graphicsItem1.setPixmap(
- self.pixMapList[0].scaled(min(self.width(), self.width() * scale), self.height() * scale,
- Qt.KeepAspectRatio, Qt.SmoothTransformation))
+ self.pixMapList[0].scaled(minWidth, minHeight, Qt.KeepAspectRatio, Qt.SmoothTransformation))
self.graphicsItem2.setPixmap(
- self.pixMapList[1].scaled(min(self.width(), self.width() * scale), self.height() * scale,
- Qt.KeepAspectRatio, Qt.SmoothTransformation))
+ self.pixMapList[1].scaled(minWidth, minHeight, Qt.KeepAspectRatio, Qt.SmoothTransformation))
self.graphicsItem3.setPixmap(
- self.pixMapList[2].scaled(min(self.width(), self.width() * scale), self.height() * scale,
- Qt.KeepAspectRatio, Qt.SmoothTransformation))
+ self.pixMapList[2].scaled(minWidth, minHeight, Qt.KeepAspectRatio, Qt.SmoothTransformation))
height1 = self.graphicsItem1.pixmap().size().height()
width1 = self.graphicsItem1.pixmap().size().width()
width2 = self.graphicsItem2.pixmap().size().width()
@@ -412,8 +491,6 @@ def UpdatePos(self, value):
return
self.readImg.curIndex -= 1
subValue = scroll.value()
- self.graphicsView.verticalScrollBar().valueChanged.disconnect(self.OnValueChange)
- self.graphicsView.horizontalScrollBar().valueChanged.disconnect(self.OnValueChange)
self.readImg.ShowImg()
self.readImg.ShowOtherPage()
if self.qtTool.stripModel == ReadMode.UpDown:
@@ -421,16 +498,12 @@ def UpdatePos(self, value):
else:
height = self.graphicsItem1.pixmap().size().width()
subValue += height
- scroll.ResetScroll()
scroll.setValue(subValue)
- scroll.RestartScroll()
- self.graphicsView.verticalScrollBar().valueChanged.connect(self.OnValueChange)
- self.graphicsView.horizontalScrollBar().valueChanged.connect(self.OnValueChange)
pass
## 切换下一图片
- elif value > 0 and scroll.value() > height:
+ elif value > 0 and scroll.value() >= height:
if self.readImg.curIndex >= self.readImg.maxPic - 1:
return
if self.qtTool.stripModel == ReadMode.RightLeftDouble:
@@ -439,17 +512,11 @@ def UpdatePos(self, value):
else:
self.readImg.curIndex += 1
subValue = scroll.value() - height
- self.graphicsView.verticalScrollBar().valueChanged.disconnect(self.OnValueChange)
- self.graphicsView.horizontalScrollBar().valueChanged.disconnect(self.OnValueChange)
self.readImg.ShowImg()
self.readImg.ShowOtherPage()
# print(subValue)
- scroll.ResetScroll()
scroll.setValue(subValue)
- scroll.RestartScroll()
- self.graphicsView.verticalScrollBar().valueChanged.connect(self.OnValueChange)
- self.graphicsView.horizontalScrollBar().valueChanged.connect(self.OnValueChange)
else:
if value <= 0 and self.readImg.curIndex >= self.readImg.maxPic - 1:
QtMsgLabel().ShowMsgEx(self.readImg, self.tr("已经到最后一页"))
@@ -461,17 +528,11 @@ def UpdatePos(self, value):
return
self.readImg.curIndex -= 1
subValue = scroll.value() - height
- self.graphicsView.verticalScrollBar().valueChanged.disconnect(self.OnValueChange)
- self.graphicsView.horizontalScrollBar().valueChanged.disconnect(self.OnValueChange)
self.readImg.ShowImg()
self.readImg.ShowOtherPage()
# print(subValue)
- scroll.ResetScroll()
scroll.setValue(subValue)
- scroll.RestartScroll()
- self.graphicsView.verticalScrollBar().valueChanged.connect(self.OnValueChange)
- self.graphicsView.horizontalScrollBar().valueChanged.connect(self.OnValueChange)
pass
## 切换下一图片
@@ -480,14 +541,41 @@ def UpdatePos(self, value):
return
self.readImg.curIndex += 1
subValue = scroll.value()
- self.graphicsView.verticalScrollBar().valueChanged.disconnect(self.OnValueChange)
- self.graphicsView.horizontalScrollBar().valueChanged.disconnect(self.OnValueChange)
self.readImg.ShowImg()
self.readImg.ShowOtherPage()
height = self.graphicsItem1.pixmap().size().width()
subValue += height
- scroll.ResetScroll()
scroll.setValue(subValue)
- scroll.RestartScroll()
- self.graphicsView.verticalScrollBar().valueChanged.connect(self.OnValueChange)
- self.graphicsView.horizontalScrollBar().valueChanged.connect(self.OnValueChange)
\ No newline at end of file
+
+ def HandlerKey(self, key):
+ from src.qt.read.qtreadimg import ReadMode
+ model = self.qtTool.stripModel
+ if key == Qt.Key_Left:
+ if model in [ReadMode.UpDown, ReadMode.LeftRightDouble, ReadMode.RightLeftDouble]:
+ self.qtTool.LastPage()
+ elif model in [ReadMode.UpDown]:
+ self.graphicsView.Scroll(-self.height())
+ elif model in [ReadMode.LeftRightScroll, ReadMode.LeftRightDouble]:
+ self.graphicsView.Scroll(-self.width()//2)
+ elif key == Qt.Key_Right:
+ if model in [ReadMode.UpDown, ReadMode.LeftRightDouble, ReadMode.RightLeftDouble]:
+ self.qtTool.NextPage()
+ elif model in [ReadMode.UpDown]:
+ self.graphicsView.Scroll(self.height())
+ elif model in [ReadMode.LeftRightScroll, ReadMode.LeftRightDouble]:
+ self.graphicsView.Scroll(self.width()//2)
+ elif key == Qt.Key_Down:
+ if model in [ReadMode.UpDown, ReadMode.LeftRightDouble, ReadMode.RightLeftDouble]:
+ self.graphicsView.Scroll(self.height()//2)
+ elif model in [ReadMode.UpDown]:
+ self.graphicsView.Scroll(self.height()//2)
+ elif model in [ReadMode.LeftRightScroll, ReadMode.LeftRightDouble]:
+ self.graphicsView.Scroll(self.width())
+ elif key == Qt.Key_Up:
+ if model in [ReadMode.UpDown, ReadMode.LeftRightDouble, ReadMode.RightLeftDouble]:
+ self.graphicsView.Scroll(-self.height()//2)
+ elif model in [ReadMode.UpDown]:
+ self.graphicsView.Scroll(-self.height()//2)
+ elif model in [ReadMode.LeftRightScroll, ReadMode.LeftRightDouble]:
+ self.graphicsView.Scroll(-self.width())
+ return True
\ No newline at end of file
diff --git a/src/qt/read/qtreadimg_tool.py b/src/qt/read/qtreadimg_tool.py
index 9ba65f1..4df9217 100644
--- a/src/qt/read/qtreadimg_tool.py
+++ b/src/qt/read/qtreadimg_tool.py
@@ -324,14 +324,6 @@ def UpdateText(self, model):
self.scaleLabel.setText(str(scale))
self.gpuLabel.setText(QtOwner().owner.settingForm.GetGpuName())
- def ReduceScalePic(self):
- self.readImg.zoom(1/1.1)
- return
-
- def AddScalePic(self):
- self.readImg.zoom(1.1)
- return
-
def OpenLastEps(self):
epsId = self.readImg.epsId
bookId = self.readImg.bookId
@@ -479,17 +471,15 @@ def ChangeReadMode(self, index):
self.readImg.ShowImg()
self.readImg.ShowOtherPage()
else:
- self.zoomSlider.setValue(120)
- self.scaleCnt = 2
+ self.zoomSlider.setValue(100)
+ self.scaleCnt = 0
self.imgFrame.graphicsView.verticalScrollBar().blockSignals(False)
self.imgFrame.graphicsView.horizontalScrollBar().blockSignals(True)
self.readImg.ShowOtherPage()
self.imgFrame.ScalePicture()
config.LookReadMode = index
QtOwner().SetV("Read/LookReadMode", config.LookReadMode)
-
- def ResetScroll(self):
- self.imgFrame.graphicsView.SetScrollValue(int(self.scrollSize.value()), int(self.scrollTime.value()))
+ self.imgFrame.InitHelp()
diff --git a/src/qt/user/qtfavorite_db.py b/src/qt/user/qtfavorite_db.py
deleted file mode 100644
index 0264215..0000000
--- a/src/qt/user/qtfavorite_db.py
+++ /dev/null
@@ -1,212 +0,0 @@
-import time
-
-from PySide2.QtSql import QSqlQuery, QSqlDatabase
-
-from src.user.user import User
-from src.util import Log
-
-
-# 一本书
-class DbFavorite(object):
- def __init__(self):
- self.id = "" # 唯一标识
- self.title = "" # 标题
- self.author = "" # 作者
- self.chineseTeam = "" # 汉化组
- self.description = "" # 描述
- self.epsCount = 0 # 章节数
- self.pages = 0 # 页数
- self.finished = False # 是否完本
- self.categories = [] # 分类
- self.tags = [] # tag
- self.likesCount = 0 # 爱心数
- self.created_at = 0 # 创建时间
- self.updated_at = 0 # 更新时间
- self.path = "" # 路径
- self.fileServer = "" # 路径
- self.originalName = "" # 封面名
- self.totalLikes = 0
- self.totalViews = 0
- self.lastUpdateTick = 0 # 上次更新时间
- self.sortId = 0 # 排序使用
-
-
-class QtFavoriteDb(object):
- def __init__(self, owner):
- super(self.__class__, self).__init__()
- self.db = QSqlDatabase.addDatabase("QSQLITE", "favorite")
- self.db.setDatabaseName("data/favorite.db")
- if not self.db.open():
- Log.Warn(self.db.lastError().text())
-
- query = QSqlQuery(self.db)
- sql = """\
- create table if not exists favorite(\
- id varchar,\
- user varchar,\
- title varchar,\
- author varchar,\
- chineseTeam varchar,\
- description varchar,\
- epsCount int, \
- pages int, \
- finished int,\
- likesCount int,\
- categories varchar,\
- tags varchar,\
- created_at varchar,\
- updated_at varchar,\
- path varchar,\
- fileServer varchar,\
- originalName varchar,\
- totalLikes int,\
- totalViews int,\
- lastUpdateTick int,\
- sortId int
- )\
- """
- suc = query.exec_(sql)
- if not suc:
- a = query.lastError().text()
- Log.Warn(a)
-
- sql = """\
- CREATE UNIQUE INDEX id_user ON favorite (\
- id, \
- user\
- )\
- """
- suc = query.exec_(sql)
- if not suc:
- a = query.lastError().text()
- Log.Warn(a)
-
- self.allFavoriteIds = dict()
- self.needUpdatefavorite = []
- self.maxSortId = 0
-
- def LoadAllFavorite(self):
- query = QSqlQuery(self.db)
- sql = "select * from favorite where user ='{}'".format(User().userId)
- suc = query.exec_(sql)
- now = int(time.time())
- while query.next():
- # bookId, name, epsId, index, url, path
- bookId = query.value(0)
- lastUpdateTick = query.value(19)
- # sortId = query.value(20)
- # self.maxSortId = min(sortId, self.maxSortId)
- if now - lastUpdateTick >= 3600:
- self.needUpdatefavorite.append(bookId)
- self.allFavoriteIds[bookId] = 0
- return
-
- def UpdateSortId(self, bookId):
- self.maxSortId += 1
- self.allFavoriteIds[bookId] = self.maxSortId
- return self.maxSortId
-
- def UpdateFavorite(self, book):
- assert isinstance(book, DbFavorite)
- self.allFavoriteIds[book.id] = book.sortId
- query = QSqlQuery(self.db)
- sql = "replace INTO favorite(id, user, title, author, chineseTeam, description, epsCount, pages, finished, likesCount, categories, tags," \
- "created_at, updated_at, path, fileServer, originalName, totalLikes, totalViews, lastUpdateTick, sortId) " \
- "VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', {6}, {7}, {8}, {9}, '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', {17}, {18}, {19}, {20}) " \
- .format(book.id, User().userId, book.title, book.author, book.chineseTeam, book.description, book.epsCount, book.pages, int(book.finished), book.likesCount,
- book.categories, book.tags, book.created_at, book.updated_at, book.path, book.fileServer, book.originalName, book.totalLikes, book.totalViews, book.lastUpdateTick, book.sortId)
- sql = sql.replace("\0", "")
- suc = query.exec_(sql)
- if not suc:
- Log.Warn(query.lastError().text())
- return
-
- def DelFavorite(self, bookId):
- query = QSqlQuery(self.db)
- sql = "delete from favorite where id='{}' and user='{}'".format(bookId, User().userId)
- suc = query.exec_(sql)
- if not suc:
- Log.Warn(query.lastError().text())
-
- if bookId in self.allFavoriteIds:
- sortId = self.allFavoriteIds[bookId]
- self.allFavoriteIds.pop(bookId)
- if (sortId, bookId) in self.needUpdatefavorite:
- self.needUpdatefavorite.remove((sortId, bookId))
- return
-
- def Search(self, page, sortKey=0, sortId=0):
- query = QSqlQuery(self.db)
-
- sql = "SELECT * FROM favorite WHERE user='{}' ".format(User().userId)
- if sortKey == 0:
- sql += "ORDER BY updated_at "
-
- elif sortKey == 1:
- sql += "ORDER BY sortId "
- elif sortKey == 2:
- sql += "ORDER BY created_at "
- elif sortKey == 3:
- sql += "ORDER BY totalLikes "
- elif sortKey == 4:
- sql += "ORDER BY totalViews "
- elif sortKey == 5:
- sql += "ORDER BY epsCount "
- elif sortKey == 6:
- sql += "ORDER BY pages "
-
- if sortId == 0:
- sql += "DESC"
- else:
- sql += "ASC"
- sql += " limit {},{};".format((page-1)*20, 20)
- suc = query.exec_(sql)
- if not suc:
- a = query.lastError().text()
- Log.Warn(a)
- books = []
- while query.next():
- info = DbFavorite()
- info.id = query.value(0)
- info.title = query.value(2)
- info.author = query.value(3)
- info.chineseTeam = query.value(4)
- info.description = query.value(5)
- info.epsCount = query.value(6)
- 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)
- info.fileServer = query.value(15)
- info.originalName = query.value(16)
- info.totalLikes = query.value(17)
- books.append(info)
- return books
-
- def Update(self, addData):
- self.db.transaction()
- query = QSqlQuery(self.db)
- for book in addData:
- try:
- if not book:
- continue
- sql = "update favorite set title='{0}', author='{2}', chineseTeam='{3}', description='{4}', epsCount={5}, pages={6}, finished='{7}', likesCount={8}, categories='{9}', tags='{10}'," \
- "created_at='{11}', updated_at='{12}', path='{13}', fileServer='{14}', originalName='{15}', totalLikes={16}, totalViews={17} where id='{18}';" \
- .format(book.title, book.title2, book.author, book.chineseTeam, book.description,
- book.epsCount, book.pages, int(book.finished), book.likesCount,
- book.categories, book.tags, book.created_at, book.updated_at, book.path, book.fileServer,
- book.originalName, book.totalLikes, book.totalViews, book.id)
- sql = sql.replace("\0", "")
- suc = query.exec_(sql)
- if not suc:
- a = query.lastError().text()
- Log.Warn(a)
- except Exception as ex:
- Log.Error(ex)
-
- self.db.commit()
- Log.Info("db: update favorite database, len:{} ".format(len(addData)))
\ No newline at end of file
diff --git a/start.py b/start.py
index 34c3d0d..f96df2b 100644
--- a/start.py
+++ b/start.py
@@ -6,7 +6,7 @@
# macOS 修复
import time
-from PySide2.QtGui import QPalette, QColor
+from PySide2.QtGui import QPalette, QColor, Qt
from qss.qss import QssDataMgr
@@ -38,14 +38,15 @@
if __name__ == "__main__":
+ QtWidgets.QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
Log.Init()
app = QtWidgets.QApplication(sys.argv) # 建立application对象
# app.addLibraryPath("./resources")
try:
main = BikaQtMainWindow(app)
except Exception as es:
- print(es)
- sys.exit(-2)
+ Log.Error(es)
+ sys.exit(-111)
# main.setPalette(QPalette(QColor("#464646")))
# main.setStyleSheet(QssDataMgr().GetData("darkblack"))
main.show() # 显示窗体
diff --git a/translations/build_translate.py b/translations/build_translate.py
deleted file mode 100644
index 95a7594..0000000
--- a/translations/build_translate.py
+++ /dev/null
@@ -1,23 +0,0 @@
-import os
-# import subprocess
-
-for root, dirs, filenames in os.walk("./"):
- for name in filenames:
- if name[-2:] != "ts":
- continue
- outName = name[:-6]
- tcName = outName + "_tc"
- filename = ".ts".format(tcName)
- sts = os.system("pyside2-lupdate -verbose ..\\ui\\{}.ui -ts {}.ts".format(outName, tcName))
- # sts = os.system("..\env\Scripts\pyside2-uic.exe {}.ui -o {}.py".format(outName, outName))
- # proc = subprocess.Popen(["pyside2-uic.exe {}.ui -o {}.py".format(outName, outName)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- # while True:
- # buff = proc.stdout.readline()
- # buff = buff.decode("gbk", "ignore")
- # if buff == '' and proc.poll() != None :
- # break
- # elif buff != '':
- # print(buff)
- pass
-
-print('Finished!')
\ No newline at end of file
diff --git a/translations/common_en.qm b/translations/common_en.qm
index a6634e9..615e715 100644
Binary files a/translations/common_en.qm and b/translations/common_en.qm differ
diff --git a/translations/common_en.ts b/translations/common_en.ts
index e71b35f..caf87b0 100644
--- a/translations/common_en.ts
+++ b/translations/common_en.ts
@@ -452,6 +452,31 @@
QtImgFrame
+
+
+
+ Last Page
+
+
+
+
+ Next Page
+
+
+
+
+ Slide Up
+
+
+
+
+ Slide Down
+
+
+
+
+ Menu
+
@@ -664,6 +689,11 @@
Next chapter
+
+
+
+ Scale
+
diff --git a/translations/common_tc.qm b/translations/common_tc.qm
index 09b2e13..a17fc19 100644
Binary files a/translations/common_tc.qm and b/translations/common_tc.qm differ
diff --git a/translations/common_tc.ts b/translations/common_tc.ts
index 48d0eb8..581e9dd 100644
--- a/translations/common_tc.ts
+++ b/translations/common_tc.ts
@@ -454,6 +454,31 @@
QtImgFrame
+
+
+
+ 上一頁
+
+
+
+
+ 下一頁
+
+
+
+
+ 上滑
+
+
+
+
+ 下滑
+
+
+
+
+ 菜單
+
@@ -666,6 +691,11 @@
下一章
+
+
+
+ 縮放
+
diff --git a/ui/readimg.py b/ui/readimg.py
index 6c50c07..96720d6 100644
--- a/ui/readimg.py
+++ b/ui/readimg.py
@@ -17,7 +17,7 @@ class Ui_ReadImg(object):
def setupUi(self, ReadImg):
if not ReadImg.objectName():
ReadImg.setObjectName(u"ReadImg")
- ReadImg.resize(299, 705)
+ ReadImg.resize(299, 730)
ReadImg.setAutoFillBackground(False)
ReadImg.setStyleSheet(u"")
self.gridLayout_2 = QGridLayout(ReadImg)
@@ -272,45 +272,6 @@ def setupUi(self, ReadImg):
self.verticalLayout.addLayout(self.horizontalLayout_11)
- self.horizontalLayout_4 = QHBoxLayout()
- self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
- self.label_7 = QLabel(ReadImg)
- self.label_7.setObjectName(u"label_7")
- self.label_7.setMaximumSize(QSize(90, 16777215))
-
- self.horizontalLayout_4.addWidget(self.label_7)
-
- self.scrollSize = QSpinBox(ReadImg)
- self.scrollSize.setObjectName(u"scrollSize")
- self.scrollSize.setMinimum(1)
- self.scrollSize.setMaximum(100000)
- self.scrollSize.setValue(500)
-
- self.horizontalLayout_4.addWidget(self.scrollSize)
-
-
- self.verticalLayout.addLayout(self.horizontalLayout_4)
-
- self.horizontalLayout_12 = QHBoxLayout()
- self.horizontalLayout_12.setObjectName(u"horizontalLayout_12")
- self.label_10 = QLabel(ReadImg)
- self.label_10.setObjectName(u"label_10")
- self.label_10.setMaximumSize(QSize(90, 16777215))
-
- self.horizontalLayout_12.addWidget(self.label_10)
-
- self.scrollTime = QSpinBox(ReadImg)
- self.scrollTime.setObjectName(u"scrollTime")
- self.scrollTime.setMinimum(100)
- self.scrollTime.setMaximum(600000)
- self.scrollTime.setSingleStep(100)
- self.scrollTime.setValue(500)
-
- self.horizontalLayout_12.addWidget(self.scrollTime)
-
-
- self.verticalLayout.addLayout(self.horizontalLayout_12)
-
self.horizontalLayout_10 = QHBoxLayout()
self.horizontalLayout_10.setObjectName(u"horizontalLayout_10")
self.zoomLabel = QLabel(ReadImg)
@@ -443,8 +404,6 @@ def setupUi(self, ReadImg):
self.waifu2xCancle.clicked.connect(ReadImg.Waifu2xCancle)
self.zoomSlider.valueChanged.connect(ReadImg.ScalePicture)
self.comboBox.currentIndexChanged.connect(ReadImg.ChangeReadMode)
- self.scrollSize.editingFinished.connect(ReadImg.ResetScroll)
- self.scrollTime.editingFinished.connect(ReadImg.ResetScroll)
QMetaObject.connectSlotsByName(ReadImg)
# setupUi
@@ -496,8 +455,6 @@ def retranslateUi(self, ReadImg):
self.comboBox.setItemText(4, QCoreApplication.translate("ReadImg", u"\u5de6\u53f3\u6eda\u52a8", None))
self.comboBox.setItemText(5, QCoreApplication.translate("ReadImg", u"\u53f3\u5de6\u6eda\u52a8", None))
- self.label_7.setText(QCoreApplication.translate("ReadImg", u"\u6eda\u52a8\u8ddd\u79bb\uff08\u50cf\u7d20\uff09\uff1a", None))
- self.label_10.setText(QCoreApplication.translate("ReadImg", u"\u6eda\u52a8\u65f6\u957f\uff08\u6beb\u79d2\uff09", None))
self.zoomLabel.setText(QCoreApplication.translate("ReadImg", u"\u7f29\u653e\uff08120%\uff09", None))
self.copyButton.setText(QCoreApplication.translate("ReadImg", u"\u6253\u5f00\u56fe\u7247\u5de5\u5177", None))
self.pushButton_2.setText(QCoreApplication.translate("ReadImg", u"\u9690\u85cf", None))
diff --git a/ui/readimg.ui b/ui/readimg.ui
index 4cd72c2..c2b887c 100644
--- a/ui/readimg.ui
+++ b/ui/readimg.ui
@@ -7,7 +7,7 @@
0
0
299
- 705
+ 730
@@ -463,69 +463,6 @@
- -
-
-
-
-
-
-
- 90
- 16777215
-
-
-
- 滚动距离(像素):
-
-
-
- -
-
-
- 1
-
-
- 100000
-
-
- 500
-
-
-
-
-
- -
-
-
-
-
-
-
- 90
- 16777215
-
-
-
- 滚动时长(毫秒)
-
-
-
- -
-
-
- 100
-
-
- 600000
-
-
- 100
-
-
- 500
-
-
-
-
-
-
-
@@ -708,8 +645,8 @@
OpenNextEps()
- 265
- 641
+ 285
+ 667
278
@@ -724,8 +661,8 @@
LastPage()
- 100
- 681
+ 113
+ 707
181
@@ -756,8 +693,8 @@
NextPage()
- 265
- 681
+ 285
+ 707
181
@@ -772,8 +709,8 @@
OpenLastEps()
- 70
- 641
+ 83
+ 667
278
@@ -820,8 +757,8 @@
OpenWaifu()
- 98
- 162
+ 101
+ 182
181
@@ -853,7 +790,7 @@
193
- 162
+ 186
296
@@ -869,7 +806,7 @@
284
- 162
+ 186
298
@@ -901,7 +838,7 @@
285
- 383
+ 427
402
@@ -909,38 +846,6 @@
-
- scrollSize
- editingFinished()
- ReadImg
- ResetScroll()
-
-
- 122
- 403
-
-
- 616
- 370
-
-
-
-
- scrollTime
- editingFinished()
- ReadImg
- ResetScroll()
-
-
- 188
- 432
-
-
- 514
- 409
-
-
-
LastPage()
@@ -960,6 +865,6 @@
Waifu2xCancle()
ScalePicture()
ChangeReadMode()
- ResetScroll()
+ ResetScale()