Skip to content

Commit a185f24

Browse files
committed
Added workspace selection and management features to the GUI
1 parent 5c76d8d commit a185f24

1 file changed

Lines changed: 137 additions & 0 deletions

File tree

OnlyMod/BcaslOnlyMod/gui.py

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
QFrame,
5757
QSplitter,
5858
QSizePolicy,
59+
QFileDialog,
60+
QLineEdit,
5961
)
6062
from PySide6.QtGui import QFont, QIcon
6163

@@ -270,6 +272,90 @@ def _setup_ui(self):
270272

271273
header_layout.addStretch()
272274

275+
# === Section Workspace ===
276+
workspace_layout = QHBoxLayout()
277+
workspace_layout.setSpacing(8)
278+
279+
# Label workspace
280+
workspace_label = QLabel(tr("Workspace:", "Workspace :"))
281+
workspace_label.setStyleSheet("font-weight: bold; font-size: 12px;")
282+
workspace_layout.addWidget(workspace_label)
283+
284+
# Champ de显示 du chemin du workspace
285+
self.workspace_path_edit = QLineEdit()
286+
self.workspace_path_edit.setPlaceholderText(
287+
tr("Select a workspace folder...", "Sélectionner un dossier workspace...")
288+
)
289+
self.workspace_path_edit.setReadOnly(True)
290+
self.workspace_path_edit.setMinimumWidth(250)
291+
self.workspace_path_edit.setMaximumWidth(400)
292+
self.workspace_path_edit.setStyleSheet(
293+
"""
294+
QLineEdit {
295+
background-color: #2d2d2d;
296+
color: #ffffff;
297+
border: 1px solid #404040;
298+
border-radius: 4px;
299+
padding: 4px 8px;
300+
font-size: 11px;
301+
}
302+
"""
303+
)
304+
# Afficher le workspace actuel si défini
305+
if self.workspace_dir:
306+
self.workspace_path_edit.setText(str(Path(self.workspace_dir).resolve()))
307+
workspace_layout.addWidget(self.workspace_path_edit)
308+
309+
# Bouton sélectionner workspace
310+
self.btn_select_workspace = QPushButton("📁")
311+
self.btn_select_workspace.setMinimumSize(32, 28)
312+
self.btn_select_workspace.setToolTip(
313+
tr("Select workspace folder", "Sélectionner le dossier workspace")
314+
)
315+
self.btn_select_workspace.setStyleSheet(
316+
"""
317+
QPushButton {
318+
background-color: #404040;
319+
color: white;
320+
border-radius: 4px;
321+
padding: 4px 8px;
322+
font-size: 14px;
323+
}
324+
QPushButton:hover {
325+
background-color: #4da6ff;
326+
}
327+
"""
328+
)
329+
self.btn_select_workspace.clicked.connect(self._select_workspace)
330+
workspace_layout.addWidget(self.btn_select_workspace)
331+
332+
# Bouton clear workspace
333+
self.btn_clear_workspace = QPushButton("✕")
334+
self.btn_clear_workspace.setMinimumSize(32, 28)
335+
self.btn_clear_workspace.setToolTip(
336+
tr("Clear workspace", "Effacer le workspace")
337+
)
338+
self.btn_clear_workspace.setStyleSheet(
339+
"""
340+
QPushButton {
341+
background-color: #404040;
342+
color: white;
343+
border-radius: 4px;
344+
padding: 4px 8px;
345+
font-size: 12px;
346+
}
347+
QPushButton:hover {
348+
background-color: #f44336;
349+
}
350+
"""
351+
)
352+
self.btn_clear_workspace.clicked.connect(self._clear_workspace)
353+
workspace_layout.addWidget(self.btn_clear_workspace)
354+
355+
header_layout.addLayout(workspace_layout)
356+
357+
header_layout.addSpacing(20)
358+
273359
# Version info
274360
version_text = tr(
275361
f"Core: {get_core_version()} | BCASL: {get_bcasl_version()}",
@@ -521,6 +607,49 @@ def _center_window(self):
521607
except Exception:
522608
pass
523609

610+
def _select_workspace(self):
611+
"""Ouvre une boîte de dialogue pour sélectionner le workspace."""
612+
current_path = self.workspace_dir or ""
613+
614+
folder = QFileDialog.getExistingDirectory(
615+
self,
616+
tr("Select Workspace Folder", "Sélectionner le dossier Workspace"),
617+
current_path,
618+
QFileDialog.Option.ShowDirsOnly,
619+
)
620+
621+
if folder:
622+
self.workspace_dir = folder
623+
self.workspace_path_edit.setText(str(Path(folder).resolve()))
624+
625+
# Recharger la configuration et les plugins
626+
self._load_config()
627+
self._discover_plugins()
628+
629+
self._log(
630+
tr(
631+
f"Workspace selected: {folder}",
632+
f"Workspace sélectionné : {folder}",
633+
)
634+
)
635+
self.statusBar.showMessage(tr("Workspace updated", "Workspace mis à jour"))
636+
637+
def _clear_workspace(self):
638+
"""Efface la sélection du workspace."""
639+
self.workspace_dir = None
640+
self.workspace_path_edit.clear()
641+
self.workspace_path_edit.setPlaceholderText(
642+
tr("Select a workspace folder...", "Sélectionner un dossier workspace...")
643+
)
644+
645+
# Recharger avec workspace vide
646+
self._load_config()
647+
self.plugins_meta = {}
648+
self._discover_plugins()
649+
650+
self._log(tr("Workspace cleared", "Workspace effacé"))
651+
self.statusBar.showMessage(tr("Workspace cleared", "Workspace effacé"))
652+
524653
def _is_valid(self, widget) -> bool:
525654
"""Vérifie si un widget Qt est toujours valide.
526655
@@ -637,6 +766,14 @@ def _apply_theme(self, theme_name: str):
637766
color: #000000;
638767
spacing: 5px;
639768
}
769+
QLineEdit {
770+
background-color: #ffffff;
771+
color: #000000;
772+
border: 1px solid #cccccc;
773+
border-radius: 4px;
774+
padding: 4px 8px;
775+
font-size: 11px;
776+
}
640777
QStatusBar {
641778
background-color: #e0e0e0;
642779
color: #666666;

0 commit comments

Comments
 (0)