eric7/Network/IRC/IrcChannelWidget.py

branch
eric7
changeset 8356
68ec9c3d4de5
parent 8322
b422b4e77d19
child 8358
144a6b854f70
equal deleted inserted replaced
8355:8a7677a63c8d 8356:68ec9c3d4de5
18 from PyQt6.QtGui import QIcon, QPainter, QTextCursor, QDesktopServices 18 from PyQt6.QtGui import QIcon, QPainter, QTextCursor, QDesktopServices
19 from PyQt6.QtWidgets import ( 19 from PyQt6.QtWidgets import (
20 QWidget, QListWidgetItem, QMenu, QApplication, QInputDialog, QLineEdit 20 QWidget, QListWidgetItem, QMenu, QApplication, QInputDialog, QLineEdit
21 ) 21 )
22 22
23 from E5Gui import E5MessageBox, E5FileDialog 23 from E5Gui import EricMessageBox, EricFileDialog
24 from E5Gui.E5Application import e5App 24 from E5Gui.EricApplication import ericApp
25 25
26 from .Ui_IrcChannelWidget import Ui_IrcChannelWidget 26 from .Ui_IrcChannelWidget import Ui_IrcChannelWidget
27 27
28 from .IrcUtilities import ircFilter, ircTimestamp, getChannelModesDict 28 from .IrcUtilities import ircFilter, ircTimestamp, getChannelModesDict
29 29
251 @param parent reference to the parent widget (QWidget) 251 @param parent reference to the parent widget (QWidget)
252 """ 252 """
253 super().__init__(parent) 253 super().__init__(parent)
254 self.setupUi(self) 254 self.setupUi(self)
255 255
256 self.__ui = e5App().getObject("UserInterface") 256 self.__ui = ericApp().getObject("UserInterface")
257 self.__ircWidget = parent 257 self.__ircWidget = parent
258 258
259 self.editTopicButton.setIcon( 259 self.editTopicButton.setIcon(
260 UI.PixmapCache.getIcon("ircEditTopic")) 260 UI.PixmapCache.getIcon("ircEditTopic"))
261 self.editTopicButton.hide() 261 self.editTopicButton.hide()
412 ircTimestamp(), self.__userName, 412 ircTimestamp(), self.__userName,
413 Utilities.html_encode(msg))) 413 Utilities.html_encode(msg)))
414 414
415 if msg.startswith("/"): 415 if msg.startswith("/"):
416 if self.__private: 416 if self.__private:
417 E5MessageBox.information( 417 EricMessageBox.information(
418 self, 418 self,
419 self.tr("Send Message"), 419 self.tr("Send Message"),
420 self.tr( 420 self.tr(
421 """Messages starting with a '/' are not allowed""" 421 """Messages starting with a '/' are not allowed"""
422 """ in private chats.""")) 422 """ in private chats."""))
528 528
529 def requestLeave(self): 529 def requestLeave(self):
530 """ 530 """
531 Public method to leave the channel. 531 Public method to leave the channel.
532 """ 532 """
533 ok = E5MessageBox.yesNo( 533 ok = EricMessageBox.yesNo(
534 self, 534 self,
535 self.tr("Leave IRC channel"), 535 self.tr("Leave IRC channel"),
536 self.tr( 536 self.tr(
537 """Do you really want to leave the IRC channel""" 537 """Do you really want to leave the IRC channel"""
538 """ <b>{0}</b>?""").format(self.__name)) 538 """ <b>{0}</b>?""").format(self.__name))
1362 if hasText: 1362 if hasText:
1363 if Utilities.isWindowsPlatform(): 1363 if Utilities.isWindowsPlatform():
1364 htmlExtension = "htm" 1364 htmlExtension = "htm"
1365 else: 1365 else:
1366 htmlExtension = "html" 1366 htmlExtension = "html"
1367 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 1367 fname, selectedFilter = EricFileDialog.getSaveFileNameAndFilter(
1368 self, 1368 self,
1369 self.tr("Save Messages"), 1369 self.tr("Save Messages"),
1370 "", 1370 "",
1371 self.tr( 1371 self.tr(
1372 "HTML Files (*.{0});;Text Files (*.txt);;All Files (*)") 1372 "HTML Files (*.{0});;Text Files (*.txt);;All Files (*)")
1373 .format(htmlExtension), 1373 .format(htmlExtension),
1374 None, 1374 None,
1375 E5FileDialog.DontConfirmOverwrite) 1375 EricFileDialog.DontConfirmOverwrite)
1376 if fname: 1376 if fname:
1377 ext = QFileInfo(fname).suffix() 1377 ext = QFileInfo(fname).suffix()
1378 if not ext: 1378 if not ext:
1379 ex = selectedFilter.split("(*")[1].split(")")[0] 1379 ex = selectedFilter.split("(*")[1].split(")")[0]
1380 if ex: 1380 if ex:
1381 fname += ex 1381 fname += ex
1382 ext = QFileInfo(fname).suffix() 1382 ext = QFileInfo(fname).suffix()
1383 if QFileInfo(fname).exists(): 1383 if QFileInfo(fname).exists():
1384 res = E5MessageBox.yesNo( 1384 res = EricMessageBox.yesNo(
1385 self, 1385 self,
1386 self.tr("Save Messages"), 1386 self.tr("Save Messages"),
1387 self.tr("<p>The file <b>{0}</b> already exists." 1387 self.tr("<p>The file <b>{0}</b> already exists."
1388 " Overwrite it?</p>").format(fname), 1388 " Overwrite it?</p>").format(fname),
1389 icon=E5MessageBox.Warning) 1389 icon=EricMessageBox.Warning)
1390 if not res: 1390 if not res:
1391 return 1391 return
1392 fname = Utilities.toNativeSeparators(fname) 1392 fname = Utilities.toNativeSeparators(fname)
1393 1393
1394 try: 1394 try:
1398 self.messages.toPlainText() 1398 self.messages.toPlainText()
1399 ) 1399 )
1400 with open(fname, "w", encoding="utf-8") as f: 1400 with open(fname, "w", encoding="utf-8") as f:
1401 f.write(txt) 1401 f.write(txt)
1402 except OSError as err: 1402 except OSError as err:
1403 E5MessageBox.critical( 1403 EricMessageBox.critical(
1404 self, 1404 self,
1405 self.tr("Error saving Messages"), 1405 self.tr("Error saving Messages"),
1406 self.tr( 1406 self.tr(
1407 """<p>The messages contents could not be written""" 1407 """<p>The messages contents could not be written"""
1408 """ to <b>{0}</b></p><p>Reason: {1}</p>""") 1408 """ to <b>{0}</b></p><p>Reason: {1}</p>""")
1481 1481
1482 def __sendUserMessage(self): 1482 def __sendUserMessage(self):
1483 """ 1483 """
1484 Private slot to send a private message to a specific user. 1484 Private slot to send a private message to a specific user.
1485 """ 1485 """
1486 from E5Gui import E5TextInputDialog 1486 from E5Gui import EricTextInputDialog
1487 1487
1488 user = self.usersList.selectedItems()[0].text() 1488 user = self.usersList.selectedItems()[0].text()
1489 ok, message = E5TextInputDialog.getText( 1489 ok, message = EricTextInputDialog.getText(
1490 self, self.tr("Send Message"), 1490 self, self.tr("Send Message"),
1491 self.tr("Enter the message to be sent:"), 1491 self.tr("Enter the message to be sent:"),
1492 minimumWidth=400) 1492 minimumWidth=400)
1493 if ok and message: 1493 if ok and message:
1494 self.__processUserMessage("/MSG {0} {1}".format(user, message)) 1494 self.__processUserMessage("/MSG {0} {1}".format(user, message))
1495 1495
1496 def __sendUserQuery(self): 1496 def __sendUserQuery(self):
1497 """ 1497 """
1498 Private slot to send a query message to a specific user. 1498 Private slot to send a query message to a specific user.
1499 """ 1499 """
1500 from E5Gui import E5TextInputDialog 1500 from E5Gui import EricTextInputDialog
1501 1501
1502 user = self.usersList.selectedItems()[0].text() 1502 user = self.usersList.selectedItems()[0].text()
1503 ok, message = E5TextInputDialog.getText( 1503 ok, message = EricTextInputDialog.getText(
1504 self, self.tr("Send Query"), 1504 self, self.tr("Send Query"),
1505 self.tr("Enter the message to be sent:"), 1505 self.tr("Enter the message to be sent:"),
1506 minimumWidth=400) 1506 minimumWidth=400)
1507 if ok and message: 1507 if ok and message:
1508 self.__processUserMessage("/QUERY {0} {1}".format(user, message)) 1508 self.__processUserMessage("/QUERY {0} {1}".format(user, message))
1509 1509
1510 def __sendUserNotice(self): 1510 def __sendUserNotice(self):
1511 """ 1511 """
1512 Private slot to send a notice message to a specific user. 1512 Private slot to send a notice message to a specific user.
1513 """ 1513 """
1514 from E5Gui import E5TextInputDialog 1514 from E5Gui import EricTextInputDialog
1515 1515
1516 user = self.usersList.selectedItems()[0].text() 1516 user = self.usersList.selectedItems()[0].text()
1517 ok, message = E5TextInputDialog.getText( 1517 ok, message = EricTextInputDialog.getText(
1518 self, self.tr("Send Notice"), 1518 self, self.tr("Send Notice"),
1519 self.tr("Enter the message to be sent:"), 1519 self.tr("Enter the message to be sent:"),
1520 minimumWidth=400) 1520 minimumWidth=400)
1521 if ok and message: 1521 if ok and message:
1522 self.__processUserMessage("/NOTICE {0} {1}".format(user, message)) 1522 self.__processUserMessage("/NOTICE {0} {1}".format(user, message))

eric ide

mercurial