From 9fa8ca55200864a4652cb199d16f0be6aea52c65 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Ouellet Date: Sun, 18 Dec 2016 18:11:45 -0500 Subject: [PATCH] Select search box contents on focus Attempt #2 --- mainwindow.ui | 5 +---- qubesmanager/main.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/mainwindow.ui b/mainwindow.ui index df45eff..ebfd960 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -58,7 +58,7 @@ 0 - + 6 @@ -72,9 +72,6 @@ - - - diff --git a/qubesmanager/main.py b/qubesmanager/main.py index 9af0e39..9667a8a 100755 --- a/qubesmanager/main.py +++ b/qubesmanager/main.py @@ -119,6 +119,23 @@ class QubesManagerFileWatcher(ProcessEvent): trayIcon.showMessage("Qubes dom0 updates available.", msecs=0) +class SearchBox(QLineEdit): + def __init__(self, parent=None): + super(SearchBox, self).__init__(parent) + self.focusing = False + + def focusInEvent(self, e): + super(SearchBox, self).focusInEvent(e) + self.selectAll() + self.focusing = True + + def mousePressEvent(self, e): + super(SearchBox, self).mousePressEvent(e) + if self.focusing: + self.selectAll() + self.focusing = False + + class VmRowInTable(object): cpu_graph_hue = 210 mem_graph_hue = 120 @@ -333,6 +350,9 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): self.blk_watch_thread.daemon = True self.blk_watch_thread.start() + self.searchbox = SearchBox() + self.searchContainer.addWidget(self.searchbox) + self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.table_selection_changed)