update: updated menu page, location page, fast creation page
This commit is contained in:
parent
4147221e09
commit
b91085ab10
1 changed files with 195 additions and 74 deletions
269
gui/__main__.py
269
gui/__main__.py
|
|
@ -226,7 +226,6 @@ class WorkerThread(QThread):
|
|||
|
||||
def sync(self):
|
||||
try:
|
||||
ConfigurationController.set_endpoint_verification_enabled(True)
|
||||
if self.action == 'SYNC_TOR':
|
||||
ConfigurationController.set_connection('tor')
|
||||
else:
|
||||
|
|
@ -1333,7 +1332,7 @@ class MenuPage(Page):
|
|||
self.button_states = {}
|
||||
self.is_system_connected = False
|
||||
self.profile_button_map = {}
|
||||
|
||||
self.font_style = f"font-family: '{main_window.open_sans_family}';" if main_window.open_sans_family else ""
|
||||
|
||||
#self.label.setStyleSheet("background-color: rgba(0, 255, 0, 51);")
|
||||
self.create_interface_elements() # Establecer el color de fondo y el color del texto utilizando hojas de estilo
|
||||
|
|
@ -1571,34 +1570,6 @@ class MenuPage(Page):
|
|||
|
||||
button.clicked.connect(lambda checked, pid=profile_id: self.print_profile_details(f"Profile_{pid}"))
|
||||
|
||||
profile = ProfileController.get(profile_id)
|
||||
if profile and profile.location and profile.location.operator:
|
||||
verification_icon = QPushButton(parent_label)
|
||||
icon_size = 23
|
||||
button_width = 175
|
||||
icon_x = button_width - icon_size - 50
|
||||
icon_y = 0
|
||||
verification_icon.setGeometry(icon_x, icon_y, icon_size, icon_size)
|
||||
verification_icon.setIcon(QIcon(os.path.join(self.btn_path, "verification_icon.png")))
|
||||
verification_icon.setIconSize(QSize(icon_size, icon_size))
|
||||
verification_icon.setStyleSheet(f"""
|
||||
QPushButton {{
|
||||
background: transparent;
|
||||
border: none;
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 3px;
|
||||
}}
|
||||
QPushButton:disabled {{
|
||||
opacity: 0.3;
|
||||
}}
|
||||
""")
|
||||
verification_icon.setCursor(QtCore.Qt.CursorShape.PointingHandCursor)
|
||||
verification_icon.setEnabled(self.connection_manager.is_synced())
|
||||
verification_icon.clicked.connect(lambda checked, pid=profile_id: self.show_profile_verification(pid))
|
||||
verification_icon.show()
|
||||
|
||||
return button
|
||||
|
||||
def create_profile_name_label(self, parent_label, name):
|
||||
|
|
@ -1690,6 +1661,132 @@ class MenuPage(Page):
|
|||
|
||||
return os.path.join(self.btn_path, f"icon_mini_{value[label_name]}.png")
|
||||
|
||||
def truncate_key(self, text, max_length=50):
|
||||
if not text or text == "N/A" or len(text) <= max_length:
|
||||
return text
|
||||
start_len = max_length // 2 - 2
|
||||
end_len = max_length // 2 - 2
|
||||
return text[:start_len] + "....." + text[-end_len:]
|
||||
|
||||
def create_verification_widget(self, profile_obj):
|
||||
verification_widget = QWidget(self)
|
||||
verification_widget.setGeometry(0, 90, 400, 300)
|
||||
verification_widget.setStyleSheet("background: transparent;")
|
||||
|
||||
verification_layout = QVBoxLayout(verification_widget)
|
||||
verification_layout.setContentsMargins(20, 20, 20, 20)
|
||||
verification_layout.setSpacing(15)
|
||||
|
||||
operator = None
|
||||
if profile_obj.location and profile_obj.location.operator:
|
||||
operator = profile_obj.location.operator
|
||||
|
||||
info_items = [
|
||||
("Operator Name", "operator_name"),
|
||||
("Nostr Key", "nostr_public_key"),
|
||||
("HydraVeil Key", "hydraveil_public_key"),
|
||||
("Nostr Verification", "nostr_attestation_event_reference"),
|
||||
]
|
||||
|
||||
for label, key in info_items:
|
||||
container = QWidget()
|
||||
container.setStyleSheet("background: transparent;")
|
||||
container_layout = QHBoxLayout(container)
|
||||
container_layout.setContentsMargins(0, 0, 0, 0)
|
||||
container_layout.setSpacing(10)
|
||||
|
||||
label_widget = QLabel(label + ":")
|
||||
label_widget.setStyleSheet(f"color: white; font-size: 12px; {self.font_style}")
|
||||
label_widget.setMinimumWidth(120)
|
||||
container_layout.addWidget(label_widget)
|
||||
|
||||
value_widget = QLineEdit()
|
||||
value_widget.setReadOnly(True)
|
||||
|
||||
if operator:
|
||||
if key == "operator_name":
|
||||
value = operator.name or "N/A"
|
||||
elif key == "nostr_public_key":
|
||||
value = operator.nostr_public_key or "N/A"
|
||||
value = self.truncate_key(value) if value != "N/A" else value
|
||||
elif key == "hydraveil_public_key":
|
||||
value = operator.public_key or "N/A"
|
||||
value = self.truncate_key(value) if value != "N/A" else value
|
||||
elif key == "nostr_attestation_event_reference":
|
||||
value = operator.nostr_attestation_event_reference or "N/A"
|
||||
value = self.truncate_key(value) if value != "N/A" else value
|
||||
else:
|
||||
value = "N/A"
|
||||
else:
|
||||
value = "N/A"
|
||||
|
||||
value_widget.setText(value)
|
||||
value_widget.setCursorPosition(0)
|
||||
value_widget.setStyleSheet(f"""
|
||||
QLineEdit {{
|
||||
color: white;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
|
||||
padding: 5px 0px;
|
||||
font-size: 12px;
|
||||
{self.font_style}
|
||||
}}
|
||||
""")
|
||||
container_layout.addWidget(value_widget, 1)
|
||||
|
||||
checkmark_widget = QLabel("✓")
|
||||
checkmark_widget.setStyleSheet(f"color: #4CAF50; font-size: 20px; font-weight: bold; {self.font_style}")
|
||||
checkmark_widget.setFixedSize(20, 20)
|
||||
checkmark_widget.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
if value and value != "N/A":
|
||||
checkmark_widget.show()
|
||||
else:
|
||||
checkmark_widget.hide()
|
||||
container_layout.addWidget(checkmark_widget)
|
||||
|
||||
copy_button = QPushButton()
|
||||
copy_button.setIcon(QIcon(os.path.join(self.btn_path, "paste_button.png")))
|
||||
copy_button.setIconSize(QSize(24, 24))
|
||||
copy_button.setFixedSize(30, 30)
|
||||
copy_button.setStyleSheet(f"""
|
||||
QPushButton {{
|
||||
background: transparent;
|
||||
border: none;
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 4px;
|
||||
}}
|
||||
""")
|
||||
|
||||
if operator:
|
||||
if key == "operator_name":
|
||||
full_value = operator.name or "N/A"
|
||||
elif key == "nostr_public_key":
|
||||
full_value = operator.nostr_public_key or "N/A"
|
||||
elif key == "hydraveil_public_key":
|
||||
full_value = operator.public_key or "N/A"
|
||||
elif key == "nostr_attestation_event_reference":
|
||||
full_value = operator.nostr_attestation_event_reference or "N/A"
|
||||
else:
|
||||
full_value = "N/A"
|
||||
else:
|
||||
full_value = "N/A"
|
||||
|
||||
copy_button.clicked.connect(lambda checked=False, val=full_value: self.copy_verification_value(val))
|
||||
container_layout.addWidget(copy_button)
|
||||
|
||||
verification_layout.addWidget(container)
|
||||
|
||||
verification_widget.show()
|
||||
return verification_widget
|
||||
|
||||
def copy_verification_value(self, value):
|
||||
if value and value != "N/A":
|
||||
clipboard = QApplication.clipboard()
|
||||
clipboard.setText(value)
|
||||
self.update_status.update_status("Verification value copied to clipboard")
|
||||
|
||||
def print_profile_details(self, profile_name):
|
||||
self.reverse_id = int(profile_name.split('_')[1])
|
||||
|
|
@ -1734,41 +1831,48 @@ class MenuPage(Page):
|
|||
|
||||
if profile:
|
||||
self.update_status.current_profile_id = self.reverse_id
|
||||
profile_number = profile_name.split("_")[1] # Extraer el número del perfil del nombre del perfil
|
||||
profile_number = profile_name.split("_")[1]
|
||||
name = profile.get("name", "")
|
||||
protocol = profile.get("protocol", "")
|
||||
location = profile.get("location", "")
|
||||
connection = profile.get("connection", "")
|
||||
country_garaje = profile.get("country_garaje", "")
|
||||
|
||||
|
||||
profile_obj = ProfileController.get(self.reverse_id)
|
||||
is_profile_enabled = self.connection_manager.is_profile_connected(self.reverse_id)
|
||||
show_verification_widget = False
|
||||
|
||||
if protocol.lower() in ["wireguard", "open", "lokinet","residential", "hidetor"]:
|
||||
|
||||
label_principal = QLabel(self)
|
||||
label_principal.setGeometry(0, 90, 400, 300)
|
||||
pixmap=QPixmap(os.path.join(self.btn_path, f"{protocol}_{location}.png"))
|
||||
label_principal.setPixmap(pixmap)
|
||||
label_principal.setScaledContents(True)
|
||||
|
||||
|
||||
label_principal.show()
|
||||
self.additional_labels.append(label_principal)
|
||||
label_principal = None
|
||||
if protocol.lower() == "wireguard" and is_profile_enabled and profile_obj and profile_obj.connection and profile_obj.connection.code == 'wireguard':
|
||||
verification_widget = self.create_verification_widget(profile_obj)
|
||||
self.additional_labels.append(verification_widget)
|
||||
show_verification_widget = True
|
||||
label_principal = None
|
||||
else:
|
||||
label_principal = QLabel(self)
|
||||
label_principal.setGeometry(0, 90, 400, 300)
|
||||
pixmap=QPixmap(os.path.join(self.btn_path, f"{protocol}_{location}.png"))
|
||||
label_principal.setPixmap(pixmap)
|
||||
label_principal.setScaledContents(True)
|
||||
label_principal.show()
|
||||
self.additional_labels.append(label_principal)
|
||||
|
||||
if protocol.lower() == "wireguard" and ConfigurationController.get_endpoint_verification_enabled():
|
||||
profile_obj = ProfileController.get(self.reverse_id)
|
||||
is_profile_enabled = self.connection_manager.is_profile_connected(self.reverse_id)
|
||||
if profile_obj and profile_obj.connection and profile_obj.connection.code == 'wireguard' and is_profile_enabled:
|
||||
if is_profile_enabled and profile_obj and profile_obj.connection and profile_obj.connection.code == 'wireguard':
|
||||
verified_icon = QLabel(self)
|
||||
verified_icon.setGeometry(0, 60, 400, 40)
|
||||
verified_icon.setGeometry(20, 60, 100, 60)
|
||||
verified_pixmap = QPixmap(os.path.join(self.btn_path, "verified_profile.png"))
|
||||
verified_icon.setPixmap(verified_pixmap)
|
||||
verified_icon.setScaledContents(True)
|
||||
verified_icon.show()
|
||||
self.additional_labels.append(verified_icon)
|
||||
|
||||
if protocol.lower() == "hidetor":
|
||||
if protocol.lower() == "hidetor" and not show_verification_widget:
|
||||
|
||||
label_principal.setGeometry(0, 80, 400, 300)
|
||||
if label_principal:
|
||||
label_principal.setGeometry(0, 80, 400, 300)
|
||||
label_background = QLabel(self)
|
||||
label_background.setGeometry(0, 60, 410, 354)
|
||||
if connection == 'just proxy':
|
||||
|
|
@ -1783,14 +1887,13 @@ class MenuPage(Page):
|
|||
self.additional_labels.append(label_background)
|
||||
|
||||
|
||||
if protocol.lower() == "wireguard" and connection.lower() == "browser-only":
|
||||
if protocol.lower() == "wireguard" and connection.lower() == "browser-only" and not show_verification_widget:
|
||||
|
||||
# Redimensionar el QLabel principal
|
||||
label_principal.setGeometry(0, 80, 400, 300)
|
||||
if label_principal:
|
||||
label_principal.setGeometry(0, 80, 400, 300)
|
||||
|
||||
# Crear QLabel con la imagen os.path.join(self.btn_path, "browser only.png") detrás del label_principal
|
||||
label_background = QLabel(self)
|
||||
label_background.setGeometry(0, 60, 410, 354) # Geometría según necesidades
|
||||
label_background.setGeometry(0, 60, 410, 354)
|
||||
is_supported = profile.get('browser_supported', False)
|
||||
image_name = "browser only.png" if is_supported else "unsupported_browser_only.png"
|
||||
pixmap = QPixmap(os.path.join(self.btn_path, image_name))
|
||||
|
|
@ -2198,6 +2301,9 @@ class MenuPage(Page):
|
|||
|
||||
self.show_disconnect_button(False, profile_type, target_button)
|
||||
self.boton_edit.setEnabled(True)
|
||||
|
||||
if profile_id == self.reverse_id:
|
||||
self.print_profile_details(f"Profile_{profile_id}")
|
||||
except IndexError:
|
||||
self.update_status.update_status('An error occurred while updating profile state.')
|
||||
|
||||
|
|
@ -3292,24 +3398,25 @@ class LocationPage(Page):
|
|||
self.initial_display.setWordWrap(True)
|
||||
|
||||
self.verification_button = QPushButton("Verification", self)
|
||||
self.verification_button.setGeometry(330, 40, 130, 40)
|
||||
self.verification_button.setGeometry(280, 40, 180, 40)
|
||||
self.verification_button.setStyleSheet(f"""
|
||||
QPushButton {{
|
||||
background-color: rgba(30, 30, 35, 0.9);
|
||||
border: 1px solid rgba(100, 100, 120, 0.6);
|
||||
background-color: rgba(60, 80, 120, 1.0);
|
||||
border: 2px solid rgba(100, 140, 200, 1.0);
|
||||
border-radius: 5px;
|
||||
color: rgb(255, 255, 255);
|
||||
font-size: 14px;
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
padding: 5px 10px;
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
background-color: rgba(50, 50, 60, 0.95);
|
||||
border: 1px solid rgba(150, 150, 180, 0.8);
|
||||
background-color: rgba(80, 100, 140, 1.0);
|
||||
border: 2px solid rgba(120, 160, 220, 1.0);
|
||||
}}
|
||||
QPushButton:disabled {{
|
||||
background-color: rgba(20, 20, 25, 0.5);
|
||||
border: 1px solid rgba(60, 60, 70, 0.4);
|
||||
opacity: 0.4;
|
||||
background-color: rgba(40, 50, 70, 0.6);
|
||||
border: 2px solid rgba(70, 90, 110, 0.6);
|
||||
opacity: 0.5;
|
||||
}}
|
||||
""")
|
||||
self.verification_button.setCursor(QtCore.Qt.CursorShape.PointingHandCursor)
|
||||
|
|
@ -3472,14 +3579,9 @@ class LocationPage(Page):
|
|||
painter.setTransform(QTransform())
|
||||
|
||||
if provider:
|
||||
provider_label_font = QApplication.font()
|
||||
provider_label_font.setPointSize(8)
|
||||
provider_label_font.setWeight(QFont.Weight.Bold)
|
||||
painter.setFont(provider_label_font)
|
||||
|
||||
painter.setPen(QColor(128, 128, 128))
|
||||
|
||||
provider_label = "Provider:"
|
||||
provider_label_rect = painter.fontMetrics().boundingRect(provider_label)
|
||||
|
||||
provider_text_font = QApplication.font()
|
||||
provider_text_font.setPointSize(7)
|
||||
|
|
@ -3487,15 +3589,13 @@ class LocationPage(Page):
|
|||
painter.setFont(provider_text_font)
|
||||
provider_text_rect = painter.fontMetrics().boundingRect(provider)
|
||||
|
||||
provider_x = ((base_image.width() - max(provider_label_rect.width(), provider_text_rect.width())) // 2) - 30
|
||||
provider_x = ((base_image.width() - provider_text_rect.width()) // 2) - 30
|
||||
provider_y = 50
|
||||
px = int(provider_x)
|
||||
py = int(provider_y)
|
||||
|
||||
painter.setFont(provider_label_font)
|
||||
painter.drawText(px + 20, py + 2, provider_label)
|
||||
painter.setFont(provider_text_font)
|
||||
painter.drawText(px + 5, py + provider_label_rect.height() + 2, provider)
|
||||
painter.drawText(px + 5, py + 2, provider)
|
||||
finally:
|
||||
painter.end()
|
||||
return base_image
|
||||
|
|
@ -6298,7 +6398,6 @@ class Settings(Page):
|
|||
return page
|
||||
|
||||
def truncate_key(self, text, max_length=50):
|
||||
"""Truncate text in the middle, showing start and end parts."""
|
||||
if not text or text == "N/A" or len(text) <= max_length:
|
||||
return text
|
||||
start_len = max_length // 2 - 2
|
||||
|
|
@ -7285,6 +7384,18 @@ class ConfirmationPopup(QWidget):
|
|||
action_button.clicked.connect(self.perform_action)
|
||||
button_layout.addWidget(action_button)
|
||||
|
||||
def perform_action(self):
|
||||
self.finished.emit(True)
|
||||
self.close()
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
self.oldPos = event.globalPosition().toPoint()
|
||||
|
||||
def mouseMoveEvent(self, event):
|
||||
delta = event.globalPosition().toPoint() - self.oldPos
|
||||
self.move(self.x() + delta.x(), self.y() + delta.y())
|
||||
self.oldPos = event.globalPosition().toPoint()
|
||||
|
||||
class EndpointVerificationPopup(QWidget):
|
||||
finished = pyqtSignal(bool, str)
|
||||
|
||||
|
|
@ -8346,12 +8457,22 @@ class FastRegistrationPage(Page):
|
|||
|
||||
def create_location_section(self):
|
||||
info_label = QLabel("Click the location for more info", self)
|
||||
info_label.setGeometry(520, 80, 230, 20)
|
||||
info_label.setStyleSheet("color: #888888; font-size: 11px; font-style: italic;")
|
||||
info_label.setGeometry(500, 80, 280, 20)
|
||||
info_label.setStyleSheet("color: #888888; font-size: 14px; font-style: italic;")
|
||||
info_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
|
||||
info_label.show()
|
||||
self.labels.append(info_label)
|
||||
|
||||
arrow_label = QLabel(self)
|
||||
arrow_label.setGeometry(540, 100, 150, 150)
|
||||
arrow_pixmap = QPixmap(os.path.join(self.btn_path, "arrow.png"))
|
||||
transform = QTransform().rotate(270)
|
||||
rotated_arrow = arrow_pixmap.transformed(transform)
|
||||
arrow_label.setPixmap(rotated_arrow)
|
||||
arrow_label.setScaledContents(True)
|
||||
arrow_label.show()
|
||||
self.labels.append(arrow_label)
|
||||
|
||||
label = QPushButton(self)
|
||||
label.setGeometry(435, 250, 185, 75)
|
||||
label.setFlat(True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue