Skip to content

Commit

Permalink
最近更新新增跳页
Browse files Browse the repository at this point in the history
  • Loading branch information
tonquer committed Jun 11, 2023
1 parent c03e771 commit 711da2b
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

UpdateVersion = "v1.1.0"
RealVersion = "v1.1.0"
VersionTime = "2023-6-5"
VersionTime = "2023-6-11"

Waifu2xVersion = "1.1.5"
LoginUserName = ""
Expand Down
56 changes: 53 additions & 3 deletions src/interface/ui_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QListWidgetItem, QSizePolicy, QTabWidget,
QVBoxLayout, QWidget)
from PySide6.QtWidgets import (QApplication, QFrame, QHBoxLayout, QLabel,
QListWidgetItem, QPushButton, QSizePolicy, QSpacerItem,
QSpinBox, QTabWidget, QVBoxLayout, QWidget)

from component.list.comic_list_widget import ComicListWidget

class Ui_Index(object):
def setupUi(self, Index):
if not Index.objectName():
Index.setObjectName(u"Index")
Index.resize(400, 300)
Index.resize(595, 279)
self.verticalLayout_2 = QVBoxLayout(Index)
self.verticalLayout_2.setSpacing(0)
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
Expand All @@ -43,6 +44,50 @@ def setupUi(self, Index):

self.verticalLayout_2.addWidget(self.tabWidget)

self.widget = QWidget(Index)
self.widget.setObjectName(u"widget")
self.horizontalLayout = QHBoxLayout(self.widget)
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.horizontalSpacer = QSpacerItem(383, 27, QSizePolicy.Expanding, QSizePolicy.Minimum)

self.horizontalLayout.addItem(self.horizontalSpacer)

self.pages = QLabel(self.widget)
self.pages.setObjectName(u"pages")

self.horizontalLayout.addWidget(self.pages)

self.line_3 = QFrame(self.widget)
self.line_3.setObjectName(u"line_3")
self.line_3.setFrameShape(QFrame.VLine)
self.line_3.setFrameShadow(QFrame.Sunken)

self.horizontalLayout.addWidget(self.line_3)

self.spinBox = QSpinBox(self.widget)
self.spinBox.setObjectName(u"spinBox")
self.spinBox.setMinimumSize(QSize(50, 30))
self.spinBox.setMinimum(1)
self.spinBox.setMaximum(1)

self.horizontalLayout.addWidget(self.spinBox)

self.line = QFrame(self.widget)
self.line.setObjectName(u"line")
self.line.setFrameShape(QFrame.VLine)
self.line.setFrameShadow(QFrame.Sunken)

self.horizontalLayout.addWidget(self.line)

self.jumpButton = QPushButton(self.widget)
self.jumpButton.setObjectName(u"jumpButton")
self.jumpButton.setMinimumSize(QSize(0, 30))

self.horizontalLayout.addWidget(self.jumpButton)


self.verticalLayout_2.addWidget(self.widget)


self.retranslateUi(Index)

Expand All @@ -52,5 +97,10 @@ def setupUi(self, Index):
def retranslateUi(self, Index):
Index.setWindowTitle(QCoreApplication.translate("Index", u"\u9996\u9875", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QCoreApplication.translate("Index", u"\u6700\u65b0\u4e0a\u4f20", None))
self.pages.setText(QCoreApplication.translate("Index", u"\u9875", None))
self.jumpButton.setText(QCoreApplication.translate("Index", u"\u8df3\u8f6c", None))
#if QT_CONFIG(shortcut)
self.jumpButton.setShortcut(QCoreApplication.translate("Index", u"Return", None))
#endif // QT_CONFIG(shortcut)
# retranslateUi

34 changes: 28 additions & 6 deletions src/view/index/index_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def __init__(self, parent=None):
self.bookWidgetList = []
self.tabWidget.currentChanged.connect(self.SwitchCheck)
self.newIndex = 0
self.widget.setVisible(True)
self.newListWidget.LoadCallBack = self.LoadNextPage
self.jumpButton.clicked.connect(self.JumpPage)

def SwitchCurrent(self, **kwargs):
refresh = kwargs.get("refresh")
Expand All @@ -41,12 +44,12 @@ def InitBack(self, raw):
bookInfo = raw["bookInfo"]
for key, bookList in bookInfo.items():
w = self.AddTab(key)
self.newIndex += 1
for v in bookList:
w.AddBookItemByBook(v)
self.tabWidget.setCurrentIndex(0)
else:
QtOwner().CheckShowMsg( raw)
self.GetLatestInfo()
except Exception as es:
Log.Error(es)
self.isInit = False
Expand All @@ -57,22 +60,41 @@ def AddTab(self, name):
newListWidget = ComicListWidget(tab)
verticalLayout.addWidget(newListWidget)
self.bookWidgetList.append(newListWidget)
self.tabWidget.insertTab(0, tab, name)
self.tabWidget.addTab(tab, name)
return newListWidget

def SwitchCheck(self, index):
if self.tabWidget.currentIndex() == self.newIndex and not self.isInitNew:
if self.tabWidget.currentIndex() == self.newIndex:
QtOwner().ShowLoading()
self.AddHttpTask(req.GetLatestInfoReq2(), self.GetLatestInfoBack)
self.widget.setVisible(True)
self.newListWidget.clear()
self.GetLatestInfo()
else:
self.widget.setVisible(False)
return

def GetLatestInfoBack(self, raw):
def JumpPage(self):
self.newListWidget.clear()
self.GetLatestInfo(self.spinBox.value())

def GetLatestInfo(self, page=1):
QtOwner().ShowLoading()
self.AddHttpTask(req.GetLatestInfoReq2(page-1), self.GetLatestInfoBack, page)

def GetLatestInfoBack(self, raw, page):
QtOwner().CloseLoading()
st = raw["st"]
self.newListWidget.UpdateState()
if st == Status.Ok:
self.isInitNew = True
bookList = raw["bookList"]
for v in bookList:
self.newListWidget.AddBookItemByBook(v)
self.spinBox.setValue(page)
self.spinBox.setMaximum(999)
self.newListWidget.UpdatePage(page, 999)
else:
QtOwner().CheckShowMsg( raw)
QtOwner().CheckShowMsg(raw)

def LoadNextPage(self):
self.GetLatestInfo(self.newListWidget.page + 1)
76 changes: 74 additions & 2 deletions ui/ui_index.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>595</width>
<height>279</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -31,6 +31,78 @@
</widget>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>383</width>
<height>27</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="pages">
<property name="text">
<string>页</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox">
<property name="minimumSize">
<size>
<width>50</width>
<height>30</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="jumpButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>跳转</string>
</property>
<property name="shortcut">
<string>Return</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand Down

0 comments on commit 711da2b

Please sign in to comment.