2018-01-10 00:51:05 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
#
|
|
|
|
# The Qubes OS Project, http://www.qubes-os.org
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
from . import ui_devicelist # pylint: disable=no-name-in-module
|
2019-05-22 23:10:09 +02:00
|
|
|
from PyQt5 import QtWidgets # pylint: disable=import-error
|
2018-01-10 00:51:05 +01:00
|
|
|
|
|
|
|
|
2019-05-22 23:10:09 +02:00
|
|
|
class PCIDeviceListWindow(ui_devicelist.Ui_Dialog, QtWidgets.QDialog):
|
2018-01-12 23:56:48 +01:00
|
|
|
def __init__(self, vm, qapp, dev_list, no_strict_reset_list, parent=None):
|
2020-08-23 02:53:36 +02:00
|
|
|
super().__init__(parent)
|
2018-01-10 00:51:05 +01:00
|
|
|
|
|
|
|
self.vm = vm
|
|
|
|
self.qapp = qapp
|
|
|
|
self.dev_list = dev_list
|
2018-01-12 23:56:48 +01:00
|
|
|
self.no_strict_reset_list = no_strict_reset_list
|
2018-01-10 00:51:05 +01:00
|
|
|
|
|
|
|
self.setupUi(self)
|
|
|
|
|
2019-05-22 23:10:09 +02:00
|
|
|
self.buttonBox.accepted.connect(self.save_and_apply)
|
|
|
|
self.buttonBox.rejected.connect(self.reject)
|
2018-01-10 00:51:05 +01:00
|
|
|
|
2018-01-12 23:56:48 +01:00
|
|
|
self.ident_list = {}
|
2018-01-10 00:51:05 +01:00
|
|
|
self.fill_device_list()
|
|
|
|
|
|
|
|
def fill_device_list(self):
|
|
|
|
self.device_list.clear()
|
|
|
|
|
|
|
|
for i in range(self.dev_list.selected_list.count()):
|
|
|
|
text = self.dev_list.selected_list.item(i).text()
|
2019-04-02 22:05:51 +02:00
|
|
|
ident = self.dev_list.selected_list.item(i).dev.ident
|
2018-01-12 23:56:48 +01:00
|
|
|
self.device_list.addItem(text)
|
|
|
|
self.ident_list[text] = ident
|
|
|
|
if ident in self.no_strict_reset_list:
|
|
|
|
self.device_list.setItemSelected(
|
|
|
|
self.device_list.item(i), True)
|
2018-01-10 00:51:05 +01:00
|
|
|
|
|
|
|
def reject(self):
|
|
|
|
self.done(0)
|
|
|
|
|
|
|
|
def save_and_apply(self):
|
2018-01-12 23:56:48 +01:00
|
|
|
self.no_strict_reset_list.clear()
|
|
|
|
self.no_strict_reset_list.extend([self.ident_list[item.text()] for item
|
|
|
|
in self.device_list.selectedItems()])
|
2018-01-10 00:51:05 +01:00
|
|
|
self.done(0)
|