Appselect window moved to settings tab.
This commit is contained in:
parent
6aac5d8148
commit
8286a0b929
@ -69,38 +69,19 @@ class ThreadMonitor(QObject):
|
|||||||
self.event_finished.set()
|
self.event_finished.set()
|
||||||
|
|
||||||
|
|
||||||
class AppmenuSelectWindow(QDialog):
|
class AppmenuSelectManager:
|
||||||
row_height = 20
|
def __init__(self, vm, apps_multiselect, parent=None):
|
||||||
|
|
||||||
def __init__(self, vm, parent=None):
|
|
||||||
super(AppmenuSelectWindow, self).__init__(parent)
|
|
||||||
|
|
||||||
self.gridLayout = QGridLayout(self)
|
|
||||||
|
|
||||||
self.buttonBox = QDialogButtonBox(self)
|
|
||||||
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
|
|
||||||
self.connect(self.buttonBox, SIGNAL("accepted()"), self.save_and_apply)
|
|
||||||
self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
|
|
||||||
|
|
||||||
self.app_list = MultiSelectWidget(self)
|
|
||||||
|
|
||||||
|
self.app_list = apps_multiselect # this is a multiselect wiget
|
||||||
|
|
||||||
self.gridLayout.addWidget(self.app_list, 0, 0, 1, 1)
|
|
||||||
self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1)
|
|
||||||
|
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
if self.vm.template_vm:
|
if self.vm.template_vm:
|
||||||
self.source_vm = self.vm.template_vm
|
self.source_vm = self.vm.template_vm
|
||||||
else:
|
else:
|
||||||
self.source_vm = self.vm
|
self.source_vm = self.vm
|
||||||
self.setWindowTitle("Qubes Appmenus for %s" % vm.name)
|
|
||||||
self.resize(600,600)
|
|
||||||
|
|
||||||
self.fill_apps_list()
|
self.fill_apps_list()
|
||||||
|
|
||||||
def reject(self):
|
|
||||||
self.done(0)
|
|
||||||
|
|
||||||
def fill_apps_list(self):
|
def fill_apps_list(self):
|
||||||
|
|
||||||
template_dir = self.source_vm.appmenus_templates_dir
|
template_dir = self.source_vm.appmenus_templates_dir
|
||||||
@ -146,73 +127,8 @@ class AppmenuSelectWindow(QDialog):
|
|||||||
whitelisted.close()
|
whitelisted.close()
|
||||||
|
|
||||||
|
|
||||||
def save_and_apply(self):
|
def save_appmenu_select_changes(self):
|
||||||
self.save_list_of_selected()
|
self.save_list_of_selected()
|
||||||
subprocess.check_call([qubes_appmenu_remove_cmd, self.vm.name])
|
subprocess.check_call([qubes_appmenu_remove_cmd, self.vm.name])
|
||||||
subprocess.check_call([qubes_appmenu_create_cmd, self.source_vm.appmenus_templates_dir, self.vm.name])
|
subprocess.check_call([qubes_appmenu_create_cmd, self.source_vm.appmenus_templates_dir, self.vm.name])
|
||||||
self.done(0)
|
|
||||||
|
|
||||||
# Bases on the original code by:
|
|
||||||
# Copyright (c) 2002-2007 Pascal Varet <p.varet@gmail.com>
|
|
||||||
|
|
||||||
def handle_exception( exc_type, exc_value, exc_traceback ):
|
|
||||||
import sys
|
|
||||||
import os.path
|
|
||||||
import traceback
|
|
||||||
|
|
||||||
filename, line, dummy, dummy = traceback.extract_tb( exc_traceback ).pop()
|
|
||||||
filename = os.path.basename( filename )
|
|
||||||
error = "%s: %s" % ( exc_type.__name__, exc_value )
|
|
||||||
|
|
||||||
QMessageBox.critical(None, "Houston, we have a problem...",
|
|
||||||
"Whoops. A critical error has occured. This is most likely a bug "
|
|
||||||
"in Qubes Appmenu Select application.<br><br>"
|
|
||||||
"<b><i>%s</i></b>" % error +
|
|
||||||
"at <b>line %d</b> of file <b>%s</b>.<br/><br/>"
|
|
||||||
% ( line, filename ))
|
|
||||||
|
|
||||||
#sys.exit(1)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
|
|
||||||
global qubes_host
|
|
||||||
qubes_host = QubesHost()
|
|
||||||
|
|
||||||
global app
|
|
||||||
app = QApplication(sys.argv)
|
|
||||||
app.setOrganizationName("The Qubes Project")
|
|
||||||
app.setOrganizationDomain("http://qubes-os.org")
|
|
||||||
app.setApplicationName("Qubes Appmenu Select")
|
|
||||||
app.setWindowIcon(QIcon(":/qubes.png"))
|
|
||||||
|
|
||||||
sys.excepthook = handle_exception
|
|
||||||
|
|
||||||
qvm_collection = QubesVmCollection()
|
|
||||||
qvm_collection.lock_db_for_reading()
|
|
||||||
qvm_collection.load()
|
|
||||||
qvm_collection.unlock_db()
|
|
||||||
|
|
||||||
vm = None
|
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
|
||||||
vm = qvm_collection.get_vm_by_name(sys.argv[1])
|
|
||||||
if vm is None or vm.qid not in qvm_collection:
|
|
||||||
QMessageBox.critical(None, "Qubes Appmenu Select Error",
|
|
||||||
"A VM with the name '{0}' does not exist in the system.".format(sys.argv[1]))
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
vms_list = [vm.name for vm in qvm_collection.values() if (vm.is_appvm() or vm.is_template())]
|
|
||||||
vmname = QInputDialog.getItem(None, "Select VM", "Select VM:", vms_list, editable = False)
|
|
||||||
if not vmname[1]:
|
|
||||||
sys.exit(1)
|
|
||||||
vm = qvm_collection.get_vm_by_name(vmname[0])
|
|
||||||
|
|
||||||
global manager_window
|
|
||||||
select_window = AppmenuSelectWindow(vm)
|
|
||||||
|
|
||||||
select_window.show()
|
|
||||||
|
|
||||||
app.exec_()
|
|
||||||
app.exit()
|
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ def main():
|
|||||||
qvm_collection.unlock_db()
|
qvm_collection.unlock_db()
|
||||||
|
|
||||||
global global_window
|
global global_window
|
||||||
global_window = GlobalSetingsWindow()
|
global_window = GlobalSettingsWindow()
|
||||||
|
|
||||||
global_window.show()
|
global_window.show()
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ from qubes import qubesutils
|
|||||||
import qubesmanager.resources_rc
|
import qubesmanager.resources_rc
|
||||||
import ui_newappvmdlg
|
import ui_newappvmdlg
|
||||||
from ui_mainwindow import *
|
from ui_mainwindow import *
|
||||||
from appmenu_select import AppmenuSelectWindow
|
|
||||||
from settings import VMSettingsWindow
|
from settings import VMSettingsWindow
|
||||||
from restore import RestoreVMsWindow
|
from restore import RestoreVMsWindow
|
||||||
from backup import BackupVMsWindow
|
from backup import BackupVMsWindow
|
||||||
@ -1136,15 +1135,16 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
|
|||||||
@pyqtSlot(name='on_action_settings_triggered')
|
@pyqtSlot(name='on_action_settings_triggered')
|
||||||
def action_settings_triggered(self):
|
def action_settings_triggered(self):
|
||||||
vm = self.get_selected_vm()
|
vm = self.get_selected_vm()
|
||||||
settings_window = VMSettingsWindow(vm, 1)
|
settings_window = VMSettingsWindow(vm, app, "basic")
|
||||||
settings_window.exec_()
|
settings_window.exec_()
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot(name='on_action_appmenus_triggered')
|
@pyqtSlot(name='on_action_appmenus_triggered')
|
||||||
def action_appmenus_triggered(self):
|
def action_appmenus_triggered(self):
|
||||||
vm = self.get_selected_vm()
|
vm = self.get_selected_vm()
|
||||||
select_window = AppmenuSelectWindow(vm)
|
settings_window = VMSettingsWindow(vm, app, "applications")
|
||||||
select_window.exec_()
|
settings_window.exec_()
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot(name='on_action_updatevm_triggered')
|
@pyqtSlot(name='on_action_updatevm_triggered')
|
||||||
def action_updatevm_triggered(self):
|
def action_updatevm_triggered(self):
|
||||||
|
@ -46,10 +46,3 @@ class MultiSelectWidget(Ui_MultiSelectWidget, QWidget):
|
|||||||
self.available_list.clear()
|
self.available_list.clear()
|
||||||
self.selected_list.clear()
|
self.selected_list.clear()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app = QtGui.QApplication(sys.argv)
|
|
||||||
ui = MultiSelectWidget()
|
|
||||||
ui.show()
|
|
||||||
sys.exit(app.exec_())
|
|
||||||
|
@ -45,17 +45,25 @@ from operator import itemgetter
|
|||||||
|
|
||||||
from ui_settingsdlg import *
|
from ui_settingsdlg import *
|
||||||
from multiselectwidget import *
|
from multiselectwidget import *
|
||||||
|
from appmenu_select import *
|
||||||
|
|
||||||
|
|
||||||
class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
||||||
|
tabs_indices = {"basic": 0,
|
||||||
|
"advanced": 1,
|
||||||
|
"firewall": 2,
|
||||||
|
"devices": 3,
|
||||||
|
"applications": 4,
|
||||||
|
"services": 5,}
|
||||||
|
|
||||||
def __init__(self, vm, init_page=0, parent=None):
|
def __init__(self, vm, app, init_page="basic", parent=None):
|
||||||
super(VMSettingsWindow, self).__init__(parent)
|
super(VMSettingsWindow, self).__init__(parent)
|
||||||
|
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
if init_page in range(self.tabWidget.count()):
|
if init_page in self.tabs_indices:
|
||||||
self.tabWidget.setCurrentIndex(init_page)
|
idx = self.tabs_indices[init_page]
|
||||||
|
assert (idx in range(self.tabWidget.count()))
|
||||||
|
self.tabWidget.setCurrentIndex(idx)
|
||||||
|
|
||||||
self.connect(self.buttonBox, SIGNAL("accepted()"), self.save_and_apply)
|
self.connect(self.buttonBox, SIGNAL("accepted()"), self.save_and_apply)
|
||||||
self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
|
self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
|
||||||
@ -66,22 +74,49 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
self.apps_layout.addWidget(self.app_list)
|
self.apps_layout.addWidget(self.app_list)
|
||||||
self.devices_layout.addWidget(self.dev_list)
|
self.devices_layout.addWidget(self.dev_list)
|
||||||
|
|
||||||
|
self.app = app
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
if self.vm.template_vm:
|
if self.vm.template_vm:
|
||||||
self.source_vm = self.vm.template_vm
|
self.source_vm = self.vm.template_vm
|
||||||
else:
|
else:
|
||||||
self.source_vm = self.vm
|
self.source_vm = self.vm
|
||||||
|
|
||||||
|
self.AppListManager = AppmenuSelectManager(self.vm, self.app_list)
|
||||||
#self.fill_apps_list()
|
|
||||||
#self.fill_devices_list()
|
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
self.done(0)
|
self.done(0)
|
||||||
|
|
||||||
def save_and_apply(self):
|
#needed not to close the dialog before applying changes
|
||||||
|
def accept(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def save_and_apply(self):
|
||||||
|
thread_monitor = ThreadMonitor()
|
||||||
|
thread = threading.Thread (target=self.__save_changes__, args=(thread_monitor,))
|
||||||
|
thread.daemon = True
|
||||||
|
thread.start()
|
||||||
|
|
||||||
|
progress = QProgressDialog ("Applying settings to <b>{0}</b>...".format(self.vm.name), "", 0, 0)
|
||||||
|
progress.setCancelButton(None)
|
||||||
|
progress.setModal(True)
|
||||||
|
progress.show()
|
||||||
|
|
||||||
|
while not thread_monitor.is_finished():
|
||||||
|
self.app.processEvents()
|
||||||
|
time.sleep (0.1)
|
||||||
|
|
||||||
|
progress.hide()
|
||||||
|
|
||||||
|
if not thread_monitor.success:
|
||||||
|
QMessageBox.warning (None, "Error while changing settings for {0}!", "ERROR: {1}".format(self.vm.namethread_monitor.error_msg))
|
||||||
|
|
||||||
|
self.done(0)
|
||||||
|
|
||||||
|
def __save_changes__(self, thread_monitor):
|
||||||
|
self.AppListManager.save_appmenu_select_changes()
|
||||||
|
thread_monitor.set_finished()
|
||||||
|
|
||||||
|
|
||||||
# Bases on the original code by:
|
# Bases on the original code by:
|
||||||
# Copyright (c) 2002-2007 Pascal Varet <p.varet@gmail.com>
|
# Copyright (c) 2002-2007 Pascal Varet <p.varet@gmail.com>
|
||||||
|
|
||||||
@ -102,8 +137,6 @@ def handle_exception( exc_type, exc_value, exc_traceback ):
|
|||||||
% ( line, filename ))
|
% ( line, filename ))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
global qubes_host
|
global qubes_host
|
||||||
@ -137,8 +170,9 @@ def main():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
vm = qvm_collection.get_vm_by_name(vmname[0])
|
vm = qvm_collection.get_vm_by_name(vmname[0])
|
||||||
|
|
||||||
|
|
||||||
global settings_window
|
global settings_window
|
||||||
settings_window = VMSettingsWindow(vm)
|
settings_window = VMSettingsWindow(vm, app, "basic")
|
||||||
|
|
||||||
settings_window.show()
|
settings_window.show()
|
||||||
|
|
||||||
@ -146,6 +180,5 @@ def main():
|
|||||||
app.exit()
|
app.exit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user