Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
elidedlabel.h
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) Yash (http://speedovation.com/)
4 //
5 // Modifications Copyright (c) 2017, Sam Twidale.
6 // Contact: https://samcodes.co.uk/contact/
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 #include <memory>
29 
30 #include <QLabel>
31 
32 class QEvent;
33 
34 namespace geometrize
35 {
36 
37 namespace dialog
38 {
39 
43 class ElidedLabel : public QLabel
44 {
45  Q_OBJECT
46 
50  enum class TrimMode
51  {
52  None
53  };
54 
55 public:
56  explicit ElidedLabel(QWidget* parent = nullptr, Qt::WindowFlags flags = 0);
57  ElidedLabel(const QString& text, QWidget* parent = nullptr, Qt::WindowFlags flags = 0);
58  ElidedLabel(const QString& text, Qt::TextElideMode elideMode, ElidedLabel::TrimMode trimMode, QWidget* parent = nullptr, Qt::WindowFlags flags = 0);
59  virtual ~ElidedLabel();
60 
65  Qt::TextElideMode getElideMode() const;
66 
71  void setElideMode(Qt::TextElideMode elideMode);
72 
76  void setText(const QString&);
77 
78 protected:
79  void changeEvent(QEvent*) override;
80  void paintEvent(QPaintEvent*) override;
81  void resizeEvent(QResizeEvent*) override;
82 
83 private:
85  std::unique_ptr<ElidedLabelImpl> d;
86 };
87 
88 }
89 
90 }
virtual ~ElidedLabel()
Definition: elidedlabel.cpp:116
void resizeEvent(QResizeEvent *) override
Definition: elidedlabel.cpp:136
ElidedLabel(QWidget *parent=nullptr, Qt::WindowFlags flags=0)
Definition: elidedlabel.cpp:98
void setText(const QString &)
setText overrides QLabel::setText.
Definition: elidedlabel.cpp:130
The ElidedLabel class is a label that elides text that does not fit within it.
Definition: elidedlabel.h:43
Qt::TextElideMode getElideMode() const
getElideMode Get the elide mode currently used when displaying text.
Definition: elidedlabel.cpp:120
std::unique_ptr< ElidedLabelImpl > d
Definition: elidedlabel.h:84
void changeEvent(QEvent *) override
Definition: elidedlabel.cpp:152
void paintEvent(QPaintEvent *) override
Definition: elidedlabel.cpp:142
TrimMode
The TrimMode enum specifies the type of additional trimming done after the label text is elided...
Definition: elidedlabel.h:50
void setElideMode(Qt::TextElideMode elideMode)
setElideMode Set the elide mode used when displaying text.
Definition: elidedlabel.cpp:125