File tree 3 files changed +94
-0
lines changed
3 files changed +94
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ set(client_SRCS
95
95
notificationconfirmjob.cpp
96
96
servernotificationhandler.cpp
97
97
guiutility.cpp
98
+ elidedlabel.cpp
98
99
creds/credentialsfactory.cpp
99
100
creds/httpcredentialsgui.cpp
100
101
creds/oauth.cpp
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (C) by Christian Kamm <mail@ckamm.de>
3
+ *
4
+ * This program is free software; you can redistribute it and/or modify
5
+ * it under the terms of the GNU General Public License as published by
6
+ * the Free Software Foundation; either version 2 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ * for more details.
13
+ */
14
+
15
+ #include " elidedlabel.h"
16
+
17
+ #include < QResizeEvent>
18
+
19
+ namespace OCC {
20
+
21
+ ElidedLabel::ElidedLabel (const QString &text, QWidget *parent)
22
+ : QLabel(text, parent)
23
+ , _text(text)
24
+ , _elideMode(Qt::ElideNone)
25
+ {
26
+ }
27
+
28
+ void ElidedLabel::setText (const QString &text)
29
+ {
30
+ _text = text;
31
+ QLabel::setText (text);
32
+ update ();
33
+ }
34
+
35
+ void ElidedLabel::setElideMode (Qt::TextElideMode elideMode)
36
+ {
37
+ _elideMode = elideMode;
38
+ update ();
39
+ }
40
+
41
+ void ElidedLabel::resizeEvent (QResizeEvent *event)
42
+ {
43
+ QLabel::resizeEvent (event);
44
+
45
+ QFontMetrics fm = fontMetrics ();
46
+ QString elided = fm.elidedText (_text, _elideMode, event->size ().width ());
47
+ QLabel::setText (elided);
48
+ }
49
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (C) by Christian Kamm <mail@ckamm.de>
3
+ *
4
+ * This program is free software; you can redistribute it and/or modify
5
+ * it under the terms of the GNU General Public License as published by
6
+ * the Free Software Foundation; either version 2 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ * for more details.
13
+ */
14
+
15
+ #ifndef ELIDEDLABEL_H
16
+ #define ELIDEDLABEL_H
17
+
18
+ #include < QLabel>
19
+
20
+ namespace OCC {
21
+
22
+ // / Label that can elide its text
23
+ class ElidedLabel : public QLabel
24
+ {
25
+ Q_OBJECT
26
+ public:
27
+ explicit ElidedLabel (const QString &text, QWidget *parent = 0 );
28
+
29
+ void setText (const QString &text);
30
+ const QString &text () const { return _text; }
31
+
32
+ void setElideMode (Qt::TextElideMode elideMode);
33
+ Qt::TextElideMode elideMode () const { return _elideMode; }
34
+
35
+ protected:
36
+ void resizeEvent (QResizeEvent *event) override ;
37
+
38
+ private:
39
+ QString _text;
40
+ Qt::TextElideMode _elideMode;
41
+ };
42
+ }
43
+
44
+ #endif
You can’t perform that action at this time.
0 commit comments