/*************************************************************************** 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 #include #include #include #include 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(); }