Added a clear button, and some shortcuts: Ctrl+O to open, Ctrl+Shift+F to follow, Ctrl+Backspace to clear

This commit is contained in:
Raoul Snyman 2014-01-16 15:48:37 +02:00
parent 87c5064fd4
commit 2bd5ba77d8
4 changed files with 114 additions and 6 deletions

View File

@ -74,6 +74,7 @@ class UiMainWindow(object):
size_policy.setHeightForWidth(self.send_button.sizePolicy().hasHeightForWidth())
self.send_button.setSizePolicy(size_policy)
self.send_button.setMaximumSize(QtCore.QSize(100, 16777215))
self.send_button.setEnabled(False)
self.send_button.setObjectName(from_utf8('sendButton'))
self.send_layout.addWidget(self.send_button)
self.central_layout.addLayout(self.send_layout)
@ -93,6 +94,7 @@ class UiMainWindow(object):
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.open_action.setIcon(connect_icon)
self.open_action.setObjectName(from_utf8('open_action'))
self.open_action.setShortcut(QtGui.QKeySequence.Open)
self.close_action = QtGui.QAction(main_window)
disconnect_icon = QtGui.QIcon()
disconnect_icon.addPixmap(QtGui.QPixmap(from_utf8(':/toolbar/network-disconnect.png')),
@ -108,7 +110,7 @@ class UiMainWindow(object):
self.capture_action.setChecked(False)
self.capture_action.setObjectName(from_utf8('capture_action'))
self.follow_action = QtGui.QAction(main_window)
self.follow_action.setShortcut(QtCore.Qt.Key_F)
self.follow_action.setShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.SHIFT + QtCore.Qt.Key_F))
follow_icon = QtGui.QIcon()
follow_icon.addPixmap(QtGui.QPixmap(from_utf8(':/toolbar/follow-output.png')),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
@ -116,6 +118,13 @@ class UiMainWindow(object):
self.follow_action.setCheckable(True)
self.follow_action.setChecked(True)
self.follow_action.setObjectName(from_utf8('follow_action'))
self.clear_action = QtGui.QAction(main_window)
clear_icon = QtGui.QIcon()
clear_icon.addPixmap(QtGui.QPixmap(from_utf8(':/toolbar/clear.png')),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.clear_action.setIcon(clear_icon)
self.clear_action.setObjectName(from_utf8('clear_action'))
self.clear_action.setShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Backspace))
self.configure_action = QtGui.QAction(main_window)
configure_icon = QtGui.QIcon()
configure_icon.addPixmap(QtGui.QPixmap(from_utf8(':/toolbar/configure.png')),
@ -132,6 +141,7 @@ class UiMainWindow(object):
self.tool_bar.addAction(self.close_action)
self.tool_bar.addAction(self.capture_action)
self.tool_bar.addAction(self.follow_action)
self.tool_bar.addAction(self.clear_action)
self.tool_bar.addAction(self.configure_action)
self.tool_bar.addAction(self.exit_action)
@ -151,6 +161,7 @@ class UiMainWindow(object):
self.capture_action.setText(translate('MainWindow', 'Capture'))
self.capture_action.setToolTip(translate('MainWindow', 'Capture to File'))
self.follow_action.setText(translate('MainWindow', '&Follow'))
self.clear_action.setText(translate('MainWindow', 'Clear'))
self.configure_action.setText(translate('MainWindow', 'Configure...'))
self.configure_action.setToolTip(translate('MainWindow', 'Configure...'))
self.exit_action.setText(translate('MainWindow', 'Exit'))
@ -179,6 +190,7 @@ class MainWindow(QtGui.QMainWindow, UiMainWindow):
self.close_action.triggered.connect(self.on_close_action_triggered)
self.capture_action.toggled.connect(self.on_capture_action_toggled)
self.follow_action.toggled.connect(self.on_follow_action_toggled)
self.clear_action.triggered.connect(self.on_clear_action_triggered)
self.configure_action.triggered.connect(self.on_configure_action_triggered)
self.exit_action.triggered.connect(self.close)
self.send_combobox.keyPressed.connect(self.on_send_combobox_key_pressed)
@ -246,14 +258,16 @@ class MainWindow(QtGui.QMainWindow, UiMainWindow):
except SerialException as e:
QtGui.QMessageBox.critical(self, 'Error opening port', e.args[0])
self.send_combobox.setEnabled(not self.device_closed)
self.send_button.setEnabled(not self.device_closed)
if self.send_combobox.isEnabled():
self.send_combobox.setFocus()
def on_close_action_triggered(self):
self.device_closed = True
if self.device.isOpen():
if self.device and self.device.isOpen():
self.device.close()
self.send_combobox.setEnabled(not self.device_closed)
self.send_button.setEnabled(not self.device_closed)
def on_capture_action_toggled(self, enabled):
if enabled and not self.capture_file:
@ -278,6 +292,12 @@ class MainWindow(QtGui.QMainWindow, UiMainWindow):
self.output_browser.page().mainFrame().scroll(
0, self.output_browser.page().mainFrame().contentsSize().height())
def on_clear_action_triggered(self):
elements = self.output_browser.page().mainFrame().findAllElements('div')
for element in elements:
element.removeFromDocument()
del elements
def on_configure_action_triggered(self):
self.settings_dialog.set_highlights(self.highlights)
self.settings_dialog.exec_()

View File

@ -2,7 +2,7 @@
# Resource object code
#
# Created: Tue Aug 27 09:51:56 2013
# Created: Thu Jan 16 15:10:18 2014
# by: The Resource Compiler for PyQt (Qt v4.8.4)
#
# WARNING! All changes made in this file will be lost!
@ -620,6 +620,88 @@ qt_resource_data = "\
\x8e\xd8\x85\xc2\x27\xa4\x3e\x5a\x8d\xc4\x3f\x28\x21\x33\x2a\x00\
\xa6\x02\xa5\x8e\xe3\xff\xac\x3f\x00\x96\xb0\x06\xcd\xf7\xa2\xd6\
\x6c\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x04\xf4\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x16\x00\x00\x00\x16\x08\x06\x00\x00\x00\xc4\xb4\x6c\x3b\
\x00\x00\x04\xbb\x49\x44\x41\x54\x78\xda\xad\xd1\x7d\x50\xd3\x75\
\x1c\xc0\xf1\xdf\xb6\x04\x44\xe3\xb8\xe4\x88\x38\x4c\x22\xae\x7c\
\x80\xbb\x84\xcc\xae\x07\x54\xc4\x09\x2a\xc7\x50\x61\x1b\x6c\xfb\
\x8d\x31\x10\x35\x60\x24\xc2\x16\x2a\x8c\x0d\xd8\xd8\x03\xdb\x78\
\x18\x0f\xe3\x79\x01\x8e\x3d\xe3\x1c\x41\x04\x68\x6a\x89\x69\x69\
\x45\x3e\x64\xfa\x05\x4f\xcc\x8e\xab\xfc\x27\x4d\xf6\xe9\x57\xd7\
\x65\x77\xd1\xc3\x25\xef\xbb\xef\x1f\x9f\x7f\x5e\xf7\xb9\xcf\x17\
\xfb\x3f\xd9\x0d\x47\x46\x5d\x2d\xc2\x4f\x9c\xed\x15\xcb\xb0\x85\
\xea\x78\xaf\x36\x72\xa0\x45\xf8\xd3\x84\x43\x7d\xd1\xa4\x2f\xf5\
\x5d\x30\x78\xd4\x5a\xab\x70\x35\x1f\x84\x8f\x9d\xb5\xc2\x05\x43\
\xbb\xf4\x95\xbe\x43\x3d\x55\xb7\xc6\x7b\xc4\xf7\x06\x8d\xb2\xd0\
\x05\x41\x1b\x6b\xab\xbd\x87\xcc\xf5\x39\x03\x2d\xc5\x9e\x33\x16\
\x85\x45\x23\x7e\x8b\xbc\x20\x70\xd5\xfe\x84\xed\xcd\xb2\xbc\x9f\
\x3b\x15\x79\xe0\x6c\x97\xd2\x1f\x1b\x14\x66\xed\xa0\x68\x44\xcc\
\xf5\xcd\x32\xc1\xc4\xb1\x66\x11\x74\x95\x73\x40\x2d\x64\x33\x1e\
\x0b\x15\x65\x6f\x5f\xd4\x5c\xca\x92\x0c\xb6\x89\x1e\x0c\xb5\x0b\
\xa1\xb5\x3c\x13\x6a\xcb\xb2\x3d\x86\xf8\x18\x9a\x15\xc3\x48\xd8\
\x9f\x22\x66\x6f\x67\x54\xd4\x0e\x1b\x86\xf9\xfc\x23\x9a\xcb\xda\
\x42\xaa\x13\xa5\xe6\x1f\x37\x14\xcd\x8d\x74\x1f\x86\x63\x06\x11\
\xd8\x94\x99\xd0\xaf\xca\x06\x17\x6d\xf3\xf5\x7e\x0a\x79\x8b\xf1\
\x77\xbc\x8f\x40\x1d\xfe\x7e\xb2\x2f\x05\x7b\x6f\x3a\x97\xf9\xd7\
\x11\xb3\xd7\xdf\xdf\x34\x2f\x71\x75\x77\x55\xc6\x8f\x63\xc6\xc3\
\x60\x6b\x78\x1b\x06\xdb\x8a\xa1\xbf\x92\x03\x66\x02\x3f\x57\x56\
\xf0\xdd\xc9\x84\xd8\x49\x1d\x99\x44\x7d\x87\xd8\xb0\xdb\x6f\xa9\
\xe2\xea\x5e\x1e\x9a\x15\x0a\xd1\xf5\xc2\x7c\xd4\xeb\x45\x51\xce\
\x8b\xd2\xe3\x22\xc8\x9a\xc3\x7c\x87\x45\xbb\x1f\x46\x3a\x84\x30\
\xd0\x58\x00\x0e\x4d\x0e\xf4\xc9\x70\xb0\x28\x33\x60\x9c\x4b\xbf\
\x73\x65\x6f\x36\xea\xda\xf8\xea\xe5\x83\xbe\x3e\xd6\xb3\x9c\x14\
\x74\x19\xc7\xd1\x15\x2e\x17\x9d\xe7\x30\x6e\x76\x52\x48\x82\x79\
\x61\x69\x0e\x75\xab\xa2\x20\xf9\x41\x5b\xb5\x00\x4c\xba\x02\xb0\
\xd7\xee\x07\x63\x19\x03\x4c\x72\x1c\xde\x95\xa4\x7b\x4e\x27\xc5\
\x4d\x4f\xc4\xc5\xa1\xb3\xc9\x89\xe8\xa3\x34\x1a\x3a\xb7\x95\x8a\
\x3e\x63\xd0\xd1\x89\xf8\x98\x1b\xcd\x14\xd2\x01\x98\x0f\x95\xe4\
\x50\x83\x55\x82\xed\xd7\x7a\x65\x5c\x70\xe9\xf3\xa1\xa5\x3c\x03\
\x54\x22\x1c\x74\xc5\x0c\x68\x2a\x65\x43\x7b\x69\xfa\xcd\xd6\x20\
\xff\xa1\x53\x1b\xa2\xd1\x89\x35\x6b\xd0\x87\xd1\xd1\xe8\x54\xcc\
\x1b\xc8\xfd\x66\xc4\x8d\x86\x45\x4f\x1c\xe8\x78\xf4\xa9\x8f\x52\
\xe6\xc6\x2f\x36\x94\x24\xbb\xf4\xa2\x9d\x30\x50\xb7\x0f\x8e\x56\
\xf3\xa1\xa7\x92\x0d\x7a\x61\x32\xb4\x96\xec\x84\xaa\xdc\x44\xa8\
\x29\xa4\x0f\xea\x96\x78\xd7\xbf\xbf\x32\x08\x8d\x50\xc8\x68\x18\
\xc3\xd0\xe8\x12\x2f\x64\x0e\x0f\xbc\x56\x8d\x61\x09\x7f\x41\x8d\
\x65\x74\x4a\x6b\x09\x4d\xd9\x5b\xc1\x98\xeb\x92\xa4\x13\xb7\xe4\
\x42\xd7\x11\x06\x74\x94\xd1\xa1\xa5\x28\x11\xfa\xe5\x2c\x68\x10\
\xd2\xc0\xc0\x8c\x99\x19\x5f\x1d\x82\x2e\x2c\xf6\x9a\x9a\x58\xea\
\x33\x35\xba\x22\x70\xea\x3c\x99\x84\x3e\xf5\x5b\x4c\xe0\xc1\x93\
\x12\x0c\xa3\xfe\x81\x1e\xad\x60\x93\x5b\x4b\x92\x04\x23\x0d\xbc\
\xfb\xf2\xdc\x78\x70\x6b\xf9\xd0\x59\x9a\x0a\x76\x39\xb1\x2d\x81\
\x99\xa5\xa9\x30\xa0\xc1\xa1\xad\x74\x17\x8c\xb3\x62\xbf\xff\x2a\
\x34\x70\x66\xf2\xb9\xa7\x6f\x37\xbc\x16\x39\x4d\x7f\x31\xe4\xd2\
\xf8\xaa\xb0\x69\x44\xe0\xc8\xff\x49\x64\x59\xf9\xfc\xa4\x36\x34\
\x94\x8a\x99\xe5\x3c\x72\x79\xd6\x26\xc6\xa0\x8e\x33\x53\x5f\xb4\
\x03\x7a\x88\x0d\x5d\x1a\x2e\x98\xc5\x4c\x70\xaa\xd9\x60\x2c\x4f\
\x01\x97\x32\x1d\x1c\x2a\x36\xd8\x94\x6c\x38\xbd\xed\xe5\x1f\xbe\
\x7e\x29\xec\xdb\x5e\xea\xfa\xdb\xb9\xeb\xc2\xb5\x55\xc9\xaf\xc4\
\x64\x87\x2f\x1f\xf9\xfc\x85\xb0\xa9\x7b\x24\x02\x5f\x1b\x89\xf4\
\x11\x11\x3d\x98\x3a\x77\xdb\x3a\x71\x76\x6c\xa5\x5b\xcb\xbe\xaf\
\x15\x24\xc0\x58\xe3\x1e\x8f\xb5\x82\xe9\x19\x26\xf0\x1e\x49\x2a\
\x8c\x36\x66\x82\x5b\x9d\x0e\x56\x05\x13\x4e\xb5\xef\x9b\xb3\x30\
\x63\xef\x3a\x93\x62\xee\x1c\xd9\x18\xd1\x68\x92\xa6\x45\xd9\xd5\
\xbc\x90\xc2\xc8\x15\xe1\x25\xcf\x86\x1c\xbf\xba\x79\x03\xd2\x07\
\x07\x0d\x89\x31\x2c\x18\x33\xc9\x39\xc1\x76\x15\xfb\x90\x51\xbc\
\x6b\x76\xbc\x96\x0f\x63\x4d\xfc\xb9\xf7\xaa\xd8\x9e\xe1\x3a\xfc\
\xa1\x59\xce\x80\x89\x8e\x3d\x60\x92\xee\x86\x89\xce\x3d\x70\xb2\
\x35\xe7\x9e\x81\x17\x5b\xaf\x4b\x58\xab\x31\xcb\xd2\xa2\x1c\x2a\
\x3c\xd0\xad\xcb\xf0\x72\x6a\x52\x48\xca\xe5\xcb\x9f\xa9\x09\x08\
\x90\xfe\x86\xfe\x9a\xa5\x9a\xfb\xd4\x51\x39\xfb\x75\x4b\x65\x5a\
\x9f\xb5\x9a\x75\x69\x50\xc5\xb9\x65\xab\x60\xcc\x7e\xa0\xe7\x3e\
\x1c\x6b\xe2\xc1\xd9\x16\x1e\xf4\x55\xec\x86\x33\x7a\xbe\x67\x58\
\x9f\x75\xc1\xa2\xe0\xc4\xda\x54\xdc\x15\x66\x15\xd7\x57\x5b\x46\
\x27\xd3\x68\x34\x6c\xde\x4c\xa6\x14\x92\xa5\x26\xc3\xc7\xae\xc6\
\x57\xdb\x54\xf8\x36\xe2\xe1\x26\x19\x4b\x62\x92\xa5\x75\x3b\x54\
\xac\x93\xb6\xca\x94\x19\xbb\x92\xf9\x60\x40\x9a\xf6\x4d\x67\x39\
\xb3\xde\x59\xc3\x5b\xea\x3e\x94\x43\xbe\x18\x19\x89\xfd\x6b\x00\
\x18\xf6\x85\x78\x17\xe9\x98\x82\x4f\xb1\xca\x71\x6f\x87\x82\x1b\
\x60\x55\xe2\xab\xac\x2a\x3c\xc1\x24\x4f\x4f\x69\x28\x4e\x4c\x76\
\xd7\xe0\x9c\x9a\x83\xbb\x37\xdd\xbd\x1b\x80\xfd\x97\x7e\x01\xca\
\x69\x50\xfd\x5a\x79\x3f\xfb\x00\x00\x00\x00\x49\x45\x4e\x44\xae\
\x42\x60\x82\
\x00\x00\x02\xf8\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
@ -795,6 +877,10 @@ qt_resource_name = "\
\x00\x61\
\x00\x70\x00\x70\x00\x6c\x00\x69\x00\x63\x00\x61\x00\x74\x00\x69\x00\x6f\x00\x6e\x00\x2d\x00\x65\x00\x78\x00\x69\x00\x74\x00\x2e\
\x00\x70\x00\x6e\x00\x67\
\x00\x09\
\x0b\x85\x83\x07\
\x00\x63\
\x00\x6c\x00\x65\x00\x61\x00\x72\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x16\
\x03\x0a\xf6\xe7\
\x00\x6e\
@ -809,7 +895,7 @@ qt_resource_name = "\
qt_resource_struct = "\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x06\x00\x00\x00\x0b\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x07\x00\x00\x00\x0b\
\x00\x00\x00\x14\x00\x02\x00\x00\x00\x08\x00\x00\x00\x03\
\x00\x00\x00\x54\x00\x00\x00\x00\x00\x01\x00\x00\x02\xda\
\x00\x00\x01\x46\x00\x00\x00\x00\x00\x01\x00\x00\x11\x72\
@ -819,12 +905,13 @@ qt_resource_struct = "\
\x00\x00\x00\xea\x00\x00\x00\x00\x00\x01\x00\x00\x0d\x9e\
\x00\x00\x00\xa0\x00\x00\x00\x00\x00\x01\x00\x00\x08\xd2\
\x00\x00\x00\x2a\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x02\x10\x00\x00\x00\x00\x00\x01\x00\x00\x24\x9d\
\x00\x00\x02\x28\x00\x00\x00\x00\x00\x01\x00\x00\x29\x95\
\x00\x00\x01\x6e\x00\x00\x00\x00\x00\x01\x00\x00\x13\xaa\
\x00\x00\x01\xe2\x00\x00\x00\x00\x00\x01\x00\x00\x20\x2b\
\x00\x00\x01\xc2\x00\x00\x00\x00\x00\x01\x00\x00\x1b\xda\
\x00\x00\x01\x9a\x00\x00\x00\x00\x00\x01\x00\x00\x18\x27\
\x00\x00\x02\x42\x00\x00\x00\x00\x00\x01\x00\x00\x27\x99\
\x00\x00\x02\x10\x00\x00\x00\x00\x00\x01\x00\x00\x24\x9d\
\x00\x00\x02\x5a\x00\x00\x00\x00\x00\x01\x00\x00\x2c\x91\
"
def init_resources():

BIN
images/clear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,6 +1,7 @@
<RCC>
<qresource prefix="toolbar">
<file>capture-to-disk.png</file>
<file>clear.png</file>
<file>follow-output.png</file>
<file>configure.png</file>
<file>application-exit.png</file>