| 25 | |
| 26 | |
| 27 | class ManageProject(DefaultTab): |
| 28 | def __init__(self, root, parent, h1_description): |
| 29 | super().__init__(root, parent, h1_description) |
| 30 | self._set_page() |
| 31 | self._videos = [] |
| 32 | |
| 33 | def _set_page(self): |
| 34 | # Add config text field and button |
| 35 | project_config_layout = _create_horizontal_layout() |
| 36 | |
| 37 | cfg_text = QLabel("Active config file:") |
| 38 | |
| 39 | self.cfg_line = QLineEdit() |
| 40 | self.cfg_line.setText(self.root.config) |
| 41 | self.cfg_line.textChanged[str].connect(self.root.update_cfg) |
| 42 | |
| 43 | browse_button = QPushButton("Browse") |
| 44 | browse_button.setMaximumWidth(100) |
| 45 | browse_button.clicked.connect(self.root._open_project) |
| 46 | |
| 47 | project_config_layout.addWidget(cfg_text) |
| 48 | project_config_layout.addWidget(self.cfg_line) |
| 49 | project_config_layout.addWidget(browse_button) |
| 50 | |
| 51 | self.main_layout.addLayout(project_config_layout) |
| 52 | |
| 53 | self.edit_btn = QPushButton("Edit config.yaml") |
| 54 | self.edit_btn.setMinimumWidth(150) |
| 55 | self.edit_btn.clicked.connect(self.open_config_editor) |
| 56 | |
| 57 | self.add_videos_btn = QPushButton("Add new videos") |
| 58 | self.add_videos_btn.clicked.connect(self.add_new_videos) |
| 59 | |
| 60 | self.main_layout.addWidget(self.edit_btn, alignment=Qt.AlignRight) |
| 61 | self.main_layout.addWidget(self.add_videos_btn, alignment=Qt.AlignRight) |
| 62 | |
| 63 | def open_config_editor(self): |
| 64 | editor = ConfigEditor(self.root.config) |
| 65 | editor.show() |
| 66 | |
| 67 | def add_new_videos(self): |
| 68 | cwd = os.getcwd() |
| 69 | files = QFileDialog.getOpenFileNames( |
| 70 | self, |
| 71 | "Select videos to add to the project", |
| 72 | cwd, |
| 73 | f"Videos ({' *.'.join(DLCParams.VIDEOTYPES)[1:]})", |
| 74 | )[0] |
| 75 | if not files: |
| 76 | return |
| 77 | |
| 78 | add_new_videos(self.root.config, files) |