Example #1
0
    def _reassign_settings(self, checked):
        if not checked:
            return

        forms = {}
        components = ("planning_assignment", "planning_collision_avoidance")
        hbox = QtGui.QHBoxLayout()
        for component in components:
            form = SettingsTableWidget(self._controller.arguments,
                                       component,
                                       include_parent=True)
            forms[component] = form

            vbox = QtGui.QVBoxLayout()
            vbox.addWidget(form)

            group = QtGui.QGroupBox(form.get_title())
            group.setLayout(vbox)

            hbox.addWidget(group)

        dialog = QtGui.QDialog(self._controller.central_widget)
        dialog.setWindowTitle("Change assignment settings")

        dialogButtons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
                                               | QtGui.QDialogButtonBox.Cancel)
        dialogButtons.accepted.connect(dialog.accept)
        dialogButtons.rejected.connect(dialog.reject)

        dialogLayout = QtGui.QVBoxLayout()
        dialogLayout.addLayout(hbox)
        dialogLayout.addWidget(dialogButtons)

        dialog.setLayout(dialogLayout)

        # Show the dialog and handle the input.
        result = dialog.exec_()
        if result != QtGui.QDialog.Accepted:
            return

        # Update the settings from the dialog forms.
        for component, form in forms.iteritems():
            settings = self._controller.arguments.get_settings(component)
            try:
                values, disallowed = form.get_all_values()
                form.check_disallowed(disallowed)
            except ValueError as e:
                QtGui.QMessageBox.critical(self._controller.central_widget,
                                           "Invalid value", e.message)
                return

            for key, value in values.iteritems():
                try:
                    settings.set(key, value)
                except ValueError as e:
                    QtGui.QMessageBox.critical(self._controller.central_widget,
                                               "Settings error", e.message)
                    return
    def _reassign_settings(self, checked):
        if not checked:
            return

        forms = {}
        components = ("planning_assignment", "planning_collision_avoidance")
        hbox = QtGui.QHBoxLayout()
        for component in components:
            form = SettingsTableWidget(self._controller.arguments, component,
                                       include_parent=True)
            forms[component] = form

            vbox = QtGui.QVBoxLayout()
            vbox.addWidget(form)

            group = QtGui.QGroupBox(form.get_title())
            group.setLayout(vbox)

            hbox.addWidget(group)

        dialog = QtGui.QDialog(self._controller.central_widget)
        dialog.setWindowTitle("Change assignment settings")

        dialogButtons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
        dialogButtons.accepted.connect(dialog.accept)
        dialogButtons.rejected.connect(dialog.reject)

        dialogLayout = QtGui.QVBoxLayout()
        dialogLayout.addLayout(hbox)
        dialogLayout.addWidget(dialogButtons)

        dialog.setLayout(dialogLayout)

        # Show the dialog and handle the input.
        result = dialog.exec_()
        if result != QtGui.QDialog.Accepted:
            return

        # Update the settings from the dialog forms.
        for component, form in forms.iteritems():
            settings = self._controller.arguments.get_settings(component)
            try:
                values, disallowed = form.get_all_values()
                form.check_disallowed(disallowed)
            except ValueError as e:
                QtGui.QMessageBox.critical(self._controller.central_widget,
                                           "Invalid value", e.message)
                return

            for key, value in values.iteritems():
                try:
                    settings.set(key, value)
                except ValueError as e:
                    QtGui.QMessageBox.critical(self._controller.central_widget,
                                               "Settings error", e.message)
                    return