Add category dropdown with existing categories in macro editor
- Replace QLineEdit with editable QComboBox for category field - Populate dropdown with existing categories from saved macros - Allow typing new category names (editable combo box) - Add styled dropdown arrow and item view to match dark theme 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ from PySide6.QtWidgets import (
|
|||||||
QDialog, QVBoxLayout, QHBoxLayout, QFormLayout,
|
QDialog, QVBoxLayout, QHBoxLayout, QFormLayout,
|
||||||
QLabel, QLineEdit, QPushButton, QListWidget, QListWidgetItem,
|
QLabel, QLineEdit, QPushButton, QListWidget, QListWidgetItem,
|
||||||
QComboBox, QSpinBox, QMessageBox, QFileDialog, QWidget,
|
QComboBox, QSpinBox, QMessageBox, QFileDialog, QWidget,
|
||||||
QGroupBox, QScrollArea
|
QGroupBox, QScrollArea, QCompleter
|
||||||
)
|
)
|
||||||
from PySide6.QtCore import Qt, Signal
|
from PySide6.QtCore import Qt, Signal
|
||||||
from PySide6.QtGui import QPixmap, QIcon
|
from PySide6.QtGui import QPixmap, QIcon
|
||||||
@@ -352,6 +352,33 @@ class MacroEditorDialog(QDialog):
|
|||||||
QLineEdit:focus {{
|
QLineEdit:focus {{
|
||||||
border-color: {THEME['accent_color']};
|
border-color: {THEME['accent_color']};
|
||||||
}}
|
}}
|
||||||
|
QComboBox {{
|
||||||
|
background-color: {THEME['bg_color']};
|
||||||
|
border: 1px solid {THEME['button_bg']};
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 8px;
|
||||||
|
color: {THEME['fg_color']};
|
||||||
|
}}
|
||||||
|
QComboBox:focus {{
|
||||||
|
border-color: {THEME['accent_color']};
|
||||||
|
}}
|
||||||
|
QComboBox::drop-down {{
|
||||||
|
border: none;
|
||||||
|
width: 20px;
|
||||||
|
}}
|
||||||
|
QComboBox::down-arrow {{
|
||||||
|
image: none;
|
||||||
|
border-left: 5px solid transparent;
|
||||||
|
border-right: 5px solid transparent;
|
||||||
|
border-top: 5px solid {THEME['fg_color']};
|
||||||
|
margin-right: 5px;
|
||||||
|
}}
|
||||||
|
QComboBox QAbstractItemView {{
|
||||||
|
background-color: {THEME['bg_color']};
|
||||||
|
color: {THEME['fg_color']};
|
||||||
|
selection-background-color: {THEME['accent_color']};
|
||||||
|
border: 1px solid {THEME['button_bg']};
|
||||||
|
}}
|
||||||
""")
|
""")
|
||||||
|
|
||||||
self.setup_ui()
|
self.setup_ui()
|
||||||
@@ -400,8 +427,14 @@ class MacroEditorDialog(QDialog):
|
|||||||
category_group = QGroupBox("Category (optional)")
|
category_group = QGroupBox("Category (optional)")
|
||||||
category_group.setStyleSheet(name_group.styleSheet())
|
category_group.setStyleSheet(name_group.styleSheet())
|
||||||
category_layout = QVBoxLayout(category_group)
|
category_layout = QVBoxLayout(category_group)
|
||||||
self.category_input = QLineEdit()
|
self.category_input = QComboBox()
|
||||||
self.category_input.setPlaceholderText("Enter category")
|
self.category_input.setEditable(True)
|
||||||
|
self.category_input.setInsertPolicy(QComboBox.NoInsert)
|
||||||
|
self.category_input.lineEdit().setPlaceholderText("Select or enter category")
|
||||||
|
# Populate with existing categories (excluding "All")
|
||||||
|
existing_categories = [c for c in self.macro_manager.get_unique_tabs() if c != "All"]
|
||||||
|
self.category_input.addItem("") # Empty option for no category
|
||||||
|
self.category_input.addItems(existing_categories)
|
||||||
category_layout.addWidget(self.category_input)
|
category_layout.addWidget(self.category_input)
|
||||||
content_layout.addWidget(category_group)
|
content_layout.addWidget(category_group)
|
||||||
|
|
||||||
@@ -522,7 +555,7 @@ class MacroEditorDialog(QDialog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.name_input.setText(macro.get("name", ""))
|
self.name_input.setText(macro.get("name", ""))
|
||||||
self.category_input.setText(macro.get("category", ""))
|
self.category_input.setCurrentText(macro.get("category", ""))
|
||||||
self.command_builder.set_commands(macro.get("commands", []))
|
self.command_builder.set_commands(macro.get("commands", []))
|
||||||
|
|
||||||
if macro.get("image_path"):
|
if macro.get("image_path"):
|
||||||
@@ -563,7 +596,7 @@ class MacroEditorDialog(QDialog):
|
|||||||
QMessageBox.warning(self, "Error", "Please add at least one command")
|
QMessageBox.warning(self, "Error", "Please add at least one command")
|
||||||
return
|
return
|
||||||
|
|
||||||
category = self.category_input.text().strip()
|
category = self.category_input.currentText().strip()
|
||||||
|
|
||||||
if self.macro_id:
|
if self.macro_id:
|
||||||
# Update existing macro
|
# Update existing macro
|
||||||
|
|||||||
Reference in New Issue
Block a user