diff --git a/controls/CustomLineHeightLabel.cpp b/controls/CustomLineHeightLabel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f308775c56923b98e89910edec539063bb5f0d90 --- /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 0000000000000000000000000000000000000000..21611f58cc112ed4815351dc472ea26192894bae --- /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 457e3909cc1e372d966d0a227dc94ac104ccdd38..d098b5407ebde7021bdd364e223cbb8299fe8640 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 \