Has copy command button

This commit is contained in:
Dawson Matthews
2026-03-08 22:56:19 -06:00
parent 5e0840a59d
commit fa2d64cd1f
3 changed files with 24 additions and 233 deletions
+24 -1
View File
@@ -5,6 +5,7 @@ import json
import subprocess
import sys
import os
import shlex
from pathlib import Path
# Try to import PySide6 for the GUI
@@ -206,7 +207,7 @@ class DisplayProfileManagerGUI(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("KDE Display Profile Manager")
self.setMinimumSize(400, 300)
self.setMinimumSize(420, 300)
# Ensure default directory exists
DEFAULT_PROFILE_DIR.mkdir(parents=True, exist_ok=True)
@@ -237,6 +238,11 @@ class DisplayProfileManagerGUI(QMainWindow):
self.refresh_btn.clicked.connect(self.refresh_profiles)
btn_layout.addWidget(self.refresh_btn)
self.copy_btn = QPushButton("Copy Load Cmd")
self.copy_btn.setMinimumWidth(120)
self.copy_btn.clicked.connect(self.on_copy_clicked)
btn_layout.addWidget(self.copy_btn)
layout.addLayout(btn_layout)
def refresh_profiles(self):
@@ -291,6 +297,23 @@ class DisplayProfileManagerGUI(QMainWindow):
except Exception as e:
QMessageBox.critical(self, "Error", f"Failed to load profile: {e}")
def on_copy_clicked(self):
selected_item = self.profile_list.currentItem()
if not selected_item:
QMessageBox.warning(self, "No Selection", "Please select a profile to copy the command for.")
return
profile_name = selected_item.text()
profile_path = DEFAULT_PROFILE_DIR / f"{profile_name}.json"
script_path = os.path.abspath(__file__)
cmd = f"python3 {shlex.quote(script_path)} load {shlex.quote(str(profile_path))}"
clipboard = QApplication.clipboard()
clipboard.setText(cmd)
QMessageBox.information(self, "Command Copied", f"The following command has been copied to your clipboard:\n\n{cmd}")
def show_gui():
if not PYSIDE_AVAILABLE:
print("Error: PySide6 is not installed. Please install it to use the GUI.", file=sys.stderr)