11import enum
22import operator
33import types
4+ import warnings
45from functools import reduce
56
67import typing
78from typing import (
89 Iterable , Set , Any , Optional , Union , Tuple , Callable , Mapping , List , Dict ,
9- SupportsInt , cast , overload
10+ SupportsInt , cast , overload ,
1011)
1112
12- from AnyQt .QtCore import Qt
13- from AnyQt .QtGui import QMouseEvent , QWheelEvent
14- from AnyQt .QtWidgets import QSizePolicy
15-
16- from .qtcompat import toPyObject
17-
1813__all__ = [
1914 "dotted_getattr" ,
2015 "qualified_name" ,
3328 "findf" ,
3429 "set_flag" ,
3530 "is_flag_set" ,
36- "qsizepolicy_is_expanding" ,
37- "qsizepolicy_is_shrinking" ,
38- "is_event_source_mouse" ,
3931 "UNUSED" ,
4032]
4133
@@ -324,26 +316,6 @@ def is_flag_set(flags, mask):
324316 return bool (flags_i & mask_i )
325317
326318
327- def qsizepolicy_is_expanding (policy : QSizePolicy .Policy ) -> bool :
328- return is_flag_set (policy , QSizePolicy .ExpandFlag )
329-
330-
331- def qsizepolicy_is_shrinking (policy : QSizePolicy .Policy ) -> bool :
332- return is_flag_set (policy , QSizePolicy .ShrinkFlag )
333-
334-
335- def is_event_source_mouse (event : Union [QWheelEvent , QMouseEvent ]) -> bool :
336- """
337- Does th event originate from a mouse type device or from another source
338- (touchpad/screen).
339- """
340- try :
341- return event .source () != Qt .MouseEventNotSynthesized
342- except AttributeError : # PyQt6
343- from AnyQt .QtGui import QInputDevice
344- return event .device ().type () == QInputDevice .DeviceType .Mouse
345-
346-
347319def UNUSED (* _unused_args ) -> None :
348320 """
349321 *Mark* the function arguments as unused for a code checker
@@ -354,3 +326,21 @@ def UNUSED(*_unused_args) -> None:
354326 ... UNUSED(bar, baz)
355327 ... return True
356328 """
329+
330+
331+ # These were moved to minimize imports.
332+ _LAZY_DEPRECATED = {
333+ "qsizepolicy_is_expanding" : "orangecanvas.gui.utils.qsizepolicy_is_expanding" ,
334+ "qsizepolicy_is_shrinking" : "orangecanvas.gui.utils.qsizepolicy_is_shrinking" ,
335+ "is_event_source_mouse" : "orangecanvas.gui.utils.is_event_source_mouse" ,
336+ }
337+
338+ def __getattr__ (name ):
339+ if name in _LAZY_DEPRECATED :
340+ warnings .warn (
341+ f"'{ __name__ } .{ name } ' is deprecated, use '{ _LAZY_DEPRECATED [name ]} '" ,
342+ DeprecationWarning ,
343+ stacklevel = 2
344+ )
345+ return name_lookup (_LAZY_DEPRECATED [name ])
346+ raise AttributeError (name )
0 commit comments