88from utils import setup_language , get_text , logging
99from launchers import launch_app , system_action
1010from settings import SettingsWindow
11-
1211class IconLoader :
1312 def __init__ (self ):
1413 self .manager = QNetworkAccessManager ()
1514 self .icons = {}
16-
1715 def load_icon (self , url , callback ):
1816 if not url :
1917 logging .error ("Icon URL is empty" )
20- callback (QPixmap ()) # Return empty pixmap as fallback
18+ callback (QPixmap ()) # Return empty pixmap as fallback
2119 return
2220 request = QNetworkRequest (QUrl (url ))
2321 reply = self .manager .get (request )
2422 if reply :
2523 reply .finished .connect (lambda : self .icon_loaded (reply , callback ))
2624 else :
2725 logging .error (f"Failed to create network reply for URL: { url } " )
28- callback (QPixmap ()) # Return empty pixmap as fallback
29-
26+ callback (QPixmap ()) # Return empty pixmap as fallback
3027 def icon_loaded (self , reply , callback ):
3128 if reply .error () == QNetworkReply .NoError :
3229 pixmap = QPixmap ()
@@ -35,14 +32,12 @@ def icon_loaded(self, reply, callback):
3532 callback (pixmap .scaled (140 , 140 , Qt .KeepAspectRatio , Qt .SmoothTransformation ))
3633 else :
3734 logging .error (f"Failed to load pixmap from URL: { reply .url ().toString ()} " )
38- callback (QPixmap ()) # Fallback empty pixmap
35+ callback (QPixmap ()) # Fallback empty pixmap
3936 else :
4037 logging .error (f"Failed to load icon: { reply .errorString ()} " )
41- callback (QPixmap ()) # Fallback empty pixmap
38+ callback (QPixmap ()) # Fallback empty pixmap
4239 reply .deleteLater ()
43-
4440icon_loader = IconLoader ()
45-
4641class MainWindow (QMainWindow ):
4742 def __init__ (self ):
4843 super ().__init__ ()
@@ -54,14 +49,13 @@ def __init__(self):
5449 self .layout .setAlignment (Qt .AlignCenter )
5550 self .layout .setSpacing (60 )
5651 self .layout .setContentsMargins (80 , 80 , 80 , 80 )
57-
5852 self .top_layout = QHBoxLayout ()
5953 self .hackeros_logo = QLabel ()
6054 self .hackeros_logo .setObjectName ('logo' )
6155 pixmap_hackeros = QPixmap ('/usr/share/HackerOS/ICONS/HackerOS.png' )
6256 if pixmap_hackeros .isNull ():
6357 logging .error ("Failed to load HackerOS.png" )
64- pixmap_hackeros = QPixmap (120 , 120 ) # Fallback empty pixmap
58+ pixmap_hackeros = QPixmap (120 , 120 ) # Fallback empty pixmap
6559 pixmap_hackeros .fill (Qt .transparent )
6660 self .hackeros_logo .setPixmap (pixmap_hackeros .scaled (120 , 120 , Qt .KeepAspectRatio , Qt .SmoothTransformation ))
6761 self .hackeros_logo_opacity = QGraphicsOpacityEffect ()
@@ -73,30 +67,26 @@ def __init__(self):
7367 pixmap_hackermode = QPixmap ('/usr/share/HackerOS/ICONS/Hacker-Mode.png' )
7468 if pixmap_hackermode .isNull ():
7569 logging .error ("Failed to load Hacker-Mode.png" )
76- pixmap_hackermode = QPixmap (120 , 120 ) # Fallback empty pixmap
70+ pixmap_hackermode = QPixmap (120 , 120 ) # Fallback empty pixmap
7771 pixmap_hackermode .fill (Qt .transparent )
7872 self .hackermode_logo .setPixmap (pixmap_hackermode .scaled (120 , 120 , Qt .KeepAspectRatio , Qt .SmoothTransformation ))
7973 self .hackermode_logo_opacity = QGraphicsOpacityEffect ()
8074 self .hackermode_logo .setGraphicsEffect (self .hackermode_logo_opacity )
8175 self .top_layout .addWidget (self .hackermode_logo , alignment = Qt .AlignRight )
8276 self .layout .addLayout (self .top_layout )
83-
8477 self .title = QLabel (get_text ('title' ))
8578 self .title .setFont (QFont ('Hack' , 70 , QFont .Bold ))
8679 self .title .setObjectName ('neon-text' )
8780 self .layout .addWidget (self .title , alignment = Qt .AlignCenter )
88-
8981 self .grid_layout = QGridLayout ()
9082 self .grid_layout .setSpacing (80 )
9183 self .grid_layout .setContentsMargins (60 , 60 , 60 , 60 )
9284 self .layout .addLayout (self .grid_layout )
93-
9485 self .launcher_buttons = []
9586 self .add_launcher_button ('steam' , 'https://store.steampowered.com/favicon.ico' , 0 , 0 )
9687 self .add_launcher_button ('heroic' , 'https://www.heroicgameslauncher.com/favicon.ico' , 0 , 1 )
9788 self .add_launcher_button ('hyperplay' , 'https://www.hyperplaygaming.com/favicon.ico' , 0 , 2 )
9889 self .add_launcher_button ('lutris' , 'https://lutris.net/static/images/logo.png' , 0 , 3 )
99-
10090 self .bottom_layout = QHBoxLayout ()
10191 self .hacker_menu_btn = QPushButton (get_text ('hacker_menu' ))
10292 self .hacker_menu_btn .setObjectName ('action-btn' )
@@ -110,10 +100,8 @@ def __init__(self):
110100 self .settings_btn .clicked .connect (self .launch_settings )
111101 self .bottom_layout .addWidget (self .settings_btn , alignment = Qt .AlignRight )
112102 self .layout .addLayout (self .bottom_layout )
113-
114103 self .update_texts ()
115104 QTimer .singleShot (100 , self .animate_elements )
116-
117105 def animate_elements (self ):
118106 for i , btn in enumerate (self .launcher_buttons ):
119107 anim = QPropertyAnimation (btn , b"geometry" )
@@ -123,21 +111,18 @@ def animate_elements(self):
123111 anim .setDuration (2000 )
124112 anim .setEasingCurve (QEasingCurve .OutQuint )
125113 QTimer .singleShot (i * 400 , lambda : anim .start ())
126-
127114 logo_anim1 = QPropertyAnimation (self .hackeros_logo_opacity , b"opacity" )
128115 logo_anim1 .setStartValue (0.0 )
129116 logo_anim1 .setEndValue (1.0 )
130117 logo_anim1 .setDuration (2000 )
131118 logo_anim1 .setEasingCurve (QEasingCurve .OutQuint )
132119 QTimer .singleShot (400 , lambda : logo_anim1 .start ())
133-
134120 logo_anim2 = QPropertyAnimation (self .hackermode_logo_opacity , b"opacity" )
135121 logo_anim2 .setStartValue (0.0 )
136122 logo_anim2 .setEndValue (1.0 )
137123 logo_anim2 .setDuration (2000 )
138124 logo_anim2 .setEasingCurve (QEasingCurve .OutQuint )
139125 QTimer .singleShot (800 , lambda : logo_anim2 .start ())
140-
141126 def add_launcher_button (self , app_name , icon_url , row , col ):
142127 btn = QPushButton (objectName = 'launcher-btn' )
143128 btn .setFixedSize (280 , 280 )
@@ -154,7 +139,6 @@ def add_launcher_button(self, app_name, icon_url, row, col):
154139 btn .clicked .connect (lambda : launch_app (app_name , self ))
155140 self .grid_layout .addWidget (btn , row , col , alignment = Qt .AlignCenter )
156141 self .launcher_buttons .append (btn )
157-
158142 def update_texts (self ):
159143 self .setWindowTitle (get_text ('title' ))
160144 self .title .setText (get_text ('title' ))
@@ -164,12 +148,10 @@ def update_texts(self):
164148 label = btn .findChildren (QLabel )[1 ]
165149 key = label .text ().lower ()
166150 label .setText (get_text (key ))
167-
168151 def launch_settings (self ):
169152 self .hide ()
170153 self .settings_window = SettingsWindow (self )
171154 self .settings_window .showFullScreen ()
172-
173155 def show_hacker_menu (self ):
174156 menu = QMenu (self )
175157 menu .setObjectName ('hacker-menu' )
@@ -179,13 +161,12 @@ def show_hacker_menu(self):
179161 ('restart' , lambda : system_action ('restart' )),
180162 ('sleep' , lambda : system_action ('sleep' )),
181163 ('restart_apps' , lambda : system_action ('restartApps' , self )),
182- ('restart_sway ' , lambda : system_action ('restartWayfire' ))
164+ ('restart_app ' , lambda : system_action ('restartApps' , self ))
183165 ]
184166 for text , callback in actions :
185167 action = menu .addAction (get_text (text ))
186168 action .triggered .connect (callback )
187169 menu .exec (self .hacker_menu_btn .mapToGlobal (self .hacker_menu_btn .rect ().bottomLeft ()))
188-
189170if __name__ == '__main__' :
190171 app = QApplication (sys .argv )
191172 stylesheet = """
@@ -287,4 +268,3 @@ def show_hacker_menu(self):
287268 except Exception as e :
288269 logging .error (f'Error setting fullscreen in Wayfire: { e } ' )
289270 sys .exit (app .exec ())
290-
0 commit comments