feat: simplify backup filename timestamps to hourly granularity by removing minutes and seconds.
This commit is contained in:
68
main.py
68
main.py
@@ -739,6 +739,9 @@ class BackupApp(QMainWindow):
|
||||
|
||||
def new_job(self):
|
||||
job = ConfigManager.create_new_job()
|
||||
# Add timestamp prefix as requested
|
||||
# "kalau buat daftar pekerjaan baru, tambahkan prefix tanggal dan jam"
|
||||
job['name'] = "{} {}".format(time.strftime("%Y-%m-%d %H:%M"), job['name'])
|
||||
self.jobs.append(job)
|
||||
self.refresh_job_list()
|
||||
|
||||
@@ -1384,6 +1387,30 @@ class BackupApp(QMainWindow):
|
||||
# Disable if already activated
|
||||
if not self.trial_mode:
|
||||
self.activate_action.setEnabled(False)
|
||||
# Menu Bar
|
||||
menubar = self.menuBar()
|
||||
|
||||
# File Menu
|
||||
file_menu = menubar.addMenu('File')
|
||||
exit_action = QAction('Keluar', self)
|
||||
exit_action.triggered.connect(self.close)
|
||||
file_menu.addAction(exit_action)
|
||||
|
||||
# Settings Menu (Pengaturan)
|
||||
settings_menu = menubar.addMenu('Pengaturan')
|
||||
|
||||
# Auto Start Action
|
||||
self.auto_start_action = QAction('Auto Start saat Windows', self)
|
||||
self.auto_start_action.setCheckable(True)
|
||||
self.auto_start_action.setChecked(self.check_auto_start_status())
|
||||
self.auto_start_action.triggered.connect(self.toggle_auto_start)
|
||||
settings_menu.addAction(self.auto_start_action)
|
||||
|
||||
# Help Menu
|
||||
help_menu = menubar.addMenu('Bantuan')
|
||||
about_action = QAction('Tentang', self)
|
||||
about_action.triggered.connect(self.show_about)
|
||||
help_menu.addAction(about_action)
|
||||
|
||||
quit_action = QAction("Keluar", self)
|
||||
quit_action.triggered.connect(self.quit_app)
|
||||
@@ -1412,6 +1439,44 @@ class BackupApp(QMainWindow):
|
||||
except: pass
|
||||
event.accept()
|
||||
|
||||
def check_auto_start_status(self):
|
||||
"""Check if registry key exists for auto start"""
|
||||
try:
|
||||
import winreg
|
||||
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Run", 0, winreg.KEY_READ)
|
||||
winreg.QueryValueEx(key, "ProBackupXP")
|
||||
winreg.CloseKey(key)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
def toggle_auto_start(self, checked):
|
||||
"""Add or remove registry key for auto start"""
|
||||
import winreg
|
||||
key_path = r"Software\Microsoft\Windows\CurrentVersion\Run"
|
||||
app_name = "ProBackupXP"
|
||||
|
||||
try:
|
||||
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_path, 0, winreg.KEY_ALL_ACCESS)
|
||||
if checked:
|
||||
# Add to registry
|
||||
# Use sys.executable for the running exe path
|
||||
exe_path = '"{}"'.format(os.path.abspath(sys.executable))
|
||||
winreg.SetValueEx(key, app_name, 0, winreg.REG_SZ, exe_path)
|
||||
self.log("Auto Start diaktifkan.")
|
||||
else:
|
||||
# Remove from registry
|
||||
try:
|
||||
winreg.DeleteValue(key, app_name)
|
||||
self.log("Auto Start dinonaktifkan.")
|
||||
except:
|
||||
pass # Key might not exist
|
||||
winreg.CloseKey(key)
|
||||
except Exception as e:
|
||||
QMessageBox.critical(self, "Error", "Gagal mengubah pengaturan registry:\n{}".format(e))
|
||||
# Revert checkbox state if failed
|
||||
self.auto_start_action.setChecked(not checked)
|
||||
|
||||
def show_window(self):
|
||||
self.show()
|
||||
self.raise_()
|
||||
@@ -1492,6 +1557,9 @@ if __name__ == "__main__":
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
|
||||
except: pass
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
app.setQuitOnLastWindowClosed(False) # For tray icon
|
||||
|
||||
|
||||
Reference in New Issue
Block a user