Skip to content
Snippets Groups Projects
ScreenOverlaying.h 1.38 KiB
Newer Older
#ifndef SCREENOVERLAYING_H
#define SCREENOVERLAYING_H

#include <QWidget>
konstantin.kukharenko's avatar
konstantin.kukharenko committed
#include <QGraphicsOpacityEffect>
#include <QGraphicsBlurEffect>
konstantin.kukharenko's avatar
konstantin.kukharenko committed
#include <QDebug>
#include <QMainWindow>
konstantin.kukharenko's avatar
konstantin.kukharenko committed
/* css style
 #ScreenBlureOpocityEffect
{
    background-color: color
    qproperty-blureRadius: integer property
    qproperty-opocity: double property 0...1
}

 */
class ScreenOverlaying: public QWidget
{
    Q_OBJECT
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    Q_PROPERTY(int blurRadius WRITE setBlurRadius DESIGNABLE true)
    Q_PROPERTY(qreal opacity WRITE setOpacity DESIGNABLE true)
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ScreenOverlaying(QMainWindow *a_parent = nullptr);
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    /// 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);
konstantin.kukharenko's avatar
konstantin.kukharenko committed
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);
konstantin.kukharenko's avatar
konstantin.kukharenko committed
private:
konstantin.kukharenko's avatar
konstantin.kukharenko committed
   QWidget* m_blurParent;
   QWidget* m_opacityParent;
konstantin.kukharenko's avatar
konstantin.kukharenko committed
   int blurRadius;
   qreal opacity;
};
#endif // SCREENOVERLAYING_H