tabs!
This commit is contained in:
parent
54f1b521ab
commit
0363d80af2
9 changed files with 86 additions and 6 deletions
Binary file not shown.
BIN
oyoyo/client.pyc
BIN
oyoyo/client.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
oyoyo/parse.pyc
BIN
oyoyo/parse.pyc
Binary file not shown.
|
@ -8,5 +8,6 @@
|
||||||
"carcinoGeneticist",
|
"carcinoGeneticist",
|
||||||
"tentacleTherapist"
|
"tentacleTherapist"
|
||||||
],
|
],
|
||||||
"theme": "pesterchum"
|
"theme": "pesterchum",
|
||||||
|
"tabs": true
|
||||||
}
|
}
|
|
@ -77,6 +77,8 @@ class userConfig(object):
|
||||||
return self.config['chums']
|
return self.config['chums']
|
||||||
def getTheme(self):
|
def getTheme(self):
|
||||||
return self.theme
|
return self.theme
|
||||||
|
def tabs(self):
|
||||||
|
return self.config["tabs"]
|
||||||
|
|
||||||
class exitButton(QtGui.QPushButton):
|
class exitButton(QtGui.QPushButton):
|
||||||
def __init__(self, icon, parent=None):
|
def __init__(self, icon, parent=None):
|
||||||
|
@ -144,6 +146,58 @@ class MovingWindow(QtGui.QFrame):
|
||||||
self.update()
|
self.update()
|
||||||
self.moving = None
|
self.moving = None
|
||||||
|
|
||||||
|
class PesterTabWindow(QtGui.QFrame):
|
||||||
|
def __init__(self, mainwindow, parent=None):
|
||||||
|
QtGui.QFrame.__init__(self, parent)
|
||||||
|
self.mainwindow = mainwindow
|
||||||
|
self.theme = mainwindow.theme
|
||||||
|
self.resize(*self.theme["convo/size"])
|
||||||
|
self.setStyleSheet(self.theme["convo/style"])
|
||||||
|
|
||||||
|
self.tabs = QtGui.QTabBar(self)
|
||||||
|
self.connect(self.tabs, QtCore.SIGNAL('currentChanged(int)'),
|
||||||
|
self, QtCore.SLOT('changeTab(int)'))
|
||||||
|
self.tabs.setShape(self.theme["convo/tabstyle"])
|
||||||
|
|
||||||
|
|
||||||
|
self.layout = QtGui.QVBoxLayout()
|
||||||
|
self.layout.setContentsMargins(0,0,0,0)
|
||||||
|
self.layout.addWidget(self.tabs)
|
||||||
|
self.setLayout(self.layout)
|
||||||
|
self.convos = {}
|
||||||
|
self.tabIndices = {}
|
||||||
|
self.currentConvo = None
|
||||||
|
self.changedTab = False
|
||||||
|
def addChat(self, convo):
|
||||||
|
self.convos[convo.chum.handle] = convo
|
||||||
|
# either addTab or setCurrentIndex will trigger changed()
|
||||||
|
newindex = self.tabs.addTab(convo.chum.handle)
|
||||||
|
self.tabIndices[convo.chum.handle] = newindex
|
||||||
|
self.tabs.setCurrentIndex(newindex)
|
||||||
|
self.tabs.setTabIcon(newindex, convo.chum.mood.icon(self.theme))
|
||||||
|
def showChat(self, handle):
|
||||||
|
self.tabs.setCurrentIndex(self.tabIndices[handle])
|
||||||
|
def keyPressEvent(self, event):
|
||||||
|
keypress = event.key()
|
||||||
|
mods = event.modifiers()
|
||||||
|
if ((mods & QtCore.Qt.ControlModifier) and
|
||||||
|
keypress == QtCore.Qt.Key_Tab):
|
||||||
|
nexti = (self.tabIndices[self.currentConvo.chum.handle] + 1) % self.tabs.count()
|
||||||
|
self.tabs.setCurrentIndex(nexti)
|
||||||
|
|
||||||
|
@QtCore.pyqtSlot(int)
|
||||||
|
def changeTab(self, i):
|
||||||
|
if self.changedTab:
|
||||||
|
self.changedTab = False
|
||||||
|
return
|
||||||
|
handle = unicode(self.tabs.tabText(i))
|
||||||
|
convo = self.convos[handle]
|
||||||
|
if self.currentConvo:
|
||||||
|
self.layout.removeWidget(self.currentConvo)
|
||||||
|
self.currentConvo = convo
|
||||||
|
self.layout.addWidget(convo)
|
||||||
|
convo.raiseChat()
|
||||||
|
|
||||||
class PesterText(QtGui.QTextEdit):
|
class PesterText(QtGui.QTextEdit):
|
||||||
def __init__(self, theme, parent=None):
|
def __init__(self, theme, parent=None):
|
||||||
QtGui.QTextEdit.__init__(self, parent)
|
QtGui.QTextEdit.__init__(self, parent)
|
||||||
|
@ -191,6 +245,9 @@ class PesterConvo(QtGui.QFrame):
|
||||||
|
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
|
if parent:
|
||||||
|
parent.addChat(self)
|
||||||
|
|
||||||
def updateMood(self, mood):
|
def updateMood(self, mood):
|
||||||
self.setWindowIcon(mood.icon(self.theme))
|
self.setWindowIcon(mood.icon(self.theme))
|
||||||
# print mood update?
|
# print mood update?
|
||||||
|
@ -200,11 +257,19 @@ class PesterConvo(QtGui.QFrame):
|
||||||
else:
|
else:
|
||||||
chum = self.chum
|
chum = self.chum
|
||||||
self.textArea.addMessage(text, chum)
|
self.textArea.addMessage(text, chum)
|
||||||
def showChat(self):
|
def raiseChat(self):
|
||||||
self.activateWindow()
|
self.activateWindow()
|
||||||
self.raise_()
|
self.raise_()
|
||||||
self.textInput.setFocus()
|
self.textInput.setFocus()
|
||||||
|
|
||||||
|
def showChat(self):
|
||||||
|
if self.parent():
|
||||||
|
self.parent().showChat(self.chum.handle)
|
||||||
|
self.raiseChat()
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
self.windowClosed.emit(self.chum.handle)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def sentMessage(self):
|
def sentMessage(self):
|
||||||
text = self.textInput.text()
|
text = self.textInput.text()
|
||||||
|
@ -214,7 +279,7 @@ class PesterConvo(QtGui.QFrame):
|
||||||
self.messageSent.emit(text, self.chum)
|
self.messageSent.emit(text, self.chum)
|
||||||
|
|
||||||
messageSent = QtCore.pyqtSignal(QtCore.QString, PesterProfile)
|
messageSent = QtCore.pyqtSignal(QtCore.QString, PesterProfile)
|
||||||
|
windowClosed = QtCore.pyqtSignal(QtCore.QString)
|
||||||
|
|
||||||
class PesterWindow(MovingWindow):
|
class PesterWindow(MovingWindow):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
@ -241,9 +306,12 @@ class PesterWindow(MovingWindow):
|
||||||
|
|
||||||
self.profile = PesterProfile("superGhost", QtGui.QColor("red"), Mood(0))
|
self.profile = PesterProfile("superGhost", QtGui.QColor("red"), Mood(0))
|
||||||
self.convos = {}
|
self.convos = {}
|
||||||
|
self.tabconvo = None
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
for c in self.convos.itervalues():
|
for c in self.convos.itervalues():
|
||||||
c.close()
|
c.close()
|
||||||
|
if self.tabconvo:
|
||||||
|
self.tabconvo.close()
|
||||||
event.accept()
|
event.accept()
|
||||||
def newMessage(self, handle, msg):
|
def newMessage(self, handle, msg):
|
||||||
if not self.convos.has_key(handle):
|
if not self.convos.has_key(handle):
|
||||||
|
@ -268,6 +336,12 @@ class PesterWindow(MovingWindow):
|
||||||
# add pesterchum:begin
|
# add pesterchum:begin
|
||||||
pass
|
pass
|
||||||
return
|
return
|
||||||
|
if self.config.tabs:
|
||||||
|
if not self.tabconvo:
|
||||||
|
self.tabconvo = PesterTabWindow(self)
|
||||||
|
convoWindow = PesterConvo(chum, initiated, self, self.tabconvo)
|
||||||
|
self.tabconvo.show()
|
||||||
|
else:
|
||||||
convoWindow = PesterConvo(chum, initiated, self)
|
convoWindow = PesterConvo(chum, initiated, self)
|
||||||
self.connect(convoWindow, QtCore.SIGNAL('messageSent(QString, PyQt_PyObject)'),
|
self.connect(convoWindow, QtCore.SIGNAL('messageSent(QString, PyQt_PyObject)'),
|
||||||
self, QtCore.SIGNAL('sendMessage(QString, PyQt_PyObject)'))
|
self, QtCore.SIGNAL('sendMessage(QString, PyQt_PyObject)'))
|
||||||
|
@ -279,6 +353,10 @@ class PesterWindow(MovingWindow):
|
||||||
def newConversationWindow(self, chumlisting):
|
def newConversationWindow(self, chumlisting):
|
||||||
chum = chumlisting.chum
|
chum = chumlisting.chum
|
||||||
self.newConversation(chum)
|
self.newConversation(chum)
|
||||||
|
@QtCore.pyqtSlot(QtCore.QString)
|
||||||
|
def closeConvo(self, handle):
|
||||||
|
h = str(handle)
|
||||||
|
del self.convos[chum.handle]
|
||||||
|
|
||||||
@QtCore.pyqtSlot(QtCore.QString, Mood)
|
@QtCore.pyqtSlot(QtCore.QString, Mood)
|
||||||
def updateMoodSlot(self, handle, mood):
|
def updateMoodSlot(self, handle, mood):
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
},
|
},
|
||||||
"input": {
|
"input": {
|
||||||
"style": "background: white;"
|
"style": "background: white;"
|
||||||
}
|
},
|
||||||
|
"tabstyle": 0
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue