Made that setting are stored in the home folder of the user.
This commit is contained in:
parent
01823f50d6
commit
9f0aece4bf
2 changed files with 17 additions and 35 deletions
25
gui.py
25
gui.py
|
@ -25,7 +25,7 @@ from PySide6.QtWidgets import (
|
||||||
)
|
)
|
||||||
|
|
||||||
class OptimaLab35(QMainWindow, Ui_MainWindow):
|
class OptimaLab35(QMainWindow, Ui_MainWindow):
|
||||||
def __init__(self, exif_file):
|
def __init__(self):
|
||||||
super(OptimaLab35, self).__init__()
|
super(OptimaLab35, self).__init__()
|
||||||
self.name = "OptimaLab35"
|
self.name = "OptimaLab35"
|
||||||
self.version = "0.0.1"
|
self.version = "0.0.1"
|
||||||
|
@ -33,7 +33,8 @@ class OptimaLab35(QMainWindow, Ui_MainWindow):
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
self.o = OptimaManager()
|
self.o = OptimaManager()
|
||||||
self.u = Utilities()
|
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.available_exif_data = None
|
||||||
self.settings = {}
|
self.settings = {}
|
||||||
self.setWindowTitle(f"{self.name} v{self.version}")
|
self.setWindowTitle(f"{self.name} v{self.version}")
|
||||||
|
@ -41,9 +42,7 @@ class OptimaLab35(QMainWindow, Ui_MainWindow):
|
||||||
self._define_gui_interaction()
|
self._define_gui_interaction()
|
||||||
|
|
||||||
self.sd = SimpleDialog()
|
self.sd = SimpleDialog()
|
||||||
|
self._change_statusbar(f"Using {self.o.name} v{self.o.version}", 5000)
|
||||||
if exif_file == "config/exif_example.yaml":
|
|
||||||
self._change_statusbar("Using example exif...", 10000)
|
|
||||||
|
|
||||||
def _default_ui_layout(self):
|
def _default_ui_layout(self):
|
||||||
self.ui.png_quality_spinBox.setVisible(False)
|
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}"
|
user_data["software"] = f"{self.o.name} {self.o.version}"
|
||||||
return user_data
|
return user_data
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
def main(exif_file):
|
|
||||||
app = QtWidgets.QApplication(sys.argv)
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
window = OptimaLab35(exif_file = exif_file)
|
window = OptimaLab35()
|
||||||
window.show()
|
window.show()
|
||||||
app.exec()
|
app.exec()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if os.path.isfile("config/exif.yaml"):
|
main()
|
||||||
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)
|
|
||||||
|
|
27
tui.py
27
tui.py
|
@ -6,15 +6,16 @@ from utils.utility import Utilities
|
||||||
from ui.simple_tui import SimpleTUI
|
from ui.simple_tui import SimpleTUI
|
||||||
|
|
||||||
class Optima35TUI():
|
class Optima35TUI():
|
||||||
def __init__(self, exif_file, settings_file):
|
def __init__(self):
|
||||||
self.name = "OptimaLab35-lite"
|
self.name = "OptimaLab35-lite"
|
||||||
self.version = "0.0.1"
|
self.version = "0.0.1"
|
||||||
self.o = OptimaManager()
|
self.o = OptimaManager()
|
||||||
self.u = Utilities()
|
self.u = Utilities()
|
||||||
self.tui = SimpleTUI()
|
self.tui = SimpleTUI()
|
||||||
self.exif_file = exif_file
|
self.u.program_configs()
|
||||||
self.available_exif_data = self.u.read_yaml(exif_file)
|
self.exif_file = os.path.expanduser("~/.config/OptimaLab35/exif.yaml")
|
||||||
self.setting_file = settings_file
|
self.available_exif_data = self.u.read_yaml(self.exif_file)
|
||||||
|
self.setting_file = os.path.expanduser("~/.config/OptimaLab35/tui_settings.yaml")
|
||||||
self.settings = {
|
self.settings = {
|
||||||
"input_folder": None,
|
"input_folder": None,
|
||||||
"output_folder": None,
|
"output_folder": None,
|
||||||
|
@ -153,6 +154,7 @@ class Optima35TUI():
|
||||||
|
|
||||||
def _ask_for_settings(self):
|
def _ask_for_settings(self):
|
||||||
print("Asking for new settings...\n")
|
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["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["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)
|
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):
|
def _collect_exif_data(self):
|
||||||
"""Collect EXIF data based on user input."""
|
"""Collect EXIF data based on user input."""
|
||||||
|
print(f"Exif file can be found {self.exif_file}...")
|
||||||
user_data = {}
|
user_data = {}
|
||||||
fields = [
|
fields = [
|
||||||
"make", "model", "lens", "iso", "image_description",
|
"make", "model", "lens", "iso", "image_description",
|
||||||
|
@ -318,19 +321,9 @@ class Optima35TUI():
|
||||||
self._process()
|
self._process()
|
||||||
print("Done")
|
print("Done")
|
||||||
|
|
||||||
|
def main():
|
||||||
|
app = Optima35TUI()
|
||||||
def main(exif_file, config_file):
|
|
||||||
app = Optima35TUI(exif_file, config_file)
|
|
||||||
app.run()
|
app.run()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if os.path.isfile("config/exif.yaml"):
|
main()
|
||||||
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")
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue