-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaPic.py
More file actions
121 lines (95 loc) · 3.43 KB
/
MaPic.py
File metadata and controls
121 lines (95 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env python3
"""
Image Viewer + AI Metadata
Author: Majika77
Date: 2026-05-18
Description: A lightweight image viewer that displays AI generation metadata alongside images.
Developed with assistance from ChatGPT (OpenAI GPT-5 mini) & Claude (Anthropic) :)
"""
import sys
import os
import traceback
import requests
from packaging.version import Version
from config import DEBUG, GITHUB_REPO, APP_VERSION
from ui import ImageViewer
# Biztosítjuk hogy a script könyvtára benne van a Python path-ban
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
if SCRIPT_DIR not in sys.path:
sys.path.insert(0, SCRIPT_DIR)
from PyQt6.QtCore import QSettings, pyqtSignal, QThread, qInstallMessageHandler
from PyQt6.QtWidgets import QApplication
from PyQt6.QtGui import QIcon
# ============ Settings ============
settings = QSettings("Majika", "MaPic")
# Default settings értékek
def get_setting(key, default):
"""Beállítás lekérése default értékkel"""
return settings.value(key, default, type=type(default))
def set_setting(key, value):
"""Beállítás mentése"""
settings.setValue(key, value)
# ============ Debug funkciók ============
def dlog(*args):
"""Debug log fájlba írás"""
try:
with open("mapic_debug.log", "a", encoding="utf-8") as f:
f.write(" ".join(str(a) for a in args) + "\n")
except:
pass
def debug_log(*args):
"""Console debug log"""
if DEBUG:
print("[DEBUG]", *args)
def global_exception_hook(exctype, value, tb):
"""Globális exception handler"""
print("[UNCAUGHT EXCEPTION]")
traceback.print_exception(exctype, value, tb)
sys.excepthook = global_exception_hook
def qt_message_handler(mode, context, message):
"""Qt üzenetek kezelése"""
print(f"[Qt {mode.name}] {message}")
qInstallMessageHandler(qt_message_handler)
# ============ Update Checker ============
def get_latest_version():
"""GitHub API-tól lekéri a legújabb verziót"""
url = f"https://api.github.com/repos/{GITHUB_REPO}/releases/latest"
r = requests.get(url, timeout=5)
data = r.json()
return data["tag_name"].lstrip("v")
def is_newer(latest, current):
"""Verzió összehasonlítás"""
return Version(latest) > Version(current)
class UpdateChecker(QThread):
"""Háttérben futó verzió ellenőrző thread"""
update_found = pyqtSignal(str) # ha új verzió van
up_to_date = pyqtSignal() # ha minden ok
def __init__(self, manual=False, parent=None):
super().__init__(parent)
self.manual = manual
def run(self):
settings = QSettings("Majika", "MaPic")
if not self.manual and settings.value("skip_update_warning", False, bool):
return
try:
latest = get_latest_version()
if is_newer(latest, APP_VERSION):
self.update_found.emit(latest)
else:
self.up_to_date.emit()
except Exception as e:
print("Update check failed:", e)
# ============ Main Application ============
if __name__ == "__main__":
app = QApplication(sys.argv)
# Ablak létrehozása
w = ImageViewer()
app.setWindowIcon(QIcon("MaPic.ico"))
w.setWindowIcon(QIcon("MaPic.ico"))
w.resize(1000, 850)
# Parancssor argumentum kezelése (kép megnyitása)
if len(sys.argv) > 1:
fname = os.path.abspath(sys.argv[1])
w.open_folder_and_select(fname)
w.show()
sys.exit(app.exec())