QTfrontend/hwform.cpp
changeset 6574 ec059b55aa72
parent 6572 0d0af531c1c7
child 6604 9cc612a24b43
equal deleted inserted replaced
6573:632fa142c2cf 6574:ec059b55aa72
   218     connect(ui.pageOptions->WeaponNew, SIGNAL(clicked()), this, SLOT(GoToSelectNewWeapon()));
   218     connect(ui.pageOptions->WeaponNew, SIGNAL(clicked()), this, SLOT(GoToSelectNewWeapon()));
   219     connect(ui.pageOptions->WeaponDelete, SIGNAL(clicked()), this, SLOT(DeleteWeaponSet()));
   219     connect(ui.pageOptions->WeaponDelete, SIGNAL(clicked()), this, SLOT(DeleteWeaponSet()));
   220     connect(ui.pageOptions->SchemeEdit, SIGNAL(clicked()), this, SLOT(GoToEditScheme()));
   220     connect(ui.pageOptions->SchemeEdit, SIGNAL(clicked()), this, SLOT(GoToEditScheme()));
   221     connect(ui.pageOptions->SchemeNew, SIGNAL(clicked()), this, SLOT(GoToNewScheme()));
   221     connect(ui.pageOptions->SchemeNew, SIGNAL(clicked()), this, SLOT(GoToNewScheme()));
   222     connect(ui.pageOptions->SchemeDelete, SIGNAL(clicked()), this, SLOT(DeleteScheme()));
   222     connect(ui.pageOptions->SchemeDelete, SIGNAL(clicked()), this, SLOT(DeleteScheme()));
       
   223     connect(ui.pageOptions->CBFrontendEffects, SIGNAL(toggled(bool)), this, SLOT(onFrontendEffects(bool)) );
   223     connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsChanged()), this, SLOT(UpdateWeapons()));
   224     connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsChanged()), this, SLOT(UpdateWeapons()));
   224 
   225 
   225     connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect()));
   226     connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect()));
   226     connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
   227     connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
   227     pageSwitchMapper->setMapping(ui.pageNet->BtnNetSvrStart, ID_PAGE_NETSERVER);
   228     pageSwitchMapper->setMapping(ui.pageNet->BtnNetSvrStart, ID_PAGE_NETSERVER);
   281     ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini");
   282     ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini");
   282     ui.pageScheme->setModel(ammoSchemeModel);
   283     ui.pageScheme->setModel(ammoSchemeModel);
   283     ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel);
   284     ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel);
   284     ui.pageOptions->SchemesName->setModel(ammoSchemeModel);
   285     ui.pageOptions->SchemesName->setModel(ammoSchemeModel);
   285 
   286 
   286     wBackground = NULL;
   287     wBackground = new BGWidget(this);
   287     if (config->isFrontendEffects()) {
   288     wBackground->setFixedSize(this->width(), this->height());
   288        wBackground = new BGWidget(this);
   289     wBackground->lower();
   289        wBackground->setFixedSize(this->width(), this->height());
   290     wBackground->init();
   290        wBackground->lower();
   291     wBackground->enabled = config->isFrontendEffects();
   291        wBackground->init();
   292     wBackground->startAnimation();
   292        wBackground->startAnimation();
       
   293     }
       
   294 
   293 
   295     //Install all eventFilters :
   294     //Install all eventFilters :
   296 
   295 
   297     MouseOverFilter *filter = new MouseOverFilter();
   296     MouseOverFilter *filter = new MouseOverFilter();
   298     filter->setUi(&ui);
   297     filter->setUi(&ui);
   363   else {
   362   else {
   364     setWindowState(windowState() & static_cast<int>(!Qt::WindowFullScreen));
   363     setWindowState(windowState() & static_cast<int>(!Qt::WindowFullScreen));
   365   }
   364   }
   366 }
   365 }
   367 
   366 
       
   367 void HWForm::onFrontendEffects(bool value)
       
   368 {
       
   369     wBackground->enabled = value;
       
   370     if (value)
       
   371         wBackground->startAnimation();
       
   372     else
       
   373         wBackground->stopAnimation();
       
   374 }
       
   375 
   368 /*
   376 /*
   369 void HWForm::keyReleaseEvent(QKeyEvent *event)
   377 void HWForm::keyReleaseEvent(QKeyEvent *event)
   370 {
   378 {
   371   if (event->key() == Qt::Key_Escape) 
   379   if (event->key() == Qt::Key_Escape) 
   372     this->GoBack();
   380     this->GoBack();
   583     ui.Pages->setCurrentIndex(id);
   591     ui.Pages->setCurrentIndex(id);
   584 
   592 
   585     if (id == ID_PAGE_DRAWMAP)
   593     if (id == ID_PAGE_DRAWMAP)
   586         stopAnim = true;
   594         stopAnim = true;
   587 
   595 
   588     if (frontendEffects && !stopAnim)
   596     if (!stopAnim)
   589     {
   597     {
   590         /**Start animation :**/
   598         /**Start animation :**/
   591         int coeff = 1;
   599         int coeff = 1;
   592 #ifndef Q_OS_MAC
   600 #ifndef Q_OS_MAC
   593         coeff = 2;
   601         coeff = 2;
   595         ui.Pages->widget(id)->setGraphicsEffect(effectNew);
   603         ui.Pages->widget(id)->setGraphicsEffect(effectNew);
   596 
   604 
   597         QGraphicsOpacityEffect *effectLast = new QGraphicsOpacityEffect(ui.Pages->widget(lastid));
   605         QGraphicsOpacityEffect *effectLast = new QGraphicsOpacityEffect(ui.Pages->widget(lastid));
   598         ui.Pages->widget(lastid)->setGraphicsEffect(effectLast);
   606         ui.Pages->widget(lastid)->setGraphicsEffect(effectLast);
   599 #endif
   607 #endif
       
   608         // no effects, means 0 effect duration :D
       
   609         int duration = config->isFrontendEffects() ? 500 : 0;
   600 
   610 
   601         //New page animation
   611         //New page animation
   602         animationNewSlide = new QPropertyAnimation(ui.Pages->widget(id), "pos");
   612         animationNewSlide = new QPropertyAnimation(ui.Pages->widget(id), "pos");
   603         animationNewSlide->setDuration(500);
   613         animationNewSlide->setDuration(duration);
   604         animationNewSlide->setStartValue(QPoint(width()/coeff, 0));
   614         animationNewSlide->setStartValue(QPoint(width()/coeff, 0));
   605         animationNewSlide->setEndValue(QPoint(0, 0));
   615         animationNewSlide->setEndValue(QPoint(0, 0));
   606         animationNewSlide->setEasingCurve(QEasingCurve::OutExpo);
   616         animationNewSlide->setEasingCurve(QEasingCurve::OutExpo);
   607 
   617 
   608 #ifndef Q_OS_MAC
   618 #ifndef Q_OS_MAC
   609         animationNewOpacity = new QPropertyAnimation(effectNew, "opacity");
   619         animationNewOpacity = new QPropertyAnimation(effectNew, "opacity");
   610         animationNewOpacity->setDuration(500);
   620         animationNewOpacity->setDuration(duration);
   611         animationNewOpacity->setStartValue(0.01);
   621         animationNewOpacity->setStartValue(0.01);
   612         animationNewOpacity->setEndValue(1);
   622         animationNewOpacity->setEndValue(1);
   613         animationNewOpacity->setEasingCurve(QEasingCurve::OutExpo);
   623         animationNewOpacity->setEasingCurve(QEasingCurve::OutExpo);
   614 #endif
   624 #endif
   615 
   625 
   616         //Last page animation
   626         //Last page animation
   617         ui.Pages->widget(lastid)->setHidden(false);
   627         ui.Pages->widget(lastid)->setHidden(false);
   618 
   628 
   619         animationOldSlide = new QPropertyAnimation(ui.Pages->widget(lastid), "pos");
   629         animationOldSlide = new QPropertyAnimation(ui.Pages->widget(lastid), "pos");
   620         animationOldSlide->setDuration(500);
   630         animationOldSlide->setDuration(duration);
   621         animationOldSlide->setStartValue(QPoint(0, 0));
   631         animationOldSlide->setStartValue(QPoint(0, 0));
   622         animationOldSlide->setEndValue(QPoint(-width()/coeff, 0));
   632         animationOldSlide->setEndValue(QPoint(-width()/coeff, 0));
   623         animationOldSlide->setEasingCurve(QEasingCurve::OutExpo);
   633         animationOldSlide->setEasingCurve(QEasingCurve::OutExpo);
   624 
   634 
   625 #ifndef Q_OS_MAC
   635 #ifndef Q_OS_MAC
   626         animationOldOpacity = new QPropertyAnimation(effectLast, "opacity");
   636         animationOldOpacity = new QPropertyAnimation(effectLast, "opacity");
   627         animationOldOpacity->setDuration(500);
   637         animationOldOpacity->setDuration(duration);
   628         animationOldOpacity->setStartValue(1);
   638         animationOldOpacity->setStartValue(1);
   629         animationOldOpacity->setEndValue(0.01);
   639         animationOldOpacity->setEndValue(0.01);
   630         animationOldOpacity->setEasingCurve(QEasingCurve::OutExpo);
   640         animationOldOpacity->setEasingCurve(QEasingCurve::OutExpo);
   631 #endif
   641 #endif
   632 
   642 
   690     if (curid == ID_PAGE_SCHEME)
   700     if (curid == ID_PAGE_SCHEME)
   691         ammoSchemeModel->Save();
   701         ammoSchemeModel->Save();
   692 
   702 
   693     /**Start animation :**/
   703     /**Start animation :**/
   694 
   704 
   695     if (curid != 0 && frontendEffects && !stopAnim)
   705     if (curid != 0 && !stopAnim)
   696     {
   706     {
   697         int coeff = 1;
   707         int coeff = 1;
   698 #ifndef Q_OS_MAC
   708 #ifndef Q_OS_MAC
   699         coeff = 2;
   709         coeff = 2;
   700         QGraphicsOpacityEffect *effectNew = new QGraphicsOpacityEffect(ui.Pages->widget(id));
   710         QGraphicsOpacityEffect *effectNew = new QGraphicsOpacityEffect(ui.Pages->widget(id));
   702         ui.Pages->widget(id)->setGraphicsEffect(effectNew);
   712         ui.Pages->widget(id)->setGraphicsEffect(effectNew);
   703 
   713 
   704         QGraphicsOpacityEffect *effectLast = new QGraphicsOpacityEffect(ui.Pages->widget(curid));
   714         QGraphicsOpacityEffect *effectLast = new QGraphicsOpacityEffect(ui.Pages->widget(curid));
   705         ui.Pages->widget(curid)->setGraphicsEffect(effectLast);
   715         ui.Pages->widget(curid)->setGraphicsEffect(effectLast);
   706 #endif
   716 #endif
       
   717         // no effects, means 0 effect duration :D
       
   718         int duration = config->isFrontendEffects() ? 500 : 0;
   707 
   719 
   708         //Last page animation
   720         //Last page animation
   709         animationOldSlide = new QPropertyAnimation(ui.Pages->widget(id), "pos");
   721         animationOldSlide = new QPropertyAnimation(ui.Pages->widget(id), "pos");
   710         animationOldSlide->setDuration(500);
   722         animationOldSlide->setDuration(duration);
   711         animationOldSlide->setStartValue(QPoint(-width()/coeff, 0));
   723         animationOldSlide->setStartValue(QPoint(-width()/coeff, 0));
   712         animationOldSlide->setEndValue(QPoint(0, 0));
   724         animationOldSlide->setEndValue(QPoint(0, 0));
   713         animationOldSlide->setEasingCurve(QEasingCurve::OutExpo);
   725         animationOldSlide->setEasingCurve(QEasingCurve::OutExpo);
   714 
   726 
   715 #ifndef Q_OS_MAC
   727 #ifndef Q_OS_MAC
   716         animationOldOpacity = new QPropertyAnimation(effectLast, "opacity");
   728         animationOldOpacity = new QPropertyAnimation(effectLast, "opacity");
   717         animationOldOpacity->setDuration(500);
   729         animationOldOpacity->setDuration(duration);
   718         animationOldOpacity->setStartValue(1);
   730         animationOldOpacity->setStartValue(1);
   719         animationOldOpacity->setEndValue(0.01);
   731         animationOldOpacity->setEndValue(0.01);
   720         animationOldOpacity->setEasingCurve(QEasingCurve::OutExpo);
   732         animationOldOpacity->setEasingCurve(QEasingCurve::OutExpo);
   721 #endif
   733 #endif
   722         //New page animation
   734         //New page animation
   723         ui.Pages->widget(curid)->setHidden(false);
   735         ui.Pages->widget(curid)->setHidden(false);
   724 
   736 
   725         animationNewSlide = new QPropertyAnimation(ui.Pages->widget(curid), "pos");
   737         animationNewSlide = new QPropertyAnimation(ui.Pages->widget(curid), "pos");
   726         animationNewSlide->setDuration(500);
   738         animationNewSlide->setDuration(duration);
   727         animationNewSlide->setStartValue(QPoint(0, 0));
   739         animationNewSlide->setStartValue(QPoint(0, 0));
   728         animationNewSlide->setEndValue(QPoint(width()/coeff, 0));
   740         animationNewSlide->setEndValue(QPoint(width()/coeff, 0));
   729         animationNewSlide->setEasingCurve(QEasingCurve::OutExpo);
   741         animationNewSlide->setEasingCurve(QEasingCurve::OutExpo);
   730 
   742 
   731 #ifndef Q_OS_MAC
   743 #ifndef Q_OS_MAC
   732         animationNewOpacity = new QPropertyAnimation(effectNew, "opacity");
   744         animationNewOpacity = new QPropertyAnimation(effectNew, "opacity");
   733         animationNewOpacity->setDuration(500);
   745         animationNewOpacity->setDuration(duration);
   734         animationNewOpacity->setStartValue(0.01);
   746         animationNewOpacity->setStartValue(0.01);
   735         animationNewOpacity->setEndValue(1);
   747         animationNewOpacity->setEndValue(1);
   736         animationNewOpacity->setEasingCurve(QEasingCurve::OutExpo);
   748         animationNewOpacity->setEasingCurve(QEasingCurve::OutExpo);
   737 #endif
   749 #endif
   738 
   750 
   745 #endif
   757 #endif
   746         group->start();
   758         group->start();
   747 
   759 
   748         connect(animationNewSlide, SIGNAL(finished()), ui.Pages->widget(curid), SLOT(hide()));
   760         connect(animationNewSlide, SIGNAL(finished()), ui.Pages->widget(curid), SLOT(hide()));
   749     }
   761     }
   750 
       
   751 
       
   752 }
   762 }
   753 
   763 
   754 void HWForm::OpenSnapshotFolder()
   764 void HWForm::OpenSnapshotFolder()
   755 {
   765 {
   756     QString path = QDir::toNativeSeparators(cfgdir->absolutePath() + "/Screenshots");
   766     QString path = QDir::toNativeSeparators(cfgdir->absolutePath() + "/Screenshots");