first re-commit.
This commit is contained in:
115
swcontrol.cpp
Normal file
115
swcontrol.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QLinearGradient>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <swcontrol.h>
|
||||
|
||||
|
||||
SWControl::SWControl( QWidget* parent, QSettings* settings )
|
||||
: QWidget( parent ), _settings{ settings }
|
||||
{
|
||||
|
||||
_effect = new QGraphicsOpacityEffect;
|
||||
//setGraphicsEffect( _effect );
|
||||
|
||||
_animFadeIn = new QPropertyAnimation( _effect, "opacity" );
|
||||
_animFadeIn->setDuration( SWFadingDuration );
|
||||
_animFadeIn->setStartValue( 0.0 );
|
||||
_animFadeIn->setEndValue( 1.0 );
|
||||
//_animFadeIn->setEasingCurve( QEasingCurve::InBack );
|
||||
|
||||
_animFadeOut = new QPropertyAnimation( _effect, "opacity" );
|
||||
_animFadeOut->setDuration( SWFadingDuration );
|
||||
_animFadeOut->setStartValue( 1.0 );
|
||||
_animFadeOut->setEndValue( 0.0 );
|
||||
//_animFadeOut->setEasingCurve( QEasingCurve::OutBack );
|
||||
|
||||
connect( _animFadeOut, &QPropertyAnimation::finished, [=] { hide(); } );
|
||||
hide();
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWControl::~SWControl()
|
||||
{
|
||||
// ??
|
||||
//saveSettings();
|
||||
delete _effect;
|
||||
delete _animFadeIn;
|
||||
delete _animFadeOut;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QSettings& SWControl::settings()
|
||||
{
|
||||
Q_ASSERT( nullptr != _settings );
|
||||
return *_settings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Wird beim vor dem Einblenden des Controls
|
||||
* aufgerufen, um ggf. eine Eingabemaske vorzubereiten.
|
||||
* Die Funktion ist nur dann nötig, wenn Eingabemöglichkeiten
|
||||
* vorhanden sind, deswegen nicht abstract sondern in einer
|
||||
* dummy-Implementierung
|
||||
*/
|
||||
|
||||
void SWControl::onShow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Wird nach dem Ausblenden des Controls aufgerufen.
|
||||
* @see onShow()
|
||||
*/
|
||||
|
||||
void SWControl::onHide()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Blendet das Control ein
|
||||
* @see onShow()
|
||||
*/
|
||||
|
||||
void SWControl::fadeIn()
|
||||
{
|
||||
onShow();
|
||||
show();
|
||||
setGraphicsEffect( _effect );
|
||||
_animFadeIn->start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Blendet das Control aus
|
||||
* @see onHide()
|
||||
*/
|
||||
|
||||
void SWControl::fadeOut()
|
||||
{
|
||||
onHide();
|
||||
setGraphicsEffect( _effect );
|
||||
_animFadeOut->start();
|
||||
}
|
||||
|
Reference in New Issue
Block a user