1 /* 2 * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org> 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 or (at your option) 7 * version 3 of the License. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef KEEPASSX_ELIDEDLABEL_H 19 #define KEEPASSX_ELIDEDLABEL_H 20 21 #include <QLabel> 22 23 class QResizeEvent; 24 25 class ElidedLabel : public QLabel 26 { 27 Q_OBJECT 28 Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode NOTIFY elideModeChanged) 29 Q_PROPERTY(QString rawText READ rawText WRITE setRawText NOTIFY rawTextChanged) 30 Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged) 31 public: 32 explicit ElidedLabel(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); 33 explicit ElidedLabel(const QString& text, QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); 34 35 Qt::TextElideMode elideMode() const; 36 QString rawText() const; 37 QString url() const; 38 39 public slots: 40 void setElideMode(Qt::TextElideMode elideMode); 41 void setRawText(const QString& rawText); 42 void setUrl(const QString& url); 43 void clear(); 44 45 signals: 46 void elideModeChanged(Qt::TextElideMode elideMode); 47 void rawTextChanged(QString rawText); 48 void urlChanged(QString url); 49 50 private slots: 51 void updateElidedText(); 52 53 private: 54 void resizeEvent(QResizeEvent* event); 55 56 Qt::TextElideMode m_elideMode; 57 QString m_rawText; 58 QString m_url; 59 }; 60 61 #endif // KEEPASSX_ELIDEDLABEL_H 62