|
@@ -276,23 +276,63 @@ class Gui(QtGui.QMainWindow):
|
|
|
self.help.addAction(tr("Button", "Open Manual"), lambda: webbrowser.open(config.install_path + "Documentation/build/html/index.html"))
|
|
|
self.help.addAction(tr("Button", "About"), self.showAbout)
|
|
|
|
|
|
- def saveConfig(self, board_id):
|
|
|
+ def _show_board_chooser(self):
|
|
|
+ selected_boards = []
|
|
|
+ if len(available_boards.board_ids) == 1:
|
|
|
+ return [available_boards.board_ids[0]]
|
|
|
+ chooser = QtGui.QDialog(self)
|
|
|
+ chooser.setWindowTitle("KCG - Choose Boards")
|
|
|
+
|
|
|
+
|
|
|
+ chooser_layout = QtGui.QVBoxLayout()
|
|
|
+ chooser.setLayout(chooser_layout)
|
|
|
+ chooser_layout.addWidget(QtGui.QLabel("Choose Boards"))
|
|
|
+ boards = {}
|
|
|
+ for bid in available_boards.board_ids:
|
|
|
+ boards[bid] = QtGui.QCheckBox(str(bid), chooser)
|
|
|
+ chooser_layout.addWidget(boards[bid])
|
|
|
+ button = QtGui.QPushButton("OK", chooser)
|
|
|
+ def ok():
|
|
|
+ for bi, box in boards.items():
|
|
|
+ if box.isChecked():
|
|
|
+ selected_boards.append(bi)
|
|
|
+ chooser.close()
|
|
|
+ button.clicked.connect(ok)
|
|
|
+ chooser_layout.addWidget(button)
|
|
|
+ chooser.exec_()
|
|
|
+ return selected_boards
|
|
|
+
|
|
|
+
|
|
|
+ def saveConfig(self, board_id=None):
|
|
|
"""
|
|
|
Save the current configuration to a configuration file
|
|
|
:param board_id: the board to save the configuration for
|
|
|
"""
|
|
|
+
|
|
|
filenameDialog = QtGui.QFileDialog(self, tr("Heading", "Save Configuration"), '', 'KAPTURE Configuration File (*.kcf)')
|
|
|
filenameDialog.setDefaultSuffix("kcf")
|
|
|
filenameDialog.setAcceptMode(filenameDialog.AcceptSave)
|
|
|
filenameDialog.exec_()
|
|
|
filename = filenameDialog.selectedFiles()
|
|
|
- if filename[0]:
|
|
|
- if not board.get_board_config(board_id).save_config(filename[0]):
|
|
|
+ if not filename[0]:
|
|
|
+ return
|
|
|
+
|
|
|
+ if board_id is None:
|
|
|
+ board_id = self._show_board_chooser()
|
|
|
+ elif not isinstance(board_id, list):
|
|
|
+ board_id = [board_id]
|
|
|
+
|
|
|
+
|
|
|
+ fname = filename[0].split(".")
|
|
|
+ for bid in board_id:
|
|
|
+ if len(board_id) == 1:
|
|
|
+ fname_board = filename[0]
|
|
|
+ else:
|
|
|
+ fname_board = ".".join(map(str, fname[:-1]))+"_"+str(bid)+"."+fname[-1]
|
|
|
+ if not board.get_board_config(bid).save_config(fname_board):
|
|
|
QtGui.QMessageBox.critical(self, tr("Heading", "Error Saving Config"), tr("Dialog", "There was an error saving to a config file."))
|
|
|
- else:
|
|
|
- QtGui.QMessageBox.critical(self, tr("Heading", "Error Saving Config"), tr("Dialog", "There was an error saving to a config file."))
|
|
|
|
|
|
- def loadConfig(self, board_id):
|
|
|
+ def loadConfig(self, board_id=None):
|
|
|
"""
|
|
|
Load the configuration for the given board from a file
|
|
|
:param board_id: the board to read the configuration for
|
|
@@ -300,10 +340,18 @@ class Gui(QtGui.QMainWindow):
|
|
|
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open Configuration', '', 'KAPTURE Configuration File (*.kcf)')
|
|
|
if not filename:
|
|
|
return
|
|
|
- if board.get_board_config(board_id).load_config(filename):
|
|
|
- bif.bk_write_values(board_id, defaults=False)
|
|
|
- else:
|
|
|
- QtGui.QMessageBox.critical(self, tr("Heading", "Error Loading Config"), tr("Dialog", "There was an error loading the config file, make sure it is valid and try again."))
|
|
|
+
|
|
|
+
|
|
|
+ if board_id is None:
|
|
|
+ board_id = self._show_board_chooser()
|
|
|
+ elif not isinstance(board_id, list):
|
|
|
+ board_id = [board_id]
|
|
|
+
|
|
|
+ for bid in board_id:
|
|
|
+ if board.get_board_config(bid).load_config(filename):
|
|
|
+ bif.bk_write_values(bid, defaults=False)
|
|
|
+ else:
|
|
|
+ QtGui.QMessageBox.critical(self, tr("Heading", "Error Loading Config"), tr("Dialog", "There was an error loading the config file, make sure it is valid and try again."))
|
|
|
|
|
|
def rerunConfig(self):
|
|
|
"""
|