Line data Source code
1 : # SPDX-FileCopyrightText: 2025 Pairinteraction Developers 2 : # SPDX-License-Identifier: LGPL-3.0-or-later 3 : 4 0 : import logging 5 0 : from functools import partial 6 0 : from typing import Optional 7 : 8 0 : from PySide6.QtCore import QObject, QTimer 9 0 : from PySide6.QtGui import QStatusTipEvent 10 0 : from PySide6.QtWidgets import QApplication 11 : 12 : 13 0 : def show_status_tip(parent: QObject, message: str, timeout: int = 0, logger: Optional[logging.Logger] = None) -> None: 14 : """Show a status tip message using QStatusTipEvent.""" 15 0 : QApplication.sendEvent(parent, QStatusTipEvent(message)) 16 0 : if logger: 17 0 : logger.info(message) 18 0 : if timeout > 0: 19 0 : QTimer.singleShot(timeout, partial(reset_status_tip, parent)) 20 : 21 : 22 0 : def reset_status_tip(parent: QObject) -> None: 23 : """Hide the status tip by sending an empty message.""" 24 0 : QApplication.sendEvent(parent, QStatusTipEvent("Ready"))