LibrePCB Developers Documentation
Loading...
Searching...
No Matches
partinformationtooltip.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_PARTINFORMATIONTOOLTIP_H
21#define LIBREPCB_EDITOR_PARTINFORMATIONTOOLTIP_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29#include <QtWidgets>
30
31#include <memory>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class NetworkRequest;
39class WorkspaceSettings;
40
41namespace editor {
42
43class WaitingSpinnerWidget;
44
45namespace Ui {
46class PartInformationToolTip;
47}
48
49/*******************************************************************************
50 * Class PartInformationToolTip
51 ******************************************************************************/
52
56class PartInformationToolTip final : public QFrame {
57 Q_OBJECT
58
59public:
60 // Constructors / Destructor
63 explicit PartInformationToolTip(const WorkspaceSettings& settings,
64 QWidget* parent = nullptr) noexcept;
65 ~PartInformationToolTip() noexcept;
66
67 // Setters
68 void setProviderInfo(const QString& name, const QUrl& url,
69 const QPixmap& logo, const QUrl& infoUrl) noexcept;
70 void showPart(const std::shared_ptr<
72 const QPoint& pos) noexcept;
73
74 // General Methods
75 void hideAndReset(bool reset = true) noexcept;
76 virtual bool eventFilter(QObject* watched, QEvent* event) noexcept override;
77
78 // Operator Overloads
79 PartInformationToolTip& operator=(const PartInformationToolTip& rhs) = delete;
80
81protected:
82 virtual void showEvent(QShowEvent* e) noexcept override;
83 virtual void hideEvent(QHideEvent* e) noexcept override;
84
85private: // Methods
86 void scheduleLoadPicture() noexcept;
87 void startLoadPicture(bool onlyCache) noexcept;
88 void setLabelPixmap(QLabel* label, const QPixmap& pixmap,
89 const QSize& space) noexcept;
90 void updateShape() noexcept;
91 void setSourceDetailsExpanded(bool expanded, bool animated) noexcept;
92 void openUrl(const QUrl& url) noexcept;
93
94private: // Data
96 QScopedPointer<Ui::PartInformationToolTip> mUi;
98 QScopedPointer<QVariantAnimation> mExpandAnimation;
99
100 QScopedPointer<QTimer> mPopUpDelayTimer;
101
104 QScopedPointer<QTimer> mPictureDelayTimer;
105
106 // Constants
107 static const constexpr int sPopupDelayMs = 300;
108 static const constexpr int sWindowArrowSize = 8;
109};
110
111/*******************************************************************************
112 * End of File
113 ******************************************************************************/
114
115} // namespace editor
116} // namespace librepcb
117
118#endif
Container for all workspace related settings.
Definition workspacesettings.h:60
Parts information provider & cache.
Definition partinformationprovider.h:53
The PartInformationToolTip class.
Definition partinformationtooltip.h:56
PartInformationToolTip(const PartInformationToolTip &other)=delete
void openUrl(const QUrl &url) noexcept
Definition partinformationtooltip.cpp:385
virtual bool eventFilter(QObject *watched, QEvent *event) noexcept override
Definition partinformationtooltip.cpp:243
virtual void showEvent(QShowEvent *e) noexcept override
Definition partinformationtooltip.cpp:264
QScopedPointer< Ui::PartInformationToolTip > mUi
Definition partinformationtooltip.h:96
void showPart(const std::shared_ptr< const PartInformationProvider::PartInformation > &info, const QPoint &pos) noexcept
Definition partinformationtooltip.cpp:158
virtual void hideEvent(QHideEvent *e) noexcept override
Definition partinformationtooltip.cpp:272
void setLabelPixmap(QLabel *label, const QPixmap &pixmap, const QSize &space) noexcept
Definition partinformationtooltip.cpp:338
void updateShape() noexcept
Definition partinformationtooltip.cpp:348
QScopedPointer< QTimer > mPopUpDelayTimer
Definition partinformationtooltip.h:100
int mArrowPositionY
Definition partinformationtooltip.h:102
void scheduleLoadPicture() noexcept
Definition partinformationtooltip.cpp:281
QScopedPointer< QVariantAnimation > mExpandAnimation
Definition partinformationtooltip.h:98
std::shared_ptr< const PartInformationProvider::PartInformation > mPartInfo
Definition partinformationtooltip.h:103
QScopedPointer< QTimer > mPictureDelayTimer
Definition partinformationtooltip.h:104
void startLoadPicture(bool onlyCache) noexcept
Definition partinformationtooltip.cpp:290
QScopedPointer< WaitingSpinnerWidget > mWaitingSpinner
Definition partinformationtooltip.h:97
static const constexpr int sPopupDelayMs
Definition partinformationtooltip.h:107
const WorkspaceSettings & mSettings
Definition partinformationtooltip.h:95
void setProviderInfo(const QString &name, const QUrl &url, const QPixmap &logo, const QUrl &infoUrl) noexcept
Definition partinformationtooltip.cpp:128
static const constexpr int sWindowArrowSize
Definition partinformationtooltip.h:108
void setSourceDetailsExpanded(bool expanded, bool animated) noexcept
Definition partinformationtooltip.cpp:364
void hideAndReset(bool reset=true) noexcept
Definition partinformationtooltip.cpp:235
A widget drawing a rotating spinner to indicate an ongoing operation.
Definition waitingspinnerwidget.h:52
Definition occmodel.cpp:76
Definition uuid.h:186
Definition partinformationprovider.h:77