Add a resource exporter module
This commit is contained in:
@@ -82,7 +82,8 @@ SOURCES += src/main.cpp\
|
||||
src/capture/workers/graphicalscreenshotsaver.cpp \
|
||||
src/capture/workers/imgur/loadspinner.cpp \
|
||||
src/capture/workers/imgur/imagelabel.cpp \
|
||||
src/capture/workers/imgur/notificationwidget.cpp
|
||||
src/capture/workers/imgur/notificationwidget.cpp \
|
||||
src/core/resourceexporter.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/capture/widget/buttonhandler.h \
|
||||
@@ -129,7 +130,8 @@ HEADERS += \
|
||||
src/capture/workers/graphicalscreenshotsaver.h \
|
||||
src/capture/workers/imgur/loadspinner.h \
|
||||
src/capture/workers/imgur/imagelabel.h \
|
||||
src/capture/workers/imgur/notificationwidget.h
|
||||
src/capture/workers/imgur/notificationwidget.h \
|
||||
src/core/resourceexporter.h
|
||||
|
||||
RESOURCES += \
|
||||
graphics.qrc
|
||||
|
||||
@@ -133,10 +133,10 @@ QIcon CaptureButton::icon() const {
|
||||
void CaptureButton::mousePressEvent(QMouseEvent *e) {
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
Q_EMIT pressedButton(this);
|
||||
Q_EMIT pressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CaptureButton::animatedShow() {
|
||||
if(!isVisible()) {
|
||||
show();
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "src/utils/screengrabber.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include "src/utils/systemnotification.h"
|
||||
#include "src/core/controller.h"
|
||||
#include "src/core/resourceexporter.h"
|
||||
#include <QScreen>
|
||||
#include <QGuiApplication>
|
||||
#include <QApplication>
|
||||
@@ -562,21 +562,21 @@ QRegion CaptureWidget::handleMask() const {
|
||||
}
|
||||
|
||||
void CaptureWidget::copyScreenshot() {
|
||||
Controller::getInstance()->captureToClipboard(pixmap());
|
||||
ResourceExporter().captureToClipboard(pixmap());
|
||||
close();
|
||||
}
|
||||
|
||||
void CaptureWidget::saveScreenshot() {
|
||||
if (m_forcedSavePath.isEmpty()) {
|
||||
Controller::getInstance()->captureToFileUi(pixmap());
|
||||
ResourceExporter().captureToFileUi(pixmap());
|
||||
} else {
|
||||
Controller::getInstance()->captureToFile(pixmap(), m_forcedSavePath);
|
||||
ResourceExporter().captureToFile(pixmap(), m_forcedSavePath);
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
void CaptureWidget::uploadToImgur() {
|
||||
Controller::getInstance()->captureToImgur(pixmap());
|
||||
ResourceExporter().captureToImgur(pixmap());
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
#include "src/infowindow.h"
|
||||
#include "src/config/configwindow.h"
|
||||
#include "src/capture/widget/capturebutton.h"
|
||||
#include "src/utils/screengrabber.h"
|
||||
#include "src/capture/workers/imgur/imguruploader.h"
|
||||
#include "src/capture/workers/screenshotsaver.h"
|
||||
#include "src/capture/workers/graphicalscreenshotsaver.h"
|
||||
#include <QFile>
|
||||
#include <QApplication>
|
||||
#include <QSystemTrayIcon>
|
||||
@@ -47,7 +43,6 @@ Controller::Controller() : m_captureWindow(nullptr)
|
||||
|
||||
QString StyleSheet = CaptureButton::globalStyleSheet();
|
||||
qApp->setStyleSheet(StyleSheet);
|
||||
|
||||
}
|
||||
|
||||
Controller *Controller::getInstance() {
|
||||
@@ -55,19 +50,6 @@ Controller *Controller::getInstance() {
|
||||
return &c;
|
||||
}
|
||||
|
||||
void Controller::saveFullScreenshot(const QString &path,
|
||||
bool const toClipboard) {
|
||||
QPixmap p(ScreenGrabber().grabEntireDesktop());
|
||||
if(toClipboard) {
|
||||
captureToClipboard(p);
|
||||
}
|
||||
if(path.isEmpty()) {
|
||||
captureToFileUi(p);
|
||||
} else {
|
||||
captureToFile(p, path);
|
||||
}
|
||||
}
|
||||
|
||||
// initDefaults inits the global config in the first execution of the program
|
||||
void Controller::initDefaults() {
|
||||
ConfigHandler config;
|
||||
@@ -147,21 +129,3 @@ void Controller::updateConfigComponents() {
|
||||
m_configWindow->updateComponents();
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::captureToClipboard(const QPixmap &p) {
|
||||
ScreenshotSaver().saveToClipboard(p);
|
||||
}
|
||||
|
||||
void Controller::captureToFile(const QPixmap &p, const QString &path) {
|
||||
ScreenshotSaver().saveToFilesystem(p, path);
|
||||
}
|
||||
|
||||
void Controller::captureToFileUi(const QPixmap &p) {
|
||||
auto w = new GraphicalScreenshotSaver(p);
|
||||
w->show();
|
||||
}
|
||||
|
||||
void Controller::captureToImgur(const QPixmap &p) {
|
||||
auto w = new ImgurUploader(p);
|
||||
w->show();
|
||||
}
|
||||
|
||||
@@ -36,8 +36,6 @@ public:
|
||||
void operator =(const Controller&) = delete;
|
||||
|
||||
public slots:
|
||||
void saveFullScreenshot(const QString &path = QString(),
|
||||
bool const toClipboard = false);
|
||||
void createVisualCapture(const QString &forcedSavePath = QString());
|
||||
|
||||
void openConfigWindow();
|
||||
@@ -48,12 +46,6 @@ public slots:
|
||||
|
||||
void updateConfigComponents();
|
||||
|
||||
void captureToClipboard(const QPixmap &p);
|
||||
void captureToFile(const QPixmap &p, const QString &path);
|
||||
void captureToFileUi(const QPixmap &p);
|
||||
void captureToImgur(const QPixmap &p);
|
||||
|
||||
|
||||
private slots:
|
||||
void initDefaults();
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
|
||||
#include "flameshotdbusadapter.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include "src/utils/screengrabber.h"
|
||||
#include "src/core/controller.h"
|
||||
#include "src/core/resourceexporter.h"
|
||||
#include <QTimer>
|
||||
|
||||
FlameshotDBusAdapter::FlameshotDBusAdapter(QObject *parent)
|
||||
@@ -39,11 +41,18 @@ void FlameshotDBusAdapter::graphicCapture(QString path, int delay) {
|
||||
}
|
||||
|
||||
void FlameshotDBusAdapter::fullScreen(QString path, bool toClipboard, int delay) {
|
||||
auto controller = Controller::getInstance();
|
||||
auto f = [controller, path, toClipboard, this]() {
|
||||
controller->saveFullScreenshot(path, toClipboard);
|
||||
auto f = [path, toClipboard, this]() {
|
||||
QPixmap p(ScreenGrabber().grabEntireDesktop());
|
||||
if(toClipboard) {
|
||||
ResourceExporter().captureToClipboard(p);
|
||||
}
|
||||
if(path.isEmpty()) {
|
||||
ResourceExporter().captureToFileUi(p);
|
||||
} else {
|
||||
ResourceExporter().captureToFile(p, path);
|
||||
}
|
||||
};
|
||||
QTimer::singleShot(delay, controller, f);
|
||||
QTimer::singleShot(delay, this, f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
43
src/core/resourceexporter.cpp
Normal file
43
src/core/resourceexporter.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2017 Alejandro Sirgo Rica
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "resourceexporter.h"
|
||||
#include "src/capture/workers/imgur/imguruploader.h"
|
||||
#include "src/capture/workers/screenshotsaver.h"
|
||||
#include "src/capture/workers/graphicalscreenshotsaver.h"
|
||||
|
||||
ResourceExporter::ResourceExporter() {
|
||||
|
||||
}
|
||||
|
||||
void ResourceExporter::captureToClipboard(const QPixmap &p) {
|
||||
ScreenshotSaver().saveToClipboard(p);
|
||||
}
|
||||
|
||||
void ResourceExporter::captureToFile(const QPixmap &p, const QString &path) {
|
||||
ScreenshotSaver().saveToFilesystem(p, path);
|
||||
}
|
||||
|
||||
void ResourceExporter::captureToFileUi(const QPixmap &p) {
|
||||
auto w = new GraphicalScreenshotSaver(p);
|
||||
w->show();
|
||||
}
|
||||
|
||||
void ResourceExporter::captureToImgur(const QPixmap &p) {
|
||||
auto w = new ImgurUploader(p);
|
||||
w->show();
|
||||
}
|
||||
33
src/core/resourceexporter.h
Normal file
33
src/core/resourceexporter.h
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2017 Alejandro Sirgo Rica
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef RESOURCEEXPORTER_H
|
||||
#define RESOURCEEXPORTER_H
|
||||
|
||||
#include <QPixmap>
|
||||
|
||||
class ResourceExporter {
|
||||
public:
|
||||
ResourceExporter();
|
||||
|
||||
void captureToClipboard(const QPixmap &p);
|
||||
void captureToFile(const QPixmap &p, const QString &path);
|
||||
void captureToFileUi(const QPixmap &p);
|
||||
void captureToImgur(const QPixmap &p);
|
||||
};
|
||||
|
||||
#endif // RESOURCEEXPORTER_H
|
||||
Reference in New Issue
Block a user