improved tabs
This commit is contained in:
parent
067d5796dd
commit
0f02cb5ae7
1 changed files with 41 additions and 3 deletions
|
@ -187,8 +187,11 @@ class PesterTabWindow(QtGui.QFrame):
|
||||||
self.setStyleSheet(self.theme["convo/style"])
|
self.setStyleSheet(self.theme["convo/style"])
|
||||||
|
|
||||||
self.tabs = QtGui.QTabBar(self)
|
self.tabs = QtGui.QTabBar(self)
|
||||||
|
self.tabs.setTabsClosable(True)
|
||||||
self.connect(self.tabs, QtCore.SIGNAL('currentChanged(int)'),
|
self.connect(self.tabs, QtCore.SIGNAL('currentChanged(int)'),
|
||||||
self, QtCore.SLOT('changeTab(int)'))
|
self, QtCore.SLOT('changeTab(int)'))
|
||||||
|
self.connect(self.tabs, QtCore.SIGNAL('tabCloseRequested(int)'),
|
||||||
|
self, QtCore.SLOT('tabClose(int)'))
|
||||||
self.tabs.setShape(self.theme["convo/tabstyle"])
|
self.tabs.setShape(self.theme["convo/tabstyle"])
|
||||||
|
|
||||||
|
|
||||||
|
@ -220,8 +223,36 @@ class PesterTabWindow(QtGui.QFrame):
|
||||||
def updateMood(self, handle, mood):
|
def updateMood(self, handle, mood):
|
||||||
i = self.tabIndices[handle]
|
i = self.tabIndices[handle]
|
||||||
self.tabs.setTabIcon(i, mood.icon(self.theme))
|
self.tabs.setTabIcon(i, mood.icon(self.theme))
|
||||||
|
def closeEvent(self, event):
|
||||||
|
while self.tabs.count() > 0:
|
||||||
|
self.tabClose(0)
|
||||||
|
self.windowClosed.emit()
|
||||||
|
|
||||||
|
@QtCore.pyqtSlot(int)
|
||||||
|
def tabClose(self, i):
|
||||||
|
handle = unicode(self.tabs.tabText(i))
|
||||||
|
convo = self.convos[handle]
|
||||||
|
del self.convos[handle]
|
||||||
|
del self.tabIndices[handle]
|
||||||
|
self.tabs.removeTab(i)
|
||||||
|
for (h, j) in self.tabIndices.iteritems():
|
||||||
|
if j > i:
|
||||||
|
self.tabIndices[h] = j-1
|
||||||
|
self.layout.removeWidget(convo)
|
||||||
|
convo.close()
|
||||||
|
if self.tabs.count() == 0:
|
||||||
|
self.close()
|
||||||
|
return
|
||||||
|
if self.currentConvo == convo:
|
||||||
|
currenti = self.tabs.currentIndex()
|
||||||
|
currenth = unicode(self.tabs.tabText(currenti))
|
||||||
|
self.currentConvo = self.convos[currenth]
|
||||||
|
self.currentConvo.raiseChat()
|
||||||
|
|
||||||
@QtCore.pyqtSlot(int)
|
@QtCore.pyqtSlot(int)
|
||||||
def changeTab(self, i):
|
def changeTab(self, i):
|
||||||
|
if i < 0:
|
||||||
|
return
|
||||||
if self.changedTab:
|
if self.changedTab:
|
||||||
self.changedTab = False
|
self.changedTab = False
|
||||||
return
|
return
|
||||||
|
@ -236,6 +267,8 @@ class PesterTabWindow(QtGui.QFrame):
|
||||||
self.raise_()
|
self.raise_()
|
||||||
convo.raiseChat()
|
convo.raiseChat()
|
||||||
|
|
||||||
|
windowClosed = QtCore.pyqtSignal()
|
||||||
|
|
||||||
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)
|
||||||
|
@ -257,7 +290,6 @@ class PesterInput(QtGui.QLineEdit):
|
||||||
class PesterConvo(QtGui.QFrame):
|
class PesterConvo(QtGui.QFrame):
|
||||||
def __init__(self, chum, initiated, mainwindow, parent=None):
|
def __init__(self, chum, initiated, mainwindow, parent=None):
|
||||||
QtGui.QFrame.__init__(self, parent)
|
QtGui.QFrame.__init__(self, parent)
|
||||||
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
||||||
|
|
||||||
self.chum = chum
|
self.chum = chum
|
||||||
self.theme = mainwindow.theme
|
self.theme = mainwindow.theme
|
||||||
|
@ -371,7 +403,7 @@ class PesterWindow(MovingWindow):
|
||||||
self.tabconvo = None
|
self.tabconvo = None
|
||||||
self.optionmenu = None
|
self.optionmenu = None
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
for c in self.convos.itervalues():
|
for c in self.convos.values():
|
||||||
c.close()
|
c.close()
|
||||||
if self.tabconvo:
|
if self.tabconvo:
|
||||||
self.tabconvo.close()
|
self.tabconvo.close()
|
||||||
|
@ -402,6 +434,8 @@ class PesterWindow(MovingWindow):
|
||||||
if self.config.tabs():
|
if self.config.tabs():
|
||||||
if not self.tabconvo:
|
if not self.tabconvo:
|
||||||
self.tabconvo = PesterTabWindow(self)
|
self.tabconvo = PesterTabWindow(self)
|
||||||
|
self.connect(self.tabconvo, QtCore.SIGNAL('windowClosed()'),
|
||||||
|
self, QtCore.SLOT('tabsClosed()'))
|
||||||
convoWindow = PesterConvo(chum, initiated, self, self.tabconvo)
|
convoWindow = PesterConvo(chum, initiated, self, self.tabconvo)
|
||||||
self.tabconvo.show()
|
self.tabconvo.show()
|
||||||
else:
|
else:
|
||||||
|
@ -423,6 +457,10 @@ class PesterWindow(MovingWindow):
|
||||||
h = str(handle)
|
h = str(handle)
|
||||||
del self.convos[h]
|
del self.convos[h]
|
||||||
self.convoClosed.emit(handle)
|
self.convoClosed.emit(handle)
|
||||||
|
@QtCore.pyqtSlot(QtCore.QString)
|
||||||
|
def tabsClosed(self):
|
||||||
|
del self.tabconvo
|
||||||
|
self.tabconvo = None
|
||||||
|
|
||||||
@QtCore.pyqtSlot(QtCore.QString, Mood)
|
@QtCore.pyqtSlot(QtCore.QString, Mood)
|
||||||
def updateMoodSlot(self, handle, mood):
|
def updateMoodSlot(self, handle, mood):
|
||||||
|
@ -497,9 +535,9 @@ class PesterIRC(QtCore.QObject):
|
||||||
@QtCore.pyqtSlot(QtCore.QString, bool)
|
@QtCore.pyqtSlot(QtCore.QString, bool)
|
||||||
def startConvo(self, handle, initiated):
|
def startConvo(self, handle, initiated):
|
||||||
h = str(handle)
|
h = str(handle)
|
||||||
helpers.msg(self.cli, h, "COLOR >%s" % (self.profile.colorcmd()))
|
|
||||||
if initiated:
|
if initiated:
|
||||||
helpers.msg(self.cli, h, "PESTERCHUM:BEGIN")
|
helpers.msg(self.cli, h, "PESTERCHUM:BEGIN")
|
||||||
|
helpers.msg(self.cli, h, "COLOR >%s" % (self.profile.colorcmd()))
|
||||||
@QtCore.pyqtSlot(QtCore.QString)
|
@QtCore.pyqtSlot(QtCore.QString)
|
||||||
def endConvo(self, handle):
|
def endConvo(self, handle):
|
||||||
h = str(handle)
|
h = str(handle)
|
||||||
|
|
Loading…
Reference in a new issue