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::Expanding, QSizePolicy::Expanding); |
|
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 // framerate |
|
575 framerateBox = new QSpinBox(pOptionsGroup); |
|
576 framerateBox->setRange(1, 200); |
|
577 framerateBox->setSingleStep(1); |
|
578 pOptLayout->addWidget(framerateBox, 6, 1); |
|
579 |
|
580 // label for Bitrate |
|
581 QLabel *labelBitrate = new QLabel(pOptionsGroup); |
|
582 labelBitrate->setText(QLabel::tr("Bitrate (Kbps)")); |
|
583 pOptLayout->addWidget(labelBitrate, 6, 2); |
|
584 |
|
585 // bitrate |
|
586 bitrateBox = new QSpinBox(pOptionsGroup); |
|
587 bitrateBox->setRange(100, 5000); |
|
588 bitrateBox->setSingleStep(100); |
|
589 pOptLayout->addWidget(bitrateBox, 6, 3); |
|
590 |
|
591 // button 'set default options' |
|
592 btnDefaults = new QPushButton(pOptionsGroup); |
|
593 btnDefaults->setText(QPushButton::tr("Set default options")); |
|
594 btnDefaults->setWhatsThis(QPushButton::tr("Restore default coding parameters")); |
|
595 pOptLayout->addWidget(btnDefaults, 7, 0, 1, 5); |
|
596 |
|
597 page3Layout->addWidget(pOptionsGroup, 1, 0); |
|
598 } |
|
599 #endif |
480 |
600 |
481 previousQuality = this->SLQuality->value(); |
601 previousQuality = this->SLQuality->value(); |
482 previousResolutionIndex = this->CBResolution->currentIndex(); |
602 previousResolutionIndex = this->CBResolution->currentIndex(); |
483 previousFullscreenValue = this->CBFullscreen->isChecked(); |
603 previousFullscreenValue = this->CBFullscreen->isChecked(); |
484 |
604 |
490 return NULL; |
610 return NULL; |
491 } |
611 } |
492 |
612 |
493 void PageOptions::connectSignals() |
613 void PageOptions::connectSignals() |
494 { |
614 { |
|
615 #ifdef VIDEOREC |
|
616 connect(checkUseGameRes, SIGNAL(stateChanged(int)), this, SLOT(changeUseGameRes(int))); |
|
617 connect(checkRecordAudio, SIGNAL(stateChanged(int)), this, SLOT(changeRecordAudio(int))); |
|
618 connect(comboAVFormats, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAVFormat(int))); |
|
619 connect(btnDefaults, SIGNAL(clicked()), this, SLOT(setDefaultOptions())); |
|
620 #endif |
|
621 |
495 connect(SLQuality, SIGNAL(valueChanged(int)), this, SLOT(setQuality(int))); |
622 connect(SLQuality, SIGNAL(valueChanged(int)), this, SLOT(setQuality(int))); |
496 connect(CBResolution, SIGNAL(currentIndexChanged(int)), this, SLOT(setResolution(int))); |
623 connect(CBResolution, SIGNAL(currentIndexChanged(int)), this, SLOT(setResolution(int))); |
497 connect(CBFullscreen, SIGNAL(stateChanged(int)), this, SLOT(setFullscreen(int))); |
624 connect(CBFullscreen, SIGNAL(stateChanged(int)), this, SLOT(setFullscreen(int))); |
498 connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int))); |
625 connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int))); |
499 connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick())); |
626 connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick())); |
500 connect(CBSavePassword, SIGNAL(stateChanged(int)), this, SLOT(savePwdChanged(int))); |
627 connect(CBSavePassword, SIGNAL(stateChanged(int)), this, SLOT(savePwdChanged(int))); |
501 } |
628 } |
502 |
629 |
503 PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent) |
630 PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent), config(0) |
504 { |
631 { |
505 initPage(); |
632 initPage(); |
506 } |
633 } |
507 |
634 |
508 void PageOptions::forceFullscreen(int index) |
635 void PageOptions::forceFullscreen(int index) |
617 sbProxyPort->setEnabled(b); |
744 sbProxyPort->setEnabled(b); |
618 leProxy->setEnabled(b); |
745 leProxy->setEnabled(b); |
619 leProxyLogin->setEnabled(b); |
746 leProxyLogin->setEnabled(b); |
620 leProxyPassword->setEnabled(b); |
747 leProxyPassword->setEnabled(b); |
621 } |
748 } |
|
749 |
|
750 // Video Recording |
|
751 |
|
752 void PageOptions::setConfig(GameUIConfig * config) |
|
753 { |
|
754 this->config = config; |
|
755 } |
|
756 |
|
757 // user changed file format, we need to update list of codecs |
|
758 void PageOptions::changeAVFormat(int index) |
|
759 { |
|
760 // remember selected codecs |
|
761 QString prevVCodec = videoCodec(); |
|
762 QString prevACodec = audioCodec(); |
|
763 |
|
764 // clear lists of codecs |
|
765 comboVideoCodecs->clear(); |
|
766 comboAudioCodecs->clear(); |
|
767 |
|
768 // get list of codecs for specified format |
|
769 LibavInteraction::instance().fillCodecs(comboAVFormats->itemData(index).toString(), comboVideoCodecs, comboAudioCodecs); |
|
770 |
|
771 // disable audio if there is no audio codec |
|
772 if (comboAudioCodecs->count() == 0) |
|
773 { |
|
774 checkRecordAudio->setChecked(false); |
|
775 checkRecordAudio->setEnabled(false); |
|
776 } |
|
777 else |
|
778 checkRecordAudio->setEnabled(true); |
|
779 |
|
780 // restore selected codecs if possible |
|
781 int iVCodec = comboVideoCodecs->findData(prevVCodec); |
|
782 if (iVCodec != -1) |
|
783 comboVideoCodecs->setCurrentIndex(iVCodec); |
|
784 int iACodec = comboAudioCodecs->findData(prevACodec); |
|
785 if (iACodec != -1) |
|
786 comboAudioCodecs->setCurrentIndex(iACodec); |
|
787 } |
|
788 |
|
789 // user switched checkbox 'use game resolution' |
|
790 void PageOptions::changeUseGameRes(int state) |
|
791 { |
|
792 if (state && config) |
|
793 { |
|
794 // set resolution to game resolution |
|
795 QRect resolution = config->vid_Resolution(); |
|
796 widthEdit->setText(QString::number(resolution.width())); |
|
797 heightEdit->setText(QString::number(resolution.height())); |
|
798 } |
|
799 widthEdit->setEnabled(!state); |
|
800 heightEdit->setEnabled(!state); |
|
801 } |
|
802 |
|
803 // user switched checkbox 'record audio' |
|
804 void PageOptions::changeRecordAudio(int state) |
|
805 { |
|
806 comboAudioCodecs->setEnabled(!!state); |
|
807 } |
|
808 |
|
809 void PageOptions::setDefaultCodecs() |
|
810 { |
|
811 // VLC should be able to handle any of these configurations |
|
812 // Quicktime X only opens the first one |
|
813 // Windows Media Player TODO |
|
814 if (tryCodecs("mp4", "libx264", "aac")) |
|
815 return; |
|
816 if (tryCodecs("mp4", "libx264", "libfaac")) |
|
817 return; |
|
818 if (tryCodecs("mp4", "libx264", "libmp3lame")) |
|
819 return; |
|
820 if (tryCodecs("mp4", "libx264", "mp2")) |
|
821 return; |
|
822 if (tryCodecs("avi", "libxvid", "libmp3lame")) |
|
823 return; |
|
824 if (tryCodecs("avi", "libxvid", "ac3_fixed")) |
|
825 return; |
|
826 if (tryCodecs("avi", "libxvid", "mp2")) |
|
827 return; |
|
828 if (tryCodecs("avi", "mpeg4", "libmp3lame")) |
|
829 return; |
|
830 if (tryCodecs("avi", "mpeg4", "ac3_fixed")) |
|
831 return; |
|
832 if (tryCodecs("avi", "mpeg4", "mp2")) |
|
833 return; |
|
834 |
|
835 // this shouldn't happen, just in case |
|
836 if (tryCodecs("ogg", "libtheora", "libvorbis")) |
|
837 return; |
|
838 tryCodecs("ogg", "libtheora", "flac"); |
|
839 } |
|
840 |
|
841 void PageOptions::setDefaultOptions() |
|
842 { |
|
843 framerateBox->setValue(30); |
|
844 bitrateBox->setValue(1000); |
|
845 checkRecordAudio->setChecked(true); |
|
846 checkUseGameRes->setChecked(true); |
|
847 setDefaultCodecs(); |
|
848 } |
|
849 |
|
850 bool PageOptions::tryCodecs(const QString & format, const QString & vcodec, const QString & acodec) |
|
851 { |
|
852 // first we should change format |
|
853 int iFormat = comboAVFormats->findData(format); |
|
854 if (iFormat == -1) |
|
855 return false; |
|
856 comboAVFormats->setCurrentIndex(iFormat); |
|
857 // format was changed, so lists of codecs were automatically updated to codecs supported by this format |
|
858 |
|
859 // try to find video codec |
|
860 int iVCodec = comboVideoCodecs->findData(vcodec); |
|
861 if (iVCodec == -1) |
|
862 return false; |
|
863 comboVideoCodecs->setCurrentIndex(iVCodec); |
|
864 |
|
865 // try to find audio codec |
|
866 int iACodec = comboAudioCodecs->findData(acodec); |
|
867 if (iACodec == -1 && checkRecordAudio->isChecked()) |
|
868 return false; |
|
869 if (iACodec != -1) |
|
870 comboAudioCodecs->setCurrentIndex(iACodec); |
|
871 |
|
872 return true; |
|
873 } |