'refresh available apps' button in VM Setting

added a button in VM Settings, Applications tab to refresh the list of
available apps
This commit is contained in:
Marta Marczykowska-Górecka 2017-07-28 16:47:11 +02:00
parent d349248b35
commit 2dda433fd3
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
2 changed files with 55 additions and 7 deletions

View File

@ -62,9 +62,9 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.vm = vm
self.qapp = qapp
if self.vm.template:
try:
self.source_vm = self.vm.template
else:
except AttributeError:
self.source_vm = self.vm
self.setupUi(self)
@ -117,6 +117,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.app_list = multiselectwidget.MultiSelectWidget(self)
self.apps_layout.addWidget(self.app_list)
self.AppListManager = AppmenuSelectManager(self.vm, self.app_list)
self.refresh_apps_button.clicked.connect(self.refresh_apps_button_pressed)
def reject(self):
self.done(0)
@ -446,7 +447,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
else:
self.kernel_groupbox.setVisible(False)
if not hasattr(self.vm, "drive"):
if True or not hasattr(self.vm, "drive"):
self.drive_groupbox.setVisible(False)
else:
self.drive_groupbox.setVisible(True)
@ -661,6 +662,46 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.dmm_warning_adv.hide()
self.dmm_warning_dev.hide()
######## applications tab
def refresh_apps_in_vm(self, t_monitor):
try:
target_vm = self.vm.template
except AttributeError:
target_vm = self.vm
if not target_vm.is_running():
not_running = True
target_vm.start()
else:
not_running = False
subprocess.check_call(['qvm-sync-appmenus', target_vm.name])
if not_running:
target_vm.shutdown()
t_monitor.set_finished()
def refresh_apps_button_pressed(self):
self.refresh_apps_button.setEnabled(False)
self.refresh_apps_button.setText(self.tr('Refresh in progress...'))
t_monitor = thread_monitor.ThreadMonitor()
thread = threading.Thread(target=self.refresh_apps_in_vm, args=(t_monitor,))
thread.daemon = True
thread.start()
while not t_monitor.is_finished():
self.qapp.processEvents()
time.sleep (0.1)
self.AppListManager = AppmenuSelectManager(self.vm, self.app_list)
self.refresh_apps_button.setEnabled(True)
self.refresh_apps_button.setText(self.tr('Refresh Applications'))
######## services tab
def __init_services_tab__(self):

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>708</width>
<height>529</height>
<width>773</width>
<height>573</height>
</rect>
</property>
<property name="windowTitle">
@ -29,7 +29,7 @@
<locale language="English" country="UnitedStates"/>
</property>
<property name="currentIndex">
<number>1</number>
<number>4</number>
</property>
<widget class="QWidget" name="basic_tab">
<property name="locale">
@ -1027,9 +1027,16 @@
<string>Applications</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<item row="1" column="0">
<layout class="QVBoxLayout" name="apps_layout"/>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="refresh_apps_button">
<property name="text">
<string>Refresh Applications</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="services_tab">