|
1 | | -from PyQt5.QtWidgets import QWidget, QScrollArea, QLabel, QVBoxLayout, QApplication, QHBoxLayout, QSpacerItem, \ |
| 1 | +from PyQt5.QtWidgets import QWidget, QDialog, QScrollArea, QLabel, QVBoxLayout, QApplication, QHBoxLayout, QSpacerItem, \ |
2 | 2 | QSizePolicy, QPushButton, QFrame, QMessageBox, QFormLayout, QProgressDialog, QTextEdit, QComboBox |
3 | 3 | from githubApi import GitHub, Release, SourceManager, PingThread |
4 | 4 | from PyQt5.QtCore import QObject, pyqtSlot, Qt, pyqtSignal, QUrl, QPropertyAnimation, \ |
@@ -47,12 +47,12 @@ def animationStart(self, check): |
47 | 47 | class ReleaseFrame(QFrame): |
48 | 48 | downLoadFile = pyqtSignal(Release) |
49 | 49 |
|
50 | | - def __init__(self, release: Release, mode=">", parent=None): |
| 50 | + def __init__(self, release: Release, mode=">", parent=None, r_path=""): |
51 | 51 | super().__init__(parent) |
52 | 52 | self.release: Release = release |
53 | 53 | self.showButton = AnimationButton() |
54 | 54 | self.showButton.setCheckable(True) |
55 | | - self.showButton.pixmap = QPixmap("media/unfold.png") |
| 55 | + self.showButton.pixmap = QPixmap(str(r_path.with_name('media').joinpath('unfold.png')).replace("\\", "/")) |
56 | 56 | self.dateTimeLabel = QLabel() |
57 | 57 | self.titleWidget = QWidget() |
58 | 58 | self.formWidget = QWidget() |
@@ -169,9 +169,10 @@ def downLoadButtonClicked(self): |
169 | 169 | self.downLoadFile.emit(self.release) |
170 | 170 |
|
171 | 171 |
|
172 | | -class CheckUpdateGui(QWidget): |
| 172 | +class CheckUpdateGui(QDialog): |
173 | 173 | def __init__(self, github: GitHub, parent=None): |
174 | | - super().__init__(parent) |
| 174 | + super().__init__(parent.mainWindow) |
| 175 | + self.r_path = parent.r_path |
175 | 176 | self.github: GitHub = github |
176 | 177 | self.github.setParent(self) |
177 | 178 | self.checkUpdateButton = QPushButton( |
@@ -253,7 +254,7 @@ def checkUpdate(self, releases: list): |
253 | 254 | layout.setContentsMargins(0, 0, 0, 0) |
254 | 255 | for release in releases: |
255 | 256 | frame = ReleaseFrame( |
256 | | - release, self.github.compareVersion(release.tag_name)) |
| 257 | + release, self.github.compareVersion(release.tag_name), r_path=self.r_path) |
257 | 258 | layout.addWidget(frame) |
258 | 259 | frame.downLoadFile.connect(self.github.downloadRelease) |
259 | 260 | # 底部加一个空白区域 |
@@ -300,14 +301,14 @@ def downloadCancel(self): |
300 | 301 | self.processDialog.close() |
301 | 302 | self.processDialog = None |
302 | 303 |
|
303 | | -if __name__ == '__main__': |
304 | | - import sys |
305 | | - app = QApplication(sys.argv) |
306 | | - data = { |
307 | | - "Github": "https://api.github.com/repos/", |
308 | | - "fff666": "https://fff666.top/", |
309 | | - } |
310 | | - w = CheckUpdateGui(GitHub(SourceManager(data), "eee555", |
311 | | - "Solvable-Minesweeper", "3.1.9", "(\d+\.\d+\.\d+)")) |
312 | | - w.show() |
313 | | - sys.exit(app.exec_()) |
| 304 | +# if __name__ == '__main__': |
| 305 | +# import sys |
| 306 | +# app = QApplication(sys.argv) |
| 307 | +# data = { |
| 308 | +# "Github": "https://api.github.com/repos/", |
| 309 | +# "fff666": "https://fff666.top/", |
| 310 | +# } |
| 311 | +# w = CheckUpdateGui(GitHub(SourceManager(data), "eee555", |
| 312 | +# "Solvable-Minesweeper", "3.1.9", "(\d+\.\d+\.\d+)")) |
| 313 | +# w.show() |
| 314 | +# sys.exit(app.exec_()) |
0 commit comments