From 79d84543a8f2b47a707d809b3489fea346e36448 Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Sun, 21 Aug 2011 20:39:14 -0700 Subject: [PATCH] Chumroll chum sign-in/out notifications --- CHANGELOG.mkdn | 1 + TODO.mkdn | 2 +- pesterchum.py | 58 ++++++++++++++++++++++++++++++++++++++--- themes/arrow_left.png | Bin 0 -> 355 bytes themes/arrow_right.png | Bin 0 -> 363 bytes 5 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 themes/arrow_left.png create mode 100644 themes/arrow_right.png diff --git a/CHANGELOG.mkdn b/CHANGELOG.mkdn index 8a7588d..06e33df 100644 --- a/CHANGELOG.mkdn +++ b/CHANGELOG.mkdn @@ -60,6 +60,7 @@ CHANGELOG * Founder, admin, and halfop support - Kiooeht [evacipatedBox] * Button for direct access to logs directory - Kiooeht [evacipatedBox] * Minimizable memo userlist - Kiooeht [evacipatedBox] (Idea: [alGore], [lostGash]) +* Chumroll notifications on chum sign-in/out - Kiooeht [evacipatedBox] * Bug fixes * Logviewer updates - Kiooeht [evacipatedBox] * Memo scrollbar thing - Kiooeht [evacipatedBox] diff --git a/TODO.mkdn b/TODO.mkdn index 41bece4..a7a2bb3 100644 --- a/TODO.mkdn +++ b/TODO.mkdn @@ -18,7 +18,7 @@ Features * Customizable name alerts * When 'banned' make impossible to connect using timestamp banned under * Explain why a chumhandle is invalid -* Notify on sign on/offs in chumroll (toasts) +* Fully working Toasts * Auto download/install updates via Windows installer Bugs diff --git a/pesterchum.py b/pesterchum.py index be1b3a7..53b1d0a 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -641,16 +641,42 @@ class chumListing(QtGui.QTreeWidgetItem): self.chum = chum self.handle = chum.handle self.setMood(Mood("offline")) + self.status = None def setMood(self, mood): + if self.mainwindow.chumList.notify: + #print "%s -> %s" % (self.chum.mood.name(), mood.name()) + if mood.name() == "offline" and self.chum.mood.name() != "offline": + #print "OFFLINE NOTIFY: " + self.handle + uri = "file://" + os.path.abspath(os.path.curdir) + "/themes/enamel/distraught2.gif" + n = self.mainwindow.tm.Toast(self.mainwindow.tm.appName, + "%s is Offline" % (self.handle), uri) + #n.show() + elif mood.name() != "offline" and self.chum.mood.name() == "offline": + #print "ONLINE NOTIFY: " + self.handle + uri = "file://" + os.path.abspath(os.path.curdir) + "/themes/enamel/chummy2.gif" + n = self.mainwindow.tm.Toast(self.mainwindow.tm.appName, + "%s is Online" % (self.handle), uri) + #n.show() + login = False + logout = False + if mood.name() == "offline" and self.chum.mood.name() != "offline": + logout = True + elif mood.name() != "offline" and self.chum.mood.name() == "offline": + login = True self.chum.mood = mood - self.updateMood() + self.updateMood(login=login, logout=logout) def setColor(self, color): self.chum.color = color - def updateMood(self, unblock=False): + def updateMood(self, unblock=False, login=False, logout=False): mood = self.chum.mood self.mood = mood icon = self.mood.icon(self.mainwindow.theme) - self.setIcon(0, icon) + if login: + self.login() + elif logout: + self.logout() + else: + self.setIcon(0, icon) try: self.setTextColor(0, QtGui.QColor(self.mainwindow.theme["main/chums/moods"][self.mood.name()]["color"])) except KeyError: @@ -662,6 +688,23 @@ class chumListing(QtGui.QTreeWidgetItem): self.setTextColor(0, QtGui.QColor(self.mainwindow.theme["main/chums/moods"][self.mood.name()]["color"])) except KeyError: self.setTextColor(0, QtGui.QColor(self.mainwindow.theme["main/chums/moods/chummy/color"])) + def login(self): + self.setIcon(0, PesterIcon("themes/arrow_right.png")) + self.status = "in" + QtCore.QTimer.singleShot(5000, self.doneLogin) + def doneLogin(self): + icon = self.mood.icon(self.mainwindow.theme) + self.setIcon(0, icon) + def logout(self): + self.setIcon(0, PesterIcon("themes/arrow_left.png")) + self.status = "out" + QtCore.QTimer.singleShot(5000, self.doneLogout) + def doneLogout(self): + hideoff = self.mainwindow.config.hideOfflineChums() + icon = self.mood.icon(self.mainwindow.theme) + self.setIcon(0, icon) + if hideoff and self.status and self.status == "out": + self.mainwindow.chumList.takeItem(self) def __lt__(self, cl): h1 = self.handle.lower() h2 = cl.handle.lower() @@ -670,6 +713,8 @@ class chumListing(QtGui.QTreeWidgetItem): class chumArea(RightClickTree): def __init__(self, chums, parent=None): QtGui.QTreeWidget.__init__(self, parent) + self.notify = False + QtCore.QTimer.singleShot(5000, self, QtCore.SLOT('beginNotify()')) self.mainwindow = parent theme = self.mainwindow.theme self.chums = chums @@ -744,6 +789,11 @@ class chumArea(RightClickTree): self.connect(self, QtCore.SIGNAL('itemDoubleClicked(QTreeWidgetItem *, int)'), self, QtCore.SLOT('expandGroup()')) + @QtCore.pyqtSlot() + def beginNotify(self): + print "BEGIN NOTIFY" + self.notify = True + def getOptionsMenu(self): text = str(self.currentItem().text(0)) if text.rfind(" (") != -1: @@ -1036,7 +1086,7 @@ class chumArea(RightClickTree): for c in chums: if (hasattr(c, 'mood')): c.setMood(mood) - self.takeItem(c) + #self.takeItem(c) chums = [] for c in chums: if (hasattr(c, 'mood')): diff --git a/themes/arrow_left.png b/themes/arrow_left.png new file mode 100644 index 0000000000000000000000000000000000000000..275d0ebf8760fb04a335ca1e6468679b0d008ce9 GIT binary patch literal 355 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgg)4t7=n?Vt8C=YT?wJzX3_EKWZS zw$3`@z*8&SrhDw_7w^0Ys^KRN)^OZE@Zj9hkayd>riUbUi&!>FKfX4}W|pULx_yq| zX5R!>Cm|1h+j%KP=XM;GD_H#3xIy5MTFZub<^=s${-Jl*F&cDpDYiHVitMhOXUM}m zL(+vskWsL)2D$~vYa5)+HtI_3ngc>U|J<@cPmuJ^x79RK+0))^i_#~#7h>ypJ)ouQ$%ohOt9 v_fARuxh={~uu^H!_5FPF19v=*|G_p@dT$vs^A|&)cNsig{an^LB{Ts5z<`Kn literal 0 HcmV?d00001 diff --git a/themes/arrow_right.png b/themes/arrow_right.png new file mode 100644 index 0000000000000000000000000000000000000000..6c061a6bfa20d139a714342ffdfc8fbca5e80962 GIT binary patch literal 363 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgg)4t7=nqq!kl_<%yMJzX3_EKWb2 zyx#9<0MD`g-gzF+($$s)Hn0@VPtNl<+IfA(?AZ~0?gBCvPEMPAm6lIm^VTvpF#3mj z!)lKBpo?mMzk1JpcZTQq3l{fR{fwtJ?a}Od^yNB(l9j>d&$n-#J9A;%TE>P|hpPDn z8I7Ae6qFQ{1Oy*hw0)O5Y+w@_TFS}rd+L;BnrC=UZ*mCT&Y`&Hbg1ZMlh~BVZx>9? zUagzEW|hI_wTY~?EG+^co%=06+*|y5mwv9X@v}-d5m%2%ERQV~z5nh0{7&NSgXL46 z|1>qe-*uw9_}!c1;VWMMigS7A#PNLox)0~;ABsBH9SFJpBjO3r+YFwrelF{r5}E*% CrIWD$ literal 0 HcmV?d00001