mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9970086901 | |||
| 0d631e0ab8 |
@@ -103,9 +103,13 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
pyinstaller --onefile --windowed \
|
pyinstaller --onefile --windowed \
|
||||||
--add-data "build_info.json;." \
|
--add-data "build_info.json;." \
|
||||||
|
--add-data "build_info.json;core" \
|
||||||
|
--add-data "build_info.json;core/interface" \
|
||||||
--add-data "deps/aria2c.exe;." \
|
--add-data "deps/aria2c.exe;." \
|
||||||
--add-data "core/interface/assets;core/interface/assets" \
|
--add-data "core/interface/assets;core/interface/assets" \
|
||||||
--icon "core/interface/assets/logo.png" \
|
--icon "core/interface/assets/logo.png" \
|
||||||
|
--exclude-module PyQt6 \
|
||||||
|
--exclude-module PyQt5 \
|
||||||
--hidden-import=backports.tarfile \
|
--hidden-import=backports.tarfile \
|
||||||
--hidden-import=backports \
|
--hidden-import=backports \
|
||||||
--hidden-import=jaraco.context \
|
--hidden-import=jaraco.context \
|
||||||
@@ -120,8 +124,12 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
pyinstaller --onefile --windowed \
|
pyinstaller --onefile --windowed \
|
||||||
--add-data "build_info.json:." \
|
--add-data "build_info.json:." \
|
||||||
|
--add-data "build_info.json:core" \
|
||||||
|
--add-data "build_info.json:core/interface" \
|
||||||
--add-data "core/interface/assets:core/interface/assets" \
|
--add-data "core/interface/assets:core/interface/assets" \
|
||||||
--icon "core/interface/assets/logo.png" \
|
--icon "core/interface/assets/logo.png" \
|
||||||
|
--exclude-module PyQt6 \
|
||||||
|
--exclude-module PyQt5 \
|
||||||
--hidden-import=backports.tarfile \
|
--hidden-import=backports.tarfile \
|
||||||
--hidden-import=backports \
|
--hidden-import=backports \
|
||||||
--hidden-import=jaraco.context \
|
--hidden-import=jaraco.context \
|
||||||
|
|||||||
@@ -214,3 +214,7 @@ __marimo__/
|
|||||||
*.sublime-project
|
*.sublime-project
|
||||||
*.code-workspace
|
*.code-workspace
|
||||||
*.swp
|
*.swp
|
||||||
|
|
||||||
|
# Local build files
|
||||||
|
build-local.ps1
|
||||||
|
build-local.bat
|
||||||
+81
-23
@@ -1,5 +1,5 @@
|
|||||||
from PySide6 import QtWidgets
|
from PySide6 import QtWidgets
|
||||||
from PySide6.QtCore import Qt, QTimer, QModelIndex, QAbstractTableModel, Signal
|
from PySide6.QtCore import Qt, QTimer, QModelIndex, QAbstractTableModel, Signal, QEvent
|
||||||
from PySide6.QtWidgets import (
|
from PySide6.QtWidgets import (
|
||||||
QLineEdit,
|
QLineEdit,
|
||||||
QTableView,
|
QTableView,
|
||||||
@@ -16,6 +16,10 @@ from PySide6.QtWidgets import (
|
|||||||
QMessageBox,
|
QMessageBox,
|
||||||
QTableWidget,
|
QTableWidget,
|
||||||
QTextEdit,
|
QTextEdit,
|
||||||
|
QStyle,
|
||||||
|
QStyleOptionButton,
|
||||||
|
QStyledItemDelegate,
|
||||||
|
QApplication,
|
||||||
)
|
)
|
||||||
|
|
||||||
from PySide6.QtGui import QIcon, QAction, QCloseEvent, QImage, QPixmap
|
from PySide6.QtGui import QIcon, QAction, QCloseEvent, QImage, QPixmap
|
||||||
@@ -54,11 +58,11 @@ def download_update(latest_version):
|
|||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
msg = QMessageBox()
|
msg = QMessageBox()
|
||||||
msg.setIcon(QMessageBox.Information)
|
msg.setIcon(QMessageBox.Icon.Information)
|
||||||
msg.setWindowTitle("New Version")
|
msg.setWindowTitle("New Version")
|
||||||
msg.setText("New version installed.")
|
msg.setText("New version installed.")
|
||||||
msg.setInformativeText("Please remove the old exe.")
|
msg.setInformativeText("Please remove the old exe.")
|
||||||
msg.setStandardButtons(QMessageBox.Ok)
|
msg.setStandardButtons(QMessageBox.StandardButton.Ok)
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
@@ -72,18 +76,16 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.log_signal.connect(self._on_log_signal)
|
self.log_signal.connect(self._on_log_signal)
|
||||||
|
|
||||||
def get_asset_path(filename):
|
def get_asset_path(filename):
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
base_path = sys._MEIPASS
|
||||||
|
else:
|
||||||
|
base_path = os.path.dirname(__file__)
|
||||||
|
|
||||||
asset_paths = [
|
asset_path = os.path.join(base_path, 'core', 'interface', 'assets', filename)
|
||||||
os.path.join('core/interface/assets', filename),
|
if os.path.exists(asset_path):
|
||||||
os.path.join(os.path.dirname(__file__), '..', 'assets', filename),
|
return asset_path
|
||||||
os.path.join(os.path.dirname(sys.executable), 'core/interface/assets', filename),
|
|
||||||
]
|
|
||||||
|
|
||||||
for path in asset_paths:
|
return os.path.join('core', 'interface', 'assets', filename)
|
||||||
if os.path.exists(path):
|
|
||||||
return path
|
|
||||||
|
|
||||||
return asset_paths[0]
|
|
||||||
|
|
||||||
self.setWindowIcon(QIcon(get_asset_path("logo.png")))
|
self.setWindowIcon(QIcon(get_asset_path("logo.png")))
|
||||||
|
|
||||||
@@ -111,14 +113,14 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
|
|
||||||
if assets:
|
if assets:
|
||||||
msg = QMessageBox()
|
msg = QMessageBox()
|
||||||
msg.setIcon(QMessageBox.Information)
|
msg.setIcon(QMessageBox.Icon.Information)
|
||||||
msg.setWindowTitle("Update Available")
|
msg.setWindowTitle("Update Available")
|
||||||
msg.setText("A new version is available.")
|
msg.setText("A new version is available.")
|
||||||
msg.setInformativeText("Press Ok to download the update.")
|
msg.setInformativeText("Press Ok to download the update.")
|
||||||
msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Ignore)
|
msg.setStandardButtons(QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Ignore)
|
||||||
|
|
||||||
response = msg.exec_()
|
response = msg.exec_()
|
||||||
if response == QMessageBox.Ok:
|
if response == QMessageBox.StandardButton.Ok:
|
||||||
download_update(latest_version)
|
download_update(latest_version)
|
||||||
|
|
||||||
self.setWindowTitle("Software Manager")
|
self.setWindowTitle("Software Manager")
|
||||||
@@ -177,7 +179,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
class DownloadModel(QAbstractTableModel):
|
class DownloadModel(QAbstractTableModel):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.headers = ["Name", "Status", "Progress", "Speed", "Size", "Total Size"]
|
self.headers = ["Action", "Name", "Status", "Progress", "Speed", "Size", "Total Size"]
|
||||||
|
|
||||||
def rowCount(self, parent=QModelIndex()):
|
def rowCount(self, parent=QModelIndex()):
|
||||||
return len(state.downloads)
|
return len(state.downloads)
|
||||||
@@ -191,24 +193,65 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def data(self, index, role=Qt.DisplayRole):
|
def data(self, index, role=Qt.DisplayRole):
|
||||||
if role == Qt.DisplayRole:
|
col = index.column()
|
||||||
download = state.downloads[index.row()]
|
download = state.downloads[index.row()]
|
||||||
|
if role == Qt.DisplayRole:
|
||||||
col = index.column()
|
col = index.column()
|
||||||
|
|
||||||
if col == 0:
|
if col == 0:
|
||||||
return download.name
|
return "Resume" if download.is_paused else "Pause"
|
||||||
elif col == 1:
|
elif col == 1:
|
||||||
return getattr(download, 'status', 'Downloading')
|
return download.name
|
||||||
elif col == 2:
|
elif col == 2:
|
||||||
return f"{int(download.progress)}%"
|
return getattr(download, 'status', 'Downloading')
|
||||||
elif col == 3:
|
elif col == 3:
|
||||||
return f"{download.download_speed_string()}"
|
return f"{int(download.progress)}%"
|
||||||
elif col == 4:
|
elif col == 4:
|
||||||
pass
|
return f"{download.download_speed_string()}"
|
||||||
elif col == 5:
|
elif col == 5:
|
||||||
|
pass
|
||||||
|
elif col == 6:
|
||||||
return f"{download.total_length_string()}"
|
return f"{download.total_length_string()}"
|
||||||
|
|
||||||
|
if role == Qt.UserRole and col == 0:
|
||||||
|
return download.is_paused
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def toggle_pause_resume(self, row):
|
||||||
|
download = state.downloads[row]
|
||||||
|
if download.is_paused:
|
||||||
|
download.resume()
|
||||||
|
else:
|
||||||
|
download.pause()
|
||||||
|
idx = self.index(row, 0)
|
||||||
|
self.dataChanged.emit(idx, idx, [Qt.DisplayRole, Qt.UserRole])
|
||||||
|
|
||||||
|
class PauseResumeDelegate(QStyledItemDelegate):
|
||||||
|
clicked = Signal(int)
|
||||||
|
|
||||||
|
def paint(self, painter, option, index):
|
||||||
|
if index.column() != 0:
|
||||||
|
super().paint(painter, option, index)
|
||||||
|
return
|
||||||
|
|
||||||
|
paused = index.data(Qt.UserRole)
|
||||||
|
|
||||||
|
button = QStyleOptionButton()
|
||||||
|
button.rect = option.rect
|
||||||
|
button.text = "Resume" if paused else "Pause"
|
||||||
|
button.state = QStyle.State_Enabled
|
||||||
|
|
||||||
|
QApplication.style().drawControl(
|
||||||
|
QStyle.CE_PushButton, button, painter
|
||||||
|
)
|
||||||
|
|
||||||
|
def editorEvent(self, event, model, option, index):
|
||||||
|
if index.column() == 0 and event.type() == QEvent.Type.MouseButtonPress:
|
||||||
|
self.clicked.emit(index.row())
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
self.download_model = DownloadModel()
|
self.download_model = DownloadModel()
|
||||||
self.downloadList.setModel(self.download_model)
|
self.downloadList.setModel(self.download_model)
|
||||||
self.downloadList.horizontalHeader().setStretchLastSection(False)
|
self.downloadList.horizontalHeader().setStretchLastSection(False)
|
||||||
@@ -217,6 +260,21 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.downloadList.setAttribute(Qt.WA_TranslucentBackground)
|
self.downloadList.setAttribute(Qt.WA_TranslucentBackground)
|
||||||
self.downloadList.viewport().setAttribute(Qt.WA_TranslucentBackground)
|
self.downloadList.viewport().setAttribute(Qt.WA_TranslucentBackground)
|
||||||
|
|
||||||
|
download_model = self.download_model
|
||||||
|
|
||||||
|
def on_pause_resume_clicked(row):
|
||||||
|
download_model.toggle_pause_resume(row)
|
||||||
|
|
||||||
|
download = state.downloads[row]
|
||||||
|
if download.is_paused:
|
||||||
|
download.pause()
|
||||||
|
else:
|
||||||
|
download.resume()
|
||||||
|
|
||||||
|
delegate = PauseResumeDelegate(self.downloadList)
|
||||||
|
self.downloadList.setItemDelegateForColumn(0, delegate)
|
||||||
|
delegate.clicked.connect(on_pause_resume_clicked)
|
||||||
|
|
||||||
# download button triggers
|
# download button triggers
|
||||||
self.dlbutton.clicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(self.qtablewidget.currentItem(), state.posts, state.post_titles))))
|
self.dlbutton.clicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(self.qtablewidget.currentItem(), state.posts, state.post_titles))))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user