diff --git a/plugins/video/macro-condition-video.cpp b/plugins/video/macro-condition-video.cpp index 06a5e5277..9cd76f820 100644 --- a/plugins/video/macro-condition-video.cpp +++ b/plugins/video/macro-condition-video.cpp @@ -1433,8 +1433,9 @@ void MacroConditionVideoEdit::ImageBrowseButtonClicked() return; } - auto screenshot = - ScreenshotDialog::AskForScreenshot(_entryData->_video); + ; + auto screenshot = ScreenshotDialog::AskForScreenshot( + _entryData->_video, _entryData->_areaParameters); if (!screenshot) { return; } diff --git a/plugins/video/screenshot-dialog.cpp b/plugins/video/screenshot-dialog.cpp index 613168d35..e2d7004f3 100644 --- a/plugins/video/screenshot-dialog.cpp +++ b/plugins/video/screenshot-dialog.cpp @@ -7,22 +7,27 @@ namespace advss { -ScreenshotDialog::ScreenshotDialog(obs_source_t *source) +ScreenshotDialog::ScreenshotDialog(obs_source_t *source, + const AreaParameters &area) : QDialog(GetSettingsWindow()), _scrollArea(new QScrollArea), _imageLabel(new QLabel(this)), _rubberBand(new QRubberBand(QRubberBand::Rectangle, this)), - _buttonbox(new QDialogButtonBox(QDialogButtonBox::Ok | + _buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel)), - _screenshot(source, {}, true) + _screenshot(source, + area.enable ? QRect(area.area.x, area.area.y, + area.area.width, area.area.height) + : QRect(), + true) { setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle")); setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); - QWidget::connect(_buttonbox, &QDialogButtonBox::accepted, this, + QWidget::connect(_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); - QWidget::connect(_buttonbox, &QDialogButtonBox::rejected, this, + QWidget::connect(_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); _imageLabel->setPixmap(QPixmap::fromImage(_screenshot.GetImage())); @@ -48,7 +53,7 @@ ScreenshotDialog::ScreenshotDialog(obs_source_t *source) layout->addWidget(new QLabel(obs_module_text( "AdvSceneSwitcher.condition.video.screenshot.selectArea"))); layout->addWidget(_scrollArea); - layout->addWidget(_buttonbox); + layout->addWidget(_buttonBox); setLayout(layout); _result = _screenshot.GetImage(); @@ -95,14 +100,15 @@ void ScreenshotDialog::mouseReleaseEvent(QMouseEvent *) } std::optional -ScreenshotDialog::AskForScreenshot(const VideoInput &input) +ScreenshotDialog::AskForScreenshot(const VideoInput &input, + const AreaParameters &area) { if (!input.ValidSelection()) { return {}; } auto source = OBSGetStrongRef(input.GetVideo()); - ScreenshotDialog dialog(source); + ScreenshotDialog dialog(source, area); if (dialog.exec() != DialogCode::Accepted) { return {}; } diff --git a/plugins/video/screenshot-dialog.hpp b/plugins/video/screenshot-dialog.hpp index 78ce88de0..5cb0b6815 100644 --- a/plugins/video/screenshot-dialog.hpp +++ b/plugins/video/screenshot-dialog.hpp @@ -17,10 +17,11 @@ class ScreenshotDialog : public QDialog { Q_OBJECT public: - static std::optional AskForScreenshot(const VideoInput &); + static std::optional AskForScreenshot(const VideoInput &, + const AreaParameters &); private: - ScreenshotDialog(obs_source_t *source); + ScreenshotDialog(obs_source_t *source, const AreaParameters &area); void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); @@ -32,7 +33,7 @@ class ScreenshotDialog : public QDialog { QPoint _origin; QRubberBand *_rubberBand = nullptr; - QDialogButtonBox *_buttonbox; + QDialogButtonBox *_buttonBox; QImage _result; Screenshot _screenshot;