24 |
24 |
25 @signal connectNetwork(str,bool) emitted to connect or disconnect from a network |
25 @signal connectNetwork(str,bool) emitted to connect or disconnect from a network |
26 @signal editNetwork(str) emitted to edit a network configuration |
26 @signal editNetwork(str) emitted to edit a network configuration |
27 @signal joinChannel(str) emitted to join a channel |
27 @signal joinChannel(str) emitted to join a channel |
28 @signal nickChanged(str) emitted to change the nick name |
28 @signal nickChanged(str) emitted to change the nick name |
|
29 @signal sendData(str) emitted to send a message to the channel |
29 """ |
30 """ |
30 connectNetwork = pyqtSignal(str, bool) |
31 connectNetwork = pyqtSignal(str, bool) |
31 editNetwork = pyqtSignal(str) |
32 editNetwork = pyqtSignal(str) |
32 joinChannel = pyqtSignal(str) |
33 joinChannel = pyqtSignal(str) |
33 nickChanged = pyqtSignal(str) |
34 nickChanged = pyqtSignal(str) |
|
35 sendData = pyqtSignal(str) |
34 |
36 |
35 |
37 |
36 # TODO: add context menu to messages pane with these entries: |
38 # TODO: add context menu to messages pane with these entries: |
37 # Copy |
39 # Copy |
38 # Copy Link Location |
40 # Copy Link Location |
39 # Copy All |
41 # Copy All |
40 # Clear |
42 # Clear |
41 # Save |
43 # Save |
42 # TODO: add AWAY support (toolbutton in widget) |
|
43 def __init__(self, parent=None): |
44 def __init__(self, parent=None): |
44 """ |
45 """ |
45 Constructor |
46 Constructor |
46 |
47 |
47 @param parent reference to the parent widget (QWidget) |
48 @param parent reference to the parent widget (QWidget) |
50 self.setupUi(self) |
51 self.setupUi(self) |
51 |
52 |
52 self.connectButton.setIcon(UI.PixmapCache.getIcon("ircConnect.png")) |
53 self.connectButton.setIcon(UI.PixmapCache.getIcon("ircConnect.png")) |
53 self.editButton.setIcon(UI.PixmapCache.getIcon("ircConfigure.png")) |
54 self.editButton.setIcon(UI.PixmapCache.getIcon("ircConfigure.png")) |
54 self.joinButton.setIcon(UI.PixmapCache.getIcon("ircJoinChannel.png")) |
55 self.joinButton.setIcon(UI.PixmapCache.getIcon("ircJoinChannel.png")) |
|
56 self.awayButton.setIcon(UI.PixmapCache.getIcon("ircUserPresent.png")) |
55 |
57 |
56 self.joinButton.setEnabled(False) |
58 self.joinButton.setEnabled(False) |
57 self.nickCombo.setEnabled(False) |
59 self.nickCombo.setEnabled(False) |
|
60 self.awayButton.setEnabled(False) |
58 |
61 |
59 self.__manager = None |
62 self.__manager = None |
60 self.__connected = False |
63 self.__connected = False |
61 self.__registered = False |
64 self.__registered = False |
|
65 self.__away = False |
62 |
66 |
63 def initialize(self, manager): |
67 def initialize(self, manager): |
64 """ |
68 """ |
65 Public method to initialize the widget. |
69 Public method to initialize the widget. |
66 |
70 |
105 """ |
109 """ |
106 Private slot to connect to a network. |
110 Private slot to connect to a network. |
107 """ |
111 """ |
108 network = self.networkCombo.currentText() |
112 network = self.networkCombo.currentText() |
109 self.connectNetwork.emit(network, not self.__connected) |
113 self.connectNetwork.emit(network, not self.__connected) |
|
114 |
|
115 @pyqtSlot() |
|
116 def on_awayButton_clicked(self): |
|
117 """ |
|
118 Private slot to toggle the away status. |
|
119 """ |
|
120 if self.__away: |
|
121 self.sendData.emit("AWAY") |
|
122 self.awayButton.setIcon(UI.PixmapCache.getIcon("ircUserPresent.png")) |
|
123 self.__away = False |
|
124 else: |
|
125 networkName = self.networkCombo.currentText() |
|
126 identityName = self.__manager.getNetwork(networkName).getIdentityName() |
|
127 awayMessage = self.__manager.getIdentity(identityName).getAwayMessage() |
|
128 self.sendData.emit("AWAY :" + awayMessage) |
|
129 self.awayButton.setIcon(UI.PixmapCache.getIcon("ircUserAway.png")) |
|
130 self.__away = True |
110 |
131 |
111 @pyqtSlot() |
132 @pyqtSlot() |
112 def on_editButton_clicked(self): |
133 def on_editButton_clicked(self): |
113 """ |
134 """ |
114 Private slot to edit a network. |
135 Private slot to edit a network. |
261 """ |
282 """ |
262 self.__registered = registered |
283 self.__registered = registered |
263 on = bool(self.channelCombo.currentText()) and self.__registered |
284 on = bool(self.channelCombo.currentText()) and self.__registered |
264 self.joinButton.setEnabled(on) |
285 self.joinButton.setEnabled(on) |
265 self.nickCombo.setEnabled(registered) |
286 self.nickCombo.setEnabled(registered) |
|
287 self.awayButton.setEnabled(registered) |
|
288 if registered: |
|
289 self.awayButton.setIcon(UI.PixmapCache.getIcon("ircUserPresent.png")) |
|
290 self.__away = False |