src/eric7/Cooperation/ChatWidget.py

branch
eric7
changeset 9413
80c06d472826
parent 9221
bf71ee032bb4
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9412:45e7bb09c120 9413:80c06d472826
11 11
12 from PyQt6.QtCore import Qt, pyqtSlot, pyqtSignal, QDateTime, QPoint 12 from PyQt6.QtCore import Qt, pyqtSlot, pyqtSignal, QDateTime, QPoint
13 from PyQt6.QtGui import QColor 13 from PyQt6.QtGui import QColor
14 from PyQt6.QtWidgets import QWidget, QListWidgetItem, QMenu, QApplication 14 from PyQt6.QtWidgets import QWidget, QListWidgetItem, QMenu, QApplication
15 15
16 from EricWidgets.EricApplication import ericApp 16 from eric7.EricWidgets.EricApplication import ericApp
17 from EricWidgets import EricMessageBox, EricFileDialog 17 from eric7.EricWidgets import EricMessageBox, EricFileDialog
18 18
19 from Globals import recentNameHosts 19 from eric7.Globals import recentNameHosts
20 20
21 from .CooperationClient import CooperationClient 21 from .CooperationClient import CooperationClient
22 22
23 from .Ui_ChatWidget import Ui_ChatWidget 23 from .Ui_ChatWidget import Ui_ChatWidget
24 24
25 import Preferences 25 from eric7 import Preferences
26 import UI.PixmapCache 26 from eric7.EricGui import EricPixmapCache
27 27
28 28
29 class ChatWidget(QWidget, Ui_ChatWidget): 29 class ChatWidget(QWidget, Ui_ChatWidget):
30 """ 30 """
31 Class implementing the chat dialog. 31 Class implementing the chat dialog.
57 @param parent reference to the parent widget (QWidget) 57 @param parent reference to the parent widget (QWidget)
58 """ 58 """
59 super().__init__(parent) 59 super().__init__(parent)
60 self.setupUi(self) 60 self.setupUi(self)
61 61
62 self.shareButton.setIcon(UI.PixmapCache.getIcon("sharedEditDisconnected")) 62 self.shareButton.setIcon(EricPixmapCache.getIcon("sharedEditDisconnected"))
63 self.startEditButton.setIcon(UI.PixmapCache.getIcon("sharedEditStart")) 63 self.startEditButton.setIcon(EricPixmapCache.getIcon("sharedEditStart"))
64 self.sendEditButton.setIcon(UI.PixmapCache.getIcon("sharedEditSend")) 64 self.sendEditButton.setIcon(EricPixmapCache.getIcon("sharedEditSend"))
65 self.cancelEditButton.setIcon(UI.PixmapCache.getIcon("sharedEditCancel")) 65 self.cancelEditButton.setIcon(EricPixmapCache.getIcon("sharedEditCancel"))
66 66
67 self.hostEdit.lineEdit().setClearButtonEnabled(True) 67 self.hostEdit.lineEdit().setClearButtonEnabled(True)
68 68
69 self.__ui = ui 69 self.__ui = ui
70 self.__client = CooperationClient(self) 70 self.__client = CooperationClient(self)
174 ) 174 )
175 self.chatEdit.append(self.tr("* {0} has joined.\n").format(nick)) 175 self.chatEdit.append(self.tr("* {0} has joined.\n").format(nick))
176 self.chatEdit.setTextColor(color) 176 self.chatEdit.setTextColor(color)
177 177
178 QListWidgetItem( 178 QListWidgetItem(
179 UI.PixmapCache.getIcon( 179 EricPixmapCache.getIcon(
180 "chatUser{0}".format(1 + self.usersList.count() % 6) 180 "chatUser{0}".format(1 + self.usersList.count() % 6)
181 ), 181 ),
182 nick, 182 nick,
183 self.usersList, 183 self.usersList,
184 ) 184 )
186 if not self.__connected: 186 if not self.__connected:
187 self.__setConnected(True) 187 self.__setConnected(True)
188 188
189 if not self.isVisible(): 189 if not self.isVisible():
190 self.__ui.showNotification( 190 self.__ui.showNotification(
191 UI.PixmapCache.getPixmap("cooperation48"), 191 EricPixmapCache.getPixmap("cooperation48"),
192 self.tr("New User"), 192 self.tr("New User"),
193 self.tr("{0} has joined.").format(nick), 193 self.tr("{0} has joined.").format(nick),
194 ) 194 )
195 195
196 def __participantLeft(self, nick): 196 def __participantLeft(self, nick):
219 if not self.__client.hasConnections(): 219 if not self.__client.hasConnections():
220 self.__setConnected(False) 220 self.__setConnected(False)
221 221
222 if not self.isVisible(): 222 if not self.isVisible():
223 self.__ui.showNotification( 223 self.__ui.showNotification(
224 UI.PixmapCache.getPixmap("cooperation48"), 224 EricPixmapCache.getPixmap("cooperation48"),
225 self.tr("User Left"), 225 self.tr("User Left"),
226 self.tr("{0} has left.").format(nick), 226 self.tr("{0} has left.").format(nick),
227 ) 227 )
228 228
229 def appendMessage(self, from_, message): 229 def appendMessage(self, from_, message):
246 bar = self.chatEdit.verticalScrollBar() 246 bar = self.chatEdit.verticalScrollBar()
247 bar.setValue(bar.maximum()) 247 bar.setValue(bar.maximum())
248 248
249 if not self.isVisible(): 249 if not self.isVisible():
250 self.__ui.showNotification( 250 self.__ui.showNotification(
251 UI.PixmapCache.getPixmap("cooperation48"), 251 EricPixmapCache.getPixmap("cooperation48"),
252 self.tr("Message from <{0}>").format(from_), 252 self.tr("Message from <{0}>").format(from_),
253 message, 253 message,
254 ) 254 )
255 255
256 @pyqtSlot(str) 256 @pyqtSlot(str)
405 @param fileName project relative file name of the editor (string) 405 @param fileName project relative file name of the editor (string)
406 @param message command message (string) 406 @param message command message (string)
407 """ 407 """
408 self.editorCommand.emit(hashStr, fileName, message) 408 self.editorCommand.emit(hashStr, fileName, message)
409 409
410 from QScintilla.Editor import Editor 410 from eric7.QScintilla.Editor import Editor
411 411
412 if message.startswith( 412 if message.startswith(
413 Editor.StartEditToken + Editor.Separator 413 Editor.StartEditToken + Editor.Separator
414 ) or message.startswith(Editor.EndEditToken + Editor.Separator): 414 ) or message.startswith(Editor.EndEditToken + Editor.Separator):
415 vm = ericApp().getObject("ViewManager") 415 vm = ericApp().getObject("ViewManager")
423 Private slot to share the current editor. 423 Private slot to share the current editor.
424 424
425 @param checked flag indicating the button state (boolean) 425 @param checked flag indicating the button state (boolean)
426 """ 426 """
427 if checked: 427 if checked:
428 self.shareButton.setIcon(UI.PixmapCache.getIcon("sharedEditConnected")) 428 self.shareButton.setIcon(EricPixmapCache.getIcon("sharedEditConnected"))
429 else: 429 else:
430 self.shareButton.setIcon(UI.PixmapCache.getIcon("sharedEditDisconnected")) 430 self.shareButton.setIcon(EricPixmapCache.getIcon("sharedEditDisconnected"))
431 self.startEditButton.setEnabled(checked) 431 self.startEditButton.setEnabled(checked)
432 432
433 self.shareEditor.emit(checked) 433 self.shareEditor.emit(checked)
434 434
435 @pyqtSlot(bool) 435 @pyqtSlot(bool)
481 """ 481 """
482 shareable, sharing, editing, remoteEditing = editor.getSharingStatus() 482 shareable, sharing, editing, remoteEditing = editor.getSharingStatus()
483 483
484 self.shareButton.setChecked(sharing) 484 self.shareButton.setChecked(sharing)
485 if sharing: 485 if sharing:
486 self.shareButton.setIcon(UI.PixmapCache.getIcon("sharedEditConnected")) 486 self.shareButton.setIcon(EricPixmapCache.getIcon("sharedEditConnected"))
487 else: 487 else:
488 self.shareButton.setIcon(UI.PixmapCache.getIcon("sharedEditDisconnected")) 488 self.shareButton.setIcon(EricPixmapCache.getIcon("sharedEditDisconnected"))
489 self.startEditButton.setChecked(editing) 489 self.startEditButton.setChecked(editing)
490 490
491 self.shareButton.setEnabled(shareable and not editing) 491 self.shareButton.setEnabled(shareable and not editing)
492 self.startEditButton.setEnabled(sharing and not editing and not remoteEditing) 492 self.startEditButton.setEnabled(sharing and not editing and not remoteEditing)
493 self.sendEditButton.setEnabled(editing) 493 self.sendEditButton.setEnabled(editing)
497 """ 497 """
498 Private slot to initialize the chat edit context menu. 498 Private slot to initialize the chat edit context menu.
499 """ 499 """
500 self.__chatMenu = QMenu(self) 500 self.__chatMenu = QMenu(self)
501 self.__copyChatAct = self.__chatMenu.addAction( 501 self.__copyChatAct = self.__chatMenu.addAction(
502 UI.PixmapCache.getIcon("editCopy"), self.tr("Copy"), self.__copyChat 502 EricPixmapCache.getIcon("editCopy"), self.tr("Copy"), self.__copyChat
503 ) 503 )
504 self.__chatMenu.addSeparator() 504 self.__chatMenu.addSeparator()
505 self.__cutAllChatAct = self.__chatMenu.addAction( 505 self.__cutAllChatAct = self.__chatMenu.addAction(
506 UI.PixmapCache.getIcon("editCut"), self.tr("Cut all"), self.__cutAllChat 506 EricPixmapCache.getIcon("editCut"), self.tr("Cut all"), self.__cutAllChat
507 ) 507 )
508 self.__copyAllChatAct = self.__chatMenu.addAction( 508 self.__copyAllChatAct = self.__chatMenu.addAction(
509 UI.PixmapCache.getIcon("editCopy"), self.tr("Copy all"), self.__copyAllChat 509 EricPixmapCache.getIcon("editCopy"), self.tr("Copy all"), self.__copyAllChat
510 ) 510 )
511 self.__chatMenu.addSeparator() 511 self.__chatMenu.addSeparator()
512 self.__clearChatAct = self.__chatMenu.addAction( 512 self.__clearChatAct = self.__chatMenu.addAction(
513 UI.PixmapCache.getIcon("editDelete"), self.tr("Clear"), self.__clearChat 513 EricPixmapCache.getIcon("editDelete"), self.tr("Clear"), self.__clearChat
514 ) 514 )
515 self.__chatMenu.addSeparator() 515 self.__chatMenu.addSeparator()
516 self.__saveChatAct = self.__chatMenu.addAction( 516 self.__saveChatAct = self.__chatMenu.addAction(
517 UI.PixmapCache.getIcon("fileSave"), self.tr("Save"), self.__saveChat 517 EricPixmapCache.getIcon("fileSave"), self.tr("Save"), self.__saveChat
518 ) 518 )
519 519
520 self.on_chatEdit_copyAvailable(False) 520 self.on_chatEdit_copyAvailable(False)
521 521
522 @pyqtSlot(bool) 522 @pyqtSlot(bool)
623 """ 623 """
624 Private slot to initialize the users list context menu. 624 Private slot to initialize the users list context menu.
625 """ 625 """
626 self.__usersMenu = QMenu(self) 626 self.__usersMenu = QMenu(self)
627 self.__kickUserAct = self.__usersMenu.addAction( 627 self.__kickUserAct = self.__usersMenu.addAction(
628 UI.PixmapCache.getIcon("chatKickUser"), 628 EricPixmapCache.getIcon("chatKickUser"),
629 self.tr("Kick User"), 629 self.tr("Kick User"),
630 self.__kickUser, 630 self.__kickUser,
631 ) 631 )
632 self.__banUserAct = self.__usersMenu.addAction( 632 self.__banUserAct = self.__usersMenu.addAction(
633 UI.PixmapCache.getIcon("chatBanUser"), self.tr("Ban User"), self.__banUser 633 EricPixmapCache.getIcon("chatBanUser"), self.tr("Ban User"), self.__banUser
634 ) 634 )
635 self.__banKickUserAct = self.__usersMenu.addAction( 635 self.__banKickUserAct = self.__usersMenu.addAction(
636 UI.PixmapCache.getIcon("chatBanKickUser"), 636 EricPixmapCache.getIcon("chatBanKickUser"),
637 self.tr("Ban and Kick User"), 637 self.tr("Ban and Kick User"),
638 self.__banKickUser, 638 self.__banKickUser,
639 ) 639 )
640 640
641 @pyqtSlot(QPoint) 641 @pyqtSlot(QPoint)

eric ide

mercurial