2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2010-08-02 14:50:38 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-08-02 14:50:38 +02:00
|
|
|
|
2014-12-13 00:18:59 +01:00
|
|
|
#include "../utils_global.h"
|
2014-12-08 10:57:05 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QPixmap>
|
2014-12-13 00:18:59 +01:00
|
|
|
#include <QVariant>
|
2022-05-24 13:45:35 +02:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QVBoxLayout;
|
|
|
|
|
QT_END_NAMESPACE
|
2011-02-21 16:45:07 +01:00
|
|
|
|
2013-01-10 15:07:17 +01:00
|
|
|
namespace Utils {
|
2010-08-31 17:41:34 +02:00
|
|
|
namespace Internal {
|
2010-08-02 14:50:38 +02:00
|
|
|
|
2018-11-21 10:17:25 +01:00
|
|
|
class TipLabel : public QLabel
|
2010-08-02 14:50:38 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2018-11-21 10:17:25 +01:00
|
|
|
TipLabel(QWidget *parent);
|
2010-08-02 14:50:38 +02:00
|
|
|
|
2014-12-13 00:18:59 +01:00
|
|
|
virtual void setContent(const QVariant &content) = 0;
|
|
|
|
|
virtual bool isInteractive() const { return false; }
|
|
|
|
|
virtual int showTime() const = 0;
|
2020-08-06 13:42:30 +02:00
|
|
|
virtual void configure(const QPoint &pos) = 0;
|
2014-12-13 00:18:59 +01:00
|
|
|
virtual bool canHandleContentReplacement(int typeId) const = 0;
|
2019-01-29 11:43:43 +01:00
|
|
|
virtual bool equals(int typeId, const QVariant &other, const QVariant &contextHelp) const = 0;
|
|
|
|
|
virtual void setContextHelp(const QVariant &help);
|
|
|
|
|
virtual QVariant contextHelp() const;
|
2015-08-07 17:21:38 +02:00
|
|
|
|
2018-11-21 10:17:25 +01:00
|
|
|
protected:
|
|
|
|
|
const QMetaObject *metaObject() const override;
|
|
|
|
|
|
2015-08-07 17:21:38 +02:00
|
|
|
private:
|
2019-01-29 11:43:43 +01:00
|
|
|
QVariant m_contextHelp;
|
2010-08-02 14:50:38 +02:00
|
|
|
};
|
|
|
|
|
|
2019-11-04 17:14:25 +01:00
|
|
|
using TextItem = std::pair<QString, Qt::TextFormat>;
|
|
|
|
|
|
2018-11-21 10:17:25 +01:00
|
|
|
class TextTip : public TipLabel
|
2010-08-02 14:50:38 +02:00
|
|
|
{
|
2020-11-12 15:16:24 +01:00
|
|
|
Q_OBJECT
|
2010-08-02 14:50:38 +02:00
|
|
|
public:
|
2014-12-08 10:57:05 +01:00
|
|
|
TextTip(QWidget *parent);
|
2010-08-02 14:50:38 +02:00
|
|
|
|
2018-09-21 01:15:38 +03:00
|
|
|
void setContent(const QVariant &content) override;
|
|
|
|
|
bool isInteractive() const override;
|
2020-08-06 13:42:30 +02:00
|
|
|
void configure(const QPoint &pos) override;
|
2018-09-21 01:15:38 +03:00
|
|
|
bool canHandleContentReplacement(int typeId) const override;
|
|
|
|
|
int showTime() const override;
|
2019-01-29 11:43:43 +01:00
|
|
|
bool equals(int typeId, const QVariant &other, const QVariant &otherContextHelp) const override;
|
2018-09-21 01:15:38 +03:00
|
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
2014-12-13 00:18:59 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString m_text;
|
2019-11-04 17:14:25 +01:00
|
|
|
Qt::TextFormat m_format = Qt::AutoText;
|
2010-08-02 14:50:38 +02:00
|
|
|
};
|
|
|
|
|
|
2018-11-21 10:17:25 +01:00
|
|
|
class ColorTip : public TipLabel
|
2010-08-23 15:21:02 +02:00
|
|
|
{
|
2020-11-12 15:16:24 +01:00
|
|
|
Q_OBJECT
|
2010-08-23 15:21:02 +02:00
|
|
|
public:
|
2014-12-08 10:57:05 +01:00
|
|
|
ColorTip(QWidget *parent);
|
2010-08-23 15:21:02 +02:00
|
|
|
|
2018-09-21 01:15:38 +03:00
|
|
|
void setContent(const QVariant &content) override;
|
2020-08-06 13:42:30 +02:00
|
|
|
void configure(const QPoint &pos) override;
|
2018-09-21 01:15:38 +03:00
|
|
|
bool canHandleContentReplacement(int typeId) const override;
|
|
|
|
|
int showTime() const override { return 4000; }
|
2019-01-29 11:43:43 +01:00
|
|
|
bool equals(int typeId, const QVariant &other, const QVariant &otherContextHelp) const override;
|
2018-09-21 01:15:38 +03:00
|
|
|
void paintEvent(QPaintEvent *event) override;
|
2014-12-08 10:57:05 +01:00
|
|
|
|
2014-12-13 00:18:59 +01:00
|
|
|
private:
|
|
|
|
|
QColor m_color;
|
|
|
|
|
QPixmap m_tilePixmap;
|
2010-08-23 15:21:02 +02:00
|
|
|
};
|
|
|
|
|
|
2018-11-21 10:17:25 +01:00
|
|
|
class WidgetTip : public TipLabel
|
2011-02-21 16:45:07 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2014-12-13 00:18:59 +01:00
|
|
|
|
2011-02-21 16:45:07 +01:00
|
|
|
public:
|
2018-09-21 01:15:38 +03:00
|
|
|
explicit WidgetTip(QWidget *parent = nullptr);
|
2014-12-13 00:18:59 +01:00
|
|
|
void pinToolTipWidget(QWidget *parent);
|
2011-02-21 16:45:07 +01:00
|
|
|
|
2018-09-21 01:15:38 +03:00
|
|
|
void setContent(const QVariant &content) override;
|
2020-08-06 13:42:30 +02:00
|
|
|
void configure(const QPoint &pos) override;
|
2018-09-21 01:15:38 +03:00
|
|
|
bool canHandleContentReplacement(int typeId) const override;
|
|
|
|
|
int showTime() const override { return 30000; }
|
2019-01-29 11:43:43 +01:00
|
|
|
bool equals(int typeId, const QVariant &other, const QVariant &otherContextHelp) const override;
|
2018-09-21 01:15:38 +03:00
|
|
|
bool isInteractive() const override { return true; }
|
2011-02-21 16:45:07 +01:00
|
|
|
|
|
|
|
|
private:
|
2014-12-13 00:18:59 +01:00
|
|
|
QWidget *m_widget;
|
2011-02-21 16:45:07 +01:00
|
|
|
QVBoxLayout *m_layout;
|
|
|
|
|
};
|
|
|
|
|
|
2010-08-02 14:50:38 +02:00
|
|
|
} // namespace Internal
|
2013-01-10 15:07:17 +01:00
|
|
|
} // namespace Utils
|
2019-11-04 17:14:25 +01:00
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Utils::Internal::TextItem)
|