wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ICPreviewPopup.h
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
7
8#pragma once
9
10#include <QLabel>
11#include <QPointer>
12#include <QTimer>
13#include <QWidget>
14
15class IC;
16
26class ICPreviewPopup : public QWidget
27{
28 Q_OBJECT
29
30public:
32 static constexpr int MaxWidth = 500;
33 static constexpr int MaxHeight = 350;
34
38 static constexpr int MaxElementCount = 500;
39
41 explicit ICPreviewPopup(QWidget *parent = nullptr);
42
46 void showForIC(IC *ic, const QPoint &screenPos);
47
50 void scheduleHide();
51
53 void cancelHide();
54
58 void updatePendingPos(const QPoint &screenPos);
59
61 IC *pendingIC() const;
62
66 bool isShowActiveFor(const IC *ic) const;
67
71 static QPoint clampedPopupPos(const QPoint &cursorPos, const QSize &popupSize, const QRect &availableGeometry);
72
73protected:
75 void enterEvent(QEnterEvent *event) override;
76
78 void leaveEvent(QEvent *event) override;
79
80private:
81 void executeShow();
82
83 QLabel *m_titleLabel;
84 QLabel *m_imageLabel;
85 QTimer m_hideTimer;
86 QTimer m_showTimer;
87 QPointer<IC> m_pendingIC;
88 QPoint m_pendingPos;
89};
void leaveEvent(QEvent *event) override
IC * pendingIC() const
Returns the IC currently pending display (may be null).
ICPreviewPopup(QWidget *parent=nullptr)
Constructs the popup as a frameless, non-activating child of parent.
bool isShowActiveFor(const IC *ic) const
static QPoint clampedPopupPos(const QPoint &cursorPos, const QSize &popupSize, const QRect &availableGeometry)
static constexpr int MaxWidth
Maximum preview dimensions in pixels.
static constexpr int MaxHeight
void cancelHide()
Cancels a pending show/hide.
void showForIC(IC *ic, const QPoint &screenPos)
static constexpr int MaxElementCount
void updatePendingPos(const QPoint &screenPos)
void enterEvent(QEnterEvent *event) override
Graphic element representing an Integrated Circuit (sub-circuit) box.
Definition IC.h:31