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;
37 mInputButtonGroup =
new QButtonGroup ();
39 for (
unsigned ndx (0); ndx < 8; ndx++)
41 for (
unsigned ndx (0); ndx < 4; ndx++)
47 mWithAudioCheckBox =
new QCheckBox (
"With Audio",
this);
48 mCheckFor4kCheckBox =
new QCheckBox (
"Check for 4K Input",
this);
49 mCheckFixedReference =
new QCheckBox (
"Fixed Reference",
this);
56 mFrameGrabber->
SetDeviceIndex (mBoardChoiceCombo->currentIndex ());
59 QVBoxLayout * layout (
new QVBoxLayout);
60 layout->addWidget (mBoardChoiceCombo);
61 layout->addWidget (mVideoPreviewWidget);
63 #if defined (INCLUDE_AJACC)
64 QVBoxLayout * bottomLeftLayout (
new QVBoxLayout);
65 bottomLeftLayout->setContentsMargins (0, 0, 0, 0);
67 for (
QButtonIterator iter (mInputButtonGroup->buttons()); iter.hasNext (); )
68 bottomLeftLayout->addWidget (iter.next());
70 bottomLeftLayout->addWidget (mWithAudioCheckBox);
71 bottomLeftLayout->addWidget (mCheckFor4kCheckBox);
72 bottomLeftLayout->addStretch (1);
74 QVBoxLayout * bottomRightLayout (
new QVBoxLayout);
75 bottomRightLayout->setContentsMargins (0, 0, 0, 0);
77 mCaptionButtonGroup =
new QButtonGroup ();
79 for (
unsigned ndx (1); ndx <= 8; ndx++)
80 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())),
84 for (
QButtonIterator iter (mCaptionButtonGroup->buttons()); iter.hasNext (); )
85 bottomRightLayout->addWidget (iter.next());
87 QHBoxLayout * bottomLayout (
new QHBoxLayout);
88 bottomLayout->setContentsMargins (0, 0, 0, 0);
90 bottomLayout->addLayout (bottomLeftLayout);
91 bottomLayout->addLayout (bottomRightLayout);
92 layout->addLayout (bottomLayout);
93 #else // !defined (INCLUDE_AJACC)
94 for (
QButtonIterator iter(mInputButtonGroup->buttons()); iter.hasNext(); )
95 layout->addWidget (iter.next());
96 layout->addWidget (mWithAudioCheckBox);
97 layout->addWidget (mCheckFor4kCheckBox);
98 layout->addWidget (mCheckFixedReference);
99 #endif // !defined (INCLUDE_AJACC)
101 layout->addStretch (1);
104 QObject::connect (mBoardChoiceCombo, SIGNAL(currentIndexChanged(
int)),
this, SLOT(RequestDeviceChange(
const int)));
105 QObject::connect (mInputButtonGroup, SIGNAL(buttonReleased(
int)),
this, SLOT(inputChanged(
int)));
106 QObject::connect (mWithAudioCheckBox, SIGNAL(stateChanged(
int)),
this, SLOT(withAudioChanged(
int)));
107 QObject::connect (mCheckFixedReference, SIGNAL(toggled(
bool)),
this, SLOT(fixedRefChanged(
bool)));
108 QObject::connect (mCheckFor4kCheckBox, SIGNAL(stateChanged(
int)),
this, SLOT(checkFor4kChanged(
int)));
109 connect (mFrameGrabber, SIGNAL(newFrame(
const QImage &,
bool)), mVideoPreviewWidget, SLOT(updateFrame(
const QImage &,
bool)));
110 connect (mFrameGrabber, SIGNAL(newStatusString(
const QString)), mVideoPreviewWidget, SLOT(updateStatusString(
const QString)));
111 #if defined (INCLUDE_AJACC)
112 connect (mFrameGrabber, SIGNAL (captionScreenChanged (
const ushort *)), mVideoPreviewWidget, SLOT (updateCaptionScreen (
const ushort *)));
113 QObject::connect (mCaptionButtonGroup, SIGNAL (buttonReleased (
int)), mFrameGrabber, SLOT (changeCaptionChannel (
int)));
114 #endif // defined (INCLUDE_AJACC)
117 mFrameGrabber->start ();
118 mTimerID = startTimer (100);
129 delete mFrameGrabber;
134 void NTV2QtPreview::RequestDeviceChange (
const int inDeviceIndexNum)
139 qDebug (
"## NOTE: Device changed to %d", inDeviceIndexNum);
144 void NTV2QtPreview::inputChanged (
int inputRadioButtonId)
154 qDebug (
"## DEBUG: NTV2QtPreview::inputChanged: off");
165 void NTV2QtPreview::withAudioChanged (
int state)
167 mFrameGrabber->
SetWithAudio (state == Qt::Checked ?
true :
false);
172 void NTV2QtPreview::fixedRefChanged (
bool checked)
179 void NTV2QtPreview::checkFor4kChanged (
int state)
186 void NTV2QtPreview::updateInputs (
void)
188 CNTV2Card ntv2Card (mBoardChoiceCombo->currentIndex());
189 if (ntv2Card.IsOpen())
191 for (
QButtonIterator iter(mInputButtonGroup->buttons()); iter.hasNext(); )
193 QRadioButton * pButton (
reinterpret_cast<QRadioButton*
>(iter.next()));
197 const bool hasInputSource (ntv2Card.features().CanDoInputSource(inputSource));
198 const string videoFormatStr (hasInputSource ? ::
NTV2VideoFormatToString(ntv2Card.GetInputVideoFormat(inputSource)) :
"");
199 const QString buttonLabel (QString(
"%1 %2").arg(::
NTV2InputSourceToString(inputSource,
true).c_str(), videoFormatStr.empty() ?
"No Detected Input" : videoFormatStr.c_str()));
200 pButton->setText(buttonLabel);
201 pButton->setEnabled(hasInputSource);
204 #if defined (INCLUDE_AJACC)
205 const bool hasCustomAnc (mDevice.features().CanDoCustomAnc());
206 for (
QButtonIterator iter (mCaptionButtonGroup->buttons()); iter.hasNext(); )
207 iter.next()->setEnabled(hasCustomAnc);
208 #endif // defined (INCLUDE_AJACC)
213 void NTV2QtPreview::timerEvent (QTimerEvent * event)
215 if (event->timerId() == mTimerID)
218 QWidget::timerEvent(event);
222 void NTV2QtPreview::devicesChanged (
void)
224 qDebug() <<
"devicesChanged";
228 mBoardChoiceCombo->clear();
229 for (
ULWord ndx(0); ndx < 100; ndx++)
233 mBoardChoiceCombo->addItem(tr(device.
GetDisplayName().c_str()), QVariant());
235 {mBoardChoiceCombo->addItem(tr(
"No Devices Found"));
break;}
239 mBoardChoiceCombo->setCurrentIndex(0);
243 void NTV2QtPreview::PnpCallback (
AJAPnpMessage inMessage,
void * pUserData)
249 pMainWindow->devicesChanged();