more ui updates

This commit is contained in:
2023-03-14 18:46:19 +01:00
parent 2e73026a8d
commit 029c70356f
4 changed files with 39 additions and 39 deletions

View File

@@ -1,11 +1,11 @@
########################################################### """
# * FSRImageVideoUpscalerFrontend - handler.py
# Handler for FSRImageVideoUpscalerFrontend *
# * Created by Janis Hutz 03/14/2023, Licensed under the GPL V3 License
# This code is licensed under the GPL V3 License! * https://janishutz.com, development@janishutz.com
# Developed 2022 by Janis Hutz *
# *
########################################################### """
import os import os
@@ -29,6 +29,8 @@ class Handler:
def handler(self, fsrpath, filepath, quality_mode, quality_setting, output_path): def handler(self, fsrpath, filepath, quality_mode, quality_setting, output_path):
# Function to be called when using this class as this function automatically determines if file is video or image # Function to be called when using this class as this function automatically determines if file is video or image
print( '\n\nFSRImageVideoUpscalerFrontend - V1.1.0\n\nCopyright 2023 FSRImageVideoUpscalerFrontend contributors\n\n\n\n' );
if self.os_type == "linux": if self.os_type == "linux":
self.tmppath = config["PathSettings"]["tmpPathLinux"] self.tmppath = config["PathSettings"]["tmpPathLinux"]
elif self.os_type == "win32": elif self.os_type == "win32":
@@ -55,6 +57,7 @@ class Handler:
self.photo_scaling(fsrpath, filepath, quality_mode, quality_setting, output_path) self.photo_scaling(fsrpath, filepath, quality_mode, quality_setting, output_path)
else: else:
print("not supported") print("not supported")
return False
def photo_scaling(self, fsrpath, filepath, quality_mode, quality_setting, output_path): def photo_scaling(self, fsrpath, filepath, quality_mode, quality_setting, output_path):
# DO NOT CALL THIS! Use Handler().handler() instead! # DO NOT CALL THIS! Use Handler().handler() instead!
@@ -194,13 +197,11 @@ class Handler:
else: else:
print("OS CURRENTLY UNSUPPORTED!") print("OS CURRENTLY UNSUPPORTED!")
return False return False
print(self.command, "\n\n\nCOMMAND\n\n\n")
os.system(self.command) os.system(self.command)
print("Finished upscaling this section.")
time.sleep(3) time.sleep(3)
# get Video's audio # get Video's audio
print("Retrieving Video's audio to append") print("Finished Upscaling individual images. \n\n\nRetrieving Video's audio to append")
try: try:
os.remove(f"{self.tmppath}audio.aac") os.remove(f"{self.tmppath}audio.aac")
os.remove(f"{output_path}") os.remove(f"{output_path}")

View File

