Skip to content
Snippets Groups Projects
Commit e58a7884 authored by konstantin.kukharenko's avatar konstantin.kukharenko
Browse files

Merge branch 'features-3176' into 'develop_old'

Features 3176

See merge request !19
parents 673b614d 818eb1d3
No related branches found
No related tags found
2 merge requests!19Features 3176,!17Develop old
...@@ -8,10 +8,8 @@ CustomLineHeightTextEdit::CustomLineHeightTextEdit(QWidget *a_parent) ...@@ -8,10 +8,8 @@ CustomLineHeightTextEdit::CustomLineHeightTextEdit(QWidget *a_parent)
void CustomLineHeightTextEdit::setPlaceholderText(const QString &placeholderText) void CustomLineHeightTextEdit::setPlaceholderText(const QString &placeholderText)
{ {
setProperty("state",STATE_DEFAULT); Utils::setPropertyAndUpdateStyle(this,Properties::STATE,STATE_DEFAULT);
style()->unpolish(this);
style()->polish(this);
update();
m_placeholderText = placeholderText; m_placeholderText = placeholderText;
QTextEdit::setText(textToHtml(placeholderText)); QTextEdit::setText(textToHtml(placeholderText));
//setReadOnly(true); //setReadOnly(true);
...@@ -21,10 +19,8 @@ void CustomLineHeightTextEdit::mousePressEvent(QMouseEvent *e) ...@@ -21,10 +19,8 @@ void CustomLineHeightTextEdit::mousePressEvent(QMouseEvent *e)
{ {
if(property("state").toString()==STATE_DEFAULT) if(property("state").toString()==STATE_DEFAULT)
{ {
setProperty("state",STATE_HOVER); Utils::setPropertyAndUpdateStyle(this,Properties::STATE,STATE_HOVER);
style()->unpolish(this);
style()->polish(this);
update();
QString htmlText = QString("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN' 'http://www.w3.org/TR/REC-html40/strict.dtd'>" QString htmlText = QString("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN' 'http://www.w3.org/TR/REC-html40/strict.dtd'>"
"<html><head><meta name='qrichtext' content='1' /><style type='text/css'>" "<html><head><meta name='qrichtext' content='1' /><style type='text/css'>"
"p, li { white-space: pre-wrap; }" "p, li { white-space: pre-wrap; }"
...@@ -40,12 +36,15 @@ void CustomLineHeightTextEdit::focusOutEvent(QFocusEvent *e) ...@@ -40,12 +36,15 @@ void CustomLineHeightTextEdit::focusOutEvent(QFocusEvent *e)
{ {
if(toPlainText().isEmpty()) if(toPlainText().isEmpty())
{ {
setProperty("state",STATE_DEFAULT); Utils::setPropertyAndUpdateStyle(this,Properties::STATE,STATE_DEFAULT);
style()->unpolish(this);
style()->polish(this);
update();
QTextEdit::setText(textToHtml(m_placeholderText)); QTextEdit::setText(textToHtml(m_placeholderText));
} }
else
{
Utils::setPropertyAndUpdateStyle(this,Properties::STATE,STATE_END_EDIT);
}
QTextEdit::focusOutEvent(e); QTextEdit::focusOutEvent(e);
} }
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include <QTextEdit> #include <QTextEdit>
#include "AppStyleSheetHandler.h" #include "AppStyleSheetHandler.h"
#include <QStyle> #include <QStyle>
#include "defines.h"
#include "Utils.h"
/** @brief QGraphicsDropShadowEffect that can be adjusted from css /** @brief QGraphicsDropShadowEffect that can be adjusted from css
* *
...@@ -59,6 +61,7 @@ protected: ...@@ -59,6 +61,7 @@ protected:
const QString STATE_HOVER = "hover"; const QString STATE_HOVER = "hover";
const QString STATE_DEFAULT = "default"; const QString STATE_DEFAULT = "default";
const QString STATE_END_EDIT = "endEdit";
private: private:
/** @brief Adds a style to the text from the html line height. /** @brief Adds a style to the text from the html line height.
......
...@@ -54,6 +54,8 @@ CustomPlacementButton::CustomPlacementButton(QWidget *a_parent) ...@@ -54,6 +54,8 @@ CustomPlacementButton::CustomPlacementButton(QWidget *a_parent)
connect(this, &QAbstractButton::toggled, [=](bool a_checked) { connect(this, &QAbstractButton::toggled, [=](bool a_checked) {
this->setState(this->underMouse(), a_checked); this->setState(this->underMouse(), a_checked);
}); });
} }
/** @brief Reimplemented QPushButton::setText method. Sets text property of text subcontrol. /** @brief Reimplemented QPushButton::setText method. Sets text property of text subcontrol.
...@@ -179,3 +181,32 @@ void CustomPlacementButton::setObjectName(const QString &name) ...@@ -179,3 +181,32 @@ void CustomPlacementButton::setObjectName(const QString &name)
if (m_styledShadow) if (m_styledShadow)
m_styledShadow->updateStyleProperties(); m_styledShadow->updateStyleProperties();
} }
//If there is ALIGNMENT_NONE or some erroneous value, the widgets will be invisible.
void CustomPlacementButton::setAlignment(const QString &a_spacer)
{
if(a_spacer == ALIGNMENT_LEFT)
{
m_lbLeftSpacing.setVisible(true);
m_lbRightSpacing.setVisible(false);
return;
}
if(a_spacer == ALIGNMENT_RIGHT)
{
m_lbLeftSpacing.setVisible(false);
m_lbRightSpacing.setVisible(true);
return;
}
if(a_spacer == ALIGNMENT_H_CENTER)
{
m_lbLeftSpacing.setVisible(true);
m_lbRightSpacing.setVisible(true);
return;
}
m_lbLeftSpacing.setVisible(false);
m_lbRightSpacing.setVisible(false);
}
...@@ -18,6 +18,9 @@ enum class ImagePos {Left, Right}; ...@@ -18,6 +18,9 @@ enum class ImagePos {Left, Right};
* Set style in .css file in format * Set style in .css file in format
*> #buttonName #leftSpacing { *> #buttonName #leftSpacing {
*> ...; //if max-width==0, left alinment *> ...; //if max-width==0, left alinment
* qproperty-alignment: AlignmentLeft;//AlignmentRight, AlignmentHCenter, AlignmentNone (left or right spacers)
*
*
*> } *> }
*> #buttonName::text { *> #buttonName::text {
*> ... *> ...
...@@ -51,6 +54,9 @@ enum class ImagePos {Left, Right}; ...@@ -51,6 +54,9 @@ enum class ImagePos {Left, Right};
class CustomPlacementButton : public QPushButton class CustomPlacementButton : public QPushButton
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString alignment WRITE setAlignment DESIGNABLE true)
public: public:
explicit CustomPlacementButton(QWidget *a_parent = Q_NULLPTR); explicit CustomPlacementButton(QWidget *a_parent = Q_NULLPTR);
...@@ -76,10 +82,11 @@ public: ...@@ -76,10 +82,11 @@ public:
void setImagePosition(ImagePos a_position = ImagePos::Left); void setImagePosition(ImagePos a_position = ImagePos::Left);
void setGraphicsEffect(StyledDropShadowEffect *a_effect); void setGraphicsEffect(StyledDropShadowEffect *a_effect);
///Makes widgets visible on the sides
/// @param a_spacer If there is ALIGNMENT_NONE or some erroneous value, the widgets will be invisible.
void setAlignment(const QString &a_spacer);
private:
///For effect.
StyledDropShadowEffect *m_styledShadow = nullptr;
protected: protected:
/// Cursor in. /// Cursor in.
/// @param event Signal source. /// @param event Signal source.
...@@ -95,8 +102,17 @@ protected: ...@@ -95,8 +102,17 @@ protected:
QLabel m_lbText; ///<label with text QLabel m_lbText; ///<label with text
QLabel m_lbRightSpacing; ///<label for right spacing QLabel m_lbRightSpacing; ///<label for right spacing
const QString ALIGNMENT_LEFT = "AlignmentLeft";
const QString ALIGNMENT_RIGHT = "AlignmentRight";
const QString ALIGNMENT_H_CENTER = "AlignmentHCenter";
const QString ALIGNMENT_NONE = "AlignmentNone";
private: private:
///For effect.
StyledDropShadowEffect *m_styledShadow = nullptr;
static void setWidgetState(QWidget* a_widget, bool a_isHover=false, bool a_isChecked = false); static void setWidgetState(QWidget* a_widget, bool a_isHover=false, bool a_isChecked = false);
}; };
#endif // CUSTOMPLACEMENTBUTTON_NEW_H #endif // CUSTOMPLACEMENTBUTTON_NEW_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment