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

[*]Reload effect

parent 71b9bb73
No related branches found
No related tags found
1 merge request!29[*]Reload effect
#include "ScreenOverlaying.h"
#include <QDebug>
ScreenOverlaying::ScreenOverlaying(QWidget *parent):QWidget(parent) {
ScreenOverlaying::ScreenOverlaying(QWidget *a_parent)
:QWidget(a_parent),
blurRadius(0),
opacity(0)
{
}
ScreenOverlaying::ScreenOverlaying(QWidget *blure_parent, QWidget *opacity_parent)
:QWidget(opacity_parent),
blurRadius(0),
opacity(0)
{
setObjectName("ScreenBlureOpocityEffect");
m_blurParent = blure_parent;
m_opacityParent = opacity_parent;
this->setVisible(false);
}
void ScreenOverlaying::mousePressEvent(QMouseEvent *event){
Q_UNUSED(event);
emit mousePressed();
void ScreenOverlaying::showEvent(QShowEvent *event)
{
QGraphicsBlurEffect *blurEffect = new QGraphicsBlurEffect(m_blurParent);
blurEffect->setBlurRadius(blurRadius);
m_blurParent->setGraphicsEffect(blurEffect);
setGeometry(0,0,m_opacityParent->width(),m_opacityParent->height());
QGraphicsOpacityEffect *opacityEffect = new QGraphicsOpacityEffect(this);
opacityEffect->setOpacity(opacity);
setGraphicsEffect(opacityEffect);
QWidget::showEvent(event);
}
void ScreenOverlaying::hideEvent(QHideEvent *event)
{
delete m_blurParent->graphicsEffect();
delete graphicsEffect();
QWidget::hideEvent(event);
}
void ScreenOverlaying::setBlurRadius(int &a_blurRadius)
{
blurRadius = a_blurRadius;
}
void ScreenOverlaying::paintEvent(QPaintEvent *event){
QPainter painter(this);
painter.fillRect(event->rect(), palette().color(QPalette::Window));
void ScreenOverlaying::setOpacity(qreal &a_opacity)
{
opacity = a_opacity;
}
......@@ -2,24 +2,49 @@
#define SCREENOVERLAYING_H
#include <QWidget>
#include <QPainter>
#include <QPaintEvent>
#include <QGraphicsOpacityEffect>
#include <QGraphicsBlurEffect>
//claass wich fill screen under menu
/* css style
#ScreenBlureOpocityEffect
{
background-color: color
qproperty-blureRadius: integer property
qproperty-opocity: double property 0...1
}
*/
class ScreenOverlaying: public QWidget
{
Q_OBJECT
Q_PROPERTY(int blurRadius WRITE setBlurRadius DESIGNABLE true)
Q_PROPERTY(qreal opacity WRITE setOpacity DESIGNABLE true)
public:
ScreenOverlaying(QWidget *parent = nullptr);
ScreenOverlaying(QWidget *a_parent);
protected:
/// Constructor with two widgets specified. 1st widget for creating blurring.
/// The second widget must be the parent of the first and the parent
/// of this class to create a transparent background.
/// @param blure_parent.
/// @param opocity_parent
ScreenOverlaying(QWidget *blur_parent, QWidget *opacity_parent);
virtual void mousePressEvent(QMouseEvent *event);
virtual void paintEvent(QPaintEvent *event);
protected:
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
/// Setting a parameter for the BlurEffect.
/// @param a_blureRadius.
void setBlurRadius(int &a_blurRadius);
/// Setting a parameter for the OpacityEffect.
/// @param a_opocity.
void setOpacity(qreal &a_opacity);
signals:
void mousePressed();
};
private:
QWidget* m_blurParent;
QWidget* m_opacityParent;
int blurRadius;
qreal opacity;
};
#endif // SCREENOVERLAYING_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