device_list.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/python3
  2. #
  3. # The Qubes OS Project, http://www.qubes-os.org
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public License along
  16. # with this program; if not, see <http://www.gnu.org/licenses/>.
  17. #
  18. #
  19. from . import ui_devicelist # pylint: disable=no-name-in-module
  20. from PyQt5 import QtWidgets # pylint: disable=import-error
  21. class PCIDeviceListWindow(ui_devicelist.Ui_Dialog, QtWidgets.QDialog):
  22. def __init__(self, vm, qapp, dev_list, no_strict_reset_list, parent=None):
  23. super(PCIDeviceListWindow, self).__init__(parent)
  24. self.vm = vm
  25. self.qapp = qapp
  26. self.dev_list = dev_list
  27. self.no_strict_reset_list = no_strict_reset_list
  28. self.setupUi(self)
  29. self.buttonBox.accepted.connect(self.save_and_apply)
  30. self.buttonBox.rejected.connect(self.reject)
  31. self.ident_list = {}
  32. self.fill_device_list()
  33. def fill_device_list(self):
  34. self.device_list.clear()
  35. for i in range(self.dev_list.selected_list.count()):
  36. text = self.dev_list.selected_list.item(i).text()
  37. ident = self.dev_list.selected_list.item(i).dev.ident
  38. self.device_list.addItem(text)
  39. self.ident_list[text] = ident
  40. if ident in self.no_strict_reset_list:
  41. self.device_list.setItemSelected(
  42. self.device_list.item(i), True)
  43. def reject(self):
  44. self.done(0)
  45. def save_and_apply(self):
  46. self.no_strict_reset_list.clear()
  47. self.no_strict_reset_list.extend([self.ident_list[item.text()] for item
  48. in self.device_list.selectedItems()])
  49. self.done(0)