Cleanups
This commit is contained in:
parent
c44b362d16
commit
4c13fac132
1
.bzrignore
Normal file
1
.bzrignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
.idea
|
@ -4,7 +4,8 @@ import threading
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from serial import Serial, SerialException
|
from serial import Serial, SerialException
|
||||||
|
|
||||||
from colourterm import SettingsDialog, ConnectDialog, SComboBox, Highlight, fromUtf8, translate, create_default_highlights
|
from colourterm import SettingsDialog, ConnectDialog, SComboBox, Highlight, fromUtf8, translate, \
|
||||||
|
create_default_highlights
|
||||||
from colourterm.cwebview import CWebView
|
from colourterm.cwebview import CWebView
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +20,9 @@ class Ui_MainWindow(object):
|
|||||||
self.centralLayout.setContentsMargins(0, 0, 0, 8)
|
self.centralLayout.setContentsMargins(0, 0, 0, 8)
|
||||||
self.centralLayout.setObjectName(fromUtf8('centralLayout'))
|
self.centralLayout.setObjectName(fromUtf8('centralLayout'))
|
||||||
self.outputBrowser = CWebView(self.centralwidget)
|
self.outputBrowser = CWebView(self.centralwidget)
|
||||||
self.outputBrowser.setHtml('<html><head><style>body { color: %s; font-family: monospace; margin: 0; padding: 0; }</style></head><body><pre></pre></body></html>' % str(QtGui.QApplication.palette().color(QtGui.QPalette.Text).name()))
|
self.outputBrowser.setHtml('<html><head><style>body { color: %s; font-family: monospace; margin: 0; '
|
||||||
|
'padding: 0; }</style></head><body><pre></pre></body></html>' %
|
||||||
|
str(QtGui.QApplication.palette().color(QtGui.QPalette.Text).name()))
|
||||||
self.outputBrowser.setObjectName(fromUtf8('outputBrowser'))
|
self.outputBrowser.setObjectName(fromUtf8('outputBrowser'))
|
||||||
self.centralLayout.addWidget(self.outputBrowser)
|
self.centralLayout.addWidget(self.outputBrowser)
|
||||||
self.sendLayout = QtGui.QHBoxLayout()
|
self.sendLayout = QtGui.QHBoxLayout()
|
||||||
@ -52,17 +55,20 @@ class Ui_MainWindow(object):
|
|||||||
mainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
|
mainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
|
||||||
self.openAction = QtGui.QAction(mainWindow)
|
self.openAction = QtGui.QAction(mainWindow)
|
||||||
connectIcon = QtGui.QIcon()
|
connectIcon = QtGui.QIcon()
|
||||||
connectIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/network-connect.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
connectIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/network-connect.png')),
|
||||||
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.openAction.setIcon(connectIcon)
|
self.openAction.setIcon(connectIcon)
|
||||||
self.openAction.setObjectName(fromUtf8('openAction'))
|
self.openAction.setObjectName(fromUtf8('openAction'))
|
||||||
self.closeAction = QtGui.QAction(mainWindow)
|
self.closeAction = QtGui.QAction(mainWindow)
|
||||||
disconnectIcon = QtGui.QIcon()
|
disconnectIcon = QtGui.QIcon()
|
||||||
disconnectIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/network-disconnect.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
disconnectIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/network-disconnect.png')),
|
||||||
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.closeAction.setIcon(disconnectIcon)
|
self.closeAction.setIcon(disconnectIcon)
|
||||||
self.closeAction.setObjectName(fromUtf8('closeAction'))
|
self.closeAction.setObjectName(fromUtf8('closeAction'))
|
||||||
self.captureAction = QtGui.QAction(mainWindow)
|
self.captureAction = QtGui.QAction(mainWindow)
|
||||||
captureIcon = QtGui.QIcon()
|
captureIcon = QtGui.QIcon()
|
||||||
captureIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/capture-to-disk.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
captureIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/capture-to-disk.png')),
|
||||||
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.captureAction.setIcon(captureIcon)
|
self.captureAction.setIcon(captureIcon)
|
||||||
self.captureAction.setCheckable(True)
|
self.captureAction.setCheckable(True)
|
||||||
self.captureAction.setChecked(False)
|
self.captureAction.setChecked(False)
|
||||||
@ -70,19 +76,22 @@ class Ui_MainWindow(object):
|
|||||||
self.followAction = QtGui.QAction(mainWindow)
|
self.followAction = QtGui.QAction(mainWindow)
|
||||||
self.followAction.setShortcut(QtCore.Qt.Key_F)
|
self.followAction.setShortcut(QtCore.Qt.Key_F)
|
||||||
followIcon = QtGui.QIcon()
|
followIcon = QtGui.QIcon()
|
||||||
followIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/follow-output.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
followIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/follow-output.png')),
|
||||||
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.followAction.setIcon(followIcon)
|
self.followAction.setIcon(followIcon)
|
||||||
self.followAction.setCheckable(True)
|
self.followAction.setCheckable(True)
|
||||||
self.followAction.setChecked(True)
|
self.followAction.setChecked(True)
|
||||||
self.followAction.setObjectName(fromUtf8('followAction'))
|
self.followAction.setObjectName(fromUtf8('followAction'))
|
||||||
self.configureAction = QtGui.QAction(mainWindow)
|
self.configureAction = QtGui.QAction(mainWindow)
|
||||||
configureIcon = QtGui.QIcon()
|
configureIcon = QtGui.QIcon()
|
||||||
configureIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/configure.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
configureIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/configure.png')),
|
||||||
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.configureAction.setIcon(configureIcon)
|
self.configureAction.setIcon(configureIcon)
|
||||||
self.configureAction.setObjectName(fromUtf8('configureAction'))
|
self.configureAction.setObjectName(fromUtf8('configureAction'))
|
||||||
self.exitAction = QtGui.QAction(mainWindow)
|
self.exitAction = QtGui.QAction(mainWindow)
|
||||||
exitIcon = QtGui.QIcon()
|
exitIcon = QtGui.QIcon()
|
||||||
exitIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/application-exit.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
exitIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/application-exit.png')),
|
||||||
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.exitAction.setIcon(exitIcon)
|
self.exitAction.setIcon(exitIcon)
|
||||||
self.exitAction.setObjectName(fromUtf8('exitAction'))
|
self.exitAction.setObjectName(fromUtf8('exitAction'))
|
||||||
self.toolBar.addAction(self.openAction)
|
self.toolBar.addAction(self.openAction)
|
||||||
@ -205,8 +214,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
baseDir = os.path.basename(self.captureFileName)
|
baseDir = os.path.basename(self.captureFileName)
|
||||||
else:
|
else:
|
||||||
baseDir = u''
|
baseDir = u''
|
||||||
self.captureFileName = QtGui.QFileDialog.getSaveFileName(self, u'Capture To File',
|
self.captureFileName = QtGui.QFileDialog.getSaveFileName(self, u'Capture To File', baseDir,
|
||||||
baseDir, u'Text files (*.txt *.log);;All files (*)')
|
u'Text files (*.txt *.log);;All files (*)')
|
||||||
self.captureFile = open(self.captureFileName, u'w')
|
self.captureFile = open(self.captureFileName, u'w')
|
||||||
self.statusbar.showMessage(self.captureFileName)
|
self.statusbar.showMessage(self.captureFileName)
|
||||||
elif self.captureFile and not enabled:
|
elif self.captureFile and not enabled:
|
||||||
@ -239,7 +248,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.sendComboBox.insertItem(0, output)
|
self.sendComboBox.insertItem(0, output)
|
||||||
self.sendComboBox.setCurrentIndex(0)
|
self.sendComboBox.setCurrentIndex(0)
|
||||||
self.sendComboBox.clearEditText()
|
self.sendComboBox.clearEditText()
|
||||||
self.device.write(output + u'\r\n')
|
self.device.write(output + '\r\n')
|
||||||
|
|
||||||
def onContentsSizeChanged(self, size):
|
def onContentsSizeChanged(self, size):
|
||||||
if self.followOutput:
|
if self.followOutput:
|
||||||
@ -249,7 +258,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
def onUpdateOutput(self, output):
|
def onUpdateOutput(self, output):
|
||||||
#self.terminalLines.append(output)
|
#self.terminalLines.append(output)
|
||||||
if self.captureFile:
|
if self.captureFile:
|
||||||
self.captureFile.write(output + u'\n')
|
self.captureFile.write(output + '\n')
|
||||||
self.captureFile.flush()
|
self.captureFile.flush()
|
||||||
#if len(self.terminalLines) > 5000:
|
#if len(self.terminalLines) > 5000:
|
||||||
# self.terminalLines = self.terminalLines[-5000:]
|
# self.terminalLines = self.terminalLines[-5000:]
|
||||||
@ -291,13 +300,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
style = u'%sbackground-color: %s; ' % (style, highlight.background)
|
style = u'%sbackground-color: %s; ' % (style, highlight.background)
|
||||||
break
|
break
|
||||||
if style:
|
if style:
|
||||||
try:
|
try:
|
||||||
output = u'<div style="%s">%s</div>' % (style, unicode(output, u'utf-8'))
|
output = u'<div style="%s">%s</div>' % (style, unicode(output, u'utf-8'))
|
||||||
except TypeError:
|
except TypeError:
|
||||||
output = u'<div style="%s">%s</div>' % (style, output)
|
output = u'<div style="%s">%s</div>' % (style, output)
|
||||||
else:
|
else:
|
||||||
output = u'<div>%s</div>' % output
|
output = u'<div>%s</div>' % output
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def saveHighlights(self, highlights):
|
def saveHighlights(self, highlights):
|
||||||
settings = QtCore.QSettings()
|
settings = QtCore.QSettings()
|
||||||
|
Loading…
Reference in New Issue
Block a user