summaryrefslogtreecommitdiff
path: root/portato/gui/qt
diff options
context:
space:
mode:
Diffstat (limited to 'portato/gui/qt')
-rw-r--r--portato/gui/qt/terminal.py35
-rw-r--r--portato/gui/qt/tree.py2
-rw-r--r--portato/gui/qt/windows.py2
3 files changed, 34 insertions, 5 deletions
diff --git a/portato/gui/qt/terminal.py b/portato/gui/qt/terminal.py
index 91d2e94..23e090a 100644
--- a/portato/gui/qt/terminal.py
+++ b/portato/gui/qt/terminal.py
@@ -13,8 +13,9 @@
from PyQt4 import Qt
from Queue import Queue
-from threading import Thread
-from os import read
+from threading import Thread, currentThread
+from os import read, close
+import errno
try:
from curses.ascii import ctrl
@@ -45,6 +46,13 @@ class DeleteEvent (Qt.QEvent):
Qt.QEvent.__init__(self, self.TYPE)
self.del_type = type
+class SetPtyEvent (Qt.QEvent):
+ TYPE = Qt.QEvent.Type(1003)
+
+ def __init__ (self, pty):
+ Qt.QEvent.__init__(self, self.TYPE)
+ self.pty = pty
+
class BoldFormat (Qt.QTextCharFormat):
def __init__(self):
@@ -112,6 +120,11 @@ class QtConsole (Console, Qt.QTextEdit):
# set black bg
self.palette().setColor(Qt.QPalette.Base, Qt.QColor("black"))
+
+ # set highlighting colors ... XXX: for some reasons this does not work ... Qt sucks
+ self.palette().setColor(Qt.QPalette.Highlight, Qt.QColor("white"))
+ self.palette().setColor(Qt.QPalette.HighlightedText, Qt.QColor("black"))
+
self.setBackgroundRole(Qt.QPalette.Base)
self.setAutoFillBackground(True)
@@ -151,6 +164,11 @@ class QtConsole (Console, Qt.QTextEdit):
self._deletePrev(event.del_type)
event.accept()
return True
+
+ elif event.type() == SetPtyEvent.TYPE:
+ self.set_pty(event.pty)
+ event.accept()
+ return True
event.ignore()
return False
@@ -207,6 +225,10 @@ class QtConsole (Console, Qt.QTextEdit):
self.current.start()
def set_pty (self, pty):
+ if currentThread().getName() != "MainThread":
+ Qt.QCoreApplication.postEvent(self, SetPtyEvent(pty))
+ return
+
if not self.running:
self.pty = pty
self.start_new_thread()
@@ -215,6 +237,7 @@ class QtConsole (Console, Qt.QTextEdit):
else: # quit current thread
self.run = False
self.clear()
+ close(self.pty)
self.pty = pty # set this after clearing to lose no chars :)
self.start_new_thread()
@@ -226,7 +249,13 @@ class QtConsole (Console, Qt.QTextEdit):
got_cr = False
while self.run:
- s = read(self.pty, 1)
+ try:
+ s = read(self.pty, 1)
+ except OSError, e: # bug in Python with the subprocess module
+ if e.errno == errno.EINTR:
+ continue
+ raise
+
if s == "": break # nothing read -> finish
if self.isNotWrapping and s == "\n":
diff --git a/portato/gui/qt/tree.py b/portato/gui/qt/tree.py
index 6e9950f..7c0fa4c 100644
--- a/portato/gui/qt/tree.py
+++ b/portato/gui/qt/tree.py
@@ -72,7 +72,7 @@ class QtTree (Tree):
iter += 1 # next iter ...
newIt = iter.value()
- if newIt.parent() != it.parent(): # stop if we left the current parent
+ if not newIt or newIt.parent() != it.parent(): # stop if we left the current parent
return None
else:
return newIt
diff --git a/portato/gui/qt/windows.py b/portato/gui/qt/windows.py
index 3bd9296..5f1100f 100644
--- a/portato/gui/qt/windows.py
+++ b/portato/gui/qt/windows.py
@@ -116,7 +116,7 @@ class PluginDialog (Window):
@Qt.pyqtSignature("")
def on_buttonBox_accepted(self):
for pluginKey, value in self.changedPlugins.iteritems():
- self.plugins[pluginKey].set_enabled(value)
+ self.plugins[pluginKey].set_option("disabled", not value)
self.accept()