示例#1
0
 def __init__(self, chats, user):
     self.chats = chats
     self.frame = chats.frame
     self.user = user
     self.Status = 0
     QtGui.QWidget.__init__(self, None)
     self.ui = Ui_Private()
     self.ui.setupUi(self)
     self.tag_remote = self.frame.makecolour(self.ui.ChatLog, "chatremote")
     self.tag_local = self.frame.makecolour(self.ui.ChatLog, "chatlocal")
     self.tag_me = self.frame.makecolour(self.ui.ChatLog, "chatme")
     self.tag_hilite = self.frame.makecolour(self.ui.ChatLog, "chathilite")
     if self.frame.user_stats.has_key(self.user):
         status = self.frame.user_stats[self.user][0]
         if status == 1:
             color = "useraway"
         elif status == 2:
             color = "useronline"
         else:
             color = "useroffline"
     else:
         color = "useroffline"
     self.tag_username = self.frame.makecolour(self.ui.ChatLog, color)
     self.connect(self.ui.ChatEntry, SIGNAL("returnPressed()"),
                  self.OnEnter)
     self.connect(self.ui.Close, SIGNAL("clicked()"), self.OnClose)
示例#2
0
文件: muqt.py 项目: TiBeN/museek-plus
	def __init__(self, chats, user):
		self.chats  = chats
		self.frame = chats.frame
		self.user = user
		self.Status = 0
		QtGui.QWidget.__init__(self, None)
		self.ui = Ui_Private()
		self.ui.setupUi(self)
		self.tag_remote = self.frame.makecolour(self.ui.ChatLog, "chatremote")
		self.tag_local = self.frame.makecolour(self.ui.ChatLog, "chatlocal")
		self.tag_me = self.frame.makecolour(self.ui.ChatLog, "chatme")
		self.tag_hilite = self.frame.makecolour(self.ui.ChatLog, "chathilite")
		if self.frame.user_stats.has_key(self.user):
			status = self.frame.user_stats[self.user][0]
			if status == 1:
				color = "useraway"
			elif status == 2:
				color = "useronline"
			else:
				color = "useroffline"
		else:
			color = "useroffline"
		self.tag_username = self.frame.makecolour(self.ui.ChatLog, color)
		self.connect(self.ui.ChatEntry, SIGNAL("returnPressed()" ), self.OnEnter)
		self.connect(self.ui.Close, SIGNAL("clicked()"), self.OnClose)
示例#3
0
class PrivateChat(QtGui.QWidget):
    def __init__(self, chats, user):
        self.chats = chats
        self.frame = chats.frame
        self.user = user
        self.Status = 0
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_Private()
        self.ui.setupUi(self)
        self.tag_remote = self.frame.makecolour(self.ui.ChatLog, "chatremote")
        self.tag_local = self.frame.makecolour(self.ui.ChatLog, "chatlocal")
        self.tag_me = self.frame.makecolour(self.ui.ChatLog, "chatme")
        self.tag_hilite = self.frame.makecolour(self.ui.ChatLog, "chathilite")
        if self.frame.user_stats.has_key(self.user):
            status = self.frame.user_stats[self.user][0]
            if status == 1:
                color = "useraway"
            elif status == 2:
                color = "useronline"
            else:
                color = "useroffline"
        else:
            color = "useroffline"
        self.tag_username = self.frame.makecolour(self.ui.ChatLog, color)
        self.connect(self.ui.ChatEntry, SIGNAL("returnPressed()"),
                     self.OnEnter)
        self.connect(self.ui.Close, SIGNAL("clicked()"), self.OnClose)

    def ShowMessage(self, direction, text):
        if self.user == self.frame.username:
            tag = self.tag_local
        elif text.upper().find(self.frame.username.upper()) > -1:
            tag = self.tag_hilite
        else:
            tag = self.tag_remote

        if direction == 0:
            username = self.user
        else:
            username = self.frame.username

        if text[:4] == "/me ":
            line = "* %s %s" % (username, text[4:])
            tag = self.tag_me
        else:
            line = "[%s] %s" % (username, text)
        #self.frame.RequestIcon(self.frame.PrivateChatLabel)
        AppendLine(self.ui.ChatLog,
                   line,
                   tag,
                   "%c",
                   username=self.user,
                   usertag=self.tag_username)
        #if self.z:
        #self.z = 0
        #self.tag_username.set_property("foreground", "#00FF00")
        #else:
        #self.z = 1
        #self.tag_username.set_property("foreground", "#FF0000")
        #if self.Log.get_active():
        #self.logfile = WriteLog(self.logfile, self.frame.Config["logging"]["logsdir"], self.user, line)
        #self.frame.Logging.PrivateChatLog( direction, self.user, text)

        #autoreply = self.frame.np.config.sections["server"]["autoreply"]
        #if self.frame.away and not self.autoreplied and autoreply:
        #self.SendMessage("[Auto-Message] %s" % autoreply)
        #self.autoreplied = 1
    def OnClose(self):
        self.chats.OnClose(self.user)

    def OnEnter(self):
        text = str(self.ui.ChatEntry.text())

        if text[:2] == "//":
            text = text[1:]
        self.SendMessage(text)
        self.frame.Networking.PrivateMessage(0, self.user, text)
        self.ui.ChatEntry.clear()

    def SendMessage(self, text):

        if text[:4] == "/me ":
            line = "* %s %s" % (self.frame.username, text[4:])
            tag = self.tag_me
        else:

            if text == "\x01VERSION\x01":
                line = "CTCP VERSION"
            else:
                line = "[%s] %s" % (self.frame.username, text)
            tag = self.tag_local

        AppendLine(self.ui.ChatLog,
                   line,
                   tag,
                   "%c",
                   username=self.user,
                   usertag=self.tag_username)
示例#4
0
文件: muqt.py 项目: TiBeN/museek-plus
class PrivateChat(QtGui.QWidget):
	def __init__(self, chats, user):
		self.chats  = chats
		self.frame = chats.frame
		self.user = user
		self.Status = 0
		QtGui.QWidget.__init__(self, None)
		self.ui = Ui_Private()
		self.ui.setupUi(self)
		self.tag_remote = self.frame.makecolour(self.ui.ChatLog, "chatremote")
		self.tag_local = self.frame.makecolour(self.ui.ChatLog, "chatlocal")
		self.tag_me = self.frame.makecolour(self.ui.ChatLog, "chatme")
		self.tag_hilite = self.frame.makecolour(self.ui.ChatLog, "chathilite")
		if self.frame.user_stats.has_key(self.user):
			status = self.frame.user_stats[self.user][0]
			if status == 1:
				color = "useraway"
			elif status == 2:
				color = "useronline"
			else:
				color = "useroffline"
		else:
			color = "useroffline"
		self.tag_username = self.frame.makecolour(self.ui.ChatLog, color)
		self.connect(self.ui.ChatEntry, SIGNAL("returnPressed()" ), self.OnEnter)
		self.connect(self.ui.Close, SIGNAL("clicked()"), self.OnClose)
		
	def ShowMessage(self, direction, text):
		if self.user == self.frame.username:
			tag = self.tag_local
		elif text.upper().find(self.frame.username.upper()) > -1:
			tag = self.tag_hilite
		else:
			tag = self.tag_remote
		
		if direction == 0:
			username = self.user
		else:
			username = self.frame.username
				
		if text[:4] == "/me ":
			line = "* %s %s" % (username, text[4:])
			tag = self.tag_me
		else:
			line = "[%s] %s" % (username, text)
		#self.frame.RequestIcon(self.frame.PrivateChatLabel)
		AppendLine(self.ui.ChatLog, line, tag, "%c", username=self.user, usertag=self.tag_username)
		#if self.z:
			#self.z = 0
			#self.tag_username.set_property("foreground", "#00FF00")
		#else:
			#self.z = 1
			#self.tag_username.set_property("foreground", "#FF0000")
		#if self.Log.get_active():
			#self.logfile = WriteLog(self.logfile, self.frame.Config["logging"]["logsdir"], self.user, line)
			#self.frame.Logging.PrivateChatLog( direction, self.user, text)
		
		#autoreply = self.frame.np.config.sections["server"]["autoreply"]
		#if self.frame.away and not self.autoreplied and autoreply:
			#self.SendMessage("[Auto-Message] %s" % autoreply)
			#self.autoreplied = 1
	def OnClose(self):
		self.chats.OnClose(self.user)

		
	def OnEnter(self):
		text = str(self.ui.ChatEntry.text())
		
		if text[:2] == "//":
			text = text[1:]
		self.SendMessage(text)
		self.frame.Networking.PrivateMessage(0, self.user, text)
		self.ui.ChatEntry.clear()
		
	def SendMessage(self, text):
		
		if text[:4] == "/me ":
			line = "* %s %s" % (self.frame.username, text[4:])
			tag = self.tag_me
		else:
			
			if text == "\x01VERSION\x01":
				line = "CTCP VERSION"
			else:
				line = "[%s] %s" % (self.frame.username, text)
			tag = self.tag_local
			
		AppendLine(self.ui.ChatLog, line, tag, "%c", username=self.user, usertag= self.tag_username)