|
| 1 | +# Default actions file |
| 2 | +# |
| 3 | +# Coding style/curly brackets: Allman style |
| 4 | + |
| 5 | +action.create -w=xcqd -t=tools ("optionctrlr",$tr("Option controller"),$tr("Opens a control dialog for easy CTCP ignore and joins/parts/quits management."),"kvi_bigicon_settings.png",$icon(options)) |
| 6 | +{ |
| 7 | + ################################################################# |
| 8 | + # # |
| 9 | + # File : actions.kvs (optionctrlr) v4.1.1.6810 # |
| 10 | + # Creation date : Fri Jul 22 16:57:41 2016 UTC by un1versal # |
| 11 | + # # |
| 12 | + ################################################################# |
| 13 | + |
| 14 | + # Prevent dialog from opening multiple times |
| 15 | + if(%PDisplay) |
| 16 | + halt; |
| 17 | + else |
| 18 | + %PDisplay = $true; |
| 19 | + |
| 20 | + # This prologue houses the variables for the option controller dialog |
| 21 | + # Add CTCP Protection Variables |
| 22 | + %ProtectPing = $option(boolIgnoreCTCPPing) |
| 23 | + %ProtectFinger = $option(boolIgnoreCTCPFinger) |
| 24 | + %ProtectVersion = $option(boolIgnoreCTCPVersion) |
| 25 | + %ProtectUserinfo = $option(boolIgnoreCTCPUserinfo) |
| 26 | + %ProtectClientinfo = $option(boolIgnoreCTCPClientinfo) |
| 27 | + %ProtectSource = $option(boolIgnoreCTCPSource) |
| 28 | + %ProtectTime = $option(boolIgnoreCTCPTime) |
| 29 | + %ProtectPage = $option(boolIgnoreCTCPPage) |
| 30 | + %ProtectAvatar = $option(boolIgnoreCTCPAvatar) |
| 31 | + %ProtectDCC = $option(boolIgnoreCTCPDCC) |
| 32 | + |
| 33 | + # Add Join Suppression Variables |
| 34 | + %IsJoinEnabled = $isEventEnabled(OnJoin, suppressJoinMsgs) |
| 35 | + %IsPartEnabled = $isEventEnabled(OnPart, suppressPartMsgs) |
| 36 | + %IsQuitEnabled = $isEventEnabled(OnQuit, suppressQuitMsgs) |
| 37 | + |
| 38 | + # Create the main widget as a dialog |
| 39 | + %widget = $new(dialog) |
| 40 | + %layout = $new(layout,%widget) |
| 41 | + %widget->$setWindowTitle($tr("Option Controllers - KVIrc")) |
| 42 | + |
| 43 | + # Add dialog geometry restrictions. |
| 44 | + # Prevent dialog from looking nasty when resized! |
| 45 | + # Maximum width accounts for translations |
| 46 | + %widget->$setWFlags(dialog) |
| 47 | + %widget->$setMinimumHeight(450) |
| 48 | + %widget->$setMaximumHeight(450) |
| 49 | + %widget->$setMinimumWidth(330) |
| 50 | + %widget->$setMaximumWidth(555) |
| 51 | + %widget->$resize(330,450) |
| 52 | + # Make sure dialog is ontop and can be navigated by keyboard |
| 53 | + %widget->$raise() |
| 54 | + %widget->$setfocus() |
| 55 | + |
| 56 | + # Create the CTCP controlled groupbox |
| 57 | + %groupbox = $new(groupbox,%widget) |
| 58 | + %groupbox->$setTitle($tr("CTCP Ignore Controllers")) |
| 59 | + %groupbox->$setAlignment("left") |
| 60 | + |
| 61 | + # Add groupbox to main layout |
| 62 | + %layout->$addWidget(%groupbox,0,0) |
| 63 | + |
| 64 | + # Create checkboxes + labels |
| 65 | + %vbox = $new(vbox,%groupbox) |
| 66 | + |
| 67 | + %checkboxping = $new(checkbox,%vbox) |
| 68 | + %checkboxping->$setText($tr("Enable ignore for CTCP PING")) |
| 69 | + %checkboxping->$setToolTip($tr("When checked, all CTCP PING requests are ignored.")) |
| 70 | + %checkboxping->$setchecked(%ProtectPing) |
| 71 | + |
| 72 | + # Here comes the magic |
| 73 | + privateimpl(%checkboxping,checkbox) |
| 74 | + { |
| 75 | + if(%ProtectPing) |
| 76 | + { |
| 77 | + option boolIgnoreCTCPPing 0 |
| 78 | + echo -i = $msgtype(GenericStatus) $tr("Disabled ignore for CTCP PING") |
| 79 | + } |
| 80 | + else |
| 81 | + { |
| 82 | + option boolIgnoreCTCPPing 1 |
| 83 | + echo -i = $msgtype(GenericStatus) $tr("Enabled ignore for CTCP PING") |
| 84 | + } |
| 85 | + %ProtectPing = $option(boolIgnoreCTCPPing) |
| 86 | + } |
| 87 | + objects.connect %checkboxping clicked %checkboxping checkbox |
| 88 | + |
| 89 | + %checkboxfinger = $new(checkbox,%vbox) |
| 90 | + %checkboxfinger->$setText($tr("Enable ignore for CTCP FINGER")) |
| 91 | + %checkboxfinger->$setToolTip($tr("When checked, all CTCP FINGER requests are ignored.")) |
| 92 | + %checkboxfinger->$setchecked(%ProtectFinger) |
| 93 | + |
| 94 | + # Here comes the magic |
| 95 | + privateimpl(%checkboxfinger,checkbox) |
| 96 | + { |
| 97 | + if(%ProtectFinger) |
| 98 | + { |
| 99 | + option boolIgnoreCTCPFinger 0 |
| 100 | + echo -i = $msgtype(GenericStatus) $tr("Disabled ignore for CTCP FINGER") |
| 101 | + } |
| 102 | + else |
| 103 | + { |
| 104 | + option boolIgnoreCTCPFinger 1 |
| 105 | + echo -i = $msgtype(GenericStatus) $tr("Enabled ignore for CTCP FINGER") |
| 106 | + } |
| 107 | + %ProtectFinger = $option(boolIgnoreCTCPFinger) |
| 108 | + } |
| 109 | + objects.connect %checkboxfinger clicked %checkboxfinger checkbox |
| 110 | + |
| 111 | + %checkboxversion = $new(checkbox,%vbox) |
| 112 | + %checkboxversion->$setText($tr("Enable ignore for CTCP VERSION")) |
| 113 | + %checkboxversion->$setToolTip($tr("When checked, all CTCP VERSION requests are ignored.")) |
| 114 | + %checkboxversion->$setchecked(%ProtectVersion) |
| 115 | + |
| 116 | + # Here comes the magic |
| 117 | + privateimpl(%checkboxversion,checkbox) |
| 118 | + { |
| 119 | + if(%ProtectVersion) |
| 120 | + { |
| 121 | + option boolIgnoreCTCPVersion 0 |
| 122 | + echo -i = $msgtype(GenericStatus) $tr("Disabled ignore for CTCP VERSION") |
| 123 | + } |
| 124 | + else |
| 125 | + { |
| 126 | + option boolIgnoreCTCPVersion 1 |
| 127 | + echo -i = $msgtype(GenericStatus) $tr("Enabled ignore for CTCP VERSION") |
| 128 | + } |
| 129 | + %ProtectVersion = $option(boolIgnoreCTCPVersion) |
| 130 | + } |
| 131 | + objects.connect %checkboxversion clicked %checkboxversion checkbox |
| 132 | + |
| 133 | + %checkboxuserinfo = $new(checkbox,%vbox) |
| 134 | + %checkboxuserinfo->$setText($tr("Enable ignore for CTCP USERINFO")) |
| 135 | + %checkboxuserinfo->$setToolTip($tr("When checked, all CTCP USERINFO requests are ignored.")) |
| 136 | + %checkboxuserinfo->$setchecked(%ProtectUserinfo) |
| 137 | + |
| 138 | + # Here comes the magic |
| 139 | + privateimpl(%checkboxuserinfo,checkbox) |
| 140 | + { |
| 141 | + if(%ProtectUserinfo) |
| 142 | + { |
| 143 | + option boolIgnoreCTCPUserinfo 0 |
| 144 | + echo -i = $msgtype(GenericStatus) $tr("Disabled ignore for CTCP USERINFO") |
| 145 | + } |
| 146 | + else |
| 147 | + { |
| 148 | + option boolIgnoreCTCPUserinfo 1 |
| 149 | + echo -i = $msgtype(GenericStatus) $tr("Enabled ignore for CTCP USERINFO") |
| 150 | + } |
| 151 | + %ProtectUserinfo = $option(boolIgnoreCTCPUserinfo) |
| 152 | + } |
| 153 | + objects.connect %checkboxuserinfo clicked %checkboxuserinfo checkbox |
| 154 | + |
| 155 | + %checkboxclientinfo = $new(checkbox,%vbox) |
| 156 | + %checkboxclientinfo->$setText($tr("Enable ignore for CTCP CLIENTINFO")) |
| 157 | + %checkboxclientinfo->$setToolTip($tr("When checked, all CTCP CLIENTINFO requests are ignored.")) |
| 158 | + %checkboxclientinfo->$setchecked(%ProtectClientInfo) |
| 159 | + |
| 160 | + # Here comes the magic |
| 161 | + privateimpl(%checkboxclientinfo,checkbox) |
| 162 | + { |
| 163 | + if(%ProtectClientInfo) |
| 164 | + { |
| 165 | + option boolIgnoreCTCPClientinfo 0 |
| 166 | + echo -i = $msgtype(GenericStatus) $tr("Disabled ignore for CTCP CLIENTINFO") |
| 167 | + } |
| 168 | + else |
| 169 | + { |
| 170 | + option boolIgnoreCTCPClientinfo 1 |
| 171 | + echo -i = $msgtype(GenericStatus) $tr("Enabled ignore for CTCP CLIENTINFO") |
| 172 | + } |
| 173 | + %ProtectClientInfo = $option(boolIgnoreCTCPClientinfo) |
| 174 | + } |
| 175 | + objects.connect %checkboxclientinfo clicked %checkboxclientinfo checkbox |
| 176 | + |
| 177 | + %checkboxsource = $new(checkbox,%vbox) |
| 178 | + %checkboxsource->$setText($tr("Enable ignore for CTCP SOURCE")) |
| 179 | + %checkboxsource->$setToolTip($tr("When checked, all CTCP SOURCE requests are ignored.")) |
| 180 | + %checkboxsource->$setchecked(%ProtectSource) |
| 181 | + |
| 182 | + # Here comes the magic |
| 183 | + privateimpl(%checkboxsource,checkbox) |
| 184 | + { |
| 185 | + if(%ProtectSource) |
| 186 | + { |
| 187 | + option boolIgnoreCTCPSource 0 |
| 188 | + echo -i = $msgtype(GenericStatus) $tr("Disabled ignore for CTCP SOURCE") |
| 189 | + } |
| 190 | + else |
| 191 | + { |
| 192 | + option boolIgnoreCTCPSource 1 |
| 193 | + echo -i = $msgtype(GenericStatus) $tr("Enabled ignore for CTCP SOURCE") |
| 194 | + } |
| 195 | + %ProtectSource = $option(boolIgnoreCTCPSource) |
| 196 | + } |
| 197 | + objects.connect %checkboxsource clicked %checkboxsource checkbox |
| 198 | + |
| 199 | + %checkboxtime = $new(checkbox,%vbox) |
| 200 | + %checkboxtime->$setText($tr("Enable ignore for CTCP TIME")) |
| 201 | + %checkboxtime->$setToolTip($tr("When checked, all CTCP TIME requests are ignored.")) |
| 202 | + %checkboxtime->$setchecked(%ProtectTime) |
| 203 | + |
| 204 | + # Here comes the magic |
| 205 | + privateimpl(%checkboxtime,checkbox) |
| 206 | + { |
| 207 | + if(%ProtectTime) |
| 208 | + { |
| 209 | + option boolIgnoreCTCPTime 0 |
| 210 | + echo -i = $msgtype(GenericStatus) $tr("Disabled ignore for CTCP TIME") |
| 211 | + } |
| 212 | + else |
| 213 | + { |
| 214 | + option boolIgnoreCTCPTime 1 |
| 215 | + echo -i = $msgtype(GenericStatus) $tr("Enabled ignore for CTCP TIME") |
| 216 | + } |
| 217 | + %ProtectTime = $option(boolIgnoreCTCPTime) |
| 218 | + } |
| 219 | + objects.connect %checkboxtime clicked %checkboxtime checkbox |
| 220 | + |
| 221 | + %checkboxpage = $new(checkbox,%vbox) |
| 222 | + %checkboxpage->$setText($tr("Enable ignore for CTCP PAGE")) |
| 223 | + %checkboxpage->$setToolTip($tr("When checked, all CTCP PAGE requests are ignored.")) |
| 224 | + %checkboxpage->$setchecked(%ProtectPage) |
| 225 | + |
| 226 | + # Here comes the magic |
| 227 | + privateimpl(%checkboxpage,checkbox) |
| 228 | + { |
| 229 | + if(%ProtectPage) |
| 230 | + { |
| 231 | + option boolIgnoreCTCPPage 0 |
| 232 | + echo -i = $msgtype(GenericStatus) $tr("Disabled ignore for CTCP PAGE") |
| 233 | + } |
| 234 | + else |
| 235 | + { |
| 236 | + option boolIgnoreCTCPPage 1 |
| 237 | + echo -i = $msgtype(GenericStatus) $tr("Enabled ignore for CTCP PAGE") |
| 238 | + } |
| 239 | + %ProtectPage = $option(boolIgnoreCTCPPage) |
| 240 | + } |
| 241 | + objects.connect %checkboxpage clicked %checkboxpage checkbox |
| 242 | + |
| 243 | + %checkboxavatar = $new(checkbox,%vbox) |
| 244 | + %checkboxavatar->$setText($tr("Enable ignore for CTCP AVATAR")) |
| 245 | + %checkboxavatar->$setToolTip($tr("When checked, all CTCP AVATAR requests are ignored.")) |
| 246 | + %checkboxavatar->$setchecked(%ProtectAvatar) |
| 247 | + |
| 248 | + # Here comes the magic |
| 249 | + privateimpl(%checkboxavatar,checkbox) |
| 250 | + { |
| 251 | + if(%ProtectAvatar) |
| 252 | + { |
| 253 | + option boolIgnoreCTCPAvatar 0 |
| 254 | + echo -i = $msgtype(GenericStatus) $tr("Disabled ignore for CTCP AVATAR") |
| 255 | + } |
| 256 | + else |
| 257 | + { |
| 258 | + option boolIgnoreCTCPAvatar 1 |
| 259 | + echo -i = $msgtype(GenericStatus) $tr("Enabled ignore for CTCP AVATAR") |
| 260 | + } |
| 261 | + %ProtectAvatar = $option(boolIgnoreCTCPAvatar) |
| 262 | + } |
| 263 | + objects.connect %checkboxavatar clicked %checkboxavatar checkbox |
| 264 | + |
| 265 | + %checkboxdcc = $new(checkbox,%vbox) |
| 266 | + %checkboxdcc->$setText($tr("Enable ignore for CTCP DCC")) |
| 267 | + %checkboxdcc->$setToolTip($tr("When checked, all CTCP DCC requests are ignored.")) |
| 268 | + %checkboxdcc->$setchecked(%ProtectDCC) |
| 269 | + |
| 270 | + # Here comes the magic |
| 271 | + privateimpl(%checkboxdcc,checkbox) |
| 272 | + { |
| 273 | + if(%ProtectDCC) |
| 274 | + { |
| 275 | + option boolIgnoreCTCPDCC 0 |
| 276 | + echo -i = $msgtype(GenericStatus) $tr("Disabled ignore for CTCP DCC") |
| 277 | + } |
| 278 | + else |
| 279 | + { |
| 280 | + option boolIgnoreCTCPDCC 1 |
| 281 | + echo -i = $msgtype(GenericStatus) $tr("Enabled ignore for CTCP DCC") |
| 282 | + } |
| 283 | + %ProtectDCC = $option(boolIgnoreCTCPDCC) |
| 284 | + } |
| 285 | + objects.connect %checkboxdcc clicked %checkboxdcc checkbox |
| 286 | + |
| 287 | + # Then the groupbox |
| 288 | + %groupbox = $new(groupbox,%widget) |
| 289 | + %groupbox->$setTitle($tr("Message Suppression Controllers")) |
| 290 | + %groupbox->$setAlignment("left") |
| 291 | + |
| 292 | + # Add the groupbox to the main layout |
| 293 | + %layout->$addWidget(%groupbox,1,0) |
| 294 | + |
| 295 | + # Now we create checkboxes + labels |
| 296 | + %vbox = $new(vbox,%groupbox) |
| 297 | + |
| 298 | + %checkboxjoin = $new(checkbox,%vbox) |
| 299 | + %checkboxjoin->$setText($tr("Enable join message suppression")) |
| 300 | + %checkboxjoin->$setToolTip($tr("When checked, all join messages are hidden.")) |
| 301 | + %checkboxjoin->$setchecked(%IsJoinEnabled) |
| 302 | + |
| 303 | + # Here comes the magic |
| 304 | + privateimpl(%checkboxjoin,checkbox) |
| 305 | + { |
| 306 | + if($isEventEnabled(OnJoin, suppressJoinMsgs)) |
| 307 | + { |
| 308 | + eventctl -d OnJoin suppressJoinMsgs |
| 309 | + echo -i = $msgtype(GenericStatus) $tr("Disabled join message suppression") |
| 310 | + } |
| 311 | + else |
| 312 | + { |
| 313 | + eventctl -e OnJoin suppressJoinMsgs |
| 314 | + echo -i = $msgtype(GenericStatus) $tr("Enabled join message suppression") |
| 315 | + } |
| 316 | + %IsJoinEnabled = $isEventEnabled(OnJoin, suppressJoinMsgs) |
| 317 | + } |
| 318 | + objects.connect %checkboxjoin clicked %checkboxjoin checkbox |
| 319 | + |
| 320 | + # Here comes the magic |
| 321 | + %checkboxpart = $new(checkbox,%vbox) |
| 322 | + %checkboxpart->$setText($tr("Enable part message suppression")) |
| 323 | + %checkboxpart->$setToolTip($tr("When checked, all part messages are hidden.")) |
| 324 | + %checkboxpart->$setchecked(%IsPartEnabled) |
| 325 | + |
| 326 | + privateimpl(%checkboxpart,checkbox) |
| 327 | + { |
| 328 | + if($isEventEnabled(OnPart, suppressPartMsgs)) |
| 329 | + { |
| 330 | + eventctl -d OnPart suppressPartMsgs |
| 331 | + echo -i = $msgtype(GenericStatus) $tr("Disabled part message suppression") |
| 332 | + } |
| 333 | + else |
| 334 | + { |
| 335 | + eventctl -e OnPart suppressPartMsgs |
| 336 | + echo -i = $msgtype(GenericStatus) $tr("Enabled part message suppression") |
| 337 | + } |
| 338 | + %IsPartEnabled = $isEventEnabled(OnPart, suppressPartMsgs) |
| 339 | + } |
| 340 | + objects.connect %checkboxpart clicked %checkboxpart checkbox |
| 341 | + |
| 342 | + %checkboxquit = $new(checkbox,%vbox) |
| 343 | + %checkboxquit->$setText($tr("Enable quit message suppression")) |
| 344 | + %checkboxquit->$setToolTip($tr("When checked, all part messages are hidden.")) |
| 345 | + %checkboxquit->$setchecked(%IsQuitEnabled) |
| 346 | + |
| 347 | + # Here comes the magic |
| 348 | + privateimpl(%checkboxquit,checkbox) |
| 349 | + { |
| 350 | + if($isEventEnabled(OnQuit, suppressQuitMsgs)) |
| 351 | + { |
| 352 | + eventctl -d OnQuit suppressQuitMsgs |
| 353 | + echo -i = $msgtype(GenericStatus) $tr("Disabled quit message suppression") |
| 354 | + } |
| 355 | + else |
| 356 | + { |
| 357 | + eventctl -e OnQuit suppressQuitMsgs |
| 358 | + echo -i = $msgtype(GenericStatus) $tr("Enabled quit message suppression") |
| 359 | + } |
| 360 | + %IsQuitEnabled = $isEventEnabled(OnQuit, suppressQuitMsgs) |
| 361 | + } |
| 362 | + objects.connect %checkboxquit clicked %checkboxquit checkbox |
| 363 | + |
| 364 | + # Now add the Close button |
| 365 | + %grouphbox = $new(groupbox,%widget) |
| 366 | + %hrzbox = $new(hbox,%grouphbox) |
| 367 | + %layout->$addWidget(%grouphbox,2,0) |
| 368 | + |
| 369 | + %closebutton = $new(button,%hrzbox) |
| 370 | + %closebutton->$settext($tr("Close")) |
| 371 | + |
| 372 | + %grouphbox->$isFlat($true) |
| 373 | + %grouphbox->$setInsideMargin(0) |
| 374 | + %grouphbox->$setAlignment(right) |
| 375 | + |
| 376 | + # Here comes the magic |
| 377 | + privateimpl(%widget,closeEvent) |
| 378 | + { |
| 379 | + ## And kill dialog on close |
| 380 | + delete -q $$ |
| 381 | + |
| 382 | + # Unset all the variables: after delete so %Pdisplay is definitely unset |
| 383 | + unset %PDisplay, %ProtectPing, %ProtectFinger, %ProtectVersion, %ProtectUserinfo \ |
| 384 | + %ProtectClientinfo, %ProtectSource, %ProtectTime, %ProtectPage, %ProtectAvatar \ |
| 385 | + %ProtectDCC, %IsJoinEnabled, %IsPartEnabled, %IsQuitEnabled |
| 386 | + } |
| 387 | + objects.connect %closebutton clicked %widget closeEvent |
| 388 | + |
| 389 | + # Let's show this sexy dialog |
| 390 | + %widget->$show() |
| 391 | +} |
| 392 | + |
0 commit comments