Skip to content

Commit b58ff8f

Browse files
committed
back to 00's msn
1 parent e16dabf commit b58ff8f

File tree

4 files changed

+77
-2
lines changed

4 files changed

+77
-2
lines changed

qchat/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@
3232
CHEATCODE_IAMAROBOT: str = "iamarobot"
3333
CHEATCODE_10OCLOCK: str = "its10oclock"
3434
CHEATCODE_QGIS_PRO_LICENSE: str = "qgisprolicense"
35+
CHEATCODE_WIZZ: str = "wizz"
3536

3637
CHEATCODES = [
3738
CHEATCODE_DIZZY,
3839
CHEATCODE_IAMAROBOT,
3940
CHEATCODE_10OCLOCK,
4041
CHEATCODE_QGIS_PRO_LICENSE,
42+
CHEATCODE_WIZZ,
4143
]
4244

4345
# QChat message types

qchat/gui/dck_qchat.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
CHEATCODE_FLICK,
3535
CHEATCODE_IAMAROBOT,
3636
CHEATCODE_QGIS_PRO_LICENSE,
37+
CHEATCODE_WIZZ,
3738
CHEATCODES,
3839
QCHAT_MESSAGE_TYPE_BBOX,
3940
QCHAT_MESSAGE_TYPE_CRS,
@@ -46,7 +47,7 @@
4647
QCHAT_NICKNAME_MAXLENGTH_DEFAULT,
4748
QCHAT_NICKNAME_MINLENGTH,
4849
)
49-
from qchat.gui.effects import dizzy, flick_of_the_wrist
50+
from qchat.gui.effects import dizzy, flick_of_the_wrist, wizz
5051
from qchat.gui.qchat_tree_widget_items import (
5152
MESSAGE_COLUMN,
5253
QChatAdminTreeWidgetItem,
@@ -1066,6 +1067,11 @@ def check_cheatcode(self, text: str) -> bool:
10661067
flick_of_the_wrist()
10671068
return True
10681069

1070+
# make the entire QGIS application shake like MSN wizz effect
1071+
if text == CHEATCODE_WIZZ:
1072+
wizz()
1073+
return True
1074+
10691075
# QGIS pro license expiration message
10701076
if text == CHEATCODE_QGIS_PRO_LICENSE:
10711077
self.log(

qchat/gui/effects.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,55 @@ def flick():
120120
timer.start()
121121

122122
return timer
123+
124+
125+
def wizz(
126+
duration: int = 3,
127+
d: int = 12,
128+
interval: int = 50,
129+
should_start: bool = True,
130+
) -> QTimer:
131+
"""Wizz command, make the entire QGIS application shake like MSN effect.
132+
133+
:param duration: duration in seconds
134+
:param d: max offset in pixels
135+
:param interval: refresh interval in milliseconds
136+
:param should_start: whether to start the timer immediately
137+
:return: QTimer instance
138+
"""
139+
140+
main_window = iface.mainWindow()
141+
stop_time = datetime.now() + timedelta(seconds=duration)
142+
143+
# Check if window is maximized and store the state
144+
was_maximized = main_window.isMaximized()
145+
if was_maximized:
146+
main_window.showNormal() # Restore window to normal state temporarily
147+
148+
original_pos = main_window.pos()
149+
150+
timer = QTimer()
151+
timer.setInterval(interval)
152+
153+
def wizz_effect():
154+
if datetime.now() >= stop_time:
155+
timer.stop()
156+
main_window.move(original_pos)
157+
# Restore maximized state if it was maximized before
158+
if was_maximized:
159+
main_window.showMaximized()
160+
return
161+
162+
# Calculate random offset
163+
offset_x = random.randint(-d, d)
164+
offset_y = random.randint(-d, d)
165+
166+
# Apply shake effect to main window
167+
main_window.move(original_pos.x() + offset_x, original_pos.y() + offset_y)
168+
169+
timer.timeout.connect(wizz_effect)
170+
171+
if should_start:
172+
timer.start()
173+
174+
return timer

qchat/logic/slash_commands.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from dataclasses import dataclass
88
from typing import Callable, Optional
99

10-
from qchat.gui.effects import dizzy, flick_of_the_wrist
10+
from qchat.gui.effects import dizzy, flick_of_the_wrist, wizz
1111

1212

1313
@dataclass
@@ -59,6 +59,7 @@ class SlashCommandHandler:
5959
"8ball": "Ask the magic 8-ball",
6060
"dizz": "Let QGIS shake",
6161
"flick": "Look at QGIS flicking the wrist",
62+
"wizz": "Make the entire QGIS application shake like MSN effect",
6263
}
6364

6465
def __init__(self):
@@ -74,6 +75,7 @@ def __init__(self):
7475
"8ball": self.cmd_8ball,
7576
"dizz": self.cmd_dizz,
7677
"flick": self.cmd_flick,
78+
"wizz": self.cmd_wizz,
7779
}
7880

7981
def get_command_list(self) -> list[str]:
@@ -254,6 +256,19 @@ def cmd_flick(self, args: str) -> SlashCommandResult:
254256
success=True, local_action=lambda: ("show_message_bar", args)
255257
)
256258

259+
def cmd_wizz(self, args: str) -> SlashCommandResult:
260+
"""Wizz command, makes the entire QGIS application shake like MSN effect.
261+
262+
:param args: optional message displayed in message bar
263+
:return: SlashCommandResult
264+
"""
265+
266+
wizz()
267+
268+
return SlashCommandResult(
269+
success=True, local_action=lambda: ("show_message_bar", args)
270+
)
271+
257272
def cmd_list(self, args: str) -> SlashCommandResult:
258273
"""List all available commands.
259274

0 commit comments

Comments
 (0)