-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcustomlabel.h
More file actions
45 lines (41 loc) · 1.22 KB
/
customlabel.h
File metadata and controls
45 lines (41 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef CUSTOMLABEL_H
#define CUSTOMLABEL_H
#include "utilsexport.h"
#include <QLabel>
#include <QTextDocument>
#include <QAbstractTextDocumentLayout>
class UTILS_EXPORT CustomLabel : public QLabel
{
Q_OBJECT
Q_PROPERTY(int shadow READ shadow WRITE setShadow)
Q_PROPERTY(int elideMode READ elideMode WRITE setElideMode)
Q_PROPERTY(bool multilineElideEnabled READ multilineElideEnabled WRITE setMultilineElideEnabled)
public:
explicit CustomLabel(QWidget *parent = 0);
// see definitions/textflags.h for defines of shadow types
enum ShadowType
{
NoShadow = 0,
DarkShadow = 1,
LightShadow = 2
};
int shadow() const;
void setShadow(int shadow);
Qt::TextElideMode elideMode() const;
void setElideMode(/*Qt::TextElideMode*/ int mode);
bool multilineElideEnabled() const;
void setMultilineElideEnabled(bool on);
public:
virtual QSize sizeHint() const;
protected:
void paintEvent(QPaintEvent *);
private:
QString elidedText() const;
QTextDocument *textDocument() const;
QAbstractTextDocumentLayout::PaintContext textDocumentPaintContext(QTextDocument *doc) const;
private:
ShadowType shadowType;
Qt::TextElideMode textElideMode;
bool multilineElide;
};
#endif // CUSTOMLABEL_H