updated location mapping

This commit is contained in:
Your Name 2025-04-15 15:53:11 +01:00
parent 4b616da939
commit f0fadbdd3a
57 changed files with 50 additions and 64 deletions

View file

@ -233,7 +233,8 @@ class WorkerThread(QThread):
ConfigurationController.set_connection('system')
ClientController.sync(client_observer=client_observer, connection_observer=connection_observer)
locations = LocationController.get_all()
all_location_codes = [location.country_name for location in locations]
print(locations)
all_location_codes = [f"{location.country_code}_{location.code}" for location in locations]
self.sync_output.emit(all_location_codes, True, False, locations, False)
except Exception as e:
print(e)
@ -1273,8 +1274,8 @@ class MenuPage(Page):
protocol = profile.connection.code
location_code = profile.location.code if profile.location else 'None'
location = self.connection_manager.get_location_info(location_code)
location = f'{profile.location.country_code}_{profile.location.code}'
new_profile['location'] = location
if protocol == 'wireguard':
@ -1368,7 +1369,6 @@ class MenuPage(Page):
self.button_group.addButton(button)
self.buttons.append(button)
# Use profile_id directly in lambda
button.clicked.connect(lambda checked, pid=profile_id: self.print_profile_details(f"Profile_{pid}"))
return button
@ -1397,9 +1397,7 @@ class MenuPage(Page):
image_path = self.get_icon_path(label_name, value, connection_type)
pixmap = QPixmap(image_path)
# Check if the pixmap is null (image doesn't exist)
if pixmap.isNull() and label_name == 'location':
# Use a fallback/default image
fallback_path = os.path.join(self.btn_path, "default_location_mini.png")
pixmap = QPixmap(fallback_path)
if pixmap.isNull():
@ -1419,13 +1417,11 @@ class MenuPage(Page):
image_path = self.get_icon_path(label_name, value, connection_type)
pixmap = QPixmap(image_path)
if pixmap.isNull() and label_name == 'location':
# Use a fallback/default image
fallback_path = os.path.join(self.btn_path, "default_location_mini.png")
pixmap = QPixmap(fallback_path)
# If even the fallback is null, create a simple colored square
if pixmap.isNull():
pixmap = QPixmap(50, 50)
pixmap.fill(QtGui.QColor(200, 200, 200)) # Light gray fallback
pixmap.fill(QtGui.QColor(200, 200, 200))
child_label.setPixmap(pixmap)
child_label.show()
@ -1435,13 +1431,15 @@ class MenuPage(Page):
return os.path.join(self.btn_path, "toricon_mini.png") if value['location'] in self.connection_manager.get_non_residential_proxy_list() else os.path.join(self.btn_path, "residential tor_mini.png")
elif connection_type == 'just proxy':
return os.path.join(self.btn_path, "just proxy_mini.png")
return os.path.join(self.btn_path, "wireguard_mini.png")
elif label_name == 'browser':
if connection_type == 'system-wide':
return os.path.join(self.btn_path, "wireguard_system_wide.png")
else:
return os.path.join(self.btn_path, f"{value[label_name]} latest_mini.png")
return os.path.join(self.btn_path, f"{value[label_name]}_mini.png")
return os.path.join(self.btn_path, f"icon_mini_{value[label_name]}.png")
def print_profile_details(self, profile_name):
@ -1491,7 +1489,7 @@ class MenuPage(Page):
label_principal = QLabel(self)
label_principal.setGeometry(0, 90, 400, 300)
pixmap=QPixmap(os.path.join(self.btn_path, f"{protocol} {location}.png"))
pixmap=QPixmap(os.path.join(self.btn_path, f"{protocol}_{location}.png"))
label_principal.setPixmap(pixmap)
label_principal.setScaledContents(True)
@ -1505,9 +1503,9 @@ class MenuPage(Page):
label_background = QLabel(self)
label_background.setGeometry(0, 60, 410, 354)
if connection == 'just proxy':
image_path = os.path.join(self.btn_path, f"{location}.png")
image_path = os.path.join(self.btn_path, f"icon_{location}.png")
else:
image_path = os.path.join(self.btn_path, f"{location}_hdtor.png")
image_path = os.path.join(self.btn_path, f"hdtor_{location}.png")
pixmap = QPixmap(image_path)
label_background.setPixmap(pixmap)
label_background.show()
@ -2627,7 +2625,7 @@ class ProtocolPage(Page):
self.sync_button(False, True)
location_page = self.find_location_page()
hidetor_page = self.find_hidetor_page()
print(f' the available locations list is {available_locations_list}')
if location_page:
location_page.create_interface_elements(available_locations_list)
@ -2877,7 +2875,9 @@ class HidetorPage(Page):
boton.setCheckable(True)
if icon_name == 'Malaysia':
boton.setVisible(False)
boton.setIcon(QIcon(os.path.join(self.btn_path, f"{icon_name}_button.png")))
boton.setIcon(QIcon(os.path.join(self.btn_path, f"button_{icon_name}.png")))
if boton.icon().isNull():
boton.setPixmap(QPixmap(os.path.join(self.btn_path, "default_location_button.png")))
self.buttons.append(boton)
self.buttonGroup.addButton(boton, j)
boton.clicked.connect(lambda _, location=icon_name: self.show_location(location))
@ -2890,7 +2890,7 @@ class HidetorPage(Page):
self.update_status.write_data(inserted_data)
def show_location(self, location):
tor_hide_img = f'{location}_hdtor'
tor_hide_img = f'hdtor_{location}'
self.display.setPixmap(QPixmap(os.path.join(self.btn_path, f"{tor_hide_img}.png")).scaled(self.display.size(), Qt.AspectRatioMode.KeepAspectRatio))
self.selected_location_icon = location
self.button_next.setVisible(True)
@ -3173,7 +3173,10 @@ class LocationPage(Page):
boton.setGeometry(*geometry)
boton.setIconSize(boton.size())
boton.setCheckable(True)
boton.setIcon(QIcon(os.path.join(self.btn_path, f"{icon_name.lower()}_button.png")))
boton.setIcon(QIcon(os.path.join(self.btn_path, f"button_{icon_name}.png")))
if boton.icon().isNull():
fallback_path = os.path.join(self.btn_path, "default_location_button.png")
boton.setIcon(QIcon(fallback_path))
self.buttons.append(boton)
self.buttonGroup.addButton(boton, j)
boton.clicked.connect(lambda _, location=icon_name: self.show_location(location))
@ -3192,7 +3195,7 @@ class LocationPage(Page):
def show_location(self, location):
self.initial_display.hide()
self.display.setPixmap(QPixmap(os.path.join(self.btn_path, f"{location}.png")).scaled(self.display.size(), Qt.AspectRatioMode.KeepAspectRatio))
self.display.setPixmap(QPixmap(os.path.join(self.btn_path, f"icon_{location}.png")).scaled(self.display.size(), Qt.AspectRatioMode.KeepAspectRatio))
self.selected_location_icon = location
self.button_next.setVisible(True)
self.button_next.clicked.connect(self.go_selected)
@ -3479,10 +3482,11 @@ class ResumePage(Page):
if object_type == QLabel:
label = object_type(self)
label.setGeometry(*geometry)
icon_path = os.path.join(self.btn_path, f"{icon_name}_button.png")
if os.path.exists(icon_path):
label.setPixmap(QPixmap(icon_path))
if label.pixmap().isNull():
label.setPixmap(QPixmap(os.path.join(self.btn_path, "default_location_button.png")))
elif object_type == QLineEdit:
self.line_edit = object_type(self) # Define line_edit como un atributo de la clase ResumePage
self.line_edit.setGeometry(*geometry)
@ -3518,7 +3522,6 @@ class ResumePage(Page):
text = profile_1.get(item, "")
if text:
if item == 'browser':
# Use BrowserPage's static method
base_image = BrowserPage.create_browser_button_image(text, self.btn_path)
geometry = (585, initial_y + i * label_height, 185, 75)
parent_label = QLabel(self)
@ -3526,6 +3529,16 @@ class ResumePage(Page):
parent_label.setPixmap(base_image)
parent_label.show()
self.labels_creados.append(parent_label)
elif item == 'location':
icon_path = os.path.join(self.btn_path, f"button_{text}.png")
geometry = (585, initial_y + i * label_height, 185, 75)
parent_label = QLabel(self)
parent_label.setGeometry(*geometry)
parent_label.setPixmap(QPixmap(icon_path))
if parent_label.pixmap().isNull():
parent_label.setPixmap(QPixmap(os.path.join(self.btn_path, "default_location_button.png")))
parent_label.show()
self.labels_creados.append(parent_label)
else:
icon_path = os.path.join(self.btn_path, f"{text}_button.png")
geometry = (585, initial_y + i * label_height, 185, 75)
@ -3567,7 +3580,7 @@ class ResumePage(Page):
if profile_1.get("connection", "") == "tor":
if profile_1.get("protocol", "") == "hidetor":
location = profile_1.get("location", "")
image_path = f'btn/{location}_hdtor.png'
image_path = f'btn/hdtor_{location}.png'
else:
image_path = os.path.join(self.btn_path, "browser only.png")
label_background = QLabel(self)
@ -3696,8 +3709,9 @@ class ResumePage(Page):
application = ''
print(profile.get('location'))
location = self.connection_manager.get_location_info(profile.get('location'))
print(location)
parts = profile.get('location').split('_')
country_code = parts[0]
location_code = parts[1]
if profile.get('protocol') == 'wireguard':
connection_type = 'wireguard'
elif profile.get('protocol') == 'residential':
@ -3714,8 +3728,8 @@ class ResumePage(Page):
profile_data = {
'id': int(id),
'name': profile.get('name'),
'country_code': location.country_code,
'code': location.code,
'country_code': country_code,
'code': location_code,
'application': application,
'connection_type': connection_type,
'resolution': profile.get('dimentions', ''),
@ -3907,9 +3921,9 @@ class EditorPage(Page):
if protocol=="hidetor":
if connection == "just proxy":
self.display.setPixmap(QPixmap(os.path.join(self.btn_path, f"{location}.png")))
self.display.setPixmap(QPixmap(os.path.join(self.btn_path, f"icon_{location}.png")))
else:
self.display.setPixmap(QPixmap(os.path.join(self.btn_path, f"{location}_hdtor.png")))
self.display.setPixmap(QPixmap(os.path.join(self.btn_path, f"hdtor_{location}.png")))
self.display.show()
self.display.setGeometry(0, 100, 400, 394)
@ -3952,11 +3966,17 @@ class EditorPage(Page):
base_image = QPixmap()
else:
base_image = BrowserPage.create_browser_button_image(current_value, self.btn_path)
elif key == 'location':
image_path = os.path.join(self.btn_path, f"button_{data_profile.get(key, '')}.png")
base_image = QPixmap(image_path)
if base_image.isNull():
base_image = QPixmap(os.path.join(self.btn_path, "default_location_button.png"))
else:
image_path = os.path.join(self.btn_path, f"{data_profile.get(key, '')}_button.png")
current_value = data_profile.get(key, '')
base_image = QPixmap(image_path)
label = QLabel(key, self)
label.setGeometry(565, 90 + i * 80, 185, 75)
label.setPixmap(base_image)
@ -5141,7 +5161,6 @@ class PaymentPage(Page):
currency = 'Bitcoin Lightning'
preferred_method = next((pm for pm in invoice_data.payment_methods if pm.name.lower() == currency.lower()), None)
if preferred_method:
billing_details['due_amount'] = preferred_method.due
billing_details['address'] = preferred_method.address
@ -5674,7 +5693,6 @@ class ConfirmationPopup(QWidget):
def perform_action(self):
self.finished.emit(True)
self.close()
def mousePressEvent(self, event):
self.oldPos = event.globalPosition().toPoint()
@ -5711,3 +5729,4 @@ if __name__ == "__main__":
window = CustomWindow()
window.show()
sys.exit(app.exec())

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

View file

@ -1,33 +0,0 @@
#define 6a2e3c05bd3d4859d314a826ef31f5dcuqWRmCFzQ8jhwLsO_width 50
#define 6a2e3c05bd3d4859d314a826ef31f5dcuqWRmCFzQ8jhwLsO_height 50
static char 6a2e3c05bd3d4859d314a826ef31f5dcuqWRmCFzQ8jhwLsO_bits[] = {
0x00, 0x00, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x07,
0x00, 0x00, 0x00,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0xC0, 0x1F, 0x00, 0xE0,
0x1F, 0xC0, 0x0F, 0xE0, 0x1F, 0x00, 0xC0, 0x3F, 0xE0, 0x19, 0xF0, 0x0F,
0x00, 0xC0, 0x7F, 0x3C, 0xE0, 0xF8, 0x0F, 0x00, 0xC0, 0xFF, 0x0F, 0x80,
0xFF, 0x0F, 0x00, 0x80, 0xFF, 0x03, 0x00, 0xFE, 0x0F, 0x00, 0x80, 0xFF,
0x03, 0x00, 0xFE, 0x07, 0x00, 0x80, 0xFF, 0x07, 0x80, 0xFF, 0x07, 0x00,
0x80, 0xFF, 0x1F, 0xC0, 0xFF, 0x07, 0x00, 0x00, 0xFF, 0x3F, 0xF0, 0xFF,
0x03, 0x00, 0x00, 0xFF, 0xFF, 0xF8, 0xFF, 0x03, 0x00, 0x00, 0xFE, 0xFF,
0xFD, 0xFF, 0x01, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00,
0xFC, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0x3F, 0x00,
0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF,
0x07, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00,
0xFC, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00,
0x00, 0x00, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x00,
0x00, 0x00, };

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

View file

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View file

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View file

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View file

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

View file

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View file

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View file

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View file

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View file

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 158 KiB

View file

Before

Width:  |  Height:  |  Size: 165 KiB

After

Width:  |  Height:  |  Size: 165 KiB

View file

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 188 KiB

View file

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

View file

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 176 KiB

View file

Before

Width:  |  Height:  |  Size: 182 KiB

After

Width:  |  Height:  |  Size: 182 KiB

View file

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

View file

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 85 KiB

View file

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

View file

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

View file

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View file

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View file

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View file

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 101 KiB

View file

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 92 KiB

View file

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 111 KiB

View file

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

View file

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

View file

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

View file

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB

View file

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

View file

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

View file

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

View file

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB

View file

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB