src/eric7/Network/IRC/IrcChannelWidget.py

branch
eric7
changeset 9413
80c06d472826
parent 9221
bf71ee032bb4
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9412:45e7bb09c120 9413:80c06d472826
29 QApplication, 29 QApplication,
30 QInputDialog, 30 QInputDialog,
31 QLineEdit, 31 QLineEdit,
32 ) 32 )
33 33
34 from EricWidgets import EricMessageBox, EricFileDialog 34 from eric7.EricWidgets import EricMessageBox, EricFileDialog
35 from EricWidgets.EricApplication import ericApp 35 from eric7.EricWidgets.EricApplication import ericApp
36 36
37 from .Ui_IrcChannelWidget import Ui_IrcChannelWidget 37 from .Ui_IrcChannelWidget import Ui_IrcChannelWidget
38 38
39 from .IrcUtilities import ircFilter, ircTimestamp, getChannelModesDict 39 from .IrcUtilities import ircFilter, ircTimestamp, getChannelModesDict
40 40
41 import Utilities 41 from eric7.EricGui import EricPixmapCache
42 import UI.PixmapCache 42 from eric7 import Preferences, Utilities
43 import Preferences 43
44 44 from eric7.UI.Info import Version, Copyright
45 from UI.Info import Version, Copyright
46 45
47 46
48 class IrcUserItem(QListWidgetItem): 47 class IrcUserItem(QListWidgetItem):
49 """ 48 """
50 Class implementing a list widget item containing an IRC channel user. 49 Class implementing a list widget item containing an IRC channel user.
138 """ 137 """
139 Private method to set the icon dependent on user privileges. 138 Private method to set the icon dependent on user privileges.
140 """ 139 """
141 # step 1: determine the icon 140 # step 1: determine the icon
142 if self.__privilege & IrcUserItem.Voice: 141 if self.__privilege & IrcUserItem.Voice:
143 icon = UI.PixmapCache.getIcon("ircVoice") 142 icon = EricPixmapCache.getIcon("ircVoice")
144 elif self.__privilege & IrcUserItem.Owner: 143 elif self.__privilege & IrcUserItem.Owner:
145 icon = UI.PixmapCache.getIcon("ircOwner") 144 icon = EricPixmapCache.getIcon("ircOwner")
146 elif self.__privilege & IrcUserItem.Operator: 145 elif self.__privilege & IrcUserItem.Operator:
147 icon = UI.PixmapCache.getIcon("ircOp") 146 icon = EricPixmapCache.getIcon("ircOp")
148 elif self.__privilege & IrcUserItem.Halfop: 147 elif self.__privilege & IrcUserItem.Halfop:
149 icon = UI.PixmapCache.getIcon("ircHalfop") 148 icon = EricPixmapCache.getIcon("ircHalfop")
150 elif self.__privilege & IrcUserItem.Admin: 149 elif self.__privilege & IrcUserItem.Admin:
151 icon = UI.PixmapCache.getIcon("ircAdmin") 150 icon = EricPixmapCache.getIcon("ircAdmin")
152 else: 151 else:
153 icon = UI.PixmapCache.getIcon("ircNormal") 152 icon = EricPixmapCache.getIcon("ircNormal")
154 if self.__privilege & IrcUserItem.Away: 153 if self.__privilege & IrcUserItem.Away:
155 icon = self.__awayIcon(icon) 154 icon = self.__awayIcon(icon)
156 155
157 # step 2: set the icon 156 # step 2: set the icon
158 self.setIcon(icon) 157 self.setIcon(icon)
163 162
164 @param icon icon to be converted (QIcon) 163 @param icon icon to be converted (QIcon)
165 @return away icon (QIcon) 164 @return away icon (QIcon)
166 """ 165 """
167 pix1 = icon.pixmap(16, 16) 166 pix1 = icon.pixmap(16, 16)
168 pix2 = UI.PixmapCache.getPixmap("ircAway") 167 pix2 = EricPixmapCache.getPixmap("ircAway")
169 painter = QPainter(pix1) 168 painter = QPainter(pix1)
170 painter.drawPixmap(0, 0, pix2) 169 painter.drawPixmap(0, 0, pix2)
171 painter.end() 170 painter.end()
172 return QIcon(pix1) 171 return QIcon(pix1)
173 172
271 self.setupUi(self) 270 self.setupUi(self)
272 271
273 self.__ui = ericApp().getObject("UserInterface") 272 self.__ui = ericApp().getObject("UserInterface")
274 self.__ircWidget = parent 273 self.__ircWidget = parent
275 274
276 self.editTopicButton.setIcon(UI.PixmapCache.getIcon("ircEditTopic")) 275 self.editTopicButton.setIcon(EricPixmapCache.getIcon("ircEditTopic"))
277 self.editTopicButton.hide() 276 self.editTopicButton.hide()
278 277
279 height = self.usersList.height() + self.messages.height() 278 height = self.usersList.height() + self.messages.height()
280 self.splitter.setSizes([int(height * 0.3), int(height * 0.7)]) 279 self.splitter.setSizes([int(height * 0.3), int(height * 0.7)])
281 280
708 ) 707 )
709 ) 708 )
710 if Preferences.getIrc("ShowNotifications"): 709 if Preferences.getIrc("ShowNotifications"):
711 if Preferences.getIrc("NotifyMessage"): 710 if Preferences.getIrc("NotifyMessage"):
712 self.__ui.showNotification( 711 self.__ui.showNotification(
713 UI.PixmapCache.getPixmap("irc48"), self.tr("Channel Message"), msg 712 EricPixmapCache.getPixmap("irc48"), self.tr("Channel Message"), msg
714 ) 713 )
715 elif ( 714 elif (
716 Preferences.getIrc("NotifyNick") 715 Preferences.getIrc("NotifyNick")
717 and self.__userName.lower() in msg.lower() 716 and self.__userName.lower() in msg.lower()
718 ): 717 ):
719 self.__ui.showNotification( 718 self.__ui.showNotification(
720 UI.PixmapCache.getPixmap("irc48"), self.tr("Nick mentioned"), msg 719 EricPixmapCache.getPixmap("irc48"), self.tr("Nick mentioned"), msg
721 ) 720 )
722 721
723 def addUsers(self, users): 722 def addUsers(self, users):
724 """ 723 """
725 Public method to add users to the channel. 724 Public method to add users to the channel.
752 self.__addManagementMessage(IrcChannelWidget.JoinIndicator, msg) 751 self.__addManagementMessage(IrcChannelWidget.JoinIndicator, msg)
753 if Preferences.getIrc("ShowNotifications") and Preferences.getIrc( 752 if Preferences.getIrc("ShowNotifications") and Preferences.getIrc(
754 "NotifyJoinPart" 753 "NotifyJoinPart"
755 ): 754 ):
756 self.__ui.showNotification( 755 self.__ui.showNotification(
757 UI.PixmapCache.getPixmap("irc48"), self.tr("Join Channel"), msg 756 EricPixmapCache.getPixmap("irc48"), self.tr("Join Channel"), msg
758 ) 757 )
759 return True 758 return True
760 759
761 return False 760 return False
762 761
785 self.__addManagementMessage(IrcChannelWidget.LeaveIndicator, msg) 784 self.__addManagementMessage(IrcChannelWidget.LeaveIndicator, msg)
786 if Preferences.getIrc("ShowNotifications") and Preferences.getIrc( 785 if Preferences.getIrc("ShowNotifications") and Preferences.getIrc(
787 "NotifyJoinPart" 786 "NotifyJoinPart"
788 ): 787 ):
789 self.__ui.showNotification( 788 self.__ui.showNotification(
790 UI.PixmapCache.getPixmap("irc48"), self.tr("Leave Channel"), nmsg 789 EricPixmapCache.getPixmap("irc48"), self.tr("Leave Channel"), nmsg
791 ) 790 )
792 return True 791 return True
793 792
794 return False 793 return False
795 794
814 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, msg) 813 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, msg)
815 if Preferences.getIrc("ShowNotifications") and Preferences.getIrc( 814 if Preferences.getIrc("ShowNotifications") and Preferences.getIrc(
816 "NotifyJoinPart" 815 "NotifyJoinPart"
817 ): 816 ):
818 self.__ui.showNotification( 817 self.__ui.showNotification(
819 UI.PixmapCache.getPixmap("irc48"), self.tr("Quit"), msg 818 EricPixmapCache.getPixmap("irc48"), self.tr("Quit"), msg
820 ) 819 )
821 820
822 # always return False for other channels and server to process 821 # always return False for other channels and server to process
823 return False 822 return False
824 823
1458 """ 1457 """
1459 Private slot to initialize the context menu of the messages pane. 1458 Private slot to initialize the context menu of the messages pane.
1460 """ 1459 """
1461 self.__messagesMenu = QMenu(self) 1460 self.__messagesMenu = QMenu(self)
1462 self.__copyMessagesAct = self.__messagesMenu.addAction( 1461 self.__copyMessagesAct = self.__messagesMenu.addAction(
1463 UI.PixmapCache.getIcon("editCopy"), self.tr("Copy"), self.__copyMessages 1462 EricPixmapCache.getIcon("editCopy"), self.tr("Copy"), self.__copyMessages
1464 ) 1463 )
1465 self.__messagesMenu.addSeparator() 1464 self.__messagesMenu.addSeparator()
1466 self.__cutAllMessagesAct = self.__messagesMenu.addAction( 1465 self.__cutAllMessagesAct = self.__messagesMenu.addAction(
1467 UI.PixmapCache.getIcon("editCut"), self.tr("Cut all"), self.__cutAllMessages 1466 EricPixmapCache.getIcon("editCut"),
1467 self.tr("Cut all"),
1468 self.__cutAllMessages,
1468 ) 1469 )
1469 self.__copyAllMessagesAct = self.__messagesMenu.addAction( 1470 self.__copyAllMessagesAct = self.__messagesMenu.addAction(
1470 UI.PixmapCache.getIcon("editCopy"), 1471 EricPixmapCache.getIcon("editCopy"),
1471 self.tr("Copy all"), 1472 self.tr("Copy all"),
1472 self.__copyAllMessages, 1473 self.__copyAllMessages,
1473 ) 1474 )
1474 self.__messagesMenu.addSeparator() 1475 self.__messagesMenu.addSeparator()
1475 self.__clearMessagesAct = self.__messagesMenu.addAction( 1476 self.__clearMessagesAct = self.__messagesMenu.addAction(
1476 UI.PixmapCache.getIcon("editDelete"), self.tr("Clear"), self.__clearMessages 1477 EricPixmapCache.getIcon("editDelete"),
1478 self.tr("Clear"),
1479 self.__clearMessages,
1477 ) 1480 )
1478 self.__messagesMenu.addSeparator() 1481 self.__messagesMenu.addSeparator()
1479 self.__saveMessagesAct = self.__messagesMenu.addAction( 1482 self.__saveMessagesAct = self.__messagesMenu.addAction(
1480 UI.PixmapCache.getIcon("fileSave"), self.tr("Save"), self.__saveMessages 1483 EricPixmapCache.getIcon("fileSave"), self.tr("Save"), self.__saveMessages
1481 ) 1484 )
1482 self.__messagesMenu.addSeparator() 1485 self.__messagesMenu.addSeparator()
1483 self.__setMarkerMessagesAct = self.__messagesMenu.addAction( 1486 self.__setMarkerMessagesAct = self.__messagesMenu.addAction(
1484 self.tr("Mark Current Position"), self.setMarkerLine 1487 self.tr("Mark Current Position"), self.setMarkerLine
1485 ) 1488 )
1530 1533
1531 def __sendUserMessage(self): 1534 def __sendUserMessage(self):
1532 """ 1535 """
1533 Private slot to send a private message to a specific user. 1536 Private slot to send a private message to a specific user.
1534 """ 1537 """
1535 from EricWidgets import EricTextInputDialog 1538 from eric7.EricWidgets import EricTextInputDialog
1536 1539
1537 user = self.usersList.selectedItems()[0].text() 1540 user = self.usersList.selectedItems()[0].text()
1538 ok, message = EricTextInputDialog.getText( 1541 ok, message = EricTextInputDialog.getText(
1539 self, 1542 self,
1540 self.tr("Send Message"), 1543 self.tr("Send Message"),
1546 1549
1547 def __sendUserQuery(self): 1550 def __sendUserQuery(self):
1548 """ 1551 """
1549 Private slot to send a query message to a specific user. 1552 Private slot to send a query message to a specific user.
1550 """ 1553 """
1551 from EricWidgets import EricTextInputDialog 1554 from eric7.EricWidgets import EricTextInputDialog
1552 1555
1553 user = self.usersList.selectedItems()[0].text() 1556 user = self.usersList.selectedItems()[0].text()
1554 ok, message = EricTextInputDialog.getText( 1557 ok, message = EricTextInputDialog.getText(
1555 self, 1558 self,
1556 self.tr("Send Query"), 1559 self.tr("Send Query"),
1562 1565
1563 def __sendUserNotice(self): 1566 def __sendUserNotice(self):
1564 """ 1567 """
1565 Private slot to send a notice message to a specific user. 1568 Private slot to send a notice message to a specific user.
1566 """ 1569 """
1567 from EricWidgets import EricTextInputDialog 1570 from eric7.EricWidgets import EricTextInputDialog
1568 1571
1569 user = self.usersList.selectedItems()[0].text() 1572 user = self.usersList.selectedItems()[0].text()
1570 ok, message = EricTextInputDialog.getText( 1573 ok, message = EricTextInputDialog.getText(
1571 self, 1574 self,
1572 self.tr("Send Notice"), 1575 self.tr("Send Notice"),

eric ide

mercurial