From 324843c92f9890bd5b7611b01c2799adad4c3b29 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 20 Sep 2025 17:01:33 +0100 Subject: [PATCH] new copy and execute buttons on debug help --- gui/__main__.py | 103 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 21 deletions(-) diff --git a/gui/__main__.py b/gui/__main__.py index 5dce5b6..7750e51 100755 --- a/gui/__main__.py +++ b/gui/__main__.py @@ -4923,11 +4923,6 @@ class Settings(Page): scroll_layout.addWidget(ping_group) - app_path = "./hydra-veil-x86_64.AppImage" - if hasattr(sys, 'frozen'): - app_dir = os.path.dirname(app_path) - else: - app_dir = os.path.dirname(os.path.dirname(app_path)) command_group = QGroupBox("CLI Commands") command_group.setStyleSheet(f""" @@ -4991,7 +4986,7 @@ class Settings(Page): find_command = QLineEdit() find_command.setReadOnly(True) - find_command.setText("find ~ -name 'hydra-veil-x86_64.AppImage' 2>/dev/null") + find_command.setText(f"find ~ -name '{os.environ.get('APPIMAGE') or 'hydra-veil-x86_64.AppImage'}' 2>/dev/null") find_command.setStyleSheet(f""" QLineEdit {{ color: white; @@ -5006,9 +5001,11 @@ class Settings(Page): """) command_layout.addWidget(find_command) - copy_button = QPushButton("Copy Command") - copy_button.setFixedSize(120, 40) - copy_button.setStyleSheet(f""" + cli_buttons_layout = QHBoxLayout() + + cli_copy_button = QPushButton("Copy CLI Command") + cli_copy_button.setFixedSize(140, 40) + cli_copy_button.setStyleSheet(f""" QPushButton {{ font-size: 12px; background: #007AFF; @@ -5025,13 +5022,13 @@ class Settings(Page): background: #666666; }} """) - copy_button.clicked.connect(self.copy_cli_command) - copy_button.setEnabled(False) - command_layout.addWidget(copy_button) + cli_copy_button.clicked.connect(self.copy_cli_command) + cli_copy_button.setEnabled(False) + cli_buttons_layout.addWidget(cli_copy_button) - execute_button = QPushButton("Execute Command") - execute_button.setFixedSize(120, 40) - execute_button.setStyleSheet(f""" + cli_execute_button = QPushButton("Execute CLI Command") + cli_execute_button.setFixedSize(140, 40) + cli_execute_button.setStyleSheet(f""" QPushButton {{ font-size: 10px; background: #4CAF50; @@ -5048,14 +5045,65 @@ class Settings(Page): background: #666666; }} """) - execute_button.clicked.connect(self.execute_cli_command) - execute_button.setEnabled(False) - command_layout.addWidget(execute_button) + cli_execute_button.clicked.connect(self.execute_cli_command) + cli_execute_button.setEnabled(False) + cli_buttons_layout.addWidget(cli_execute_button) + + command_layout.addLayout(cli_buttons_layout) + + # Buttons for find command + find_buttons_layout = QHBoxLayout() + + find_copy_button = QPushButton("Copy Find Command") + find_copy_button.setFixedSize(140, 40) + find_copy_button.setStyleSheet(f""" + QPushButton {{ + font-size: 12px; + background: #007AFF; + color: white; + border: none; + border-radius: 5px; + font-weight: bold; + {self.font_style} + }} + QPushButton:hover {{ + background: #0056CC; + }} + QPushButton:disabled {{ + background: #666666; + }} + """) + find_copy_button.clicked.connect(lambda: self.copy_find_command(find_command.text())) + find_buttons_layout.addWidget(find_copy_button) + + find_execute_button = QPushButton("Execute Find Command") + find_execute_button.setFixedSize(140, 40) + find_execute_button.setStyleSheet(f""" + QPushButton {{ + font-size: 10px; + background: #4CAF50; + color: white; + border: none; + border-radius: 5px; + font-weight: bold; + {self.font_style} + }} + QPushButton:hover {{ + background: #45a049; + }} + QPushButton:disabled {{ + background: #666666; + }} + """) + find_execute_button.clicked.connect(lambda: self.execute_find_command(find_command.text())) + find_buttons_layout.addWidget(find_execute_button) + + command_layout.addLayout(find_buttons_layout) scroll_layout.addWidget(command_group) - self.cli_copy_button = copy_button - self.cli_execute_button = execute_button + self.cli_copy_button = cli_copy_button + self.cli_execute_button = cli_execute_button wg_quick_group = QGroupBox("Direct Systemwide Wireguard") wg_quick_group.setStyleSheet(f""" @@ -5184,6 +5232,19 @@ class Settings(Page): except Exception as e: self.update_status.update_status(f"Error executing command: {str(e)}") + def copy_find_command(self, command_text): + clipboard = QApplication.clipboard() + clipboard.setText(command_text) + self.update_status.update_status("Find command copied to clipboard") + + def execute_find_command(self, command_text): + try: + command = command_text.split() + subprocess.Popen(command) + self.update_status.update_status("Find command executed") + except Exception as e: + self.update_status.update_status(f"Error executing find command: {str(e)}") + def update_debug_profile_list(self): self.debug_profile_selector.clear() profiles = ProfileController.get_all() @@ -5217,7 +5278,7 @@ class Settings(Page): if profile and isinstance(profile, SystemProfile): - app_path = "./hydra-veil-x86_64.AppImage" + app_path = os.environ.get('APPIMAGE') or "./hydra-veil-x86_64.AppImage" self.cli_command.setText(f"{app_path} --cli profile enable -i {profile_id}") self.cli_copy_button.setEnabled(True) self.cli_execute_button.setEnabled(True)