From b7d07aabce16cc6ab79e136faa6fafd1a6f3f5f7 Mon Sep 17 00:00:00 2001 From: shun_iwasawa Date: Sep 28 2016 04:59:13 +0000 Subject: add video capture filter settings --- diff --git a/stuff/config/qss/gray_048/gray_048.less b/stuff/config/qss/gray_048/gray_048.less index 0590e85..ef27e52 100644 --- a/stuff/config/qss/gray_048/gray_048.less +++ b/stuff/config/qss/gray_048/gray_048.less @@ -1365,4 +1365,8 @@ QDialog #dialogButtonFrame { #LargeSizedText { font-size: 17px; +} + +#GearButton { + qproperty-icon: url("@{image_url}/gear.png"); } \ No newline at end of file diff --git a/stuff/config/qss/gray_048/gray_048.qss b/stuff/config/qss/gray_048/gray_048.qss index 6936166..599b359 100644 --- a/stuff/config/qss/gray_048/gray_048.qss +++ b/stuff/config/qss/gray_048/gray_048.qss @@ -1369,5 +1369,8 @@ QDialog #dialogButtonFrame { #LargeSizedText { font-size: 17px; } +#GearButton { + qproperty-icon: url("../gray_072/imgs/gear.png"); +} //# sourceMappingURL=gray_048.qss.map \ No newline at end of file diff --git a/stuff/config/qss/gray_048/gray_048_mac.qss b/stuff/config/qss/gray_048/gray_048_mac.qss index 7c6a503..e8cec36 100644 --- a/stuff/config/qss/gray_048/gray_048_mac.qss +++ b/stuff/config/qss/gray_048/gray_048_mac.qss @@ -1369,5 +1369,8 @@ QDialog #dialogButtonFrame { #LargeSizedText { font-size: 17px; } +#GearButton { + qproperty-icon: url("../gray_072/imgs/gear.png"); +} //# sourceMappingURL=gray_048_mac.qss.map \ No newline at end of file diff --git a/stuff/config/qss/gray_072/gray_072.less b/stuff/config/qss/gray_072/gray_072.less index c918bcf..aa97bd4 100644 --- a/stuff/config/qss/gray_072/gray_072.less +++ b/stuff/config/qss/gray_072/gray_072.less @@ -1365,4 +1365,8 @@ QDialog #dialogButtonFrame { #LargeSizedText { font-size: 17px; +} + +#GearButton { + qproperty-icon: url("@{image_url}/gear.png"); } \ No newline at end of file diff --git a/stuff/config/qss/gray_072/gray_072.qss b/stuff/config/qss/gray_072/gray_072.qss index 69c5a4d..f8d0649 100644 --- a/stuff/config/qss/gray_072/gray_072.qss +++ b/stuff/config/qss/gray_072/gray_072.qss @@ -1369,5 +1369,8 @@ QDialog #dialogButtonFrame { #LargeSizedText { font-size: 17px; } +#GearButton { + qproperty-icon: url("imgs/gear.png"); +} //# sourceMappingURL=gray_072.qss.map \ No newline at end of file diff --git a/stuff/config/qss/gray_072/gray_072_mac.qss b/stuff/config/qss/gray_072/gray_072_mac.qss index 182e253..2aba2c9 100644 --- a/stuff/config/qss/gray_072/gray_072_mac.qss +++ b/stuff/config/qss/gray_072/gray_072_mac.qss @@ -1369,5 +1369,8 @@ QDialog #dialogButtonFrame { #LargeSizedText { font-size: 17px; } +#GearButton { + qproperty-icon: url("imgs/gear.png"); +} //# sourceMappingURL=gray_072_mac.qss.map \ No newline at end of file diff --git a/stuff/config/qss/gray_072/imgs/gear.png b/stuff/config/qss/gray_072/imgs/gear.png new file mode 100644 index 0000000..7e07631 Binary files /dev/null and b/stuff/config/qss/gray_072/imgs/gear.png differ diff --git a/stuff/config/qss/gray_128/gray_128.less b/stuff/config/qss/gray_128/gray_128.less index 2c13e25..f52a3a8 100644 --- a/stuff/config/qss/gray_128/gray_128.less +++ b/stuff/config/qss/gray_128/gray_128.less @@ -1190,4 +1190,8 @@ QDialog #dialogButtonFrame { #LargeSizedText { font-size: 17px; +} + +#GearButton { + qproperty-icon: url("@{image_url}/gear.png"); } \ No newline at end of file diff --git a/stuff/config/qss/gray_128/gray_128.qss b/stuff/config/qss/gray_128/gray_128.qss index 1f3a66e..0763d1e 100644 --- a/stuff/config/qss/gray_128/gray_128.qss +++ b/stuff/config/qss/gray_128/gray_128.qss @@ -1108,5 +1108,8 @@ QDialog #dialogButtonFrame { #LargeSizedText { font-size: 17px; } +#GearButton { + qproperty-icon: url("imgs/gear.png"); +} //# sourceMappingURL=gray_128.qss.map \ No newline at end of file diff --git a/stuff/config/qss/gray_128/gray_128_mac.qss b/stuff/config/qss/gray_128/gray_128_mac.qss index f66c40d..8d88797 100644 --- a/stuff/config/qss/gray_128/gray_128_mac.qss +++ b/stuff/config/qss/gray_128/gray_128_mac.qss @@ -1108,5 +1108,8 @@ QDialog #dialogButtonFrame { #LargeSizedText { font-size: 17px; } +#GearButton { + qproperty-icon: url("imgs/gear.png"); +} //# sourceMappingURL=gray_128_mac.qss.map \ No newline at end of file diff --git a/stuff/config/qss/gray_128/imgs/gear.png b/stuff/config/qss/gray_128/imgs/gear.png new file mode 100644 index 0000000..36477dd Binary files /dev/null and b/stuff/config/qss/gray_128/imgs/gear.png differ diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txt index 0215c13..6bda998 100644 --- a/toonz/sources/toonz/CMakeLists.txt +++ b/toonz/sources/toonz/CMakeLists.txt @@ -375,10 +375,13 @@ if(WIN32) endif() if(WIN32) + # DirectShow strmiids library for Camera Capture + find_library(DSHOW_STRMIIDS_LIB strmiids) + target_link_libraries(OpenToonz_${VERSION} Qt5::WinMain Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Xml Qt5::Script Qt5::Widgets Qt5::PrintSupport Qt5::Multimedia - ${GL_LIB} ${GLUT_LIB} + ${GL_LIB} ${GLUT_LIB} ${DSHOW_STRMIIDS_LIB} tnzcore tnzbase toonzlib colorfx tnzext image sound toonzqt tnztools tnzstdfx tfarm ) elseif(APPLE) diff --git a/toonz/sources/toonz/penciltestpopup.cpp b/toonz/sources/toonz/penciltestpopup.cpp index 2a74e88..9ed9cdb 100644 --- a/toonz/sources/toonz/penciltestpopup.cpp +++ b/toonz/sources/toonz/penciltestpopup.cpp @@ -65,6 +65,11 @@ #include #include #include +#include + +#ifdef _WIN32 +#include +#endif using namespace DVGui; @@ -305,6 +310,90 @@ int letterToNum(QChar appendix) { return 0; } +#ifdef _WIN32 +void openCaptureFilterSettings(const QWidget* parent, + const QString& cameraName) { + HRESULT hr; + + ICreateDevEnum* createDevEnum = NULL; + IEnumMoniker* enumMoniker = NULL; + IMoniker* moniker = NULL; + + IBaseFilter* deviceFilter; + + ISpecifyPropertyPages* specifyPropertyPages; + CAUUID cauuid; + // set parent's window handle in order to make the dialog modal + HWND ghwndApp = (HWND)(parent->winId()); + + // initialize COM + CoInitialize(NULL); + + // get device list + CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, + IID_ICreateDevEnum, (PVOID*)&createDevEnum); + + // create EnumMoniker + createDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, + &enumMoniker, 0); + if (enumMoniker == NULL) { + // if no connected devices found + return; + } + + // reset EnumMoniker + enumMoniker->Reset(); + + // find target camera + ULONG fetched = 0; + bool isCameraFound = false; + while (hr = enumMoniker->Next(1, &moniker, &fetched), hr == S_OK) { + // get friendly name (= device name) of the camera + IPropertyBag* pPropertyBag; + moniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPropertyBag); + VARIANT var; + var.vt = VT_BSTR; + VariantInit(&var); + + pPropertyBag->Read(L"FriendlyName", &var, 0); + + QString deviceName = QString::fromWCharArray(var.bstrVal); + + VariantClear(&var); + + if (deviceName == cameraName) { + // bind monkier to the filter + moniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&deviceFilter); + + // release moniker etc. + moniker->Release(); + enumMoniker->Release(); + createDevEnum->Release(); + + isCameraFound = true; + break; + } + } + + // if no matching camera found + if (!isCameraFound) return; + + // open capture filter popup + hr = deviceFilter->QueryInterface(IID_ISpecifyPropertyPages, + (void**)&specifyPropertyPages); + if (hr == S_OK) { + hr = specifyPropertyPages->GetPages(&cauuid); + + hr = OleCreatePropertyFrame(ghwndApp, 30, 30, NULL, 1, + (IUnknown**)&deviceFilter, cauuid.cElems, + (GUID*)cauuid.pElems, 0, 0, NULL); + + CoTaskMemFree(cauuid.pElems); + specifyPropertyPages->Release(); + } +} +#endif + } // namespace //============================================================================= @@ -547,6 +636,12 @@ PencilTestPopup::PencilTestPopup() m_captureButton = new QPushButton(tr("Capture\n[Return key]"), this); QPushButton* closeButton = new QPushButton(tr("Close"), this); + +#ifdef _WIN32 + m_captureFilterSettingsBtn = new QPushButton(this); +#else + m_captureFilterSettingsBtn = 0; +#endif //---- m_resolutionCombo->setMaximumWidth(fontMetrics().width("0000 x 0000") + 25); @@ -598,6 +693,14 @@ PencilTestPopup::PencilTestPopup() m_captureButton->setIcon(style.standardIcon(QStyle::SP_DialogOkButton)); m_captureButton->setIconSize(QSize(30, 30)); + if (m_captureFilterSettingsBtn) { + m_captureFilterSettingsBtn->setObjectName("GearButton"); + m_captureFilterSettingsBtn->setFixedSize(23, 23); + m_captureFilterSettingsBtn->setIconSize(QSize(15, 15)); + m_captureFilterSettingsBtn->setToolTip( + tr("Video Capture Filter Settings...")); + } + //---- layout ---- QHBoxLayout* mainLay = new QHBoxLayout(); mainLay->setMargin(0); @@ -617,6 +720,12 @@ PencilTestPopup::PencilTestPopup() camLay->addSpacing(10); camLay->addWidget(new QLabel(tr("Resolution:"), this), 0); camLay->addWidget(m_resolutionCombo, 1); + + if (m_captureFilterSettingsBtn) { + camLay->addSpacing(10); + camLay->addWidget(m_captureFilterSettingsBtn); + } + camLay->addStretch(0); } leftLay->addLayout(camLay, 0); @@ -788,6 +897,9 @@ PencilTestPopup::PencilTestPopup() ret = ret && connect(closeButton, SIGNAL(clicked()), this, SLOT(reject())); ret = ret && connect(m_captureButton, SIGNAL(clicked(bool)), this, SLOT(onCaptureButtonClicked(bool))); + if (m_captureFilterSettingsBtn) + ret = ret && connect(m_captureFilterSettingsBtn, SIGNAL(pressed()), this, + SLOT(onCaptureFilterSettingsBtnPressed())); assert(ret); refreshCameraList(); @@ -1403,4 +1515,18 @@ bool PencilTestPopup::importImage(QImage& image) { //----------------------------------------------------------------------------- +void PencilTestPopup::onCaptureFilterSettingsBtnPressed() { + if (!m_currentCamera || m_deviceName.isNull()) return; + + QList cameras = QCameraInfo::availableCameras(); + for (int c = 0; c < cameras.size(); c++) { + if (cameras.at(c).deviceName() == m_deviceName) { + openCaptureFilterSettings(this, cameras.at(c).description()); + return; + } + } +} + +//----------------------------------------------------------------------------- + OpenPopupCommandHandler openPencilTestPopup(MI_PencilTest); \ No newline at end of file diff --git a/toonz/sources/toonz/penciltestpopup.h b/toonz/sources/toonz/penciltestpopup.h index 94b1172..0ff31f4 100644 --- a/toonz/sources/toonz/penciltestpopup.h +++ b/toonz/sources/toonz/penciltestpopup.h @@ -21,6 +21,7 @@ class QVideoFrame; class QTimer; class QIntValidator; class QRegExpValidator; +class QPushButton; namespace DVGui { class FileField; @@ -147,6 +148,9 @@ class PencilTestPopup : public DVGui::Dialog { QImage m_whiteBGImg; + // used only for Windows + QPushButton* m_captureFilterSettingsBtn; + int m_timerId; QString m_cacheImagePath; bool m_captureWhiteBGCue; @@ -183,6 +187,7 @@ protected slots: void onCountDown(); void onCaptureButtonClicked(bool); + void onCaptureFilterSettingsBtnPressed(); }; #endif \ No newline at end of file