Added code to manually set the AWAY status.

Wed, 05 Dec 2012 19:46:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 05 Dec 2012 19:46:44 +0100
changeset 2245
cbddacb4bc2e
parent 2244
654aaddbc2b9
child 2246
fdf22a29fbf4

Added code to manually set the AWAY status.

Network/IRC/IrcChannelWidget.py file | annotate | diff | comparison | revisions
Network/IRC/IrcNetworkWidget.py file | annotate | diff | comparison | revisions
Network/IRC/IrcNetworkWidget.ui file | annotate | diff | comparison | revisions
Network/IRC/IrcWidget.py file | annotate | diff | comparison | revisions
icons/default/ircUserAway.png file | annotate | diff | comparison | revisions
icons/default/ircUserPresent.png file | annotate | diff | comparison | revisions
--- a/Network/IRC/IrcChannelWidget.py	Mon Dec 03 10:39:56 2012 +0100
+++ b/Network/IRC/IrcChannelWidget.py	Wed Dec 05 19:46:44 2012 +0100
@@ -139,6 +139,9 @@
 class IrcChannelWidget(QWidget, Ui_IrcChannelWidget):
     """
     Class implementing the IRC channel widget.
+    
+    @signal sendData(str) emitted to send a message to the channel
+    @signal channelClosed(str) emitted after the user has left the channel
     """
     sendData = pyqtSignal(str)
     channelClosed = pyqtSignal(str)
@@ -168,7 +171,6 @@
     #       Save
     #       Remember Position
     # TODO: Remember current position with <hr/> when widget is invisible
-    # TODO: Remember current position with <hr/> upon user request (only one such line)
     # TODO: Remember current position with <hr/> when away and configured accordingly
     # TODO: Check away indication in the user list
     def __init__(self, parent=None):
--- a/Network/IRC/IrcNetworkWidget.py	Mon Dec 03 10:39:56 2012 +0100
+++ b/Network/IRC/IrcNetworkWidget.py	Wed Dec 05 19:46:44 2012 +0100
@@ -26,11 +26,13 @@
     @signal editNetwork(str) emitted to edit a network configuration
     @signal joinChannel(str) emitted to join a channel
     @signal nickChanged(str) emitted to change the nick name
+    @signal sendData(str) emitted to send a message to the channel
     """
     connectNetwork = pyqtSignal(str, bool)
     editNetwork = pyqtSignal(str)
     joinChannel = pyqtSignal(str)
     nickChanged = pyqtSignal(str)
+    sendData = pyqtSignal(str)
     
     
     # TODO: add context menu to messages pane with these entries:
@@ -39,7 +41,6 @@
     #       Copy All
     #       Clear
     #       Save
-    # TODO: add AWAY support (toolbutton in widget)
     def __init__(self, parent=None):
         """
         Constructor
@@ -52,13 +53,16 @@
         self.connectButton.setIcon(UI.PixmapCache.getIcon("ircConnect.png"))
         self.editButton.setIcon(UI.PixmapCache.getIcon("ircConfigure.png"))
         self.joinButton.setIcon(UI.PixmapCache.getIcon("ircJoinChannel.png"))
+        self.awayButton.setIcon(UI.PixmapCache.getIcon("ircUserPresent.png"))
         
         self.joinButton.setEnabled(False)
         self.nickCombo.setEnabled(False)
+        self.awayButton.setEnabled(False)
         
         self.__manager = None
         self.__connected = False
         self.__registered = False
+        self.__away = False
     
     def initialize(self, manager):
         """
@@ -109,6 +113,23 @@
         self.connectNetwork.emit(network, not self.__connected)
     
     @pyqtSlot()
+    def on_awayButton_clicked(self):
+        """
+        Private slot to toggle the away status.
+        """
+        if self.__away:
+            self.sendData.emit("AWAY")
+            self.awayButton.setIcon(UI.PixmapCache.getIcon("ircUserPresent.png"))
+            self.__away = False
+        else:
+            networkName = self.networkCombo.currentText()
+            identityName = self.__manager.getNetwork(networkName).getIdentityName()
+            awayMessage = self.__manager.getIdentity(identityName).getAwayMessage()
+            self.sendData.emit("AWAY :" + awayMessage)
+            self.awayButton.setIcon(UI.PixmapCache.getIcon("ircUserAway.png"))
+            self.__away = True
+    
+    @pyqtSlot()
     def on_editButton_clicked(self):
         """
         Private slot to edit a network.
@@ -263,3 +284,7 @@
         on = bool(self.channelCombo.currentText()) and self.__registered
         self.joinButton.setEnabled(on)
         self.nickCombo.setEnabled(registered)
+        self.awayButton.setEnabled(registered)
+        if registered:
+            self.awayButton.setIcon(UI.PixmapCache.getIcon("ircUserPresent.png"))
+            self.__away = False
--- a/Network/IRC/IrcNetworkWidget.ui	Mon Dec 03 10:39:56 2012 +0100
+++ b/Network/IRC/IrcNetworkWidget.ui	Wed Dec 05 19:46:44 2012 +0100
@@ -50,6 +50,16 @@
       </widget>
      </item>
      <item>
+      <widget class="QToolButton" name="awayButton">
+       <property name="toolTip">
+        <string>Press to set the user status to AWAY</string>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item>
       <widget class="QToolButton" name="editButton">
        <property name="toolTip">
         <string>Press to edit the networks</string>
@@ -125,6 +135,7 @@
  <tabstops>
   <tabstop>networkCombo</tabstop>
   <tabstop>connectButton</tabstop>
+  <tabstop>awayButton</tabstop>
   <tabstop>editButton</tabstop>
   <tabstop>nickCombo</tabstop>
   <tabstop>channelCombo</tabstop>
--- a/Network/IRC/IrcWidget.py	Mon Dec 03 10:39:56 2012 +0100
+++ b/Network/IRC/IrcWidget.py	Wed Dec 05 19:46:44 2012 +0100
@@ -65,6 +65,7 @@
         self.networkWidget.editNetwork.connect(self.__editNetwork)
         self.networkWidget.joinChannel.connect(self.__joinChannel)
         self.networkWidget.nickChanged.connect(self.__changeNick)
+        self.networkWidget.sendData.connect(self.__send)
         
         self.__channelList = []
         self.__channelTypePrefixes = ""
@@ -513,6 +514,8 @@
             msgType = self.trUtf8("User")
         elif code in [372, 375, 376]:
             msgType = self.trUtf8("MOTD")
+        elif code in [305, 306]:
+            msgType = self.trUtf8("Away")
         else:
             msgType = self.trUtf8("Info ({0})").format(code)
         
@@ -533,6 +536,10 @@
             parts = message.strip().split()
             message = self.trUtf8("Current users on the network: {0}, max. {1}").format(
                 parts[1], parts[2])
+        elif code == 305:
+            message = self.trUtf8("You are no longer marked as being away.")
+        elif code == 306:
+            message = self.trUtf8("You have been marked as being away.")
         else:
             first, message = message.split(None, 1)
             if message.startswith(":"):
Binary file icons/default/ircUserAway.png has changed
Binary file icons/default/ircUserPresent.png has changed

eric ide

mercurial