+ #left click profiles show
+ self.trayIcon.activated.connect(self.showTrayProfiles)
+
+
+ def showTrayProfiles(self,reason):
+ if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick):
+ print "Catched left click"
+ self.menuProfiles = QtGui.QMenu()
+ self.menuProfiles.setTitle("Profiles")
+
+ profiles = self.profileManager.getProfilesList()
+
+ for pr in profiles:
+ pr = os.path.basename(pr)
+ menuItem_Profile = self.menuProfiles.addAction(pr)
+
+ #Using lambda function to pass additional arguments to the function, in this case the path of the profile
+ receiver = lambda pr=pr: self.profileManager.activateProfile(pr)
+ self.connect(menuItem_Profile, SIGNAL('triggered()'), receiver)
+
+ self.menuProfiles.addAction(menuItem_Profile)
+
+ #menuItem_Profile = self.menuProfiles.addAction("")
+ #self.menuProfiles.addAction(menuItem_Profile)
+ self.menuProfiles.addSeparator()
+ menuItem_Profile = QtGui.QAction(" Add &Profile ", self,
+ triggered=self.addProfile, icon=QtGui.QIcon(appconf.icon))
+ self.menuProfiles.addAction(menuItem_Profile)
+
+ self.menuProfiles.activateWindow()
+ self.menuProfiles.popup(QtGui.QCursor.pos())
+
+ def addProfile(self):
+ self.setWindowTitle("Add New Profile - Dboxswitch - dropbox profile switcher")
+ self.resize(300, 100)
+ text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog',
+ 'Enter profile name:')
+
+ if ok:
+ try:
+ self.profileManager.addProfile(unicode(text))
+ except AppError, e:
+ self.showError(str(e))
+