mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 01:49:42 +02:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e950d2f90d | |||
| 1a59c45ba4 | |||
| 293c1c3ad1 | |||
| f30cc5da5e | |||
| 004c7ad416 | |||
| 65f7c04936 | |||
| 9d0d5332bf | |||
| 6d9991188a | |||
| f397bc18ce | |||
| 59e45efbb6 | |||
| 27f0a3f71d | |||
| 1d500305f7 | |||
| 20a310264f | |||
| aee8f16353 | |||
| 2354adb349 | |||
| 4c69a17f0e | |||
| 2bab6c3321 | |||
| 91482760b6 | |||
| 83fa23df58 | |||
| 41d28095c2 | |||
| de2e49e60b | |||
| dd6d16d833 | |||
| 7d0c8d16ec | |||
| 80750f010f | |||
| c93f6345c8 | |||
| a7132ed1cd | |||
| a2cff15d0d | |||
| 2eb384f7cf | |||
| 05a5b04507 | |||
| 87c974f124 |
+69
-40
@@ -25,16 +25,19 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
artifact_name: SoftwareManager-dev-linux
|
artifact_name: SoftwareManager-dev-${{ github.sha }}-linux
|
||||||
asset_name: SoftwareManager-dev-linux
|
asset_name: SoftwareManager-dev-${{ github.sha }}-linux
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
artifact_name: SoftwareManager-dev-windows.exe
|
artifact_name: SoftwareManager-dev-${{ github.sha }}-windows.exe
|
||||||
asset_name: SoftwareManager-dev-windows.exe
|
asset_name: SoftwareManager-dev-${{ github.sha }}-windows.exe
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
artifact_name: SoftwareManager-dev-macos
|
artifact_name: SoftwareManager-dev-${{ github.sha }}-macos
|
||||||
asset_name: SoftwareManager-dev-macos
|
asset_name: SoftwareManager-dev-${{ github.sha }}-macos
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.version.outputs.version }}
|
||||||
|
short_sha: ${{ steps.version.outputs.short_sha }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -66,8 +69,54 @@ jobs:
|
|||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install pyinstaller
|
pip install pyinstaller
|
||||||
|
|
||||||
- name: Build executable with PyInstaller
|
- name: Generate version
|
||||||
run: pyinstaller --onefile --windowed --name ${{ env.APP_NAME }} main.py
|
id: version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
COMMIT_SHA=${{ github.sha }}
|
||||||
|
SHORT_SHA=${COMMIT_SHA:0:7}
|
||||||
|
VERSION="${SHORT_SHA}-dev"
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
|
||||||
|
echo "Generated version: $VERSION"
|
||||||
|
|
||||||
|
- name: Inject commit hash into code
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cat > build_info.json << EOF
|
||||||
|
{
|
||||||
|
"version": "${{ env.VERSION }}"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Download aria2c (Windows)
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
run: |
|
||||||
|
mkdir -p deps
|
||||||
|
C:\msys64\usr\bin\wget.exe https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip
|
||||||
|
unzip -j aria2-1.37.0-win-64bit-build1.zip aria2-1.37.0-win-64bit-build1/aria2c.exe -d deps/
|
||||||
|
|
||||||
|
- name: Build executable with PyInstaller (Windows)
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
pyinstaller --onefile --windowed \
|
||||||
|
--add-data "build_info.json;." \
|
||||||
|
--add-data "deps/aria2c.exe;." \
|
||||||
|
--add-data "core/interface/assets;core/interface/assets" \
|
||||||
|
--name ${{ env.APP_NAME }} \
|
||||||
|
main.py
|
||||||
|
|
||||||
|
- name: Build executable with PyInstaller (Unix)
|
||||||
|
if: runner.os != 'Windows'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
pyinstaller --onefile --windowed \
|
||||||
|
--add-data "build_info.json:." \
|
||||||
|
--add-data "core/interface/assets:core/interface/assets" \
|
||||||
|
--name ${{ env.APP_NAME }} \
|
||||||
|
main.py
|
||||||
|
|
||||||
- name: Make executable (Unix)
|
- name: Make executable (Unix)
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
@@ -94,49 +143,29 @@ jobs:
|
|||||||
if: success()
|
if: success()
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
- uses: actions/download-artifact@v4
|
||||||
|
|
||||||
- name: Download all artifacts
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
path: artifacts
|
path: artifacts
|
||||||
|
|
||||||
- name: Display downloaded artifacts
|
|
||||||
run: |
|
|
||||||
echo "Downloaded artifacts:"
|
|
||||||
find artifacts -type f
|
|
||||||
ls -la artifacts/
|
|
||||||
|
|
||||||
- name: Generate version
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
COMMIT_SHA=${{ github.sha }}
|
|
||||||
SHORT_SHA=${COMMIT_SHA:0:7}
|
|
||||||
VERSION="${SHORT_SHA}-dev"
|
|
||||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
||||||
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
|
||||||
echo "Generated version: ${VERSION}"
|
|
||||||
|
|
||||||
- name: Prepare release files
|
- name: Prepare release files
|
||||||
run: |
|
run: |
|
||||||
mkdir -p release
|
mkdir -p release
|
||||||
cp artifacts/ubuntu-latest-build/SoftwareManager-dev-linux release/SoftwareManager-dev-linux
|
SHORT_SHA="${{ needs.build.outputs.short_sha }}"
|
||||||
cp artifacts/windows-latest-build/SoftwareManager-dev-windows.exe release/SoftwareManager-dev-windows.exe
|
cp artifacts/ubuntu-latest-build/SoftwareManager-dev-*-linux release/SoftwareManager-dev-${SHORT_SHA}-linux
|
||||||
cp artifacts/macos-latest-build/SoftwareManager-dev-macos release/SoftwareManager-dev-macos
|
cp artifacts/windows-latest-build/SoftwareManager-dev-*-windows.exe release/SoftwareManager-dev-${SHORT_SHA}-windows.exe
|
||||||
chmod +x release/SoftwareManager-dev-linux release/SoftwareManager-dev-macos
|
cp artifacts/macos-latest-build/SoftwareManager-dev-*-macos release/SoftwareManager-dev-${SHORT_SHA}-macos
|
||||||
|
chmod +x release/SoftwareManager-dev-*-linux release/SoftwareManager-dev-*-macos
|
||||||
ls -la release/
|
ls -la release/
|
||||||
|
|
||||||
- name: Create Release (Public)
|
- name: Create Release (Public)
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.version.outputs.version }}
|
tag_name: ${{ needs.build.outputs.version }}
|
||||||
name: ${{ steps.version.outputs.version }}
|
name: ${{ needs.build.outputs.version }}
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
files: |
|
files: |
|
||||||
release/SoftwareManager-dev-linux
|
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-linux
|
||||||
release/SoftwareManager-dev-windows.exe
|
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-windows.exe
|
||||||
release/SoftwareManager-dev-macos
|
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-macos
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"Version": "dev"
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import requests
|
import requests
|
||||||
import asyncio
|
import asyncio
|
||||||
import aiohttp
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,21 @@ def settings_dialog(self):
|
|||||||
speed_limit.setFixedHeight(30)
|
speed_limit.setFixedHeight(30)
|
||||||
dialog.layout().addWidget(speed_limit_container)
|
dialog.layout().addWidget(speed_limit_container)
|
||||||
|
|
||||||
|
###############
|
||||||
|
# IMAGE PATH #
|
||||||
|
###############
|
||||||
|
|
||||||
|
image_path_container = QWidget()
|
||||||
|
image_path_layout = QHBoxLayout()
|
||||||
|
|
||||||
|
image_path = QLineEdit()
|
||||||
|
image_path_layout.addWidget(QLabel("Image Path (requires restart):"))
|
||||||
|
image_path_layout.addWidget(image_path)
|
||||||
|
image_path_container.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
|
||||||
|
image_path_container.setLayout(image_path_layout)
|
||||||
|
image_path.setText(state.image_path)
|
||||||
|
dialog.layout().addWidget(image_path_container)
|
||||||
|
|
||||||
###############
|
###############
|
||||||
# SAVE/CANCEL #
|
# SAVE/CANCEL #
|
||||||
###############
|
###############
|
||||||
@@ -122,7 +137,7 @@ def settings_dialog(self):
|
|||||||
|
|
||||||
save_btn = QPushButton("Save")
|
save_btn = QPushButton("Save")
|
||||||
cancel_btn = QPushButton("Cancel")
|
cancel_btn = QPushButton("Cancel")
|
||||||
save_btn.clicked.connect(lambda: save_settings(thread_box.value(), close_settings, api_url.text(), download_path.text(), speed_limit.value()))
|
save_btn.clicked.connect(lambda: save_settings(thread_box.value(), close_settings, api_url.text(), download_path.text(), speed_limit.value(), image_path.text()))
|
||||||
|
|
||||||
cancel_btn.clicked.connect(dialog.reject)
|
cancel_btn.clicked.connect(dialog.reject)
|
||||||
layout.addWidget(cancel_btn)
|
layout.addWidget(cancel_btn)
|
||||||
|
|||||||
+65
-20
@@ -1,6 +1,6 @@
|
|||||||
from PySide6 import QtWidgets
|
from PySide6 import QtWidgets
|
||||||
from PySide6 import QtCore
|
from PySide6 import QtCore
|
||||||
from PySide6.QtCore import Qt, QTimer, QModelIndex, QAbstractTableModel
|
from PySide6.QtCore import Qt, QTimer, QModelIndex, QAbstractTableModel, Signal
|
||||||
from PySide6.QtWidgets import (
|
from PySide6.QtWidgets import (
|
||||||
QLineEdit,
|
QLineEdit,
|
||||||
QTableView,
|
QTableView,
|
||||||
@@ -16,10 +16,9 @@ from PySide6.QtWidgets import (
|
|||||||
QHeaderView,
|
QHeaderView,
|
||||||
QMessageBox,
|
QMessageBox,
|
||||||
QTableWidget,
|
QTableWidget,
|
||||||
QTableWidgetItem
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from PySide6.QtGui import QIcon, QAction, QCloseEvent, QPalette
|
from PySide6.QtGui import QIcon, QAction, QCloseEvent, QImage, QPixmap
|
||||||
import darkdetect
|
import darkdetect
|
||||||
import threading
|
import threading
|
||||||
import platform
|
import platform
|
||||||
@@ -28,7 +27,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
from core.utils.config.settings import save_settings
|
import json
|
||||||
from core.utils.general.wrappers import run_thread
|
from core.utils.general.wrappers import run_thread
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
from core.utils.network.download import download_selected
|
from core.utils.network.download import download_selected
|
||||||
@@ -39,39 +38,53 @@ from core.interface.utils.searchhelper import return_pressed
|
|||||||
from core.interface.dialogs.settings import settings_dialog
|
from core.interface.dialogs.settings import settings_dialog
|
||||||
from core.network.aria2_integration import dlprogress
|
from core.network.aria2_integration import dlprogress
|
||||||
|
|
||||||
|
|
||||||
def download_update(latest_version):
|
def download_update(latest_version):
|
||||||
filename = "SoftwareManager-dev-windows.exe"
|
new_filename = f"SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows.exe"
|
||||||
url = "https://github.com/KeksPirates/SoftwareManager/releases/latest/download/SoftwareManager-dev-windows.exe"
|
url = f"https://github.com/KeksPirates/SoftwareManager/releases/latest/download/SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows.exe"
|
||||||
|
|
||||||
print("Downloading update...")
|
print("Downloading update...")
|
||||||
if os.path.exists(filename):
|
|
||||||
os.remove(filename)
|
|
||||||
response = r.get(url, allow_redirects=True)
|
response = r.get(url, allow_redirects=True)
|
||||||
with open(filename, "wb") as f:
|
with open(new_filename, "wb") as f:
|
||||||
f.write(response.content)
|
f.write(response.content)
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(new_filename):
|
||||||
raise FileNotFoundError(f"Executable not found")
|
raise FileNotFoundError("Executable not found")
|
||||||
subprocess.Popen([filename], shell=True)
|
subprocess.Popen([new_filename], shell=True)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
save_settings(version=latest_version)
|
|
||||||
|
msg = QMessageBox()
|
||||||
|
msg.setIcon(QMessageBox.Information)
|
||||||
|
msg.setWindowTitle("New Version")
|
||||||
|
msg.setText("New version installed.")
|
||||||
|
msg.setInformativeText("Please remove the old exe.")
|
||||||
|
msg.setStandardButtons(QMessageBox.Ok)
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QtWidgets.QMainWindow, QWidget):
|
class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
build_info_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "build_info.json")
|
||||||
|
if os.path.exists(build_info_path):
|
||||||
|
with open(build_info_path, "r") as f:
|
||||||
|
build_info = json.load(f)
|
||||||
|
state.version = build_info.get("version")
|
||||||
|
|
||||||
# Check for updates on Windows
|
# Check for updates on Windows
|
||||||
if state.ignore_updates is False:
|
if state.ignore_updates is False:
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
result = check_for_updates()
|
result = check_for_updates()
|
||||||
|
if result != (None, None):
|
||||||
assets, latest_version = result
|
assets, latest_version = result
|
||||||
|
|
||||||
if assets:
|
if assets:
|
||||||
msg = QMessageBox()
|
msg = QMessageBox()
|
||||||
msg.setIcon(QMessageBox.Information)
|
msg.setIcon(QMessageBox.Information)
|
||||||
msg.setWindowTitle("Update Available")
|
msg.setWindowTitle("Update Available")
|
||||||
msg.setText(f"A new version is available.")
|
msg.setText("A new version is available.")
|
||||||
msg.setInformativeText("Please visit the GitHub releases page to download the latest version.")
|
msg.setInformativeText("Press Ok to download the update.")
|
||||||
msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Ignore)
|
msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Ignore)
|
||||||
|
|
||||||
response = msg.exec_()
|
response = msg.exec_()
|
||||||
@@ -98,19 +111,25 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.emptyResults.setAlignment(Qt.AlignCenter)
|
self.emptyResults.setAlignment(Qt.AlignCenter)
|
||||||
self.emptyResults.hide()
|
self.emptyResults.hide()
|
||||||
|
|
||||||
|
|
||||||
self.download_model = None
|
self.download_model = None
|
||||||
self.downloadList = QTableView()
|
self.downloadList = QTableView()
|
||||||
self.emptyLibrary = QLabel("No items in library.")
|
self.emptyLibrary = QLabel("No items in library.")
|
||||||
self.emptyDownload = QLabel("No items in downloads.")
|
self.emptyDownload = QLabel("No items in downloads.")
|
||||||
self.progressbar = QProgressBar()
|
self.progressbar = QProgressBar()
|
||||||
|
|
||||||
|
# Table Widget for Item List
|
||||||
self.qtablewidget = QTableWidget()
|
self.qtablewidget = QTableWidget()
|
||||||
|
|
||||||
self.qtablewidget.setColumnCount(2)
|
self.qtablewidget.setColumnCount(2)
|
||||||
self.qtablewidget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
|
self.qtablewidget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
|
||||||
self.qtablewidget.verticalHeader().setVisible(False)
|
self.qtablewidget.verticalHeader().setVisible(False)
|
||||||
self.qtablewidget.setHorizontalHeaderLabels(["Post Title", "Author"])
|
self.qtablewidget.setHorizontalHeaderLabels(["Post Title", "Author"])
|
||||||
self.qtablewidget.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
|
|
||||||
|
header = self.qtablewidget.horizontalHeader()
|
||||||
|
header.setSectionResizeMode(0, QHeaderView.Stretch)
|
||||||
|
header.setSectionResizeMode(1, QHeaderView.Fixed)
|
||||||
|
header.setStretchLastSection(False)
|
||||||
|
|
||||||
self.qtablewidget.setAttribute(Qt.WA_TranslucentBackground)
|
self.qtablewidget.setAttribute(Qt.WA_TranslucentBackground)
|
||||||
self.qtablewidget.viewport().setAttribute(Qt.WA_TranslucentBackground)
|
self.qtablewidget.viewport().setAttribute(Qt.WA_TranslucentBackground)
|
||||||
|
|
||||||
@@ -183,12 +202,25 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.tab2 = create_tab("Library", self.emptyLibrary, self.libraryList, self.tabs, None, None)
|
self.tab2 = create_tab("Library", self.emptyLibrary, self.libraryList, self.tabs, None, None)
|
||||||
self.tab3 = create_tab("Downloads", self.emptyDownload, self.downloadList, self.tabs, None, None)
|
self.tab3 = create_tab("Downloads", self.emptyDownload, self.downloadList, self.tabs, None, None)
|
||||||
|
|
||||||
|
self.image = QImage(state.image_path)
|
||||||
|
self.pixmap = QPixmap.fromImage(self.image)
|
||||||
|
self.overlay_label = QLabel(self)
|
||||||
|
self.overlay_label.setPixmap(self.pixmap)
|
||||||
|
self.overlay_label.adjustSize()
|
||||||
|
self.overlay_label.raise_()
|
||||||
|
|
||||||
|
offset_x = -1350
|
||||||
|
offset_y = -550
|
||||||
|
x = self.width() - self.overlay_label.width() - offset_x
|
||||||
|
y = self.height() - self.overlay_label.height() - offset_y
|
||||||
|
self.overlay_label.move(x, y)
|
||||||
|
|
||||||
|
# temporarily disabled
|
||||||
|
# state.image_changed.connect(self.update_image_overlay)
|
||||||
|
|
||||||
containerLayout.addWidget(self.tabs)
|
containerLayout.addWidget(self.tabs)
|
||||||
|
|
||||||
containerLayout.setAlignment(Qt.AlignmentFlag.AlignBottom)
|
containerLayout.setAlignment(Qt.AlignmentFlag.AlignBottom)
|
||||||
|
|
||||||
toolbar = QToolBar("Main Toolbar")
|
toolbar = QToolBar("Main Toolbar")
|
||||||
self.addToolBar(toolbar)
|
self.addToolBar(toolbar)
|
||||||
toolbar.setLayoutDirection(Qt.RightToLeft)
|
toolbar.setLayoutDirection(Qt.RightToLeft)
|
||||||
@@ -198,9 +230,8 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.tracker_list.activated.connect(self.set_tracker)
|
self.tracker_list.activated.connect(self.set_tracker)
|
||||||
|
|
||||||
if darkdetect.isDark():
|
if darkdetect.isDark():
|
||||||
settings_action = QAction(QIcon("core/interface/assets/settings_white.png"), "Settings", self)
|
|
||||||
else:
|
|
||||||
settings_action = QAction(QIcon("core/interface/assets/settings_black.png"), "Settings", self)
|
settings_action = QAction(QIcon("core/interface/assets/settings_black.png"), "Settings", self)
|
||||||
|
settings_action = QAction(QIcon("core/interface/assets/settings_white.png"), "Settings", self)
|
||||||
|
|
||||||
settings_action.triggered.connect(lambda: settings_dialog(self))
|
settings_action.triggered.connect(lambda: settings_dialog(self))
|
||||||
toolbar.addAction(settings_action)
|
toolbar.addAction(settings_action)
|
||||||
@@ -219,6 +250,13 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.download_timer.timeout.connect(lambda: run_thread(threading.Thread(target=self.download_list_update)))
|
self.download_timer.timeout.connect(lambda: run_thread(threading.Thread(target=self.download_list_update)))
|
||||||
self.download_timer.start(500)
|
self.download_timer.start(500)
|
||||||
|
|
||||||
|
def update_image_overlay(self, new_image_path):
|
||||||
|
self.image = QImage(new_image_path)
|
||||||
|
self.pixmap = QPixmap.fromImage(self.image)
|
||||||
|
|
||||||
|
self.overlay_label.setPixmap(self.pixmap)
|
||||||
|
self.overlay_label.adjustSize()
|
||||||
|
|
||||||
def download_list_update(self):
|
def download_list_update(self):
|
||||||
if self.download_model:
|
if self.download_model:
|
||||||
self.download_model.layoutAboutToBeChanged.emit()
|
self.download_model.layoutAboutToBeChanged.emit()
|
||||||
@@ -242,3 +280,10 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
else:
|
else:
|
||||||
self.emptyResults.hide()
|
self.emptyResults.hide()
|
||||||
self.qtablewidget.show()
|
self.qtablewidget.show()
|
||||||
|
|
||||||
|
|
||||||
|
# thank you claude
|
||||||
|
def resizeEvent(self, event):
|
||||||
|
super().resizeEvent(event)
|
||||||
|
table_width = self.qtablewidget.viewport().width()
|
||||||
|
self.qtablewidget.setColumnWidth(1, int(table_width * 0.3))
|
||||||
@@ -7,7 +7,7 @@ def create_config():
|
|||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
|
||||||
config["General"] = {"debug": True, "api_url": f"{state.api_url}", "aria2_threads": f"{state.aria2_threads}", "download_path": f"{state.download_path}", f"speed_limit": f"{state.speed_limit}",
|
config["General"] = {"debug": True, "api_url": f"{state.api_url}", "aria2_threads": f"{state.aria2_threads}", "download_path": f"{state.download_path}", f"speed_limit": f"{state.speed_limit}",
|
||||||
"version": f"{state.version}", "ignore_updates": f"{state.ignore_updates}"}
|
"ignore_updates": f"{state.ignore_updates}", "image_path": f"{state.image_path}"}
|
||||||
|
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
|
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
|
||||||
@@ -37,10 +37,17 @@ def read_config():
|
|||||||
|
|
||||||
config.read(config_file)
|
config.read(config_file)
|
||||||
|
|
||||||
|
if state.debug is not None:
|
||||||
state.debug = config.getboolean("General", "debug")
|
state.debug = config.getboolean("General", "debug")
|
||||||
|
if state.api_url is not None:
|
||||||
state.api_url = config.get("General", "api_url")
|
state.api_url = config.get("General", "api_url")
|
||||||
|
if state.aria2_threads is not None:
|
||||||
state.aria2_threads = config.getint("General", "aria2_threads")
|
state.aria2_threads = config.getint("General", "aria2_threads")
|
||||||
|
if state.download_path is not None:
|
||||||
state.download_path = config.get("General", "download_path")
|
state.download_path = config.get("General", "download_path")
|
||||||
|
if state.speed_limit is not None:
|
||||||
state.speed_limit = config.getint("General", "speed_limit")
|
state.speed_limit = config.getint("General", "speed_limit")
|
||||||
state.version = config.get("General", "version")
|
if state.ignore_updates is not None:
|
||||||
state.ignore_updates = config.getboolean("General", "ignore_updates")
|
state.ignore_updates = config.getboolean("General", "ignore_updates")
|
||||||
|
if state.image_path is not None:
|
||||||
|
state.image_path = config.get("General", "image_path")
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ def restart_aria2c():
|
|||||||
atexit.unregister(kill_aria2server)
|
atexit.unregister(kill_aria2server)
|
||||||
atexit.register(kill_aria2server)
|
atexit.register(kill_aria2server)
|
||||||
|
|
||||||
def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None, version=None):
|
def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None, image_path=None):
|
||||||
if thread_count is not None:
|
if thread_count is not None:
|
||||||
state.aria2_threads = thread_count
|
state.aria2_threads = thread_count
|
||||||
if apiurl is not None:
|
if apiurl is not None:
|
||||||
@@ -22,8 +22,8 @@ def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_p
|
|||||||
state.download_path = download_path
|
state.download_path = download_path
|
||||||
if speed_limit is not None:
|
if speed_limit is not None:
|
||||||
state.speed_limit = speed_limit
|
state.speed_limit = speed_limit
|
||||||
if version is not None:
|
if image_path is not None:
|
||||||
state.version = version
|
state.image_path = image_path
|
||||||
|
|
||||||
create_config()
|
create_config()
|
||||||
restart_aria2c()
|
restart_aria2c()
|
||||||
|
|||||||
+34
-20
@@ -1,24 +1,38 @@
|
|||||||
from dataclasses import dataclass
|
from PySide6.QtCore import QObject, Signal
|
||||||
from typing import Optional, Any, List, Dict
|
from typing import Optional, Any, List, Dict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@dataclass
|
class AppState(QObject):
|
||||||
class AppState:
|
image_changed = Signal(str)
|
||||||
posts: List[Dict[str, Any]]
|
|
||||||
post_titles: List[str]
|
|
||||||
post_urls: List[str]
|
|
||||||
post_author: List[str]
|
|
||||||
downloads: List[str]
|
|
||||||
version: str
|
|
||||||
ignore_updates: bool = False
|
|
||||||
debug: bool = False
|
|
||||||
tracker: str = "rutracker"
|
|
||||||
api_url: str = "https://api.michijackson.xyz"
|
|
||||||
download_path: str = str(Path.home() / "Downloads")
|
|
||||||
speed_limit: int = 0
|
|
||||||
aria2process: Optional[Any] = None
|
|
||||||
aria2: Any = None
|
|
||||||
aria2p: Any = None
|
|
||||||
aria2_threads: int = 4
|
|
||||||
|
|
||||||
state = AppState(posts=[], post_titles=[], post_urls=[], post_author=[], downloads=[], download_path="", version="")
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.posts: List[Dict[str, Any]] = []
|
||||||
|
self.post_titles: List[str] = []
|
||||||
|
self.post_urls: List[str] = []
|
||||||
|
self.post_author: List[str] = []
|
||||||
|
self.downloads: List[str] = []
|
||||||
|
self.version: str = "dev"
|
||||||
|
self._image_path: str = ""
|
||||||
|
self.ignore_updates: bool = False
|
||||||
|
self.debug: bool = False
|
||||||
|
self.tracker: str = "rutracker"
|
||||||
|
self.api_url: str = "https://api.michijackson.xyz"
|
||||||
|
self.download_path: str = str(Path.home() / "Downloads")
|
||||||
|
self.speed_limit: int = 0
|
||||||
|
self.aria2process: Optional[Any] = None
|
||||||
|
self.aria2: Any = None
|
||||||
|
self.aria2p: Any = None
|
||||||
|
self.aria2_threads: int = 4
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image_path(self) -> str:
|
||||||
|
return self._image_path
|
||||||
|
|
||||||
|
@image_path.setter
|
||||||
|
def image_path(self, new_path: str):
|
||||||
|
if new_path != self._image_path:
|
||||||
|
self._image_path = new_path
|
||||||
|
self.image_changed.emit(new_path)
|
||||||
|
|
||||||
|
state = AppState()
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ def check_for_updates():
|
|||||||
for asset in assets:
|
for asset in assets:
|
||||||
print(f" - {asset['name']}: {asset['browser_download_url']}")
|
print(f" - {asset['name']}: {asset['browser_download_url']}")
|
||||||
return assets, latest_version
|
return assets, latest_version
|
||||||
|
else:
|
||||||
|
return None, None
|
||||||
else:
|
else:
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print("Already up-to-date.")
|
print("Already up-to-date.")
|
||||||
|
|||||||
Reference in New Issue
Block a user