Made that setting are stored in the home folder of the user.

This commit is contained in:
Mr Finchum 2025-01-02 23:05:43 +01:00
parent 01823f50d6
commit 9f0aece4bf
2 changed files with 17 additions and 35 deletions

25
gui.py
View file

@ -25,7 +25,7 @@ from PySide6.QtWidgets import (
)
class OptimaLab35(QMainWindow, Ui_MainWindow):
def __init__(self, exif_file):
def __init__(self):
super(OptimaLab35, self).__init__()
self.name = "OptimaLab35"
self.version = "0.0.1"
@ -33,7 +33,8 @@ class OptimaLab35(QMainWindow, Ui_MainWindow):
self.ui.setupUi(self)
self.o = OptimaManager()
self.u = Utilities()
self.exif_file = exif_file
self.u.program_configs()
self.exif_file = os.path.expanduser("~/.config/OptimaLab35/exif.yaml")
self.available_exif_data = None
self.settings = {}
self.setWindowTitle(f"{self.name} v{self.version}")
@ -41,9 +42,7 @@ class OptimaLab35(QMainWindow, Ui_MainWindow):
self._define_gui_interaction()
self.sd = SimpleDialog()
if exif_file == "config/exif_example.yaml":
self._change_statusbar("Using example exif...", 10000)
self._change_statusbar(f"Using {self.o.name} v{self.o.version}", 5000)
def _default_ui_layout(self):
self.ui.png_quality_spinBox.setVisible(False)
@ -273,21 +272,11 @@ class OptimaLab35(QMainWindow, Ui_MainWindow):
user_data["software"] = f"{self.o.name} {self.o.version}"
return user_data
def main(exif_file):
def main():
app = QtWidgets.QApplication(sys.argv)
window = OptimaLab35(exif_file = exif_file)
window = OptimaLab35()
window.show()
app.exec()
if __name__ == "__main__":
if os.path.isfile("config/exif.yaml"):
exif_file = "config/exif.yaml"
print("Fall back to exif example file...")
elif os.path.isfile("config/exif_example.yaml"):
exif_file = "config/exif_example.yaml"
else:
print("Exif file missing, please ensure an exif file exist in config folder (exif.yaml, or exif_example_yaml)\nExiting...")
exit()
main(exif_file)
main()

27
tui.py
View file

@ -6,15 +6,16 @@ from utils.utility import Utilities
from ui.simple_tui import SimpleTUI
class Optima35TUI():
def __init__(self, exif_file, settings_file):
def __init__(self):
self.name = "OptimaLab35-lite"
self.version = "0.0.1"
self.o = OptimaManager()
self.u = Utilities()
self.tui = SimpleTUI()
self.exif_file = exif_file
self.available_exif_data = self.u.read_yaml(exif_file)
self.setting_file = settings_file
self.u.program_configs()
self.exif_file = os.path.expanduser("~/.config/OptimaLab35/exif.yaml")
self.available_exif_data = self.u.read_yaml(self.exif_file)
self.setting_file = os.path.expanduser("~/.config/OptimaLab35/tui_settings.yaml")
self.settings = {
"input_folder": None,
"output_folder": None,
@ -153,6 +154,7 @@ class Optima35TUI():
def _ask_for_settings(self):
print("Asking for new settings...\n")
print(f"Settings for {self.name} v{self.version} will be saved {self.setting_file}...")
self.settings["resize"] = self.take_input_and_validate(question = "Default resize percentage (below 100 downscale, above upscale): ", accepted_type = int, min_value = 10, max_value = 200)
self.settings["contrast"] = self.take_input_and_validate(question = "Default contrast percentage (negative = decrease, positive = increase): ", accepted_type = int, min_value = -100, max_value = 100)
self.settings["brightness"] = self.take_input_and_validate(question = "Default brighness percentage (negative = decrease, positive = increase): ", accepted_type = int, min_value = -100, max_value = 100)
@ -189,6 +191,7 @@ class Optima35TUI():
def _collect_exif_data(self):
"""Collect EXIF data based on user input."""
print(f"Exif file can be found {self.exif_file}...")
user_data = {}
fields = [
"make", "model", "lens", "iso", "image_description",
@ -318,19 +321,9 @@ class Optima35TUI():
self._process()
print("Done")
def main(exif_file, config_file):
app = Optima35TUI(exif_file, config_file)
def main():
app = Optima35TUI()
app.run()
if __name__ == "__main__":
if os.path.isfile("config/exif.yaml"):
exif_file = "config/exif.yaml"
elif os.path.isfile("config/exif_example.yaml"):
exif_file = "config/exif_example.yaml"
print("Fall back to exif example file...")
else:
print("Exif file missing, please ensure an exif file exist in config folder (exif.yaml, or exif_example_yaml)\nExiting...")
exit()
main(exif_file, "config/tui_settings.yaml")
main()