|
34 | 34 | ) |
35 | 35 | from PyQt6.QtGui import QAction, QCloseEvent, QFont, QPainter, QPaintEvent, QPen, QShortcut |
36 | 36 | from PyQt6.QtWidgets import ( |
37 | | - QApplication, QFileDialog, QFormLayout, QHBoxLayout, QLabel, QLineEdit, |
38 | | - QListView, QMenu, QScrollArea, QStackedWidget, QStyledItemDelegate, |
| 37 | + QApplication, QFormLayout, QHBoxLayout, QLabel, QLineEdit, QListView, |
| 38 | + QMenu, QScrollArea, QStackedWidget, QStyledItemDelegate, |
39 | 39 | QStyleOptionViewItem, QVBoxLayout, QWidget |
40 | 40 | ) |
41 | 41 |
|
@@ -351,20 +351,22 @@ def _openContextMenu(self, pos: QPoint) -> None: |
351 | 351 |
|
352 | 352 | def _processOpenProjectRequest(self, path: str) -> None: |
353 | 353 | """Process an open project request which may involve create.""" |
354 | | - if path == SAMPLE_KEY and (location := QFileDialog.getExistingDirectory( |
355 | | - self, self.tr("Select Folder"), str(CONFIG.homePath), |
356 | | - options=QFileDialog.Option.ShowDirsOnly, |
357 | | - )): |
358 | | - path = str(Path(location) / SAMPLE_NAME) |
359 | | - data = { |
360 | | - "name": SAMPLE_NAME, |
361 | | - "path": path, |
362 | | - "sample": True, |
363 | | - } |
364 | | - builder = ProjectBuilder() |
365 | | - builder.buildProject(data) |
366 | | - |
367 | | - self.openProjectRequest.emit(Path(path)) |
| 354 | + if path == SAMPLE_KEY: |
| 355 | + if location := SHARED.getProjectFolder(self, CONFIG.homePath()): |
| 356 | + sample = location / SAMPLE_NAME |
| 357 | + data = { |
| 358 | + "name": SAMPLE_NAME, |
| 359 | + "path": sample, |
| 360 | + "sample": True, |
| 361 | + } |
| 362 | + builder = ProjectBuilder() |
| 363 | + if builder.buildProject(data): |
| 364 | + self.openProjectRequest.emit(sample) |
| 365 | + else: |
| 366 | + SHARED.error(self.tr("You must select a location for the example project.")) |
| 367 | + return |
| 368 | + else: |
| 369 | + self.openProjectRequest.emit(Path(path)) |
368 | 370 |
|
369 | 371 | def _selectFirstItem(self) -> None: |
370 | 372 | """Select the first item, if any are available.""" |
@@ -709,11 +711,8 @@ def getProjectData(self) -> dict: |
709 | 711 | @pyqtSlot() |
710 | 712 | def _doBrowse(self) -> None: |
711 | 713 | """Select a project folder.""" |
712 | | - if path := QFileDialog.getExistingDirectory( |
713 | | - self, self.tr("Select Project Folder"), |
714 | | - str(self._basePath), options=QFileDialog.Option.ShowDirsOnly |
715 | | - ): |
716 | | - self._basePath = Path(path) |
| 714 | + if path := SHARED.getProjectFolder(self, self._basePath): |
| 715 | + self._basePath = path |
717 | 716 | self._updateProjPath() |
718 | 717 | CONFIG.setLastPath("project", path) |
719 | 718 |
|
|
0 commit comments