def OnAuthTumblr(self): self.User = self.le_mail.text() self.Password = self.le_password.text() self.Blog = self.le_url.text() self.error = None if not self.User.isEmpty() | self.Password.isEmpty() | self.Blog.isEmpty(): self.api = Api(self.Blog,self.User,self.Password) try: self.auth = self.api.auth_check() #Abrir la ventana del dashboard dashboard = Dashboard(self) self.hide() dashboard.show() #print 'Te haz logueado' except TumblrAuthError: self.error = errors['403'] except urllib2.HTTPError: self.error = errors['404'] except urllib2.URLError: self.error = errors['urlopen'] finally: if self.error != None: QtGui.QMessageBox.warning(self,'Error','Occurrio un error: \n' + self.error,QtGui.QMessageBox.Ok) else: QtGui.QMessageBox.warning(self,'Error','Todos los Campos son necesarios',QtGui.QMessageBox.Ok)
def OnAuthTumblr(self): self.User = self.le_mail.text().trimmed() self.Password = self.le_password.text() self.Blog = self.le_url.text().trimmed() self.error = None if not self.User.isEmpty() | self.Password.isEmpty() | self.Blog.isEmpty(): self.api = Api(self.Blog,self.User,self.Password) try: self.auth = self.api.auth_check() if QtGui.QSystemTrayIcon.isSystemTrayAvailable(): self.hide() tray = TumblrTray(self) else: dashboard = Dashboard(self) self.hide() dashboard.show() if self.rememberme.checkState() == 2: file = open(QtCore.QDir().homePath() + '/.opentumblr','w') file.write(self.le_mail.text()) file.write(self.le_url.text()) except TumblrAuthError: self.error = errors['403'] except urllib2.HTTPError: self.error = errors['404'] except urllib2.URLError: self.error = errors['urlopen'] finally: if self.error != None: QtGui.QMessageBox.warning(self,'Error','Occurrio un error: \n' + self.error,QtGui.QMessageBox.Ok) else: QtGui.QMessageBox.warning(self,'Error','Todos los Campos son necesarios',QtGui.QMessageBox.Ok)
def __init__(self,parent=None): super(TumblrTray, self).__init__(parent) self.setupUi(parent) #Dashboard instance self.dashboard = Dashboard(parent) self.p = parent #Connecting events self.connect(self.tray,QtCore.SIGNAL('activated(QSystemTrayIcon::ActivationReason)'),self.OnClick) self.connect(self.Text,QtCore.SIGNAL('triggered()'),self.OnText) self.connect(self.Photo, QtCore.SIGNAL('triggered()'), self.OnPhoto) self.connect(self.Quote, QtCore.SIGNAL('triggered()'), self.OnQuote) self.connect(self.Url, QtCore.SIGNAL('triggered()'), self.OnUrl) self.connect(self.Chat, QtCore.SIGNAL('triggered()'), self.OnChat) self.connect(self.Audio, QtCore.SIGNAL('triggered()'), self.OnAudio) self.connect(self.Video, QtCore.SIGNAL('triggered()'), self.OnVideo) self.connect(self.Exit, QtCore.SIGNAL('triggered()'), self.OnLogout)
class TumblrTray(QtGui.QSystemTrayIcon): def __init__(self,parent=None): super(TumblrTray, self).__init__(parent) self.setupUi(parent) #Dashboard instance self.dashboard = Dashboard(parent) self.p = parent #Connecting events self.connect(self.tray,QtCore.SIGNAL('activated(QSystemTrayIcon::ActivationReason)'),self.OnClick) self.connect(self.Text,QtCore.SIGNAL('triggered()'),self.OnText) self.connect(self.Photo, QtCore.SIGNAL('triggered()'), self.OnPhoto) self.connect(self.Quote, QtCore.SIGNAL('triggered()'), self.OnQuote) self.connect(self.Url, QtCore.SIGNAL('triggered()'), self.OnUrl) self.connect(self.Chat, QtCore.SIGNAL('triggered()'), self.OnChat) self.connect(self.Audio, QtCore.SIGNAL('triggered()'), self.OnAudio) self.connect(self.Video, QtCore.SIGNAL('triggered()'), self.OnVideo) self.connect(self.Exit, QtCore.SIGNAL('triggered()'), self.OnLogout) def setupUi(self,parent): icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap("/usr/share/pixmaps/opentumblr-qt/dashboard/opentumblr_icon.jpg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tray = QtGui.QSystemTrayIcon(parent) self.tray.setIcon(icon) self.tray.show() #Creating the context menu self.Traymenu = QtGui.QMenu(parent) self.Text = QtGui.QAction("&Text",parent) self.Photo = QtGui.QAction("&Photo",parent) self.Quote = QtGui.QAction("&Quote",parent) self.Url = QtGui.QAction("&Url",parent) self.Chat = QtGui.QAction("&Chat",parent) self.Audio = QtGui.QAction("&Audio",parent) self.Video = QtGui.QAction("&Video",parent) self.Exit = QtGui.QAction("&Exit",parent) self.Traymenu.addAction(self.Text) self.Traymenu.addAction(self.Photo) self.Traymenu.addAction(self.Quote) self.Traymenu.addAction(self.Url) self.Traymenu.addAction(self.Chat) self.Traymenu.addAction(self.Audio) self.Traymenu.addAction(self.Video) self.Traymenu.addAction(self.Exit) self.setContextMenu(self.Traymenu) def OnClick(self,reason): #Dashboard if reason == QtGui.QSystemTrayIcon.DoubleClick: if self.dashboard.isVisible(): self.dashboard.hide() else: self.dashboard.show() #Direct posting options (showing context menu) if reason == QtGui.QSystemTrayIcon.Context: self.contextMenu().popup(QtGui.QCursor.pos()) def OnText(self): text = Text(self.parent()) text.show() def OnPhoto(self): photo = Photo(self.parent()) photo.show() def OnQuote(self): quote = Quote(self.parent()) quote.show() def OnUrl(self): link = Link(self.parent()) link.show() def OnChat(self): chat = Chat(self.parent()) chat.show() def OnAudio(self): audio = Audio(None,self.parent().api) audio.show() def OnVideo(self): video = Video(self.parent()) video.show() def OnLogout(self): self.parent().close()