Пример #1
0
 def onNameChanged(self, name):
     if len(name) == 0:
         self.container.name = self.container.image_name
     else:
         self.container.name = name
     containers_service.fire(self.container, 'name', name)
     self.container.save()
Пример #2
0
    def undo(self):
        if self.conf_obj.table == self.container.tableName():
            # We have to check the container object because the value of this object is still accessing from many places
            # So, in case of undo, we need to update both the in-memory and in-db as well
            # And, if the object table is container, the type of it will always be AuditUpdate
            setattr(self.container, self.conf_obj.field, self.conf_obj.value_from)
            self.container.save()
        else:
            for table in tables.db_tables:
                if self.conf_obj.table.lower() != table._meta.name.lower():
                    continue
                obj_instance = table.get(table.id == self.conf_obj.record_id)
                if isinstance(self.conf_obj, AuditUpdate):
                    setattr(obj_instance, self.conf_obj.field, self.conf_obj.value_from)
                    obj_instance.save()
                else:
                    if self.conf_obj.audit_mode == constants.AUDIT_CREATE:
                        obj_instance.delete_instance()
                    elif self.conf_obj.audit_mode == constants.AUDIT_DELETE:
                        setattr(obj_instance, "status", constants.STATUS_ADDED)
                        obj_instance.save()

                if self.conf_obj.table == "PreferencesShortcut":
                    containers_service.fire(self.container, SHORTCUT_CONF_CHANGED_CHANNEL)
                break

        self.conf_obj.delete_instance()
        self.ui.parentWidget().layout().removeWidget(self.ui)
        self.ui.deleteLater()
Пример #3
0
 def onSwitched(self, check):
     previous_val = self.shortcut.enabled
     self.shortcut.enabled = check
     self.shortcut.save()
     auditing_service.audit_update(self.shortcut.container,
                                   self.shortcut.tableName(),
                                   self.shortcut.id, "enabled",
                                   previous_val, check)
     containers_service.fire(self.shortcut.container,
                             SHORTCUT_CONF_CHANGED_CHANNEL)
Пример #4
0
 def onImageTagChange(self, index):
     if index > 0:
         tag = self.ui.image_tags.itemText(index).split(':')[1]
         previous_tag = self.container.tag
         self.container.tag = tag
         self.container.save()
         auditing_service.audit_update(self.container,
                                       self.container.tableName(),
                                       self.container.id, "tag",
                                       previous_tag, tag)
         containers_service.fire(self.container, 'tag_index', index)
Пример #5
0
 def resetContainer(self):
     message = self.tr(
         "Are you sure you want to reset this container? All configurations "
         "you made for it will be lost!")
     button_reply = QMessageBox.question(
         self.ui, 'Reset container', message,
         QMessageBox.Ok | QMessageBox.Cancel, QMessageBox.Cancel)
     if button_reply == QMessageBox.Ok:
         containers_service.deleteConfigurations(self.container)
         containers_service.fire(self.container,
                                 SHORTCUT_CONF_CHANGED_CHANNEL)
 def onDeleteShortcutClicked(self):
     indicates = self.ui.shortcut_table.selectionModel().selectedRows()
     for item in sorted(indicates, reverse=True):
         self.ui.shortcut_table.model().removeRow(item.row())
     self.ui.shortcut_table.resizeRowsToContents()
     containers_service.fire(self.container, SHORTCUT_CONF_CHANGED_CHANNEL)
 def reloadData(self):
     table_data = list(shortcut_service.getShortcuts(self.container))
     self.table_model.updateData(list(table_data))
     self.ui.shortcut_table.resizeRowsToContents()
     self.drawSwitches(table_data)
     containers_service.fire(self.container, SHORTCUT_CONF_CHANGED_CHANNEL)