2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-08-02 14:50:38 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-08-02 14:50:38 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-08-02 14:50:38 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-08-02 14:50:38 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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 <QSharedPointer>
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
#include <QVBoxLayout>
|
2011-02-21 16:45:07 +01:00
|
|
|
|
2010-08-31 17:41:34 +02:00
|
|
|
#ifndef Q_MOC_RUN
|
2013-01-10 15:07:17 +01:00
|
|
|
namespace Utils {
|
2010-08-31 17:41:34 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
#endif
|
2010-08-02 14:50:38 +02:00
|
|
|
|
2010-08-23 15:21:02 +02:00
|
|
|
// Please do not change the name of this class. Detailed comments in tooltip.h.
|
|
|
|
|
class QTipLabel : public QLabel
|
2010-08-02 14:50:38 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2014-12-13 00:18:59 +01:00
|
|
|
QTipLabel(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;
|
2010-09-01 12:08:38 +02:00
|
|
|
virtual void configure(const QPoint &pos, QWidget *w) = 0;
|
2014-12-13 00:18:59 +01:00
|
|
|
virtual bool canHandleContentReplacement(int typeId) const = 0;
|
2015-08-07 17:21:38 +02:00
|
|
|
virtual bool equals(int typeId, const QVariant &other, const QString &helpId) const = 0;
|
|
|
|
|
virtual void setHelpId(const QString &id);
|
|
|
|
|
virtual QString helpId() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString m_helpId;
|
2010-08-02 14:50:38 +02:00
|
|
|
};
|
|
|
|
|
|
2014-12-08 10:57:05 +01:00
|
|
|
class TextTip : public QTipLabel
|
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;
|
|
|
|
|
void configure(const QPoint &pos, QWidget *w) override;
|
|
|
|
|
bool canHandleContentReplacement(int typeId) const override;
|
|
|
|
|
int showTime() const override;
|
|
|
|
|
bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const override;
|
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
2014-12-13 00:18:59 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString m_text;
|
2010-08-02 14:50:38 +02:00
|
|
|
};
|
|
|
|
|
|
2014-12-08 10:57:05 +01:00
|
|
|
class ColorTip : public QTipLabel
|
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;
|
|
|
|
|
void configure(const QPoint &pos, QWidget *w) override;
|
|
|
|
|
bool canHandleContentReplacement(int typeId) const override;
|
|
|
|
|
int showTime() const override { return 4000; }
|
|
|
|
|
bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const override;
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
2011-02-21 16:45:07 +01:00
|
|
|
class WidgetTip : public QTipLabel
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
void configure(const QPoint &pos, QWidget *w) override;
|
|
|
|
|
bool canHandleContentReplacement(int typeId) const override;
|
|
|
|
|
int showTime() const override { return 30000; }
|
|
|
|
|
bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const override;
|
|
|
|
|
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-31 17:41:34 +02:00
|
|
|
#ifndef Q_MOC_RUN
|
2010-08-02 14:50:38 +02:00
|
|
|
} // namespace Internal
|
2013-01-10 15:07:17 +01:00
|
|
|
} // namespace Utils
|
2010-08-31 17:41:34 +02:00
|
|
|
#endif
|