diff --git a/flameshot.pro b/flameshot.pro
index 0889994b..07966b20 100644
--- a/flameshot.pro
+++ b/flameshot.pro
@@ -4,7 +4,7 @@
#
#-------------------------------------------------
-win32:LIBS += -luser32 #-lshell32
+win32:LIBS += -luser32 -lshell32
TAG_VERSION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
DEFINES += APP_VERSION=\\\"$$TAG_VERSION\\\"
@@ -127,7 +127,8 @@ SOURCES += src/main.cpp \
src/capture/tools/blurtool.cpp \
src/capture/workers/launcher/terminallauncher.cpp \
src/config/visualseditor.cpp \
- src/config/extendedslider.cpp
+ src/config/extendedslider.cpp \
+ src/capture/workers/launcher/openwithprogram.cpp
HEADERS += src/capture/widget/buttonhandler.h \
src/infowindow.h \
@@ -183,7 +184,8 @@ HEADERS += src/capture/widget/buttonhandler.h \
src/capture/tools/blurtool.h \
src/capture/workers/launcher/terminallauncher.h \
src/config/visualseditor.h \
- src/config/extendedslider.h
+ src/config/extendedslider.h \
+ src/capture/workers/launcher/openwithprogram.h
unix:!macx {
SOURCES += src/core/flameshotdbusadapter.cpp \
diff --git a/src/capture/widget/capturewidget.cpp b/src/capture/widget/capturewidget.cpp
index 7ef85de6..056ba0a1 100644
--- a/src/capture/widget/capturewidget.cpp
+++ b/src/capture/widget/capturewidget.cpp
@@ -628,12 +628,14 @@ void CaptureWidget::updateCursor() {
void CaptureWidget::copyScreenshot() {
m_captureDone = true;
+ hide();
ResourceExporter().captureToClipboard(pixmap());
close();
}
void CaptureWidget::saveScreenshot() {
m_captureDone = true;
+ hide();
if (m_forcedSavePath.isEmpty()) {
ResourceExporter().captureToFileUi(pixmap());
} else {
@@ -644,12 +646,14 @@ void CaptureWidget::saveScreenshot() {
void CaptureWidget::uploadToImgur() {
m_captureDone = true;
+ hide();
ResourceExporter().captureToImgur(pixmap());
close();
}
void CaptureWidget::openWithProgram() {
m_captureDone = true;
+ hide();
ResourceExporter().captureToProgram(pixmap());
close();
}
diff --git a/src/capture/workers/launcher/openwithprogram.cpp b/src/capture/workers/launcher/openwithprogram.cpp
new file mode 100644
index 00000000..d01c3a8a
--- /dev/null
+++ b/src/capture/workers/launcher/openwithprogram.cpp
@@ -0,0 +1,54 @@
+// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
+//
+// This file is part of Flameshot.
+//
+// Flameshot is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Flameshot is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Flameshot. If not, see .
+
+
+#include "openwithprogram.h"
+
+#if defined(Q_OS_WIN)
+#include "src/utils/filenamehandler.h"
+#include
+#include
+#include
+#include
+
+#pragma comment(lib, "Shell32.lib")
+#else
+#include "src/capture/workers/launcher/applauncherwidget.h"
+#endif
+
+void showOpenWithMenu(const QPixmap &capture) {
+#if defined(Q_OS_WIN)
+ QString tempFile =
+ FileNameHandler().generateAbsolutePath(QDir::tempPath()) + ".png";
+ bool ok = capture.save(tempFile);
+ if (!ok) {
+ QMessageBox::about(nullptr, QObject::tr("Error"),
+ QObject::tr("Unable to write in") + QDir::tempPath());
+ return;
+ }
+
+ OPENASINFO info;
+ auto wStringFile = tempFile.replace("/", "\\").toStdWString();
+ info.pcszFile = wStringFile.c_str();
+ info.pcszClass = nullptr;
+ info.oaifInFlags = OAIF_ALLOW_REGISTRATION | OAIF_EXEC;
+ SHOpenWithDialog(nullptr, &info);
+#else
+ auto w = new AppLauncherWidget(capture);
+ w->show();
+#endif
+}
diff --git a/src/capture/workers/launcher/openwithprogram.h b/src/capture/workers/launcher/openwithprogram.h
new file mode 100644
index 00000000..f144561d
--- /dev/null
+++ b/src/capture/workers/launcher/openwithprogram.h
@@ -0,0 +1,25 @@
+// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
+//
+// This file is part of Flameshot.
+//
+// Flameshot is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Flameshot is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Flameshot. If not, see .
+
+#ifndef OPENWITHPROGRAM_H
+#define OPENWITHPROGRAM_H
+
+#include
+
+void showOpenWithMenu(const QPixmap &capture);
+
+#endif // OPENWITHPROGRAM_H
diff --git a/src/core/resourceexporter.cpp b/src/core/resourceexporter.cpp
index a3ab19c0..4dedf5a0 100644
--- a/src/core/resourceexporter.cpp
+++ b/src/core/resourceexporter.cpp
@@ -19,7 +19,7 @@
#include "src/capture/workers/imgur/imguruploader.h"
#include "src/capture/workers/screenshotsaver.h"
#include "src/capture/workers/graphicalscreenshotsaver.h"
-#include "src/capture/workers/launcher/applauncherwidget.h"
+#include "src/capture/workers/launcher/openwithprogram.h"
ResourceExporter::ResourceExporter() {
@@ -44,6 +44,5 @@ void ResourceExporter::captureToImgur(const QPixmap &p) {
}
void ResourceExporter::captureToProgram(const QPixmap &p) {
- auto w = new AppLauncherWidget(p);
- w->show();
+ showOpenWithMenu(p);
}