From 4c93898d32024e8a27fb7fcc912e517094eac071 Mon Sep 17 00:00:00 2001
From: "konstantin.kukharenko" <konstantin.kukharenko@demlabs.net>
Date: Sat, 8 Feb 2020 04:34:10 +0000
Subject: [PATCH] [+]New class

---
 controls/CustomLineHeightLabel.cpp | 35 ++++++++++++++++++++++++++++++
 controls/CustomLineHeightLabel.h   | 20 +++++++++++++++++
 controls/controls.pri              |  2 ++
 3 files changed, 57 insertions(+)
 create mode 100644 controls/CustomLineHeightLabel.cpp
 create mode 100644 controls/CustomLineHeightLabel.h

diff --git a/controls/CustomLineHeightLabel.cpp b/controls/CustomLineHeightLabel.cpp
new file mode 100644
index 0000000..f308775
--- /dev/null
+++ b/controls/CustomLineHeightLabel.cpp
@@ -0,0 +1,35 @@
+#include "CustomLineHeightLabel.h"
+#include "AppStyleSheetHandler.h"
+
+CustomLineHeightLabel::CustomLineHeightLabel(QWidget *a_parent)
+    :QLabel (a_parent)
+{
+}
+
+void CustomLineHeightLabel::setText(const QString &text)
+{
+    if(m_lineHeight.isEmpty())m_lineHeight = "100";
+    QString textToHtml = QString("<p style = 'line-height:%1;'> %2 </p>").arg(m_lineHeight).arg(text);
+
+    QLabel::setText(textToHtml);
+
+}
+
+void CustomLineHeightLabel::setObjectName(const QString &name)
+{
+    QObject::setObjectName(name);
+
+    updateStyleSheets();
+}
+
+void CustomLineHeightLabel::updateStyleSheets()
+{
+
+    StyleSheatSearchPar searchPar;
+    searchPar.widgetName = "#" + this->objectName();
+
+    QString stylesheet = AppStyleSheetHandler::getWidgetStyleSheet(searchPar);
+    //line-height:
+    m_lineHeight = AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "line-height");
+
+}
diff --git a/controls/CustomLineHeightLabel.h b/controls/CustomLineHeightLabel.h
new file mode 100644
index 0000000..21611f5
--- /dev/null
+++ b/controls/CustomLineHeightLabel.h
@@ -0,0 +1,20 @@
+#ifndef CUSTOMLINEHEIGHTLABEL_H
+#define CUSTOMLINEHEIGHTLABEL_H
+
+#include <QLabel>
+
+class CustomLineHeightLabel: public QLabel
+{
+public:
+    explicit CustomLineHeightLabel(QWidget *a_parent = Q_NULLPTR);
+
+    void setText(const QString &text);
+    void setObjectName(const QString &name);
+
+    void updateStyleSheets();
+
+private:
+    QString m_lineHeight;
+};
+
+#endif // CUSTOMLINEHEIGHTLABEL_H
diff --git a/controls/controls.pri b/controls/controls.pri
index 457e390..d098b54 100644
--- a/controls/controls.pri
+++ b/controls/controls.pri
@@ -1,6 +1,7 @@
 SOURCES += \
     $$PWD/AnimationChangingWidget.cpp \
     $$PWD/ComboBoxDelegate.cpp \
+    $$PWD/CustomLineHeightLabel.cpp \
     $$PWD/CustomPlacementButton.cpp \
     $$PWD/ServersComboBox.cpp \
     $$PWD/AnimatedLineEdit.cpp \
@@ -11,6 +12,7 @@ SOURCES += \
 HEADERS += \
     $$PWD/AnimationChangingWidget.h \
     $$PWD/ComboBoxDelegate.h \
+    $$PWD/CustomLineHeightLabel.h \
     $$PWD/CustomPlacementButton.h \
     $$PWD/ServersComboBox.h \
     $$PWD/AnimatedLineEdit.h \
-- 
GitLab