Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions frontend/utility/ScreenshotObj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,7 @@ void ScreenshotObj::onFinished()

if (outputWidth > 0 && outputHeight > 0) {
if (outputToFile) {
OBSBasic *main = OBSBasic::Get();
main->ShowStatusBarMessage(
QTStr("Basic.StatusBar.ScreenshotSavedTo").arg(QT_UTF8(path.c_str())));
main->lastScreenshot = path;
main->OnEvent(OBS_FRONTEND_EVENT_SCREENSHOT_TAKEN);
emit imageSaved(path);
}

emit imageReady(image.copy());
Expand Down
18 changes: 10 additions & 8 deletions frontend/utility/ScreenshotObj.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,23 @@ class ScreenshotObj : public QObject {

enum class Stage { Render, Download, Output, Finished };

void processStage();
void renderScreenshot();
void downloadData();
void copyData();
void saveToFile();
void muxFile();
void onFinished();

Stage stage() { return stage_; }
void setStage(Stage stage) { stage_ = stage; }

void setSize(QSize size);
void setSize(int width, int height);
void setSaveToFile(bool save);

void processStage();

private:
void renderScreenshot();
void downloadData();
void copyData();
void saveToFile();
void muxFile();
void onFinished();

Stage stage_ = Stage::Render;

gs_texrender_t *texrender = nullptr;
Expand All @@ -69,6 +70,7 @@ class ScreenshotObj : public QObject {
bool outputToFile = true;

signals:
void imageSaved(std::string path);
void imageReady(QImage image);

private slots:
Expand Down
1 change: 1 addition & 0 deletions frontend/widgets/OBSBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <settings/OBSBasicSettings.hpp>
#include <utility/QuickTransition.hpp>
#include <utility/SceneRenameDelegate.hpp>
#include <utility/ScreenshotObj.hpp>
#if defined(_WIN32) || defined(WHATSNEW_ENABLED)
#include <utility/WhatsNewInfoThread.hpp>
#endif
Expand Down
5 changes: 3 additions & 2 deletions frontend/widgets/OBSBasic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include <QAccessible>
#include <QSystemTrayIcon>
#include <QPointer>

#include <deque>

Expand All @@ -57,6 +58,7 @@ class OBSBasicTransform;
class OBSLogViewer;
class OBSMissingFiles;
class OBSProjector;
class ScreenshotObj;
class VolumeControl;
#ifdef YOUTUBE_ENABLED
class YouTubeAppDock;
Expand Down Expand Up @@ -212,7 +214,6 @@ class OBSBasic : public OBSMainWindow {
friend class OBSYoutubeActions;
friend struct BasicOutputHandler;
friend struct OBSStudioAPI;
friend class ScreenshotObj;

enum class MoveDir { Up, Down, Left, Right };

Expand Down Expand Up @@ -1323,7 +1324,7 @@ private slots:
* -------------------------------------
*/
private:
QPointer<QObject> screenshotData;
QPointer<ScreenshotObj> screenshotData;
std::string lastScreenshot;

private slots:
Expand Down
7 changes: 7 additions & 0 deletions frontend/widgets/OBSBasic_Screenshots.cpp
Comment thread
Warchamp7 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ void OBSBasic::Screenshot(OBSSource source)
}

screenshotData = new ScreenshotObj(source);

connect(screenshotData, &ScreenshotObj::imageSaved, this, [this](std::string path) {
ShowStatusBarMessage(QTStr("Basic.StatusBar.ScreenshotSavedTo").arg(QT_UTF8(path.c_str())));
lastScreenshot = path;

OnEvent(OBS_FRONTEND_EVENT_SCREENSHOT_TAKEN);
});
}

void OBSBasic::ScreenshotSelectedSource()
Expand Down
Loading