475 onProxyTypeChanged(); |
482 onProxyTypeChanged(); |
476 } |
483 } |
477 |
484 |
478 page2Layout->addWidget(new QWidget(this), 2, 0); |
485 page2Layout->addWidget(new QWidget(this), 2, 0); |
479 } |
486 } |
|
487 #ifdef VIDEOREC |
|
488 { // page 3 |
|
489 QGridLayout * page3Layout = new QGridLayout(page3); |
|
490 |
|
491 IconedGroupBox* pOptionsGroup = new IconedGroupBox(this); |
|
492 pOptionsGroup->setIcon(QIcon(":/res/Settings.png")); // FIXME |
|
493 pOptionsGroup->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
|
494 pOptionsGroup->setTitle(QGroupBox::tr("Video recording options")); |
|
495 QGridLayout * pOptLayout = new QGridLayout(pOptionsGroup); |
|
496 |
|
497 // label for format |
|
498 QLabel *labelFormat = new QLabel(pOptionsGroup); |
|
499 labelFormat->setText(QLabel::tr("Format")); |
|
500 pOptLayout->addWidget(labelFormat, 0, 0); |
|
501 |
|
502 // list of supported formats |
|
503 comboAVFormats = new QComboBox(pOptionsGroup); |
|
504 pOptLayout->addWidget(comboAVFormats, 0, 1, 1, 4); |
|
505 LibavInteraction::instance().fillFormats(comboAVFormats); |
|
506 |
|
507 // separator |
|
508 QFrame * hr = new QFrame(pOptionsGroup); |
|
509 hr->setFrameStyle(QFrame::HLine); |
|
510 hr->setLineWidth(3); |
|
511 hr->setFixedHeight(10); |
|
512 pOptLayout->addWidget(hr, 1, 0, 1, 5); |
|
513 |
|
514 // label for audio codec |
|
515 QLabel *labelACodec = new QLabel(pOptionsGroup); |
|
516 labelACodec->setText(QLabel::tr("Audio codec")); |
|
517 pOptLayout->addWidget(labelACodec, 2, 0); |
|
518 |
|
519 // list of supported audio codecs |
|
520 comboAudioCodecs = new QComboBox(pOptionsGroup); |
|
521 pOptLayout->addWidget(comboAudioCodecs, 2, 1, 1, 3); |
|
522 |
|
523 // checkbox 'record audio' |
|
524 checkRecordAudio = new QCheckBox(pOptionsGroup); |
|
525 checkRecordAudio->setText(QCheckBox::tr("Record audio")); |
|
526 pOptLayout->addWidget(checkRecordAudio, 2, 4); |
|
527 |
|
528 // separator |
|
529 hr = new QFrame(pOptionsGroup); |
|
530 hr->setFrameStyle(QFrame::HLine); |
|
531 hr->setLineWidth(3); |
|
532 hr->setFixedHeight(10); |
|
533 pOptLayout->addWidget(hr, 3, 0, 1, 5); |
|
534 |
|
535 // label for video codec |
|
536 QLabel *labelVCodec = new QLabel(pOptionsGroup); |
|
537 labelVCodec->setText(QLabel::tr("Video codec")); |
|
538 pOptLayout->addWidget(labelVCodec, 4, 0); |
|
539 |
|
540 // list of supported video codecs |
|
541 comboVideoCodecs = new QComboBox(pOptionsGroup); |
|
542 pOptLayout->addWidget(comboVideoCodecs, 4, 1, 1, 4); |
|
543 |
|
544 // label for resolution |
|
545 QLabel *labelRes = new QLabel(pOptionsGroup); |
|
546 labelRes->setText(QLabel::tr("Resolution")); |
|
547 pOptLayout->addWidget(labelRes, 5, 0); |
|
548 |
|
549 // width |
|
550 widthEdit = new QLineEdit(pOptionsGroup); |
|
551 widthEdit->setValidator(new QIntValidator(this)); |
|
552 pOptLayout->addWidget(widthEdit, 5, 1); |
|
553 |
|
554 // x |
|
555 QLabel *labelX = new QLabel(pOptionsGroup); |
|
556 labelX->setText("X"); |
|
557 pOptLayout->addWidget(labelX, 5, 2); |
|
558 |
|
559 // height |
|
560 heightEdit = new QLineEdit(pOptionsGroup); |
|
561 heightEdit->setValidator(new QIntValidator(pOptionsGroup)); |
|
562 pOptLayout->addWidget(heightEdit, 5, 3); |
|
563 |
|
564 // checkbox 'use game resolution' |
|
565 checkUseGameRes = new QCheckBox(pOptionsGroup); |
|
566 checkUseGameRes->setText(QCheckBox::tr("Use game resolution")); |
|
567 pOptLayout->addWidget(checkUseGameRes, 5, 4); |
|
568 |
|
569 // label for framerate |
|
570 QLabel *labelFramerate = new QLabel(pOptionsGroup); |
|
571 labelFramerate->setText(QLabel::tr("Framerate")); |
|
572 pOptLayout->addWidget(labelFramerate, 6, 0); |
|
573 |
|
574 framerateBox = new QComboBox(pOptionsGroup); |
|
575 framerateBox->addItem("24 fps", 24); |
|
576 framerateBox->addItem("25 fps", 25); |
|
577 framerateBox->addItem("30 fps", 30); |
|
578 framerateBox->addItem("50 fps", 50); |
|
579 framerateBox->addItem("60 fps", 60); |
|
580 pOptLayout->addWidget(framerateBox, 6, 1); |
|
581 |
|
582 // label for Bitrate |
|
583 QLabel *labelBitrate = new QLabel(pOptionsGroup); |
|
584 labelBitrate->setText(QLabel::tr("Bitrate (Kbps)")); |
|
585 pOptLayout->addWidget(labelBitrate, 6, 2); |
|
586 |
|
587 // bitrate |
|
588 bitrateBox = new QSpinBox(pOptionsGroup); |
|
589 bitrateBox->setRange(100, 5000); |
|
590 bitrateBox->setSingleStep(100); |
|
591 pOptLayout->addWidget(bitrateBox, 6, 3); |
|
592 |
|
593 // button 'set default options' |
|
594 btnDefaults = new QPushButton(pOptionsGroup); |
|
595 btnDefaults->setText(QPushButton::tr("Set default options")); |
|
596 btnDefaults->setWhatsThis(QPushButton::tr("Restore default coding parameters")); |
|
597 pOptLayout->addWidget(btnDefaults, 7, 0, 1, 5); |
|
598 |
|
599 page3Layout->addWidget(pOptionsGroup, 1, 0); |
|
600 } |
|
601 #endif |
480 |
602 |
481 previousQuality = this->SLQuality->value(); |
603 previousQuality = this->SLQuality->value(); |
482 previousResolutionIndex = this->CBResolution->currentIndex(); |
604 previousResolutionIndex = this->CBResolution->currentIndex(); |
483 previousFullscreenValue = this->CBFullscreen->isChecked(); |
605 previousFullscreenValue = this->CBFullscreen->isChecked(); |
484 |
606 |
490 return NULL; |
612 return NULL; |
491 } |
613 } |
492 |
614 |
493 void PageOptions::connectSignals() |
615 void PageOptions::connectSignals() |
494 { |
616 { |
|
617 #ifdef VIDEOREC |
|
618 connect(checkUseGameRes, SIGNAL(stateChanged(int)), this, SLOT(changeUseGameRes(int))); |
|
619 connect(checkRecordAudio, SIGNAL(stateChanged(int)), this, SLOT(changeRecordAudio(int))); |
|
620 connect(comboAVFormats, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAVFormat(int))); |
|
621 connect(btnDefaults, SIGNAL(clicked()), this, SLOT(setDefaultOptions())); |
|
622 #endif |
|
623 |
495 connect(SLQuality, SIGNAL(valueChanged(int)), this, SLOT(setQuality(int))); |
624 connect(SLQuality, SIGNAL(valueChanged(int)), this, SLOT(setQuality(int))); |
496 connect(CBResolution, SIGNAL(currentIndexChanged(int)), this, SLOT(setResolution(int))); |
625 connect(CBResolution, SIGNAL(currentIndexChanged(int)), this, SLOT(setResolution(int))); |
497 connect(CBFullscreen, SIGNAL(stateChanged(int)), this, SLOT(setFullscreen(int))); |
626 connect(CBFullscreen, SIGNAL(stateChanged(int)), this, SLOT(setFullscreen(int))); |
498 connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int))); |
627 connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int))); |
499 connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick())); |
628 connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick())); |
500 connect(CBSavePassword, SIGNAL(stateChanged(int)), this, SLOT(savePwdChanged(int))); |
629 connect(CBSavePassword, SIGNAL(stateChanged(int)), this, SLOT(savePwdChanged(int))); |
501 } |
630 } |
502 |
631 |
503 PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent) |
632 PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent), config(0) |
504 { |
633 { |
505 initPage(); |
634 initPage(); |
506 } |
635 } |
507 |
636 |
508 void PageOptions::forceFullscreen(int index) |
637 void PageOptions::forceFullscreen(int index) |
617 sbProxyPort->setEnabled(b); |
746 sbProxyPort->setEnabled(b); |
618 leProxy->setEnabled(b); |
747 leProxy->setEnabled(b); |
619 leProxyLogin->setEnabled(b); |
748 leProxyLogin->setEnabled(b); |
620 leProxyPassword->setEnabled(b); |
749 leProxyPassword->setEnabled(b); |
621 } |
750 } |
|
751 |
|
752 // Video Recording |
|
753 |
|
754 void PageOptions::setConfig(GameUIConfig * config) |
|
755 { |
|
756 this->config = config; |
|
757 } |
|
758 |
|
759 // user changed file format, we need to update list of codecs |
|
760 void PageOptions::changeAVFormat(int index) |
|
761 { |
|
762 // remember selected codecs |
|
763 QString prevVCodec = videoCodec(); |
|
764 QString prevACodec = audioCodec(); |
|
765 |
|
766 // clear lists of codecs |
|
767 comboVideoCodecs->clear(); |
|
768 comboAudioCodecs->clear(); |
|
769 |
|
770 // get list of codecs for specified format |
|
771 LibavInteraction::instance().fillCodecs(comboAVFormats->itemData(index).toString(), comboVideoCodecs, comboAudioCodecs); |
|
772 |
|
773 // disable audio if there is no audio codec |
|
774 if (comboAudioCodecs->count() == 0) |
|
775 { |
|
776 checkRecordAudio->setChecked(false); |
|
777 checkRecordAudio->setEnabled(false); |
|
778 } |
|
779 else |
|
780 checkRecordAudio->setEnabled(true); |
|
781 |
|
782 // restore selected codecs if possible |
|
783 int iVCodec = comboVideoCodecs->findData(prevVCodec); |
|
784 if (iVCodec != -1) |
|
785 comboVideoCodecs->setCurrentIndex(iVCodec); |
|
786 int iACodec = comboAudioCodecs->findData(prevACodec); |
|
787 if (iACodec != -1) |
|
788 comboAudioCodecs->setCurrentIndex(iACodec); |
|
789 } |
|
790 |
|
791 // user switched checkbox 'use game resolution' |
|
792 void PageOptions::changeUseGameRes(int state) |
|
793 { |
|
794 if (state && config) |
|
795 { |
|
796 // set resolution to game resolution |
|
797 QRect resolution = config->vid_Resolution(); |
|
798 widthEdit->setText(QString::number(resolution.width())); |
|
799 heightEdit->setText(QString::number(resolution.height())); |
|
800 } |
|
801 widthEdit->setEnabled(!state); |
|
802 heightEdit->setEnabled(!state); |
|
803 } |
|
804 |
|
805 // user switched checkbox 'record audio' |
|
806 void PageOptions::changeRecordAudio(int state) |
|
807 { |
|
808 comboAudioCodecs->setEnabled(!!state); |
|
809 } |
|
810 |
|
811 void PageOptions::setDefaultCodecs() |
|
812 { |
|
813 // VLC should be able to handle any of these configurations |
|
814 // Quicktime X only opens the first one |
|
815 // Windows Media Player TODO |
|
816 if (tryCodecs("mp4", "libx264", "aac")) |
|
817 return; |
|
818 if (tryCodecs("mp4", "libx264", "libfaac")) |
|
819 return; |
|
820 if (tryCodecs("mp4", "libx264", "libmp3lame")) |
|
821 return; |
|
822 if (tryCodecs("mp4", "libx264", "mp2")) |
|
823 return; |
|
824 if (tryCodecs("avi", "libxvid", "libmp3lame")) |
|
825 return; |
|
826 if (tryCodecs("avi", "libxvid", "ac3_fixed")) |
|
827 return; |
|
828 if (tryCodecs("avi", "libxvid", "mp2")) |
|
829 return; |
|
830 if (tryCodecs("avi", "mpeg4", "libmp3lame")) |
|
831 return; |
|
832 if (tryCodecs("avi", "mpeg4", "ac3_fixed")) |
|
833 return; |
|
834 if (tryCodecs("avi", "mpeg4", "mp2")) |
|
835 return; |
|
836 |
|
837 // this shouldn't happen, just in case |
|
838 if (tryCodecs("ogg", "libtheora", "libvorbis")) |
|
839 return; |
|
840 tryCodecs("ogg", "libtheora", "flac"); |
|
841 } |
|
842 |
|
843 void PageOptions::setDefaultOptions() |
|
844 { |
|
845 framerateBox->setCurrentIndex(2); |
|
846 bitrateBox->setValue(1000); |
|
847 checkRecordAudio->setChecked(true); |
|
848 checkUseGameRes->setChecked(true); |
|
849 setDefaultCodecs(); |
|
850 } |
|
851 |
|
852 bool PageOptions::tryCodecs(const QString & format, const QString & vcodec, const QString & acodec) |
|
853 { |
|
854 // first we should change format |
|
855 int iFormat = comboAVFormats->findData(format); |
|
856 if (iFormat == -1) |
|
857 return false; |
|
858 comboAVFormats->setCurrentIndex(iFormat); |
|
859 // format was changed, so lists of codecs were automatically updated to codecs supported by this format |
|
860 |
|
861 // try to find video codec |
|
862 int iVCodec = comboVideoCodecs->findData(vcodec); |
|
863 if (iVCodec == -1) |
|
864 return false; |
|
865 comboVideoCodecs->setCurrentIndex(iVCodec); |
|
866 |
|
867 // try to find audio codec |
|
868 int iACodec = comboAudioCodecs->findData(acodec); |
|
869 if (iACodec == -1 && checkRecordAudio->isChecked()) |
|
870 return false; |
|
871 if (iACodec != -1) |
|
872 comboAudioCodecs->setCurrentIndex(iACodec); |
|
873 |
|
874 return true; |
|
875 } |