@@ -18,6 +18,7 @@ checks = bin.checks.Checks()
handler = bin.handler.Handler() handler = bin.handler.Handler()
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QDialog, QFileDialog, QComboBox, QHBoxLayout, QVBoxLayout, QWidget from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QDialog, QFileDialog, QComboBox, QHBoxLayout, QVBoxLayout, QWidget
from PyQt5.QtCore import QUrl
class HomeWindow(QMainWindow): class HomeWindow(QMainWindow):
@@ -27,18 +28,29 @@ class HomeWindow(QMainWindow):
self.save_file = "" self.save_file = ""
self.open_file = "" self.open_file = ""
box = QHBoxLayout(); box = QVBoxLayout();
actionsBox = QHBoxLayout();
widget = QWidget(); widget = QWidget();
actionsWidget = QWidget();
self.button = QPushButton( 'Input file' ); self.button = QPushButton( 'Input file' );
self.button.clicked.connect( self.filechooser_clicked ); self.button.clicked.connect( self.filechooser_clicked );
self.button_out = QPushButton( 'Output file' );
self.button_out.clicked.connect( self.opfilechooser_clicked );
self.button_run = QPushButton( 'Upscale' );
self.button_run.clicked.connect( self.info_button );
self.qualitySelector = QComboBox(); self.qualitySelector = QComboBox();
self.qualitySelector.addItems( ['2x', '1.7x', '1.5x', '1.3x', 'Custom (will respect value below)' ] ); self.qualitySelector.addItems( ['2x', '1.7x', '1.5x', '1.3x', 'Custom (will respect value below)' ] );
actionsBox.addWidget( self.button );
actionsBox.addWidget( self.button_out );
actionsBox.addWidget( self.button_run );
actionsWidget.setLayout( actionsBox );
box.addWidget( self.button )
box.addWidget( self.qualitySelector ); box.addWidget( self.qualitySelector );
box.addWidget( actionsWidget );
widget.setLayout( box ); widget.setLayout( box );
self.setCentralWidget( widget ); self.setCentralWidget( widget );
@@ -53,46 +65,33 @@ class HomeWindow(QMainWindow):
self.model = quality.get_model() self.model = quality.get_model()
self.output = self.model[self.tree_iter][0] self.output = self.model[self.tree_iter][0]
def filechooser_clicked(self, widget): def filechooser_clicked( self ):
self.open_file = QFileDialog.getOpenFileName( self, 'Open input file', '', 'Image & Video files (*.jpg *.png *.mp4 *.mkv *.jpeg)' ); self.open_file = QFileDialog.getOpenFileName( self, 'Open input file', '', 'Image & Video files (*.jpg *.png *.mp4 *.mkv *.jpeg)' );
def opfilechooser_clicked(self, widget): def opfilechooser_clicked( self ):
self.path = ''; self.path = '';
if str(self.open_file)[len(self.open_file) - 4:] == '.mp4': if str( self.open_file )[len(self.open_file) - 4:] == '.mp4':
self.path = 'video.mp4'; self.path = 'video.mp4';
elif str(self.open_file)[len(self.open_file) - 4:] == '.mkv': elif str( self.open_file )[len(self.open_file) - 4:] == '.mkv':
self.path = 'video.mkv'; self.path = 'video.mkv';
elif str(self.open_file)[len(self.open_file) - 4:] == '.png': elif str( self.open_file )[len(self.open_file) - 4:] == '.png':
self.path = 'image.png'; self.path = 'image.png';
elif str(self.open_file)[len(self.open_file) - 4:] == '.jpg': elif str( self.open_file )[len(self.open_file) - 4:] == '.jpg':
self.path = 'image.jpg'; self.path = 'image.jpg';
elif str(self.open_file)[len(self.open_file) - 4:] == '.jpeg': elif str( self.open_file )[len(self.open_file) - 4:] == '.jpeg':
self.path = 'image.jpeg'; self.path = 'image.jpeg';
self.open_file_out = QFileDialog( self, 'Select output file', '', 'Image & Video files (*.jpg *.png *.mp4 *.mkv *.jpeg)' ); self.open_file_out = QFileDialog.getOpenFileName( self, 'Select output file', '', 'Image & Video files (*.jpg *.png *.mp4 *.mkv *.jpeg)' );
self.open_file_out.setAcceptMode( 'AcceptSave' );
if self.os_type == 'linux':
self.open_file_out.setDirectoryUrl( '/home' );
elif self.os_type == 'win32':
self.open_file_out.setDirectoryUrl( '%HOMEPATH%' );
else:
pass;
def info_button(self): def info_button(self):
self.info_dialog = Gtk.Dialog() self.fileMissingErrorDialog = QDialog( self );
self.remove_event = Gtk.Button(label="Don't show again") self.fileMissingErrorDialog.setWindowTitle( 'Upscaling! This process might take a LONG time!' );
self.info_dialog.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK) self.fileMissingErrorDialog.exec();
self.info_dialog.set_default_size(150, 100) self.start_clicked();
self.box = self.info_dialog.get_content_area()
self.label = Gtk.Label(label=" Upscaling. This process will take long (if a Video). \n Duration depends on your Hardware and length and resolution of video \n You may see the output of the app, if you switch to the other window that is behind it. \n\n\n click \"ok\" to start upscaling")
self.box.pack_start(self.label, True, True, 0)
self.info_dialog.show_all()
self.info_response = self.info_dialog.run()
self.info_dialog.destroy()
def start_clicked(self, widget): def start_clicked(self):
self.respawn = True self.respawn = True
try: try:
if self.scaler.is_alive(): if self.scaler.is_alive():