10 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
29 : QDialog (parent, flags)
31 if (objectName ().isEmpty ())
32 setObjectName (QString::fromUtf8 (
"Dialog"));
34 mBoardChoiceCombo =
new QComboBox;
35 for (
ULWord ndx (0); ndx < 100; ndx++)
39 mBoardChoiceCombo->addItem (tr (device.
GetDisplayName ().c_str ()));
41 {mBoardChoiceCombo->addItem (tr (
"No Devices Found"));
break;}
45 mBoardChoiceCombo->setCurrentIndex (0);
48 mInputButtonGroup =
new QButtonGroup ();
50 for (
unsigned ndx (0); ndx < 8; ndx++)
52 for (
unsigned ndx (0); ndx < 4; ndx++)
58 mWithAudioCheckBox =
new QCheckBox (
"With Audio",
this);
59 mCheckFor4kCheckBox =
new QCheckBox (
"Check for 4K Input",
this);
60 mCheckFixedReference =
new QCheckBox (
"Fixed Reference",
this);
67 mStreamGrabber->
SetDeviceIndex (mBoardChoiceCombo->currentIndex ());
70 QVBoxLayout * layout (
new QVBoxLayout);
71 layout->addWidget (mBoardChoiceCombo);
72 layout->addWidget (mVideoPreviewWidget);
74 #if defined (INCLUDE_AJACC)
75 QVBoxLayout * bottomLeftLayout (
new QVBoxLayout);
76 bottomLeftLayout->setContentsMargins (0, 0, 0, 0);
78 for (
QButtonIterator iter (mInputButtonGroup->buttons()); iter.hasNext (); )
79 bottomLeftLayout->addWidget (iter.next());
81 bottomLeftLayout->addWidget (mWithAudioCheckBox);
82 bottomLeftLayout->addWidget (mCheckFor4kCheckBox);
83 bottomLeftLayout->addStretch (1);
85 QVBoxLayout * bottomRightLayout (
new QVBoxLayout);
86 bottomRightLayout->setContentsMargins (0, 0, 0, 0);
88 mCaptionButtonGroup =
new QButtonGroup ();
90 for (
unsigned ndx (1); ndx <= 8; ndx++)
91 mCaptionButtonGroup->addButton (
new QRadioButton (QString (
"%1%2").arg (
string (ndx < 5 ?
"CC" :
"TXT").c_str(),
string (1,
char ((ndx < 5 ? ndx : ndx - 4) +
'0')).c_str())),
95 for (
QButtonIterator iter (mCaptionButtonGroup->buttons()); iter.hasNext (); )
96 bottomRightLayout->addWidget (iter.next());
98 QHBoxLayout * bottomLayout (
new QHBoxLayout);
99 bottomLayout->setContentsMargins (0, 0, 0, 0);
101 bottomLayout->addLayout (bottomLeftLayout);
102 bottomLayout->addLayout (bottomRightLayout);
103 layout->addLayout (bottomLayout);
104 #else // !defined (INCLUDE_AJACC)
105 for (
QButtonIterator iter (mInputButtonGroup->buttons()); iter.hasNext (); )
106 layout->addWidget (iter.next());
107 layout->addWidget (mWithAudioCheckBox);
108 layout->addWidget (mCheckFor4kCheckBox);
109 layout->addWidget (mCheckFixedReference);
110 #endif // !defined (INCLUDE_AJACC)
112 layout->addStretch (1);
115 QObject::connect (mBoardChoiceCombo, SIGNAL (currentIndexChanged (
int)),
this, SLOT (RequestDeviceChange (
const int)));
116 QObject::connect (mInputButtonGroup, SIGNAL (buttonReleased (
int)),
this, SLOT (inputChanged (
int)));
117 QObject::connect (mWithAudioCheckBox, SIGNAL (stateChanged (
int)),
this, SLOT (withAudioChanged (
int)));
118 QObject::connect (mCheckFixedReference, SIGNAL (toggled (
bool)),
this, SLOT (fixedRefChanged (
bool)));
119 QObject::connect (mCheckFor4kCheckBox, SIGNAL (stateChanged (
int)),
this, SLOT (checkFor4kChanged (
int)));
120 connect (mStreamGrabber, SIGNAL (newFrame (
const QImage &,
bool)), mVideoPreviewWidget, SLOT (updateFrame (
const QImage &,
bool)));
121 connect (mStreamGrabber, SIGNAL (newStatusString (
const QString)), mVideoPreviewWidget, SLOT (updateStatusString (
const QString)));
122 #if defined (INCLUDE_AJACC)
123 connect (mFrameGrabber, SIGNAL (captionScreenChanged (
const ushort *)), mVideoPreviewWidget, SLOT (updateCaptionScreen (
const ushort *)));
124 QObject::connect (mCaptionButtonGroup, SIGNAL (buttonReleased (
int)), mFrameGrabber, SLOT (changeCaptionChannel (
int)));
125 #endif // defined (INCLUDE_AJACC)
128 mStreamGrabber->start ();
129 mTimerID = startTimer (100);
139 delete mStreamGrabber;
144 void NTV2StreamPreview::RequestDeviceChange (
const int inDeviceIndexNum)
149 qDebug (
"## NOTE: Device changed to %d", inDeviceIndexNum);
154 void NTV2StreamPreview::inputChanged (
int inputRadioButtonId)
166 qDebug (
"## DEBUG: NTV2StreamPreview::inputChanged: off");
176 void NTV2StreamPreview::withAudioChanged (
int state)
178 mStreamGrabber->
SetWithAudio (state == Qt::Checked ?
true :
false);
183 void NTV2StreamPreview::fixedRefChanged (
bool checked)
190 void NTV2StreamPreview::checkFor4kChanged (
int state)
197 void NTV2StreamPreview::updateInputs (
void)
199 CNTV2Card ntv2Card (mBoardChoiceCombo->currentIndex());
200 if (ntv2Card.IsOpen())
204 for (
QButtonIterator iter (mInputButtonGroup->buttons()); iter.hasNext (); )
206 QRadioButton * pButton (
reinterpret_cast <QRadioButton*
> (iter.next ()));
211 const string videoFormatStr (hasInputSource ? ::
NTV2VideoFormatToString (ntv2Card.GetInputVideoFormat (inputSource)) :
"");
212 const QString buttonLabel (QString (
"%1 %2").arg (::
NTV2InputSourceToString (inputSource,
true).c_str(), videoFormatStr.empty() ?
"No Detected Input" : videoFormatStr.c_str()));
213 pButton->setText (buttonLabel);
214 pButton->setEnabled (hasInputSource);
218 #if defined (INCLUDE_AJACC)
220 for (
QButtonIterator iter (mCaptionButtonGroup->buttons()); iter.hasNext (); )
221 iter.next()->setEnabled (hasCustomAnc);
222 #endif // defined (INCLUDE_AJACC)
229 void NTV2StreamPreview::timerEvent (QTimerEvent * event)
231 if (event->timerId () == mTimerID)
234 QWidget::timerEvent (event);
239 void NTV2StreamPreview::devicesChanged (
void)
241 qDebug () << QString (
"devicesChanged");
245 mBoardChoiceCombo->clear ();
246 for (
ULWord ndx (0); ndx < 100; ndx++)
250 mBoardChoiceCombo->addItem (tr (device.
GetDisplayName ().c_str ()));
252 {mBoardChoiceCombo->addItem (tr (
"No Devices Found"));
break;}
256 mBoardChoiceCombo->setCurrentIndex (0);
261 void NTV2StreamPreview::PnpCallback (
AJAPnpMessage inMessage,
void * pUserData)
268 pMainWindow->devicesChanged ();