From 0363d80af230851409ea13ae6883dfbdd31e1b8a Mon Sep 17 00:00:00 2001 From: Stephen Dranger Date: Wed, 26 Jan 2011 04:32:35 -0600 Subject: [PATCH] tabs! --- oyoyo/__init__.pyc | Bin 333 -> 333 bytes oyoyo/client.pyc | Bin 9728 -> 9728 bytes oyoyo/cmdhandler.pyc | Bin 8312 -> 8312 bytes oyoyo/helpers.pyc | Bin 3869 -> 3869 bytes oyoyo/ircevents.pyc | Bin 5693 -> 5693 bytes oyoyo/parse.pyc | Bin 2869 -> 2869 bytes pesterchum.js | 3 +- pesterchum.py | 84 +++++++++++++++++++++++++++++++++++-- themes/pesterchum/style.js | 5 ++- 9 files changed, 86 insertions(+), 6 deletions(-) diff --git a/oyoyo/__init__.pyc b/oyoyo/__init__.pyc index be26c04278418a75756d2cf8046f30e23a4107ba..28e3e80c476d1ac01bd4cfb463eeb187f0612c7e 100644 GIT binary patch delta 15 WcmX@hbe4(j;wN6NbFmxQ+!+BfRRyU4 delta 15 XcmX@hbe4(j;wN6Nd*3&*xibO)HMa&+ diff --git a/oyoyo/client.pyc b/oyoyo/client.pyc index 08d3b013fe5f0b5668cbd1136ac7c611e46875ec..ad7d9f762837f88938fa10bd13f344b041befc5c 100644 GIT binary patch delta 15 WcmZqhY4BmY_=%V6TSqCHl diff --git a/oyoyo/cmdhandler.pyc b/oyoyo/cmdhandler.pyc index e9def19d77978e0983f9458c1605a5ac084df2c3..d97b3d1ff2c4eb42e44ae39815380e44fd3c0833 100644 GIT binary patch delta 15 Wcmez2@WX-a;wN6NbFmxQiWC4n$_B*% delta 15 Xcmez2@WX-a;wN6Nd*3&*6)6A!K`aMv diff --git a/oyoyo/helpers.pyc b/oyoyo/helpers.pyc index da83df78981db06980c0910251021d19a1027720..33975b371e1a509c3798a348d5a8e349f6e08817 100644 GIT binary patch delta 15 WcmbO$H&>4B;wN6NbFmxQ#Q6a)n+0D0 delta 15 XcmbO$H&>4B;wN6Nd*3&*iSq*hGW`Y# diff --git a/oyoyo/ircevents.pyc b/oyoyo/ircevents.pyc index 1f1ccd60b234136833f75055fd8d2e431da22511..c83999f5508b0e331f132f84e784455707b3e147 100644 GIT binary patch delta 15 Wcmdn1vsZ`h;wN6NbFmxQ%*6mS&IRHC delta 15 Xcmdn1vsZ`h;wN6Nd*3&*nTr7cI4}l` diff --git a/oyoyo/parse.pyc b/oyoyo/parse.pyc index e67f2eacb08e566bee9472177a2c6889c2828d09..9095b24ca7fdd4567a86d7cbbd0c9a4cc710c079 100644 GIT binary patch delta 15 WcmdlgwpEPn;wN6NbFmxQ^tk~smj#mm delta 15 XcmdlgwpEPn;wN6Nd*3&*>2m`BH2DTS diff --git a/pesterchum.js b/pesterchum.js index 5fa70ed..d076e09 100644 --- a/pesterchum.js +++ b/pesterchum.js @@ -8,5 +8,6 @@ "carcinoGeneticist", "tentacleTherapist" ], - "theme": "pesterchum" + "theme": "pesterchum", + "tabs": true } \ No newline at end of file diff --git a/pesterchum.py b/pesterchum.py index c05ae9a..c88fbda 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -77,6 +77,8 @@ class userConfig(object): return self.config['chums'] def getTheme(self): return self.theme + def tabs(self): + return self.config["tabs"] class exitButton(QtGui.QPushButton): def __init__(self, icon, parent=None): @@ -144,6 +146,58 @@ class MovingWindow(QtGui.QFrame): self.update() 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): def __init__(self, theme, parent=None): QtGui.QTextEdit.__init__(self, parent) @@ -191,6 +245,9 @@ class PesterConvo(QtGui.QFrame): self.setLayout(self.layout) + if parent: + parent.addChat(self) + def updateMood(self, mood): self.setWindowIcon(mood.icon(self.theme)) # print mood update? @@ -200,11 +257,19 @@ class PesterConvo(QtGui.QFrame): else: chum = self.chum self.textArea.addMessage(text, chum) - def showChat(self): + def raiseChat(self): self.activateWindow() self.raise_() 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() def sentMessage(self): text = self.textInput.text() @@ -214,7 +279,7 @@ class PesterConvo(QtGui.QFrame): self.messageSent.emit(text, self.chum) messageSent = QtCore.pyqtSignal(QtCore.QString, PesterProfile) - + windowClosed = QtCore.pyqtSignal(QtCore.QString) class PesterWindow(MovingWindow): def __init__(self, parent=None): @@ -241,9 +306,12 @@ class PesterWindow(MovingWindow): self.profile = PesterProfile("superGhost", QtGui.QColor("red"), Mood(0)) self.convos = {} + self.tabconvo = None def closeEvent(self, event): for c in self.convos.itervalues(): c.close() + if self.tabconvo: + self.tabconvo.close() event.accept() def newMessage(self, handle, msg): if not self.convos.has_key(handle): @@ -268,7 +336,13 @@ class PesterWindow(MovingWindow): # add pesterchum:begin pass return - convoWindow = PesterConvo(chum, initiated, self) + 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) self.connect(convoWindow, QtCore.SIGNAL('messageSent(QString, PyQt_PyObject)'), self, QtCore.SIGNAL('sendMessage(QString, PyQt_PyObject)')) self.convos[chum.handle] = convoWindow @@ -279,6 +353,10 @@ class PesterWindow(MovingWindow): def newConversationWindow(self, chumlisting): chum = chumlisting.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) def updateMoodSlot(self, handle, mood): diff --git a/themes/pesterchum/style.js b/themes/pesterchum/style.js index 139f238..ac0555c 100644 --- a/themes/pesterchum/style.js +++ b/themes/pesterchum/style.js @@ -28,7 +28,8 @@ }, "input": { "style": "background: white;" - } + }, + "tabstyle": 0 } -} \ No newline at end of file +}