Patch: updater, icon, more

This commit is contained in:
Mr Finchum 2025-02-05 14:35:12 +01:00
parent 746d0b6cdc
commit 73273266cf

View file

@ -1,6 +1,12 @@
import sys import sys
import os import os
from datetime import datetime from datetime import datetime
import importlib.resources as pkg_resources
try:
from OptimaLab35.ui import resources_rc
# keep the try for now
except Exception as e:
print(e)
from PyPiUpdater import PyPiUpdater from PyPiUpdater import PyPiUpdater
from optima35.core import OptimaManager from optima35.core import OptimaManager
@ -12,7 +18,7 @@ from OptimaLab35.ui.exif_handler_window import ExifEditor
from OptimaLab35.ui.simple_dialog import SimpleDialog # Import the SimpleDialog class from OptimaLab35.ui.simple_dialog import SimpleDialog # Import the SimpleDialog class
from OptimaLab35 import __version__ from OptimaLab35 import __version__
from PySide6.QtCore import QRunnable, QThreadPool, Signal, QObject, QRegularExpression, Qt, QTimer, Slot from PySide6.QtCore import QRunnable, QThreadPool, Signal, QObject, QRegularExpression, Qt, QTimer, Slot, QDir
from PySide6 import QtWidgets from PySide6 import QtWidgets
from PySide6.QtWidgets import ( from PySide6.QtWidgets import (
@ -31,7 +37,7 @@ from PySide6.QtWidgets import (
QProgressBar, QProgressBar,
) )
from PySide6.QtGui import QPixmap, QRegularExpressionValidator from PySide6.QtGui import QPixmap, QRegularExpressionValidator, QIcon
class OptimaLab35(QMainWindow, Ui_MainWindow): class OptimaLab35(QMainWindow, Ui_MainWindow):
def __init__(self): def __init__(self):
@ -57,6 +63,13 @@ class OptimaLab35(QMainWindow, Ui_MainWindow):
self.default_ui_layout() self.default_ui_layout()
self.define_gui_interaction() self.define_gui_interaction()
try:
self.setWindowIcon(QIcon(":app-icon.png"))
# keep the try for now
except Exception as e:
print(e)
# Init function # Init function
def default_ui_layout(self): def default_ui_layout(self):
self.ui.png_quality_spinBox.setVisible(False) self.ui.png_quality_spinBox.setVisible(False)
@ -543,8 +556,7 @@ class UpdaterWindow(QMainWindow, Ui_Updater_Window):
self.ui.check_for_update_Button.released.connect(self.cancel_long_press) self.ui.check_for_update_Button.released.connect(self.cancel_long_press)
def local_check_for_updates(self): def local_check_for_updates(self):
dist_folder = os.path.expanduser("~/git/gitlab_public/OptimaLab35/dist/") dist_folder = os.path.expanduser("~/.config/OptimaLab35/dist/")
self.ui.check_local_Button.setEnabled(False)
self.ui.label_optimalab35_latestversion.setText("Checking...") self.ui.label_optimalab35_latestversion.setText("Checking...")
self.ui.label_optima35_latestversion.setText("Checking...") self.ui.label_optima35_latestversion.setText("Checking...")
@ -564,9 +576,8 @@ class UpdaterWindow(QMainWindow, Ui_Updater_Window):
self.ui.label_optima35_latestversion.setText(o35_pkg_info[1]) self.ui.label_optima35_latestversion.setText(o35_pkg_info[1])
self.updates_available["optima35"] = o35_pkg_info[0] self.updates_available["optima35"] = o35_pkg_info[0]
def local_update(self): def local_update(self):
dist_folder = os.path.expanduser("~/git/gitlab_public/OptimaLab35/dist/") dist_folder = os.path.expanduser("~/.config/OptimaLab35/dist/")
packages_to_update = [pkg for pkg, update in self.updates_available.items() if update] packages_to_update = [pkg for pkg, update in self.updates_available.items() if update]
if not packages_to_update: if not packages_to_update:
@ -611,9 +622,12 @@ class UpdaterWindow(QMainWindow, Ui_Updater_Window):
self.restart_program() self.restart_program()
def time_to_string(self, time_time): def time_to_string(self, time_time):
dt_obj = datetime.fromtimestamp(time_time) try:
date_string = dt_obj.strftime("%d %h %H:%M") dt_obj = datetime.fromtimestamp(time_time)
return date_string date_string = dt_obj.strftime("%d %h %H:%M")
return date_string
except TypeError:
return "Missing information"
def check_for_updates(self): def check_for_updates(self):
"""Check for updates and update the UI.""" """Check for updates and update the UI."""