File indexing completed on 2024-12-22 04:13:10

0001 /*
0002  *  SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef __KIS_ELIDED_LABEL_H
0008 #define __KIS_ELIDED_LABEL_H
0009 
0010 #include <QScopedPointer>
0011 #include <QLabel>
0012 
0013 #include "kritaui_export.h"
0014 
0015 
0016 /**
0017  * A special QLabel subclass that makes the text elidable.
0018  *
0019  * Please use setLongText() instead of setText(). The latter one will
0020  * not work!
0021  */
0022 
0023 class KRITAUI_EXPORT KisElidedLabel : public QLabel
0024 {
0025 public:
0026     KisElidedLabel(const QString &text, Qt::TextElideMode mode, QWidget *parent = 0);
0027     ~KisElidedLabel() override;
0028 
0029     void setLongText(const QString &text);
0030 
0031 protected:
0032     void resizeEvent(QResizeEvent *event) override;
0033 
0034 private:
0035     void updateText();
0036     using QLabel::setText;
0037 
0038 private:
0039     struct Private;
0040     const QScopedPointer<Private> m_d;
0041 };
0042 
0043 #endif /* __KIS_ELIDED_LABEL_H */