44import os
55from show_allert import show_allert
66import webbrowser
7+ from PyQt6 .QtCore import QProcess
78def load_config_data (working_dir , avaible_languages , language ):
89 def write_new_config_file ():
910 with open (f"{ working_dir } /settings.conf" , "w" ) as f :
@@ -35,9 +36,14 @@ def read_config_data():
3536 read_config_data ()
3637
3738
38- def open_setting (language , working_dir , avaible_languages ):
39+ def open_setting (language , working_dir , avaible_languages , version ):
3940 global pacman_status , aur_status , flatpak_status , aur_method , new_language , app_image_dir
4041 load_config_data (working_dir , avaible_languages , language )
42+
43+ if not os .path .isfile (working_dir + "/script" ):
44+ script_installation_status = False
45+ else :
46+ script_installation_status = True
4147 #Edit repo
4248 def confirm_changes ():
4349 global pacman_status , aur_status , flatpak_status , aur_method , new_language , app_image_dir , old_language
@@ -92,8 +98,7 @@ def change_aur_method(button, label):
9298 else :
9399 aur_method = "paru"
94100 label .setText (lpak .get ("aur method" , language )+ ": " + aur_method )
95-
96-
101+
97102 def setting_change_appimagedir (button ):
98103 new_dir_temp = pq .QFileDialog .getExistingDirectory (settings_page , lpak .get ("select a folder" , language ))
99104 response = pq .QMessageBox .question (settings_page ,
@@ -109,6 +114,102 @@ def setting_change_appimagedir(button):
109114
110115 else :
111116 return
117+
118+ def update_arch_store ():
119+ if script_installation_status == False :
120+ def after_operations ():
121+ button_update_archStore .setText (lpak .get ("updated" , language ))
122+
123+ def start_thread_operations (label , button ):
124+
125+
126+ global proc
127+
128+ # Aggiorna subito la UI (thread principale)
129+ button .setDisabled (True )
130+ label .setText (lpak .get ("install in progress" , language ))
131+ progress_bar .setRange (0 , 0 )
132+ operations_window .repaint ()
133+
134+ proc = QProcess (operations_window )
135+
136+ def close_updates ():
137+ operations_window .close ()
138+
139+
140+ def on_finished (exitCode , exitStatus ):
141+ global install_status
142+ install_status = False
143+ progress_bar .setRange (0 , 1 )
144+ button .setText (lpak .get ("finished" , language ))
145+ label .setText (lpak .get ("updated, please restart" , language ))
146+ try :
147+ button .pressed .disconnect ()
148+ except TypeError :
149+ pass
150+ after_operations ()
151+ button .setDisabled (False )
152+ button .clicked .connect (close_updates )
153+ operations_window .update ()
154+
155+ def on_error (err ):
156+ global install_status
157+ install_status = False
158+ progress_bar .setRange (0 , 1 )
159+ label .setText (f"{ lpak .get ('error' , language )} : { err } " )
160+ button .setDisabled (False )
161+ operations_window .update ()
162+
163+ proc .finished .connect (on_finished )
164+ proc .errorOccurred .connect (on_error )
165+
166+ proc .start ("pkexec" , ["bash" , "/tmp/arch_store_actions.sh" ])
167+
168+ response = pq .QMessageBox .question (settings_page ,
169+ lpak .get ("Select a version" , language ),
170+ lpak .get ("Do you want to install the stable version?" , language ),
171+ pq .QMessageBox .StandardButton .Yes | pq .QMessageBox .StandardButton .No ,
172+ pq .QMessageBox .StandardButton .No
173+ )
174+
175+ if response == pq .QMessageBox .StandardButton .Yes :
176+ remove_other_version_command = "sudo pacman -Rns arch-store-git --noconfirm"
177+ makepkg_command = f"{ aur_method } -S arch-store --noconfirm"
178+ else :
179+ remove_other_version_command = "sudo pacman -Rns arch-store --noconfirm"
180+ makepkg_command = f"{ aur_method } -S arch-store-git --noconfirm"
181+
182+ with open (f"/tmp/arch_store_actions.sh" , "w" ) as f :
183+ f .write ("#!/bin/bash\n " )
184+ f .write (remove_other_version_command + "\n " )
185+ f .write (makepkg_command + "\n " )
186+
187+ operations_window = pq .QWidget ()
188+ operations_window .setWindowTitle (lpak .get ("start update" , language ))
189+ operations_window .setWindowIcon (QIcon ("icon.png" ))
190+ layout = pq .QVBoxLayout (operations_window )
191+ install_label = pq .QLabel (lpak .get ("click to start update" , language ))
192+ start_button = pq .QPushButton (lpak .get ("start update" , language ))
193+ start_button .pressed .connect (lambda : start_thread_operations (install_label , start_button ))
194+ progress_bar = pq .QProgressBar ()
195+
196+ layout .addWidget (install_label )
197+ layout .addWidget (progress_bar )
198+ layout .addWidget (start_button )
199+
200+ operations_window .show ()
201+ else :
202+ response = pq .QMessageBox .question (settings_page ,
203+ lpak .get ("Do you want to open GitHub?" , language ),
204+ lpak .get ("It appears that you installed ArchStore from the script. Would you like to open GitHub to rerun the script?" , language ),
205+ pq .QMessageBox .StandardButton .Yes | pq .QMessageBox .StandardButton .No ,
206+ pq .QMessageBox .StandardButton .No
207+ )
208+
209+ if response == pq .QMessageBox .StandardButton .Yes :
210+ webbrowser .open ("https://github.com/Samuobe/Arch-Store?tab=readme-ov-file#automatic-script" )
211+
212+
112213 #Other
113214 def settings_reset_settings (working_dir , avaible_languages , language ):
114215 os .remove (f"{ working_dir } /settings.conf" )
@@ -153,6 +254,9 @@ def settings_reset_settings(working_dir, avaible_languages, language):
153254 #RESET
154255 button_reset_settings = pq .QPushButton (lpak .get ("reset settings" , language ))
155256 button_reset_settings .pressed .connect (lambda : settings_reset_settings (working_dir , avaible_languages , language ))
257+ #update Arch Store
258+ button_update_archStore = pq .QPushButton (lpak .get ("Update ArchStore" , language ))
259+ button_update_archStore .pressed .connect (update_arch_store )
156260 #change AUR method
157261 label_aur_method = pq .QLabel (lpak .get ("aur method" , language )+ ": " + aur_method )
158262 button_change_aur_method = pq .QPushButton (lpak .get ("change" , language ))
@@ -178,6 +282,13 @@ def github_button():
178282 author_label = pq .QLabel (lpak .get ("made whit heart by Samuobe" , language ))
179283 project_link = pq .QPushButton (lpak .get ("github project" , language ))
180284 project_link .pressed .connect (github_button )
285+ #Version
286+ version_label = pq .QLabel (lpak .get ("version" , language ))
287+ if script_installation_status == False :
288+ archstore_installation_method = "AUR"
289+ else :
290+ archstore_installation_method = "Script"
291+ version_label_var = pq .QLabel (f"{ version } ({ lpak .get ("Installated with" , language )} { lpak .get (archstore_installation_method , language )} )" )
181292 #LINE
182293 line_separazione = pq .QFrame ()
183294 line_separazione .setFrameShape (pq .QFrame .Shape .HLine )
@@ -188,6 +299,7 @@ def github_button():
188299 layout .addWidget (settings_label_title )
189300 layout .addWidget (settings_label_title , 0 , 0 , 1 , 2 )
190301 layout .addWidget (button_reset_settings , 0 , 3 )
302+ layout .addWidget (button_update_archStore , 1 , 3 )
191303 layout .addWidget (settings_label_repo , 1 , 0 )
192304 layout .addWidget (label_repo_pacman , 2 , 0 )
193305 layout .addWidget (button_repo_pacman , 2 , 1 )
@@ -199,11 +311,9 @@ def github_button():
199311 layout .addWidget (button_change_aur_method , 5 , 1 )
200312 layout .addWidget (empty_label , 6 , 0 )
201313 layout .addWidget (label_other_settings , 7 , 0 )
202- #setLayout(layout)
203314 #
204315 layout .addWidget (label_language , 8 , 0 )
205- layout .addWidget (menu_select_language , 8 , 1 )
206-
316+ layout .addWidget (menu_select_language , 8 , 1 )
207317
208318 layout .addWidget (appimagesdir_label , 9 , 0 )
209319 layout .addWidget (appimagesdir_button , 9 , 1 )
@@ -214,6 +324,9 @@ def github_button():
214324 layout .addWidget (author_label , 13 , 0 )
215325 layout .addWidget (project_link , 13 , 1 )
216326
327+ layout .addWidget (version_label , 15 , 0 )
328+ layout .addWidget (version_label_var , 15 , 1 )
329+
217330 layout .setRowStretch (layout .rowCount (), 1 )
218331
219332 settings_page .show ()
0 commit comments