File indexing completed on 2024-05-19 05:35:20
0001 ////////////////////////////////////////////////////////////////////////////// 0002 // oxygenmdiwindowdata.cpp 0003 // mdi window data container for window titlebar buttons 0004 // ------------------- 0005 // 0006 // SPDX-FileCopyrightText: 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0007 // 0008 // SPDX-License-Identifier: MIT 0009 ////////////////////////////////////////////////////////////////////////////// 0010 0011 #include "oxygenmdiwindowdata.h" 0012 0013 namespace Oxygen 0014 { 0015 //________________________________________________ 0016 MdiWindowData::MdiWindowData(QObject *parent, QWidget *target, int duration) 0017 : AnimationData(parent, target) 0018 { 0019 _currentData._animation = new Animation(duration, this); 0020 _previousData._animation = new Animation(duration, this); 0021 setupAnimation(currentAnimation(), "currentOpacity"); 0022 setupAnimation(previousAnimation(), "previousOpacity"); 0023 0024 currentAnimation().data()->setDirection(Animation::Forward); 0025 previousAnimation().data()->setDirection(Animation::Backward); 0026 } 0027 0028 //______________________________________________ 0029 bool MdiWindowData::updateState(int primitive, bool state) 0030 { 0031 if (state) { 0032 if (primitive != _currentData._primitive) { 0033 _previousData.updateSubControl(_currentData._primitive); 0034 _currentData.updateSubControl(primitive); 0035 return true; 0036 0037 } else 0038 return false; 0039 0040 } else { 0041 bool changed(false); 0042 if (primitive == _currentData._primitive) { 0043 changed |= _currentData.updateSubControl(0); 0044 changed |= _previousData.updateSubControl(primitive); 0045 } 0046 0047 return changed; 0048 } 0049 } 0050 0051 //______________________________________________ 0052 bool MdiWindowData::Data::updateSubControl(int value) 0053 { 0054 if (_primitive == value) 0055 return false; 0056 else { 0057 _primitive = value; 0058 if (_animation.data()->isRunning()) 0059 _animation.data()->stop(); 0060 if (_primitive != 0) 0061 _animation.data()->start(); 0062 return true; 0063 } 0064 } 0065 }