mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Add configuration window and many minor change.
* src/config.py: Application config class. * src/pamhyr.py: Add app config. * src/view/ASubWindow.py: Add some methods. * src/view/ConfigureWindow.py: New app sub window. * src/view/MainWindow.py: Minor change. * src/view/ui/ConfigureDialog.ui: New ui. * src/view/ui/MainWindow.ui: Start rename some component. * src/view/ui/MainWindow_old.ui: Old version of main UI.
This commit is contained in:
1 parent
8f87bd7339
commit
cb5ee1b9bb
9 files changed
+1672
-62
No files matched your search
@@ -0,0 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import pickle
|
||||
|
||||
config_dir = "/.cache/pamhyr/"
|
||||
config_file = "config.pkl"
|
||||
|
||||
class Config(object):
|
||||
def __init__(self):
|
||||
super(Config, self).__init__()
|
||||
|
||||
self.filename = Config.filename()
|
||||
self.set_default_value()
|
||||
|
||||
def set_default_value(self):
|
||||
# Mage
|
||||
self.mage_path = ""
|
||||
self.mage_extract_path = ""
|
||||
self.mailleur_path = ""
|
||||
|
||||
# Const
|
||||
self.manning = False
|
||||
self.segment = 1000
|
||||
self.max_listing = 500000
|
||||
|
||||
# Backup
|
||||
self.backup_enable = True
|
||||
self.backup_path = ""
|
||||
self.backup_frequence = "00:05:00"
|
||||
self.backup_max = 10
|
||||
|
||||
@classmethod
|
||||
def filename(cls):
|
||||
return os.environ["HOME"] + config_dir + config_file
|
||||
|
||||
def save(self):
|
||||
os.makedirs(os.path.dirname(self.filename), exist_ok=True)
|
||||
with open(self.filename, 'wb') as out_file:
|
||||
pickle.dump(self, out_file)
|
||||
|
||||
@classmethod
|
||||
def load(cls):
|
||||
filename = cls.filename()
|
||||
if os.path.isfile(filename):
|
||||
with open(filename, 'rb') as in_file:
|
||||
me = pickle.load(in_file)
|
||||
return me
|
||||
else:
|
||||
print("config: New config")
|
||||
return cls()
|
||||
Reference in new issue
Block a user