From d12658f79e38f8a8b3c42cbaa97b76cfd63f25e7 Mon Sep 17 00:00:00 2001 From: stack Date: Mon, 9 Jul 2012 02:16:13 +0200 Subject: [PATCH] current profile icon --- current-profile.png | Bin 0 -> 1289 bytes gui.py | 15 +++++++++------ profhandler.py | 11 +++++++++++ settings.py | 1 + 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 current-profile.png diff --git a/current-profile.png b/current-profile.png new file mode 100644 index 0000000000000000000000000000000000000000..bc316c19dd1c311253c7f1620dc223e31f240e17 GIT binary patch literal 1289 zcmV+k1@`)hP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2iyk< z01pJ_^*y)%00fCiL_t(I%Z-$8Y*SSj#-DTloO}C^mTtOr8_Na^1q2B=C&&arHj(HM zLn4Mmvk?5o5(o)Vv?&W@3GzjvBoG3IFFM19gE_vKiHiFp9ReE1+(zRDWrMA~ZSQ(| zdwY)`z$saodz1IeNzO0N`@H8ogmaF^Rl|{n6*3X_5`qddlPQu!ahP*-rMY!@-=2Lz zOj9HqI1mU(PM3Pn?r`kd`06G#@5wwUii%WH1$>8O+>lD>y-_>xWVa1HVG7RU0Hpf@zvaCMTe25o9tM zcsw~|g0YGjf#dN+kt9g~IFiW;n5GFz6$pX=%d#ewQ%WIIikKEFnh`jiP7g<;krGO6 z007f8kw~OK2m$9Dq9{VojKfJw5E&msI&BWm$YWjCyF#H5x7+QYQ~{+56h#H46pErk zrZUc4+Ygya7#JMjx<1i0BXA@ZJKS`xnHh!wS$+WhZx2SVVkp{+j=}S2YCgxbNbK;8 zz^6}~4r-cq^yH~i24hKxq6krx9=3?izgm!An1iP7&$(q;M;jX(ga7;U0)c>_I^?%S zA~f8;Kb{}H8u(y~Ha zYPp6J@BN03A3NAD!7FF#1BZ4#;&I*Xx*D%HXWOckt8HUr_YjLkF+M(uNaQ|rT?bN(MKnOmbE&`v)UxOUG z52LfXK@}MTSMR~?lQ3`L9Q<%`>h1_oPd>X{&8LG}oTL3h7xY*f8#b4t^ZV=AT)ZD& z{a%l?HOrvdl&trprZ2ubFrDJ!xjrmkxd^@224SR3h|Gm01#8eZ){VBW&t?yKpq>Cw z->BKt{nnN@mpB|YP^zG$q!g(X0~a#*37QrKV+^frZRX9s{>uOyggi)Z7l73-tg1LcCD{iNli~hP ziHrNm?8QkE?U%UOv+$9faL$1YV3_G}=g(a`09@vr$H~JdHw%Ez?RFP(&Zi`vtH_%5 z)I02Wq)$3FaE@M@;wd4frfIhU+yM~hoLheb;CcMl_?Zn900000NkvXXu0mjfrh-Xe literal 0 HcmV?d00001 diff --git a/gui.py b/gui.py index a54d423..7b7fd57 100755 --- a/gui.py +++ b/gui.py @@ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import sys import os -from PyQt4 import QtGui +from PyQt4 import QtGui, QtCore from PyQt4.QtCore import SIGNAL from qmenutooltip import QMenuToolTip @@ -91,7 +91,7 @@ class Gui(QtGui.QDialog): #profile manager component self.addProfile = QtGui.QAction(" Add &Profile ", self, - triggered=self.addProfile, icon=QtGui.QIcon(appconf.icon)) + triggered=self.addProfile) def createTrayIcon(self): @@ -120,15 +120,18 @@ class Gui(QtGui.QDialog): if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick): self.menuProfiles = QMenuToolTip() self.menuProfiles.setTitle("Profiles") + QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_DontShowIconsInMenus, False) #Get profiles from the ProfHandler embedded in the gui profiles = self.profileManager.getProfilesList() - for pr in profiles: - #pr is a profile path - receiver = self.activateProfileAction(pr) - pr = os.path.basename(pr) + for prpath in profiles: + pr = os.path.basename(prpath) + receiver = self.activateProfileAction(prpath) menuItem_Profile = self.menuProfiles.addAction(pr) + if self.profileManager.isCurrentProfile(prpath): + menuItem_Profile.setIcon(QtGui.QIcon(appconf.cpicon)) + #Using lambda function to pass additional arguments to the function, in this case the path of the profile self.connect(menuItem_Profile, SIGNAL('triggered()'), receiver) #set menu item ToolTip diff --git a/profhandler.py b/profhandler.py index 19a6b97..d0fbb17 100755 --- a/profhandler.py +++ b/profhandler.py @@ -111,7 +111,18 @@ class ProfHandler(): raise AppError('Profile Name not valid') print("Profile "+profileName+" created.") + def isCurrentProfile(self, ppath): + """ Returns true if the current profile path is currently activated """ + + pl = platform.system() + if pl in ('Linux','Darwin'): + if os.path.exists(self.getDropboxDirectory()): + return True if os.readlink(self.getDropboxDirectory()) == ppath else False + else: + return False + def isValidProfileName(self, pname): + if self.reg.match(pname) is not None: return True else: diff --git a/settings.py b/settings.py index b9fb468..38859e7 100644 --- a/settings.py +++ b/settings.py @@ -38,6 +38,7 @@ class Settings(): self.appname = "dboxswitch" self.appversion = "0.1" self.icon = "./icon.png" + self.cpicon = "./current-profile.png" global conf appconf = Settings() -- 2.20.1