@@ -34,6 +34,7 @@ using std::string;
34
34
using std::vector;
35
35
using namespace dvs ;
36
36
const int ANIMATION_DURATION = 300 ;
37
+ const double OPACITY_IF_NOT_ACTIVE = 0.5 ;
37
38
38
39
DavisGUI::DavisGUI (QWidget* parent)
39
40
: QMainWindow(parent)
@@ -191,6 +192,9 @@ DavisGUI::DavisGUI(QWidget* parent)
191
192
settingsFilePath = " settings.json" ;
192
193
QJsonObject settings = loadSettings (settingsFilePath);
193
194
applySettings (settings);
195
+ animationOpacity = new QPropertyAnimation (this , " windowOpacity" );
196
+ animationOpacity->setDuration (ANIMATION_DURATION); // Длительность анимации в миллисекундах
197
+ animationOpacity->setEasingCurve (QEasingCurve::InOutQuad); // Задаем плавность кривой
194
198
}
195
199
196
200
DavisGUI::~DavisGUI () {
@@ -513,7 +517,7 @@ bool DavisGUI::mayBeShowBIN(const QString& path) {
513
517
void DavisGUI::setMaxStyleWindow (int animDuration) {
514
518
m_isMinStyleWindow = false ;
515
519
hideElementsDuringResize ();
516
-
520
+ setWindowOpacity ( 1 );
517
521
QPropertyAnimation* animationFrame = new QPropertyAnimation (ui->frame_panel , " geometry" );
518
522
animationFrame->setEasingCurve (QEasingCurve::InOutQuad);
519
523
animationFrame->setDuration (animDuration);
@@ -555,7 +559,7 @@ void DavisGUI::setMaxStyleWindow(int animDuration) {
555
559
void DavisGUI::setMinStyleWindow (int animDuration) {
556
560
m_isMinStyleWindow = true ;
557
561
hideElementsDuringResize ();
558
-
562
+ setWindowOpacity (OPACITY_IF_NOT_ACTIVE);
559
563
QPropertyAnimation* animation = new QPropertyAnimation (this , " geometry" );
560
564
animation->setDuration (animDuration);
561
565
animation->setEasingCurve (QEasingCurve::InOutQuad);
@@ -905,12 +909,19 @@ void DavisGUI::dragEnterEvent(QDragEnterEvent* event) {
905
909
906
910
group->start (QAbstractAnimation::DeleteWhenStopped);
907
911
908
-
912
+ setFullOpacity ();
909
913
if (event->mimeData ()->hasUrls ()) {
910
914
event->acceptProposedAction ();
911
915
} else {
912
916
qDebug () << " not drop" ;
913
917
}
918
+
919
+ }
920
+
921
+ void DavisGUI::dragLeaveEvent (QDragLeaveEvent* event) {
922
+ if (m_isMinStyleWindow) {
923
+ setSemiOpacity ();
924
+ }
914
925
}
915
926
916
927
@@ -1065,3 +1076,31 @@ void DavisGUI::keyPressEvent(QKeyEvent* event) {
1065
1076
}
1066
1077
}
1067
1078
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