2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include "utils_global.h"
|
2022-05-24 00:40:44 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QLabel>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
|
2017-12-01 11:21:10 +01:00
|
|
|
class QTCREATOR_UTILS_EXPORT FixedSizeClickLabel : public QLabel
|
2008-12-02 14:09:21 +01:00
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
Q_PROPERTY(QString maxText READ maxText WRITE setMaxText DESIGNABLE true)
|
|
|
|
|
|
|
|
|
|
public:
|
2018-05-07 17:33:02 +02:00
|
|
|
explicit FixedSizeClickLabel(QWidget *parent = nullptr);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
void setText(const QString &text, const QString &maxText);
|
2017-12-01 13:29:12 +01:00
|
|
|
using QLabel::setText;
|
2018-05-07 15:07:21 +02:00
|
|
|
QSize sizeHint() const override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QString maxText() const;
|
|
|
|
|
void setMaxText(const QString &maxText);
|
|
|
|
|
|
2013-04-15 18:19:34 +02:00
|
|
|
protected:
|
2018-05-07 15:07:21 +02:00
|
|
|
void mousePressEvent(QMouseEvent *ev) override;
|
|
|
|
|
void mouseReleaseEvent(QMouseEvent *ev) override;
|
2013-04-15 18:19:34 +02:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void clicked();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
QString m_maxText;
|
2018-07-23 10:45:40 +02:00
|
|
|
bool m_pressed = false;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
} // namespace Utils
|