Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_floating_message.h
Go to the documentation of this file.
1/*
2 * This file is part of KimageShop^WKrayon^WKrita
3 *
4 * SPDX-FileCopyrightText: 2004 Christian Muehlhaeuser <chris@chris.de>
5 * SPDX-FileCopyrightText: 2004-2006 Seb Ruiz <ruiz@kde.org>
6 * SPDX-FileCopyrightText: 2004, 2005 Max Howell <max.howell@methylblue.com>
7 * SPDX-FileCopyrightText: 2005 Gabor Lehel <illissius@gmail.com>
8 * SPDX-FileCopyrightText: 2008, 2009 Mark Kretschmann <kretschmann@kde.org>
9 * SPDX-FileCopyrightText: 2012 Boudewijn Rempt <boud@valdyas.org>
10 * SPDX-FileCopyrightText: 2021 Alvin Wong <alvin@alvinhc.com>
11 *
12 * SPDX-License-Identifier: GPL-2.0-or-later
13 */
14#ifndef KIS_FLOATING_MESSAGE_H
15#define KIS_FLOATING_MESSAGE_H
16
17#include <QWidget>
18#include <QString>
19#include <QImage>
20#include <QTimer>
21#include <QTimeLine>
22
23#include <kritaui_export.h>
24
25class QLabel;
26
33class KRITAUI_EXPORT KisFloatingMessage : public QWidget
34{
35 Q_OBJECT
36
37public:
38 enum Priority {
39 High = 0,
41 Low
42 };
43
44 explicit KisFloatingMessage(const QString &message, QWidget *parent, bool showOverParent, int timeout,
45 Priority priority, int alignment = Qt::AlignCenter | Qt::TextWordWrap);
46
48 void setShowOverParent(bool show);
49
50 void setIcon(const QIcon& icon);
51
52 void tryOverrideMessage(const QString message,
53 const QIcon& icon,
54 int timeout,
56 int alignment = Qt::AlignCenter | Qt::TextWordWrap);
57
58public Q_SLOTS:
59 void showMessage();
60 void removeMessage();
61
62private Q_SLOTS:
63 void startFade();
64 void updateOpacity(int value);
65 void widgetDeleted();
66private:
67
68 QRect determineMetrics(const int M);
69
70 QString m_message;
71 QImage m_icon;
72 QPixmap m_scaledIcon;
73 QTimer m_timer;
74 int m_m {0};
75 QTimeLine m_fadeTimeLine;
76 bool m_showOverParent {false};
77 int m_timeout {0};
79 int m_alignment {0};
80 bool widgetQueuedForDeletion {false};
81 QLabel *m_messageLabel {nullptr};
82 QLabel *m_iconLabel {nullptr};
83};
84
85#endif // KIS_FLOATING_MESSAGE_H
float value(const T *src, size_t ch)
The KisFloatingMessage class shows the given message in a semi-transparent bubble that doesn't take f...