diff --git a/auxiliary/Utils.cpp b/auxiliary/Utils.cpp index c273bb5d448bb9837a03aa83aa145bc4053005ad..2a3e6011691cad75ed6b7a0c2947a638bcc0f0c8 100644 --- a/auxiliary/Utils.cpp +++ b/auxiliary/Utils.cpp @@ -24,4 +24,11 @@ namespace Utils } return (result.size() == 4) ? QColor(result.at(0), result.at(1), result.at(2), result.at(3)) : QColor(); } + + int toIntValue(const QString &a_text) + { + QRegExp regString("(\\d+)"); + regString.indexIn(a_text); + return regString.cap(0).toInt(); + } } diff --git a/auxiliary/Utils.h b/auxiliary/Utils.h index a6a1b62dad0ddcf6a9431f93aa673c90662a6690..585634c70274d2462fdac9726dd09409428c3ced 100644 --- a/auxiliary/Utils.h +++ b/auxiliary/Utils.h @@ -6,6 +6,9 @@ namespace Utils { QColor toColor(const QString &strRGBA); + ///The function returns the first integer in the string. + /// 100%=>100 100px=>100 100**=>100 100=>100 + int toIntValue(const QString &a_text); }; #endif // UTILS_H diff --git a/controls/CustomComboBox.cpp b/controls/CustomComboBox.cpp new file mode 100644 index 0000000000000000000000000000000000000000..600c9d2439e5c8f653ab00e169c8af22fbda9464 --- /dev/null +++ b/controls/CustomComboBox.cpp @@ -0,0 +1,36 @@ +#include "CustomComboBox.h" + +/** @brief constructor + * @param a_parent object parent + */ +CustomComboBox::CustomComboBox(QWidget *parent): + QComboBox (parent) +{ + +} + +/** @brief Reimplemented QComboBox::enterEvent is sent to the widget when the mouse cursor enters the widget. + * @param event + */ +void CustomComboBox:: enterEvent(QEvent *event) +{ + Q_UNUSED(event); + + setProperty("hoverState",1); + style()->unpolish(this); + style()->polish(this); + update(); +} + +/** @brief Reimplemented QComboBox::leaveEvent is sent to the widget when the mouse cursor leaves the widget. + * @param event + */ +void CustomComboBox::leaveEvent(QEvent *event) +{ + Q_UNUSED(event); + + setProperty("hoverState",0); + style()->unpolish(this); + style()->polish(this); + update(); +} diff --git a/controls/CustomComboBox.h b/controls/CustomComboBox.h new file mode 100644 index 0000000000000000000000000000000000000000..7b8b113e76c1fec318b983bcfae2a660fa8b3e99 --- /dev/null +++ b/controls/CustomComboBox.h @@ -0,0 +1,28 @@ +#ifndef CUSTOMCOMBOBOX_H +#define CUSTOMCOMBOBOX_H + + +#include <QComboBox> + +/** @brief QComboBox with changing downArrow when hover on control. + +*To indicate the selection of an object in css +* +*#ComboBoxName[hoverState = "1"]::drop-down, +*{ +* image: url(path to icon); +*} +* +* Everything else unchanged +*/ +class CustomComboBox : public QComboBox +{ + Q_OBJECT +public: + CustomComboBox(QWidget *parent = Q_NULLPTR); + +protected: + void enterEvent(QEvent *event); + void leaveEvent(QEvent *event); +}; +#endif // CUSTOMCOMBOBOX_H 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/StyledDropShadowEffect.cpp b/controls/StyledDropShadowEffect.cpp index 79335d84680319f769b556be3a19e411db9b8dc8..0a886333da1c5ecdeaf0f82dc04c8df8cf6d0fd6 100755 --- a/controls/StyledDropShadowEffect.cpp +++ b/controls/StyledDropShadowEffect.cpp @@ -28,11 +28,12 @@ void StyledDropShadowEffect::updateStyle() else this->setColor(Utils::toColor(colorStr)); - int blur = AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "blur").toInt(); + int blur = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "blur")); this->setBlurRadius(blur); //Offset: - int x = AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "x").toInt(); - int y = AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "y").toInt(); + int x = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "x")); + int y = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "y")); + this->setOffset(x, y); } diff --git a/controls/controls.pri b/controls/controls.pri index 2ae39f47a39a239b53066b76d522099b97371270..cf56ecb4be5cc0ea25cfc4a65360ad4c3548f395 100644 --- a/controls/controls.pri +++ b/controls/controls.pri @@ -2,6 +2,8 @@ SOURCES += \ $$PWD/AdaptiveWidget.cpp \ $$PWD/AnimationChangingWidget.cpp \ $$PWD/ComboBoxDelegate.cpp \ + $$PWD/CustomComboBox.cpp \ + $$PWD/CustomLineHeightLabel.cpp \ $$PWD/CustomPlacementButton.cpp \ $$PWD/ServersComboBox.cpp \ $$PWD/AnimatedLineEdit.cpp \ @@ -13,6 +15,8 @@ HEADERS += \ $$PWD/AdaptiveWidget.h \ $$PWD/AnimationChangingWidget.h \ $$PWD/ComboBoxDelegate.h \ + $$PWD/CustomComboBox.h \ + $$PWD/CustomLineHeightLabel.h \ $$PWD/CustomPlacementButton.h \ $$PWD/ServersComboBox.h \ $$PWD/AnimatedLineEdit.h \