Commit c1218275 authored by Zheng Yile's avatar Zheng Yile
Browse files

尝试适应不同分辨率;将listWidget设置为平滑滚动

parent 24f45c68
......@@ -347,19 +347,24 @@ def ErrorDisplay(error, _ErrorTranslate, knownErrorInfo: str = "错误", unknown
else:
QMessageBox.critical(None, unknownErrorInfo, str(error), QMessageBox.Ok)
def AdjustWindowSize(window):
screen = QDesktopWidget().screenGeometry()
def AdjustWindowInit() -> int:
global screen, screenBASE
from math import sqrt
BASE = sqrt((screen.width() * screen.height()) / (1920 * 1080))
screen = QDesktopWidget().screenGeometry()
screenBASE = sqrt((screen.width() * screen.height()) / (1920 * 1080))
return screenBASE
def AdjustWindowSize(window) -> None:
global screen, screenBASE
stack = window.children()
while len(stack):
x = stack.pop()
stack.extend(x.children())
try:
x.setGeometry(x.x() * BASE, x.y() * BASE, x.width() * BASE, x.height() * BASE)
x.setGeometry(x.x() * screenBASE, x.y() * screenBASE, x.width() * screenBASE, x.height() * screenBASE)
except:
pass
window.setFixedSize(window.width() * BASE, window.height() * BASE)
window.setFixedSize(window.width() * screenBASE, window.height() * screenBASE)
window.setWindowFlags(window.windowFlags() & ~Qt.WindowMaximizeButtonHint)
size = window.geometry()
window.move((screen.width() - size.width()) / 2,
......
......@@ -4,9 +4,11 @@ from PyQt5.QtWidgets import QApplication
from mainFunctions import MainInit
from loginFunctions import LoginInit
from codiaclientgui.utils import AdjustWindowInit
if __name__ == "__main__":
app = QApplication(sys.argv)
AdjustWindowInit()
LoginInit(callback = MainInit)
sys.exit(app.exec_())
......
......@@ -4,7 +4,7 @@ from sys import platform
from PyQt5.QtCore import Qt, QSize, QThread, pyqtSignal
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QFileDialog
from PyQt5.QtWidgets import QFileDialog, QAbstractItemView
from PyQt5.QtWidgets import QHBoxLayout, QLabel, QVBoxLayout
from PyQt5.QtWidgets import QListWidgetItem, QWidget
from PyQt5.QtWidgets import QMessageBox, QMainWindow, QApplication
......@@ -140,7 +140,8 @@ def frameExerciseInit():
def AddItemToQuestionList(data: dict):
item = QListWidgetItem()
item.setSizeHint(QSize(960, 65))
from codiaclientgui.utils import screenBASE
item.setSizeHint(QSize(960 * screenBASE, 65 * screenBASE))
widget = GetExerciseWidget(data)
widget.setCursor(Qt.PointingHandCursor)
uiMain.listWidgetExercise.addItem(item)
......@@ -358,6 +359,11 @@ def BeginMain(callback=None):
uiMain.pushButtonShowTestData.clicked.connect(ShowTestData)
uiMain.pushButtonSubmitCodeDetails.clicked.connect(frameTestDataInit)
uiMain.listWidgetPackHistory.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
uiMain.listWidgetExercise.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
uiMain.listWidgetData.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
uiMain.listWidgetPack.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
for i in range(0, variables["packPerPage"]):
AddItemToPackList(uiMain.listWidgetPack)
......@@ -396,7 +402,8 @@ def frameTestDataInit():
def AddItemToTestDataList(index: int, status: str):
item = QListWidgetItem()
item.setSizeHint(QSize(960, 65))
from codiaclientgui.utils import screenBASE
item.setSizeHint(QSize(960 * screenBASE, 65 * screenBASE))
widget = GetTestDataWidGet(index, status)
uiMain.listWidgetData.addItem(item)
uiMain.listWidgetData.setItemWidget(item, widget)
......@@ -521,7 +528,8 @@ def frameHistoryInit():
def AddItemToHistoryList(data: dict):
item = QListWidgetItem()
item.setSizeHint(QSize(960, 65))
from codiaclientgui.utils import screenBASE
item.setSizeHint(QSize(960 * screenBASE, 65 * screenBASE))
widget = GetHistoryWidget(data)
if not widget.isEnabled():
item.setFlags(item.flags() & ~Qt.ItemIsSelectable)
......@@ -717,7 +725,7 @@ def UpdatePage():
packList = variables["packInfo"]["nodes"]
variables["lastPid"] = packList[0]["id"]
variables["firstPid"] = packList[-1]["id"]
uiMain.pushButtonPackNext.setEnabled(variables["hasNext"])
uiMain.pushButtonPackNext.setEnabled(variables["hasNext"] or not variables["pageNumber"])
uiMain.pushButtonPackPrevious.setEnabled(variables["pageNumber"] > 1)
uiMain.labelPackPage.setText("第 {} 页".format(variables["pageNumber"]))
for i in range(0, uiMain.listWidgetPack.count()):
......@@ -846,7 +854,8 @@ def GetPackWidget(data: dict):
def AddItemToPackList(packList: NewListWidget, data: dict = {}):
item = QListWidgetItem()
item.setSizeHint(QSize(960, 65))
from codiaclientgui.utils import screenBASE
item.setSizeHint(QSize(960 * screenBASE, 65 * screenBASE))
if not data:
widget = QWidget()
widget.setEnabled(False)
......
......@@ -30,7 +30,6 @@ class Ui_windowMain(object):
self.framePack.setObjectName("framePack")
self.listWidgetPack = NewListWidget(self.framePack)
self.listWidgetPack.setGeometry(QtCore.QRect(28, 30, 1024, 531))
self.listWidgetPack.setMaximumSize(QtCore.QSize(1280, 768))
self.listWidgetPack.setObjectName("listWidgetPack")
self.pushButtonPackOK = NewPushButton(self.framePack)
self.pushButtonPackOK.setGeometry(QtCore.QRect(480, 630, 120, 32))
......@@ -161,7 +160,6 @@ class Ui_windowMain(object):
self.progressBarHistory.setObjectName("progressBarHistory")
self.listWidgetPackHistory = NewListWidget(self.frameHistory)
self.listWidgetPackHistory.setGeometry(QtCore.QRect(28, 30, 1024, 531))
self.listWidgetPackHistory.setMaximumSize(QtCore.QSize(1280, 768))
self.listWidgetPackHistory.setObjectName("listWidgetPackHistory")
self.pushButtonSubmitCodeDetails = NewPushButton(self.frameHistory)
self.pushButtonSubmitCodeDetails.setGeometry(QtCore.QRect(480, 630, 120, 32))
......
......@@ -57,12 +57,6 @@
<height>531</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>1280</width>
<height>768</height>
</size>
</property>
</widget>
<widget class="NewPushButton" name="pushButtonPackOK">
<property name="geometry">
......@@ -522,12 +516,6 @@
<height>531</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>1280</width>
<height>768</height>
</size>
</property>
</widget>
<widget class="NewPushButton" name="pushButtonSubmitCodeDetails">
<property name="geometry">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment