@@ -34,6 +34,7 @@ using std::string;
3434using std::vector;
3535using namespace dvs ;
3636const int ANIMATION_DURATION = 300 ;
37+ const double OPACITY_IF_NOT_ACTIVE = 0.5 ;
3738
3839DavisGUI::DavisGUI (QWidget* parent)
3940 : QMainWindow(parent)
@@ -191,6 +192,9 @@ DavisGUI::DavisGUI(QWidget* parent)
191192 settingsFilePath = " settings.json" ;
192193 QJsonObject settings = loadSettings (settingsFilePath);
193194 applySettings (settings);
195+ animationOpacity = new QPropertyAnimation (this , " windowOpacity" );
196+ animationOpacity->setDuration (ANIMATION_DURATION); // Длительность анимации в миллисекундах
197+ animationOpacity->setEasingCurve (QEasingCurve::InOutQuad); // Задаем плавность кривой
194198}
195199
196200DavisGUI::~DavisGUI () {
@@ -513,7 +517,7 @@ bool DavisGUI::mayBeShowBIN(const QString& path) {
513517void DavisGUI::setMaxStyleWindow (int animDuration) {
514518 m_isMinStyleWindow = false ;
515519 hideElementsDuringResize ();
516-
520+ setWindowOpacity ( 1 );
517521 QPropertyAnimation* animationFrame = new QPropertyAnimation (ui->frame_panel , " geometry" );
518522 animationFrame->setEasingCurve (QEasingCurve::InOutQuad);
519523 animationFrame->setDuration (animDuration);
@@ -555,7 +559,7 @@ void DavisGUI::setMaxStyleWindow(int animDuration) {
555559void DavisGUI::setMinStyleWindow (int animDuration) {
556560 m_isMinStyleWindow = true ;
557561 hideElementsDuringResize ();
558-
562+ setWindowOpacity (OPACITY_IF_NOT_ACTIVE);
559563 QPropertyAnimation* animation = new QPropertyAnimation (this , " geometry" );
560564 animation->setDuration (animDuration);
561565 animation->setEasingCurve (QEasingCurve::InOutQuad);
@@ -905,12 +909,19 @@ void DavisGUI::dragEnterEvent(QDragEnterEvent* event) {
905909
906910 group->start (QAbstractAnimation::DeleteWhenStopped);
907911
908-
912+ setFullOpacity ();
909913 if (event->mimeData ()->hasUrls ()) {
910914 event->acceptProposedAction ();
911915 } else {
912916 qDebug () << " not drop" ;
913917 }
918+
919+ }
920+
921+ void DavisGUI::dragLeaveEvent (QDragLeaveEvent* event) {
922+ if (m_isMinStyleWindow) {
923+ setSemiOpacity ();
924+ }
914925}
915926
916927
@@ -1065,3 +1076,31 @@ void DavisGUI::keyPressEvent(QKeyEvent* event) {
10651076 }
10661077}
10671078
1079+ void DavisGUI::setFullOpacity () {
1080+ if (m_isMinStyleWindow) {
1081+ animationOpacity->stop ();
1082+ animationOpacity->setStartValue (windowOpacity ());
1083+ animationOpacity->setEndValue (1.0 ); // Непрозрачное окно
1084+ animationOpacity->start ();
1085+ }
1086+ }
1087+
1088+ void DavisGUI::enterEvent (QEvent* event) {
1089+ setFullOpacity ();
1090+ QMainWindow::enterEvent (event);
1091+ }
1092+
1093+ void DavisGUI::setSemiOpacity () {
1094+ if (m_isMinStyleWindow) {
1095+ animationOpacity->stop ();
1096+ animationOpacity->setStartValue (windowOpacity ());
1097+ animationOpacity->setEndValue (OPACITY_IF_NOT_ACTIVE); // Полупрозрачное окно
1098+ animationOpacity->start ();
1099+ }
1100+ }
1101+
1102+ void DavisGUI::leaveEvent (QEvent* event) {
1103+ setSemiOpacity ();
1104+ QMainWindow::leaveEvent (event);
1105+ }
1106+
0 commit comments