From 9ee6b1a8bdbe6be5f6876ea3f8b251a09c4fbdd0 Mon Sep 17 00:00:00 2001 From: Agnieszka Kostrzewa Date: Thu, 22 Mar 2012 22:24:57 +0100 Subject: [PATCH 1/4] Changed running icon. --- resources.qrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources.qrc b/resources.qrc index 935b43a..e8d15ce 100644 --- a/resources.qrc +++ b/resources.qrc @@ -1,5 +1,6 @@ + icons/on-icon/on.png icons/mount.png icons/pencil.png icons/redfirewall.png @@ -10,7 +11,6 @@ icons/flag-red.png icons/flag-yellow.png icons/remove.png - icons/on.png icons/appsprefs.png icons/newfirewall.png icons/qubes.png From 0e118a95f900e050d3c51efa65c92be2af3b69d2 Mon Sep 17 00:00:00 2001 From: Agnieszka Kostrzewa Date: Thu, 22 Mar 2012 22:42:04 +0100 Subject: [PATCH 2/4] No more gray not-running icon (ticket #506) --- qubesmanager/main.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/qubesmanager/main.py b/qubesmanager/main.py index 4a4bb86..c533e38 100755 --- a/qubesmanager/main.py +++ b/qubesmanager/main.py @@ -124,29 +124,18 @@ class VmNameItem (QTableWidgetItem): self.qid = vm.qid -class VmStatusIcon(QLabel): +class VmStatusIcon(VmIconWidget): def __init__(self, vm, parent=None): - super (VmStatusIcon, self).__init__(parent) + super (VmStatusIcon, self).__init__(":/on.png", True, 0.5, parent) + self.setVisible(vm.last_power_state) self.vm = vm - self.set_on_icon() self.previous_power_state = vm.last_power_state def update(self): if self.previous_power_state != self.vm.last_power_state: - self.set_on_icon() + self.setVisible(self.vm.last_power_state) self.previous_power_state = self.vm.last_power_state - def set_on_icon(self): - icon = QIcon(":/on.png") - icon_sz = QSize (VmManagerWindow.row_height * 0.5, VmManagerWindow.row_height * 0.5) - if self.vm.last_power_state: - icon_pixmap = icon.pixmap(icon_sz) - else: - icon_pixmap = icon.pixmap(icon_sz, QIcon.Disabled) - - self.setPixmap (icon_pixmap) - self.setFixedSize (icon_sz) - class VmInfoWidget (QWidget): @@ -175,6 +164,7 @@ class VmInfoWidget (QWidget): self.blk_icon = VmIconWidget(":/mount.png") layout.addWidget(self.on_icon) + layout.addItem(QSpacerItem(0, 10, QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)) layout.addWidget(self.upd_info) layout.addItem(QSpacerItem(0, 10, QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)) layout.addWidget(self.blk_icon) From 64770213c47b3e2de4a64078bc2d6624ed693074 Mon Sep 17 00:00:00 2001 From: Agnieszka Kostrzewa Date: Fri, 23 Mar 2012 09:12:30 +0100 Subject: [PATCH 3/4] Sorting by on/off and upd state (ticket #505) --- qubesmanager/main.py | 57 +++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/qubesmanager/main.py b/qubesmanager/main.py index c533e38..e66d804 100755 --- a/qubesmanager/main.py +++ b/qubesmanager/main.py @@ -146,13 +146,16 @@ class VmInfoWidget (QWidget): self.vm = vm def __lt__(self, other): - self_val = 1 if self.vm.is_running() else 0 - other_val = 1 if other.vm.is_running() else 0 - - self_val += self.upd_info_item.value - other_val += other.upd_info_item.value - - return (self_val) < (other_val) + self_val = self.upd_info_item.value + other_val = other.upd_info_item.value + if self.tableWidget().sort_state_by_upd: + self_val += 1 if self.vm.is_running() else 0 + other_val += 1 if other.vm.is_running() else 0 + return (self_val) > (other_val) #sort with Ascending Order + else: + self_val = self_val/10 + 10*(1 if self.vm.is_running() else 0) + other_val = other_val/10 + 10*(1 if other.vm.is_running() else 0) + return (self_val) < (other_val) #sort with Descending order def __init__(self, vm, parent = None): super (VmInfoWidget, self).__init__(parent) @@ -164,7 +167,6 @@ class VmInfoWidget (QWidget): self.blk_icon = VmIconWidget(":/mount.png") layout.addWidget(self.on_icon) - layout.addItem(QSpacerItem(0, 10, QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)) layout.addWidget(self.upd_info) layout.addItem(QSpacerItem(0, 10, QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)) layout.addWidget(self.blk_icon) @@ -444,7 +446,6 @@ class VmRowInTable(object): table.setItem(row_no, VmManagerWindow.columns_indices['Label'], self.label_widget.tableItem) self.name_widget = VmNameItem(vm) - #table.setCellWidget(row_no, VmManagerWindow.columns_indices['Name'], self.name_widget) table.setItem(row_no, VmManagerWindow.columns_indices['Name'], self.name_widget) self.info_widget = VmInfoWidget(vm) @@ -483,7 +484,6 @@ class VmRowInTable(object): self.mem_usage_widget.update_load(self.vm, None) self.load_widget.update_load(self.vm, cpu_load) self.mem_widget.update_load(self.vm, None) - #self.upd_widget.update_outdated(self.vm) class NewAppVmDlg (QDialog, ui_newappvmdlg.Ui_NewAppVMDlg): def __init__(self, parent = None): @@ -561,10 +561,13 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): self.table.setColumnWidth(self.columns_indices["Label"], 50) self.table.horizontalHeader().setResizeMode(QHeaderView.Fixed) + self.table.sortItems(self.columns_indices["Label"], Qt.AscendingOrder) self.sort_by_mem = None self.sort_by_cpu = None + self.sort_by_state = None + self.table.sort_state_by_upd = True self.context_menu = QMenu(self) self.context_menu.addAction(self.action_settings) @@ -721,6 +724,11 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): self.fill_table() update_devs=True + if self.sort_by_state != None and self.table.sort_state_by_upd and some_vms_have_changed_power_state: + self.table.sort_state_by_upd = not self.table.sort_state_by_upd # sorter indicator changed will switch it...and we want it to remain unswtched. + self.table.sortItems(self.columns_indices["State"], self.sort_by_state) + + blk_visible = None rows_with_blk = None if update_devs == True: @@ -747,8 +755,6 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): blk_visible = False vm_row.update(self.counter, blk_visible=blk_visible, cpu_load = cur_cpu_load) - if self.sort_by_cpu != None: - self.table.sortItems(self.columns_indices["CPU"], self.sort_by_cpu) else: for vm_row in self.vms_in_table.values(): @@ -759,10 +765,12 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): blk_visible = False vm_row.update(self.counter, blk_visible=blk_visible) - if self.sort_by_cpu != None: - self.table.sortItems(self.columns_indices["CPU"], self.sort_by_cpu) - elif self.sort_by_mem != None: - self.table.sortItems(self.columns_indices["MEM"], self.sort_by_mem) + + if self.sort_by_cpu != None: + self.table.sortItems(self.columns_indices["CPU"], self.sort_by_cpu) + elif self.sort_by_mem != None: + self.table.sortItems(self.columns_indices["MEM"], self.sort_by_mem) + self.table_selection_changed() @@ -790,14 +798,29 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): def sortIndicatorChanged(self, column, order): if column == self.columns_indices["CPU"] or column == self.columns_indices["CPU Graph"]: self.sort_by_mem = None + self.sort_by_state = None self.sort_by_cpu = order + return elif column == self.columns_indices["MEM"] or column == self.columns_indices["MEM Graph"]: self.sort_by_cpu = None + self.sort_by_state = None self.sort_by_mem = order + return + elif column == self.columns_indices["State"]: + self.table.sort_state_by_upd = not self.table.sort_state_by_upd + self.sort_by_cpu = None + self.sort_by_mem = None + if self.table.sort_state_by_upd: + self.sort_by_state = Qt.DescendingOrder + else: + self.sort_by_state = Qt.AscendingOrder + return else: self.sort_by_cpu = None self.sort_by_mem = None + self.sort_by_state = None + def table_selection_changed (self): vm = self.get_selected_vm() @@ -1049,6 +1072,7 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): assert vm.is_running() try: subprocess.check_call (["/usr/sbin/xl", "pause", vm.name]) + except Exception as ex: QMessageBox.warning (None, "Error pausing VM!", "ERROR: {0}".format(ex)) return @@ -1073,6 +1097,7 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): return trayIcon.showMessage ("Qubes Manager", "VM '{0}' is shutting down...".format(vm.name), msecs=3000) + self.shutdown_monitor[vm.qid] = VmShutdownMonitor (vm) QTimer.singleShot (vm_shutdown_timeout, self.shutdown_monitor[vm.qid].check_if_vm_has_shutdown) From 96b04cc4b86fe305111afdb47ac13c83060f6dac Mon Sep 17 00:00:00 2001 From: Agnieszka Kostrzewa Date: Fri, 23 Mar 2012 09:13:40 +0100 Subject: [PATCH 4/4] Alignment fix to #506 --- qubesmanager/main.py | 19 +++++++++++++++---- resources.qrc | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/qubesmanager/main.py b/qubesmanager/main.py index e66d804..8cd02a5 100755 --- a/qubesmanager/main.py +++ b/qubesmanager/main.py @@ -124,18 +124,29 @@ class VmNameItem (QTableWidgetItem): self.qid = vm.qid -class VmStatusIcon(VmIconWidget): +class VmStatusIcon(QLabel): def __init__(self, vm, parent=None): - super (VmStatusIcon, self).__init__(":/on.png", True, 0.5, parent) - self.setVisible(vm.last_power_state) + super (VmStatusIcon, self).__init__(parent) self.vm = vm + self.set_on_icon() self.previous_power_state = vm.last_power_state def update(self): if self.previous_power_state != self.vm.last_power_state: - self.setVisible(self.vm.last_power_state) + self.set_on_icon() self.previous_power_state = self.vm.last_power_state + def set_on_icon(self): + if self.vm.last_power_state: + icon = QIcon (":/on.png") + else: + icon = QIcon (":/off.png") + icon_sz = QSize (VmManagerWindow.row_height * 0.5, VmManagerWindow.row_height *0.5) + icon_pixmap = icon.pixmap(icon_sz) + self.setPixmap (icon_pixmap) + self.setFixedSize (icon_sz) + + class VmInfoWidget (QWidget): diff --git a/resources.qrc b/resources.qrc index e8d15ce..662aaa4 100644 --- a/resources.qrc +++ b/resources.qrc @@ -1,5 +1,6 @@ + icons/on-icon/off.png icons/on-icon/on.png icons/mount.png icons/pencil.png