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)
void CustomLineHeightTextEdit::setPlaceholderText(const QString &placeholderText)
{
setProperty("state",STATE_DEFAULT);
style()->unpolish(this);
style()->polish(this);
update();
Utils::setPropertyAndUpdateStyle(this,Properties::STATE,STATE_DEFAULT);
m_placeholderText = placeholderText;
QTextEdit::setText(textToHtml(placeholderText));
//setReadOnly(true);
......@@ -21,10 +19,8 @@ void CustomLineHeightTextEdit::mousePressEvent(QMouseEvent *e)
{
if(property("state").toString()==STATE_DEFAULT)
{
setProperty("state",STATE_HOVER);
style()->unpolish(this);
style()->polish(this);
update();
Utils::setPropertyAndUpdateStyle(this,Properties::STATE,STATE_HOVER);
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'>"
"p, li { white-space: pre-wrap; }"
......@@ -40,12 +36,15 @@ void CustomLineHeightTextEdit::focusOutEvent(QFocusEvent *e)
{
if(toPlainText().isEmpty())
{
setProperty("state",STATE_DEFAULT);
style()->unpolish(this);
style()->polish(this);
update();
Utils::setPropertyAndUpdateStyle(this,Properties::STATE,STATE_DEFAULT);
QTextEdit::setText(textToHtml(m_placeholderText));
}
else
{
Utils::setPropertyAndUpdateStyle(this,Properties::STATE,STATE_END_EDIT);
}
QTextEdit::focusOutEvent(e);
}
......
......@@ -4,6 +4,8 @@
#include <QTextEdit>
#include "AppStyleSheetHandler.h"
#include <QStyle>
#include "defines.h"
#include "Utils.h"
/** @brief QGraphicsDropShadowEffect that can be adjusted from css
*
......@@ -59,6 +61,7 @@ protected:
const QString STATE_HOVER = "hover";
const QString STATE_DEFAULT = "default";
const QString STATE_END_EDIT = "endEdit";
private:
/** @brief Adds a style to the text from the html line height.
......
......@@ -54,6 +54,8 @@ CustomPlacementButton::CustomPlacementButton(QWidget *a_parent)
connect(this, &QAbstractButton::toggled, [=](bool a_checked) {
this->setState(this->underMouse(), a_checked);
});
}
/** @brief Reimplemented QPushButton::setText method. Sets text property of text subcontrol.
......@@ -179,3 +181,32 @@ void CustomPlacementButton::setObjectName(const QString &name)
if (m_styledShadow)
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};
* Set style in .css file in format
*> #buttonName #leftSpacing {
*> ...; //if max-width==0, left alinment
* qproperty-alignment: AlignmentLeft;//AlignmentRight, AlignmentHCenter, AlignmentNone (left or right spacers)
*
*
*> }
*> #buttonName::text {
*> ...
......@@ -51,6 +54,9 @@ enum class ImagePos {Left, Right};
class CustomPlacementButton : public QPushButton
{
Q_OBJECT
Q_PROPERTY(QString alignment WRITE setAlignment DESIGNABLE true)
public:
explicit CustomPlacementButton(QWidget *a_parent = Q_NULLPTR);
......@@ -76,10 +82,11 @@ public:
void setImagePosition(ImagePos a_position = ImagePos::Left);
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:
/// Cursor in.
/// @param event Signal source.
......@@ -95,8 +102,17 @@ protected:
QLabel m_lbText; ///<label with text
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:
///For effect.
StyledDropShadowEffect *m_styledShadow = nullptr;
static void setWidgetState(QWidget* a_widget, bool a_isHover=false, bool a_isChecked = false);
};
#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