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 mFrameGrabber->
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 (mFrameGrabber, SIGNAL (newFrame (
const QImage &,
bool)), mVideoPreviewWidget, SLOT (updateFrame (
const QImage &,
bool)));
121 connect (mFrameGrabber, 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 mFrameGrabber->start ();
129 mTimerID = startTimer (100);
139 delete mFrameGrabber;
144 void NTV2QtPreview::RequestDeviceChange (
const int inDeviceIndexNum)
149 qDebug (
"## NOTE: Device changed to %d", inDeviceIndexNum);
154 void NTV2QtPreview::inputChanged (
int inputRadioButtonId)
164 qDebug (
"## DEBUG: NTV2QtPreview::inputChanged: off");
175 void NTV2QtPreview::withAudioChanged (
int state)
177 mFrameGrabber->
SetWithAudio (state == Qt::Checked ?
true :
false);
182 void NTV2QtPreview::fixedRefChanged (
bool checked)
189 void NTV2QtPreview::checkFor4kChanged (
int state)
196 void NTV2QtPreview::updateInputs (
void)
198 CNTV2Card ntv2Card (mBoardChoiceCombo->currentIndex());
199 if (ntv2Card.IsOpen())
201 for (
QButtonIterator iter(mInputButtonGroup->buttons()); iter.hasNext(); )
203 QRadioButton * pButton (
reinterpret_cast<QRadioButton*
>(iter.next()));
207 const bool hasInputSource (ntv2Card.features().CanDoInputSource(inputSource));
208 const string videoFormatStr (hasInputSource ? ::
NTV2VideoFormatToString(ntv2Card.GetInputVideoFormat(inputSource)) :
"");
209 const QString buttonLabel (QString(
"%1 %2").arg(::
NTV2InputSourceToString(inputSource,
true).c_str(), videoFormatStr.empty() ?
"No Detected Input" : videoFormatStr.c_str()));
210 pButton->setText (buttonLabel);
211 pButton->setEnabled (hasInputSource);
215 #if defined (INCLUDE_AJACC)
216 const bool hasCustomAnc (mDevice.features().CanDoCustomAnc());
217 for (
QButtonIterator iter (mCaptionButtonGroup->buttons()); iter.hasNext(); )
218 iter.next()->setEnabled(hasCustomAnc);
219 #endif // defined (INCLUDE_AJACC)
226 void NTV2QtPreview::timerEvent (QTimerEvent * event)
228 if (event->timerId () == mTimerID)
231 QWidget::timerEvent (event);
236 void NTV2QtPreview::devicesChanged (
void)
238 qDebug () << QString (
"devicesChanged");
242 mBoardChoiceCombo->clear ();
243 for (
ULWord ndx (0); ndx < 100; ndx++)
247 mBoardChoiceCombo->addItem (tr (device.
GetDisplayName ().c_str ()));
249 {mBoardChoiceCombo->addItem (tr (
"No Devices Found"));
break;}
253 mBoardChoiceCombo->setCurrentIndex (0);
258 void NTV2QtPreview::PnpCallback (
AJAPnpMessage inMessage,
void * pUserData)
265 pMainWindow->devicesChanged ();