Great reformat of 2k17
This commit is contained in:
parent
b601b958c9
commit
7737b77671
@ -8,8 +8,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <settings.hpp>
|
#include <settings.hpp>
|
||||||
|
|
||||||
CropEditor::CropEditor(QPixmap *image, QObject *parent) : QObject(parent)
|
CropEditor::CropEditor(QPixmap *image, QObject *parent) : QObject(parent) {
|
||||||
{
|
|
||||||
scene = new CropScene(parent, image);
|
scene = new CropScene(parent, image);
|
||||||
view = new CropView(scene);
|
view = new CropView(scene);
|
||||||
QPixmap *scaled = new QPixmap();
|
QPixmap *scaled = new QPixmap();
|
||||||
@ -26,13 +25,9 @@ CropEditor::CropEditor(QPixmap *image, QObject *parent) : QObject(parent)
|
|||||||
connect(scene, &CropScene::closedWithRect, this, &CropEditor::crop);
|
connect(scene, &CropScene::closedWithRect, this, &CropEditor::crop);
|
||||||
}
|
}
|
||||||
|
|
||||||
CropEditor::~CropEditor()
|
CropEditor::~CropEditor() { delete scene; }
|
||||||
{
|
|
||||||
delete scene;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CropEditor::crop(QRect rect)
|
void CropEditor::crop(QRect rect) {
|
||||||
{
|
|
||||||
QPixmap map = view->grab(rect);
|
QPixmap map = view->grab(rect);
|
||||||
QPixmap *cropp = new QPixmap;
|
QPixmap *cropp = new QPixmap;
|
||||||
map.swap(*cropp);
|
map.swap(*cropp);
|
||||||
|
@ -8,16 +8,15 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
class CropEditor : public QObject
|
class CropEditor : public QObject {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CropEditor(QPixmap *image, QObject *parent = 0);
|
CropEditor(QPixmap *image, QObject *parent = 0);
|
||||||
~CropEditor();
|
~CropEditor();
|
||||||
signals:
|
signals:
|
||||||
QPixmap *cropped(QPixmap *pixmap);
|
QPixmap *cropped(QPixmap *pixmap);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void crop(QRect rect);
|
void crop(QRect rect);
|
||||||
CropScene *scene = nullptr;
|
CropScene *scene = nullptr;
|
||||||
CropView *view = nullptr;
|
CropView *view = nullptr;
|
||||||
|
@ -17,12 +17,18 @@
|
|||||||
#include <settings.hpp>
|
#include <settings.hpp>
|
||||||
|
|
||||||
CropScene::CropScene(QObject *parent, QPixmap *pixmap)
|
CropScene::CropScene(QObject *parent, QPixmap *pixmap)
|
||||||
: QGraphicsScene(parent), prevButtons(Qt::NoButton), drawingSelectionMaker([] { return nullptr; }),
|
: QGraphicsScene(parent), prevButtons(Qt::NoButton),
|
||||||
|
drawingSelectionMaker([] { return nullptr; }),
|
||||||
_font(settings::settings().value("font", QFont()).value<QFont>()) {
|
_font(settings::settings().value("font", QFont()).value<QFont>()) {
|
||||||
pen().setColor(settings::settings().value("penColor", pen().color()).value<QColor>());
|
pen().setColor(
|
||||||
pen().setCosmetic(settings::settings().value("penCosmetic", pen().isCosmetic()).toBool());
|
settings::settings().value("penColor", pen().color()).value<QColor>());
|
||||||
pen().setWidthF(settings::settings().value("penWidth", pen().widthF()).toFloat());
|
pen().setCosmetic(
|
||||||
brush().setColor(settings::settings().value("brushColor", brush().color()).value<QColor>());
|
settings::settings().value("penCosmetic", pen().isCosmetic()).toBool());
|
||||||
|
pen().setWidthF(
|
||||||
|
settings::settings().value("penWidth", pen().widthF()).toFloat());
|
||||||
|
brush().setColor(settings::settings()
|
||||||
|
.value("brushColor", brush().color())
|
||||||
|
.value<QColor>());
|
||||||
|
|
||||||
addDrawingAction(menu, "Dot", [] { return new DotItem; });
|
addDrawingAction(menu, "Dot", [] { return new DotItem; });
|
||||||
addDrawingAction(menu, "Path", [] { return new PathItem; });
|
addDrawingAction(menu, "Path", [] { return new PathItem; });
|
||||||
@ -31,7 +37,8 @@ CropScene::CropScene(QObject *parent, QPixmap *pixmap)
|
|||||||
addDrawingAction(menu, "Text", [] { return new TextItem; });
|
addDrawingAction(menu, "Text", [] { return new TextItem; });
|
||||||
|
|
||||||
QAction *reset = menu.addAction("Reset");
|
QAction *reset = menu.addAction("Reset");
|
||||||
connect(reset, &QAction::triggered, [&] { setDrawingSelection("None", [] { return nullptr; }); });
|
connect(reset, &QAction::triggered,
|
||||||
|
[&] { setDrawingSelection("None", [] { return nullptr; }); });
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
QAction *settings = new QAction;
|
QAction *settings = new QAction;
|
||||||
@ -39,10 +46,12 @@ CropScene::CropScene(QObject *parent, QPixmap *pixmap)
|
|||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
display = menu.addAction(drawingName);
|
display = menu.addAction(drawingName);
|
||||||
display->setDisabled(true);
|
display->setDisabled(true);
|
||||||
connect(settings, &QAction::triggered, [&] { BrushPenSelection(this).exec(); });
|
connect(settings, &QAction::triggered,
|
||||||
|
[&] { BrushPenSelection(this).exec(); });
|
||||||
menu.addAction(settings);
|
menu.addAction(settings);
|
||||||
|
|
||||||
connect(menu.addAction("Set Font"), &QAction::triggered, this, &CropScene::fontAsk);
|
connect(menu.addAction("Set Font"), &QAction::triggered, this,
|
||||||
|
&CropScene::fontAsk);
|
||||||
|
|
||||||
_pixmap = pixmap;
|
_pixmap = pixmap;
|
||||||
QTimer::singleShot(0, [&] {
|
QTimer::singleShot(0, [&] {
|
||||||
@ -58,33 +67,28 @@ CropScene::CropScene(QObject *parent, QPixmap *pixmap)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CropScene::~CropScene() {
|
CropScene::~CropScene() { delete drawingSelection; }
|
||||||
delete drawingSelection;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPen &CropScene::pen() {
|
QPen &CropScene::pen() { return _pen; }
|
||||||
return _pen;
|
|
||||||
}
|
|
||||||
|
|
||||||
QBrush &CropScene::brush() {
|
QBrush &CropScene::brush() { return _brush; }
|
||||||
return _brush;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFont &CropScene::font() {
|
QFont &CropScene::font() { return _font; }
|
||||||
return _font;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CropScene::setDrawingSelection(QString name, std::function<DrawItem *()> drawAction) {
|
void CropScene::setDrawingSelection(QString name,
|
||||||
|
std::function<DrawItem *()> drawAction) {
|
||||||
drawingSelectionMaker = drawAction;
|
drawingSelectionMaker = drawAction;
|
||||||
drawingSelection = drawAction();
|
drawingSelection = drawAction();
|
||||||
drawingName = name;
|
drawingName = name;
|
||||||
if (drawingSelection) drawingSelection->init(this);
|
if (drawingSelection)
|
||||||
|
drawingSelection->init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CropScene::fontAsk() {
|
void CropScene::fontAsk() {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QFont font = QFontDialog::getFont(&ok, this->font(), nullptr, "Font to use");
|
QFont font = QFontDialog::getFont(&ok, this->font(), nullptr, "Font to use");
|
||||||
if (ok) _font = font;
|
if (ok)
|
||||||
|
_font = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CropScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
void CropScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
@ -106,12 +110,14 @@ void CropScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
initPos = p;
|
initPos = p;
|
||||||
rect->setRect(p.x(), p.y(), 1, 1);
|
rect->setRect(p.x(), p.y(), 1, 1);
|
||||||
} else {
|
} else {
|
||||||
rect->setRect(QRect(qMin(initPos.x(), p.x()), qMin(initPos.y(), p.y()), qAbs(initPos.x() - p.x()),
|
rect->setRect(
|
||||||
qAbs(initPos.y() - p.y())));
|
QRect(qMin(initPos.x(), p.x()), qMin(initPos.y(), p.y()),
|
||||||
|
qAbs(initPos.x() - p.x()), qAbs(initPos.y() - p.y())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QPolygonF poly;
|
QPolygonF poly;
|
||||||
QPointF theMagicWikipediaPoint(rect->rect().right(), sceneRect().bottom());
|
QPointF theMagicWikipediaPoint(rect->rect().right(),
|
||||||
|
sceneRect().bottom());
|
||||||
poly << sceneRect().topLeft();
|
poly << sceneRect().topLeft();
|
||||||
poly << sceneRect().topRight();
|
poly << sceneRect().topRight();
|
||||||
poly << sceneRect().bottomRight();
|
poly << sceneRect().bottomRight();
|
||||||
@ -138,15 +144,18 @@ void CropScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
drawingSelection->mouseDragEndEvent(e, this);
|
drawingSelection->mouseDragEndEvent(e, this);
|
||||||
delete drawingSelection;
|
delete drawingSelection;
|
||||||
drawingSelection = drawingSelectionMaker();
|
drawingSelection = drawingSelectionMaker();
|
||||||
if (drawingSelection) drawingSelection->init(this);
|
if (drawingSelection)
|
||||||
|
drawingSelection->init(this);
|
||||||
}
|
}
|
||||||
prevButtons = Qt::NoButton;
|
prevButtons = Qt::NoButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CropScene::addDrawingAction(QMenu &menu, QString name, std::function<DrawItem *()> item) {
|
void CropScene::addDrawingAction(QMenu &menu, QString name,
|
||||||
|
std::function<DrawItem *()> item) {
|
||||||
QAction *action = new QAction;
|
QAction *action = new QAction;
|
||||||
action->setText(name);
|
action->setText(name);
|
||||||
connect(action, &QAction::triggered, [this, item, name](bool) { setDrawingSelection(name, item); });
|
connect(action, &QAction::triggered,
|
||||||
|
[this, item, name](bool) { setDrawingSelection(name, item); });
|
||||||
menu.addAction(action);
|
menu.addAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +166,8 @@ void CropScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CropScene::keyReleaseEvent(QKeyEvent *event) {
|
void CropScene::keyReleaseEvent(QKeyEvent *event) {
|
||||||
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) done(); // Segfault
|
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
|
||||||
|
done(); // Segfault
|
||||||
}
|
}
|
||||||
|
|
||||||
void CropScene::done() {
|
void CropScene::done() {
|
||||||
|
@ -15,32 +15,32 @@ class CropScene;
|
|||||||
|
|
||||||
class CropScene : public QGraphicsScene {
|
class CropScene : public QGraphicsScene {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CropScene(QObject *parent, QPixmap *pixmap);
|
CropScene(QObject *parent, QPixmap *pixmap);
|
||||||
~CropScene();
|
~CropScene();
|
||||||
QPen &pen();
|
QPen &pen();
|
||||||
QBrush &brush();
|
QBrush &brush();
|
||||||
QFont &font();
|
QFont &font();
|
||||||
void setDrawingSelection(QString name, std::function<DrawItem *()> drawAction);
|
void setDrawingSelection(QString name,
|
||||||
QPixmap *pixmap() {
|
std::function<DrawItem *()> drawAction);
|
||||||
return _pixmap;
|
QPixmap *pixmap() { return _pixmap; }
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void fontAsk();
|
void fontAsk();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void closedWithRect(QRect rect);
|
void closedWithRect(QRect rect);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *e) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *e) override;
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *e) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *e) override;
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *e) override;
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *e) override;
|
||||||
|
|
||||||
void keyReleaseEvent(QKeyEvent *e) override;
|
void keyReleaseEvent(QKeyEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addDrawingAction(QMenu &menu, QString name, std::function<DrawItem *()> item);
|
void addDrawingAction(QMenu &menu, QString name,
|
||||||
|
std::function<DrawItem *()> item);
|
||||||
void done();
|
void done();
|
||||||
std::function<DrawItem *()> drawingSelectionMaker;
|
std::function<DrawItem *()> drawingSelectionMaker;
|
||||||
QFlags<Qt::MouseButton> prevButtons;
|
QFlags<Qt::MouseButton> prevButtons;
|
||||||
|
@ -1,19 +1,18 @@
|
|||||||
#include "cropview.hpp"
|
#include "cropview.hpp"
|
||||||
|
|
||||||
CropView::CropView(QGraphicsScene *scene) : QGraphicsView(scene)
|
CropView::CropView(QGraphicsScene *scene) : QGraphicsView(scene) {
|
||||||
{
|
setFrameShape(
|
||||||
setFrameShape(QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes.
|
QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes.
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
|
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
|
||||||
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
|
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform |
|
||||||
|
QPainter::HighQualityAntialiasing);
|
||||||
setCursor(QCursor(Qt::CrossCursor));
|
setCursor(QCursor(Qt::CrossCursor));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CropView::keyPressEvent(QKeyEvent *e)
|
void CropView::keyPressEvent(QKeyEvent *e) {
|
||||||
{
|
if (e->key() == Qt::Key_Escape) {
|
||||||
if (e->key() == Qt::Key_Escape)
|
|
||||||
{
|
|
||||||
close();
|
close();
|
||||||
e->accept();
|
e->accept();
|
||||||
return;
|
return;
|
||||||
|
@ -4,12 +4,11 @@
|
|||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
class CropView : public QGraphicsView
|
class CropView : public QGraphicsView {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
CropView(QGraphicsScene *scene);
|
CropView(QGraphicsScene *scene);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *e) override;
|
void keyPressEvent(QKeyEvent *e) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,33 +3,30 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <cropeditor/settings/blurdialog.hpp>
|
#include <cropeditor/settings/blurdialog.hpp>
|
||||||
|
|
||||||
void BlurItem::init(CropScene *)
|
void BlurItem::init(CropScene *) {
|
||||||
{
|
|
||||||
effect = new QGraphicsBlurEffect;
|
effect = new QGraphicsBlurEffect;
|
||||||
BlurDialog(effect).exec();
|
BlurDialog(effect).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlurItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene)
|
void BlurItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) {
|
||||||
{
|
if (pos.isNull()) {
|
||||||
if (pos.isNull())
|
|
||||||
{
|
|
||||||
pos = e->scenePos();
|
pos = e->scenePos();
|
||||||
rect = scene->addRect(QRect(e->scenePos().toPoint(), QSize(1, 1)), QPen(Qt::cyan), Qt::NoBrush);
|
rect = scene->addRect(QRect(e->scenePos().toPoint(), QSize(1, 1)),
|
||||||
|
QPen(Qt::cyan), Qt::NoBrush);
|
||||||
pixmap = scene->addPixmap(scene->pixmap()->copy(rect->rect().toRect()));
|
pixmap = scene->addPixmap(scene->pixmap()->copy(rect->rect().toRect()));
|
||||||
pixmap->setPos(e->scenePos());
|
pixmap->setPos(e->scenePos());
|
||||||
pixmap->setZValue(rect->zValue() - 0.1);
|
pixmap->setZValue(rect->zValue() - 0.1);
|
||||||
pixmap->setGraphicsEffect(effect);
|
pixmap->setGraphicsEffect(effect);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
QPointF p = e->scenePos();
|
QPointF p = e->scenePos();
|
||||||
rect->setRect(QRect(qMin(pos.x(), p.x()), qMin(pos.y(), p.y()), qAbs(pos.x() - p.x()), qAbs(pos.y() - p.y())));
|
rect->setRect(QRect(qMin(pos.x(), p.x()), qMin(pos.y(), p.y()),
|
||||||
|
qAbs(pos.x() - p.x()), qAbs(pos.y() - p.y())));
|
||||||
pixmap->setPixmap(scene->pixmap()->copy(rect->rect().toRect()));
|
pixmap->setPixmap(scene->pixmap()->copy(rect->rect().toRect()));
|
||||||
pixmap->setPos(rect->rect().topLeft());
|
pixmap->setPos(rect->rect().topLeft());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlurItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *)
|
void BlurItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) {
|
||||||
{
|
if (rect != nullptr)
|
||||||
if (rect != nullptr) rect->setPen(Qt::NoPen);
|
rect->setPen(Qt::NoPen);
|
||||||
}
|
}
|
||||||
|
@ -5,22 +5,16 @@
|
|||||||
|
|
||||||
#include <QGraphicsEffect>
|
#include <QGraphicsEffect>
|
||||||
|
|
||||||
class BlurItem : public DrawItem
|
class BlurItem : public DrawItem {
|
||||||
{
|
public:
|
||||||
public:
|
QString name() { return "Blur"; }
|
||||||
QString name()
|
~BlurItem() {}
|
||||||
{
|
|
||||||
return "Blur";
|
|
||||||
}
|
|
||||||
~BlurItem()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void init(CropScene *) override;
|
void init(CropScene *) override;
|
||||||
void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) override;
|
void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) override;
|
||||||
void mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) override;
|
void mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsBlurEffect *effect;
|
QGraphicsBlurEffect *effect;
|
||||||
QPointF pos;
|
QPointF pos;
|
||||||
QGraphicsRectItem *rect;
|
QGraphicsRectItem *rect;
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
#include "dotitem.hpp"
|
#include "dotitem.hpp"
|
||||||
|
|
||||||
DotItem::DotItem()
|
DotItem::DotItem() {}
|
||||||
{
|
|
||||||
|
DotItem::~DotItem() {}
|
||||||
|
|
||||||
|
void DotItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) {
|
||||||
|
scene
|
||||||
|
->addEllipse(e->pos().x() - 1.5, e->pos().y() - 1.5, 3, 3, scene->pen(),
|
||||||
|
scene->brush())
|
||||||
|
->setPos(e->scenePos());
|
||||||
}
|
}
|
||||||
|
|
||||||
DotItem::~DotItem()
|
void DotItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DotItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene)
|
|
||||||
{
|
|
||||||
scene->addEllipse(e->pos().x() - 1.5, e->pos().y() - 1.5, 3, 3, scene->pen(), scene->brush())->setPos(e->scenePos());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DotItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
@ -4,15 +4,11 @@
|
|||||||
#include "../cropscene.hpp"
|
#include "../cropscene.hpp"
|
||||||
#include "drawitem.hpp"
|
#include "drawitem.hpp"
|
||||||
|
|
||||||
class DotItem : public DrawItem
|
class DotItem : public DrawItem {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
DotItem();
|
DotItem();
|
||||||
~DotItem();
|
~DotItem();
|
||||||
QString name()
|
QString name() { return "Dots (drag to add)"; }
|
||||||
{
|
|
||||||
return "Dots (drag to add)";
|
|
||||||
}
|
|
||||||
void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene);
|
void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene);
|
||||||
void mouseDragEndEvent(QGraphicsSceneMouseEvent *e, CropScene *scene);
|
void mouseDragEndEvent(QGraphicsSceneMouseEvent *e, CropScene *scene);
|
||||||
};
|
};
|
||||||
|
@ -6,19 +6,15 @@ class DrawItem;
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <cropeditor/cropscene.hpp>
|
#include <cropeditor/cropscene.hpp>
|
||||||
|
|
||||||
class DrawItem
|
class DrawItem {
|
||||||
{
|
public:
|
||||||
public:
|
virtual ~DrawItem() {}
|
||||||
virtual ~DrawItem()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
virtual QString name() = 0;
|
virtual QString name() = 0;
|
||||||
virtual void init(CropScene *scene)
|
virtual void init(CropScene *scene) { Q_UNUSED(scene) }
|
||||||
{
|
virtual void mouseDragEvent(QGraphicsSceneMouseEvent *e,
|
||||||
Q_UNUSED(scene)
|
CropScene *scene) = 0;
|
||||||
}
|
virtual void mouseDragEndEvent(QGraphicsSceneMouseEvent *e,
|
||||||
virtual void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) = 0;
|
CropScene *scene) = 0;
|
||||||
virtual void mouseDragEndEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DRAWITEM_HPP
|
#endif // DRAWITEM_HPP
|
||||||
|
@ -1,22 +1,14 @@
|
|||||||
#include "lineitem.hpp"
|
#include "lineitem.hpp"
|
||||||
|
|
||||||
LineItem::LineItem()
|
LineItem::LineItem() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void LineItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene)
|
void LineItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) {
|
||||||
{
|
if (init.isNull()) {
|
||||||
if (init.isNull())
|
|
||||||
{
|
|
||||||
init = e->scenePos();
|
init = e->scenePos();
|
||||||
line = scene->addLine(QLineF(init, init), scene->pen());
|
line = scene->addLine(QLineF(init, init), scene->pen());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
line->setLine(QLineF(init, e->scenePos()));
|
line->setLine(QLineF(init, e->scenePos()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *)
|
void LineItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
@ -3,18 +3,14 @@
|
|||||||
|
|
||||||
#include "drawitem.hpp"
|
#include "drawitem.hpp"
|
||||||
|
|
||||||
class LineItem : public DrawItem
|
class LineItem : public DrawItem {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
LineItem();
|
LineItem();
|
||||||
QString name() override
|
QString name() override { return "Straight line"; }
|
||||||
{
|
|
||||||
return "Straight line";
|
|
||||||
}
|
|
||||||
void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) override;
|
void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) override;
|
||||||
void mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) override;
|
void mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF init;
|
QPointF init;
|
||||||
QGraphicsLineItem *line;
|
QGraphicsLineItem *line;
|
||||||
};
|
};
|
||||||
|
@ -1,28 +1,17 @@
|
|||||||
#include "pathitem.hpp"
|
#include "pathitem.hpp"
|
||||||
|
|
||||||
PathItem::PathItem()
|
PathItem::PathItem() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
PathItem::~PathItem()
|
PathItem::~PathItem() { delete path; }
|
||||||
{
|
|
||||||
delete path;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PathItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene)
|
void PathItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) {
|
||||||
{
|
if (path == nullptr) {
|
||||||
if (path == nullptr)
|
|
||||||
{
|
|
||||||
path = new QPainterPath(e->scenePos());
|
path = new QPainterPath(e->scenePos());
|
||||||
pathItem = scene->addPath(*path, scene->pen(), scene->brush());
|
pathItem = scene->addPath(*path, scene->pen(), scene->brush());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
path->quadTo(path->currentPosition(), e->scenePos());
|
path->quadTo(path->currentPosition(), e->scenePos());
|
||||||
pathItem->setPath(*path);
|
pathItem->setPath(*path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *)
|
void PathItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
@ -4,19 +4,15 @@
|
|||||||
#include "../cropscene.hpp"
|
#include "../cropscene.hpp"
|
||||||
#include "drawitem.hpp"
|
#include "drawitem.hpp"
|
||||||
|
|
||||||
class PathItem : public DrawItem
|
class PathItem : public DrawItem {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
PathItem();
|
PathItem();
|
||||||
~PathItem();
|
~PathItem();
|
||||||
QString name()
|
QString name() { return "Path"; }
|
||||||
{
|
|
||||||
return "Path";
|
|
||||||
}
|
|
||||||
void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene);
|
void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene);
|
||||||
void mouseDragEndEvent(QGraphicsSceneMouseEvent *e, CropScene *scene);
|
void mouseDragEndEvent(QGraphicsSceneMouseEvent *e, CropScene *scene);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPainterPath *path = nullptr;
|
QPainterPath *path = nullptr;
|
||||||
QGraphicsPathItem *pathItem = nullptr;
|
QGraphicsPathItem *pathItem = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -13,15 +13,13 @@ void TextItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) {
|
|||||||
textItem->setPen(scene->pen());
|
textItem->setPen(scene->pen());
|
||||||
textItem->setBrush(scene->brush());
|
textItem->setBrush(scene->brush());
|
||||||
} else {
|
} else {
|
||||||
auto ee
|
auto ee = 180 + qRadiansToDegrees(
|
||||||
= 180 + qRadiansToDegrees(qAtan2((textItem->pos().y() - e->scenePos().y()), (textItem->pos().x() - e->scenePos().x())));
|
qAtan2((textItem->pos().y() - e->scenePos().y()),
|
||||||
|
(textItem->pos().x() - e->scenePos().x())));
|
||||||
textItem->setRotation(ee);
|
textItem->setRotation(ee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) {
|
void TextItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) {}
|
||||||
}
|
|
||||||
|
|
||||||
QString TextItem::name() {
|
QString TextItem::name() { return "Text"; }
|
||||||
return "Text";
|
|
||||||
}
|
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
#include <QGraphicsSimpleTextItem>
|
#include <QGraphicsSimpleTextItem>
|
||||||
|
|
||||||
class TextItem : public DrawItem {
|
class TextItem : public DrawItem {
|
||||||
public:
|
public:
|
||||||
QString name() override;
|
QString name() override;
|
||||||
void init(CropScene *) override;
|
void init(CropScene *) override;
|
||||||
void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) override;
|
void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) override;
|
||||||
void mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) override;
|
void mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsSimpleTextItem *textItem = nullptr;
|
QGraphicsSimpleTextItem *textItem = nullptr;
|
||||||
QString text;
|
QString text;
|
||||||
};
|
};
|
||||||
|
@ -6,19 +6,24 @@
|
|||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
|
|
||||||
BlurDialog::BlurDialog(QGraphicsBlurEffect *e, QWidget *parent) : QDialog(parent), ui(new Ui::BlurDialog)
|
BlurDialog::BlurDialog(QGraphicsBlurEffect *e, QWidget *parent)
|
||||||
{
|
: QDialog(parent), ui(new Ui::BlurDialog) {
|
||||||
effect = e;
|
effect = e;
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->animated->setChecked(effect->blurHints().testFlag(QGraphicsBlurEffect::AnimationHint));
|
ui->animated->setChecked(
|
||||||
ui->performance->setChecked(effect->blurHints().testFlag(QGraphicsBlurEffect::PerformanceHint));
|
effect->blurHints().testFlag(QGraphicsBlurEffect::AnimationHint));
|
||||||
ui->quality->setChecked(effect->blurHints().testFlag(QGraphicsBlurEffect::QualityHint));
|
ui->performance->setChecked(
|
||||||
|
effect->blurHints().testFlag(QGraphicsBlurEffect::PerformanceHint));
|
||||||
|
ui->quality->setChecked(
|
||||||
|
effect->blurHints().testFlag(QGraphicsBlurEffect::QualityHint));
|
||||||
ui->radSlider->setValue(effect->blurRadius() * 100);
|
ui->radSlider->setValue(effect->blurRadius() * 100);
|
||||||
ui->radSpinner->setValue(effect->blurRadius());
|
ui->radSpinner->setValue(effect->blurRadius());
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, [&] {
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, [&] {
|
||||||
QFlags<QGraphicsBlurEffect::BlurHint> hints;
|
QFlags<QGraphicsBlurEffect::BlurHint> hints;
|
||||||
hints.setFlag(QGraphicsBlurEffect::AnimationHint, ui->animated->isChecked());
|
hints.setFlag(QGraphicsBlurEffect::AnimationHint,
|
||||||
hints.setFlag(QGraphicsBlurEffect::PerformanceHint, ui->performance->isChecked());
|
ui->animated->isChecked());
|
||||||
|
hints.setFlag(QGraphicsBlurEffect::PerformanceHint,
|
||||||
|
ui->performance->isChecked());
|
||||||
hints.setFlag(QGraphicsBlurEffect::QualityHint, ui->quality->isChecked());
|
hints.setFlag(QGraphicsBlurEffect::QualityHint, ui->quality->isChecked());
|
||||||
effect->setBlurHints(hints);
|
effect->setBlurHints(hints);
|
||||||
effect->setBlurRadius(ui->radSpinner->value());
|
effect->setBlurRadius(ui->radSpinner->value());
|
||||||
@ -27,17 +32,12 @@ BlurDialog::BlurDialog(QGraphicsBlurEffect *e, QWidget *parent) : QDialog(parent
|
|||||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, [&] { close(); });
|
connect(ui->buttonBox, &QDialogButtonBox::rejected, [&] { close(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
BlurDialog::~BlurDialog()
|
BlurDialog::~BlurDialog() { delete ui; }
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlurDialog::on_radSpinner_valueChanged(double arg1)
|
void BlurDialog::on_radSpinner_valueChanged(double arg1) {
|
||||||
{
|
|
||||||
ui->radSlider->setValue(arg1 * 100);
|
ui->radSlider->setValue(arg1 * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlurDialog::on_radSlider_sliderMoved(int position)
|
void BlurDialog::on_radSlider_sliderMoved(int position) {
|
||||||
{
|
|
||||||
ui->radSpinner->setValue(position / 100.);
|
ui->radSpinner->setValue(position / 100.);
|
||||||
}
|
}
|
||||||
|
@ -4,24 +4,22 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QGraphicsBlurEffect>
|
#include <QGraphicsBlurEffect>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui {
|
||||||
{
|
|
||||||
class BlurDialog;
|
class BlurDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
class BlurDialog : public QDialog
|
class BlurDialog : public QDialog {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BlurDialog(QGraphicsBlurEffect *effect, QWidget *parent = 0);
|
explicit BlurDialog(QGraphicsBlurEffect *effect, QWidget *parent = 0);
|
||||||
~BlurDialog();
|
~BlurDialog();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_radSpinner_valueChanged(double arg1);
|
void on_radSpinner_valueChanged(double arg1);
|
||||||
void on_radSlider_sliderMoved(int position);
|
void on_radSlider_sliderMoved(int position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::BlurDialog *ui;
|
Ui::BlurDialog *ui;
|
||||||
QGraphicsBlurEffect *effect;
|
QGraphicsBlurEffect *effect;
|
||||||
};
|
};
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include <cropeditor/cropview.hpp>
|
#include <cropeditor/cropview.hpp>
|
||||||
#include <settings.hpp>
|
#include <settings.hpp>
|
||||||
|
|
||||||
BrushPenSelection::BrushPenSelection(CropScene *scene) : QDialog(), ui(new Ui::BrushPenSelection)
|
BrushPenSelection::BrushPenSelection(CropScene *scene)
|
||||||
{
|
: QDialog(), ui(new Ui::BrushPenSelection) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->cosmetic->setChecked(scene->pen().isCosmetic());
|
ui->cosmetic->setChecked(scene->pen().isCosmetic());
|
||||||
ui->widthSlider->setValue(scene->pen().width());
|
ui->widthSlider->setValue(scene->pen().width());
|
||||||
@ -20,23 +20,17 @@ BrushPenSelection::BrushPenSelection(CropScene *scene) : QDialog(), ui(new Ui::B
|
|||||||
this->scene = scene;
|
this->scene = scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
BrushPenSelection::~BrushPenSelection()
|
BrushPenSelection::~BrushPenSelection() { delete ui; }
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BrushPenSelection::on_penColor_clicked(bool)
|
void BrushPenSelection::on_penColor_clicked(bool) {
|
||||||
{
|
|
||||||
pen = QColorDialog::getColor(pen, this, "Pen Color");
|
pen = QColorDialog::getColor(pen, this, "Pen Color");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrushPenSelection::on_brushColor_clicked(bool)
|
void BrushPenSelection::on_brushColor_clicked(bool) {
|
||||||
{
|
|
||||||
brush = QColorDialog::getColor(brush, this, "Brush Color");
|
brush = QColorDialog::getColor(brush, this, "Brush Color");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrushPenSelection::on_buttonBox_accepted()
|
void BrushPenSelection::on_buttonBox_accepted() {
|
||||||
{
|
|
||||||
scene->pen().setColor(pen);
|
scene->pen().setColor(pen);
|
||||||
scene->pen().setCosmetic(ui->cosmetic->isChecked());
|
scene->pen().setCosmetic(ui->cosmetic->isChecked());
|
||||||
scene->pen().setWidthF(ui->widthSpinner->value());
|
scene->pen().setWidthF(ui->widthSpinner->value());
|
||||||
@ -48,17 +42,12 @@ void BrushPenSelection::on_buttonBox_accepted()
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrushPenSelection::on_buttonBox_rejected()
|
void BrushPenSelection::on_buttonBox_rejected() { close(); }
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BrushPenSelection::on_widthSlider_sliderMoved(int position)
|
void BrushPenSelection::on_widthSlider_sliderMoved(int position) {
|
||||||
{
|
|
||||||
ui->widthSpinner->setValue(position / 100.);
|
ui->widthSpinner->setValue(position / 100.);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrushPenSelection::on_widthSpinner_valueChanged(double arg)
|
void BrushPenSelection::on_widthSpinner_valueChanged(double arg) {
|
||||||
{
|
|
||||||
ui->widthSlider->setValue(arg * 100);
|
ui->widthSlider->setValue(arg * 100);
|
||||||
}
|
}
|
||||||
|
@ -4,20 +4,18 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <cropeditor/cropscene.hpp>
|
#include <cropeditor/cropscene.hpp>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui {
|
||||||
{
|
|
||||||
class BrushPenSelection;
|
class BrushPenSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
class BrushPenSelection : public QDialog
|
class BrushPenSelection : public QDialog {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BrushPenSelection(CropScene *scene);
|
explicit BrushPenSelection(CropScene *scene);
|
||||||
~BrushPenSelection();
|
~BrushPenSelection();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_penColor_clicked(bool);
|
void on_penColor_clicked(bool);
|
||||||
void on_brushColor_clicked(bool);
|
void on_brushColor_clicked(bool);
|
||||||
|
|
||||||
@ -27,7 +25,7 @@ class BrushPenSelection : public QDialog
|
|||||||
void on_widthSlider_sliderMoved(int position);
|
void on_widthSlider_sliderMoved(int position);
|
||||||
void on_widthSpinner_valueChanged(double arg1);
|
void on_widthSpinner_valueChanged(double arg1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::BrushPenSelection *ui;
|
Ui::BrushPenSelection *ui;
|
||||||
CropScene *scene;
|
CropScene *scene;
|
||||||
QColor brush, pen;
|
QColor brush, pen;
|
||||||
|
@ -3,16 +3,15 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
QString formatter::format(QString toFormat)
|
QString formatter::format(QString toFormat) {
|
||||||
{
|
|
||||||
QRegExp dateRegex("%\\((.+)\\)date");
|
QRegExp dateRegex("%\\((.+)\\)date");
|
||||||
dateRegex.indexIn(toFormat);
|
dateRegex.indexIn(toFormat);
|
||||||
QStringList capturedTexts(dateRegex.capturedTexts());
|
QStringList capturedTexts(dateRegex.capturedTexts());
|
||||||
QString formatted(toFormat);
|
QString formatted(toFormat);
|
||||||
QDateTime date = QDateTime::currentDateTime();
|
QDateTime date = QDateTime::currentDateTime();
|
||||||
for (int i = 0; i < capturedTexts.length(); i += 2)
|
for (int i = 0; i < capturedTexts.length(); i += 2) {
|
||||||
{
|
formatted = formatted.replace(capturedTexts.at(i),
|
||||||
formatted = formatted.replace(capturedTexts.at(i), date.toString(capturedTexts.at(i + 1)));
|
date.toString(capturedTexts.at(i + 1)));
|
||||||
}
|
}
|
||||||
return formatted;
|
return formatted;
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace formatter
|
namespace formatter {
|
||||||
{
|
|
||||||
QString format(QString toFormat);
|
QString format(QString toFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,12 +8,11 @@
|
|||||||
QMap<QString, QHotkey *> hotkeys;
|
QMap<QString, QHotkey *> hotkeys;
|
||||||
|
|
||||||
// func gets bound only on first set, or load
|
// func gets bound only on first set, or load
|
||||||
void hotkeying::hotkey(QString seqName, QKeySequence seq, std::function<void()> func)
|
void hotkeying::hotkey(QString seqName, QKeySequence seq,
|
||||||
{
|
std::function<void()> func) {
|
||||||
if (hotkeys.contains(seqName))
|
if (hotkeys.contains(seqName))
|
||||||
hotkeys.value(seqName)->setShortcut(seq, true);
|
hotkeys.value(seqName)->setShortcut(seq, true);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
QHotkey *hotkey = new QHotkey(seq, true);
|
QHotkey *hotkey = new QHotkey(seq, true);
|
||||||
QObject::connect(hotkey, &QHotkey::activated, func);
|
QObject::connect(hotkey, &QHotkey::activated, func);
|
||||||
hotkeys.insert(seqName, hotkey);
|
hotkeys.insert(seqName, hotkey);
|
||||||
@ -22,25 +21,25 @@ void hotkeying::hotkey(QString seqName, QKeySequence seq, std::function<void()>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// forces the hotkey from settings
|
// forces the hotkey from settings
|
||||||
void hotkeying::load(QString seqName, std::function<void()> func)
|
void hotkeying::load(QString seqName, std::function<void()> func) {
|
||||||
{
|
|
||||||
QHotkey *h;
|
QHotkey *h;
|
||||||
QString name = seqName;
|
QString name = seqName;
|
||||||
name.prepend("hotkey_");
|
name.prepend("hotkey_");
|
||||||
if (settings::settings().contains(name))
|
if (settings::settings().contains(name))
|
||||||
h = new QHotkey(QKeySequence(settings::settings().value(name).toString()), true);
|
h = new QHotkey(QKeySequence(settings::settings().value(name).toString()),
|
||||||
|
true);
|
||||||
else
|
else
|
||||||
h = new QHotkey;
|
h = new QHotkey;
|
||||||
QObject::connect(h, &QHotkey::activated, func);
|
QObject::connect(h, &QHotkey::activated, func);
|
||||||
hotkeys.insert(seqName, h);
|
hotkeys.insert(seqName, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hotkeying::valid(QString seq)
|
bool hotkeying::valid(QString seq) {
|
||||||
{
|
|
||||||
return seq.isEmpty() || !QKeySequence(seq).toString().isEmpty();
|
return seq.isEmpty() || !QKeySequence(seq).toString().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString hotkeying::sequence(QString seqName)
|
QString hotkeying::sequence(QString seqName) {
|
||||||
{
|
return hotkeys.contains(seqName)
|
||||||
return hotkeys.contains(seqName) ? hotkeys.value(seqName)->shortcut().toString() : "";
|
? hotkeys.value(seqName)->shortcut().toString()
|
||||||
|
: "";
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace hotkeying
|
namespace hotkeying {
|
||||||
{
|
|
||||||
void hotkey(QString seqName, QKeySequence seq, std::function<void()> func);
|
void hotkey(QString seqName, QKeySequence seq, std::function<void()> func);
|
||||||
bool valid(QString seq);
|
bool valid(QString seq);
|
||||||
void load(QString seqName, std::function<void()> func);
|
void load(QString seqName, std::function<void()> func);
|
||||||
|
@ -4,16 +4,15 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
|
|
||||||
namespace ioutils
|
namespace ioutils {
|
||||||
{
|
|
||||||
QNetworkAccessManager networkManager;
|
QNetworkAccessManager networkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ioutils::getJson(QUrl target, QList<QPair<QString, QString>> headers, std::function<void(QJsonDocument, QNetworkReply *)> callback)
|
void ioutils::getJson(
|
||||||
{
|
QUrl target, QList<QPair<QString, QString>> headers,
|
||||||
|
std::function<void(QJsonDocument, QNetworkReply *)> callback) {
|
||||||
QNetworkRequest req(target);
|
QNetworkRequest req(target);
|
||||||
for (auto header : headers)
|
for (auto header : headers) {
|
||||||
{
|
|
||||||
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
||||||
}
|
}
|
||||||
QNetworkReply *reply = networkManager.get(req);
|
QNetworkReply *reply = networkManager.get(req);
|
||||||
@ -23,14 +22,11 @@ void ioutils::getJson(QUrl target, QList<QPair<QString, QString>> headers, std::
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ioutils::postJson(QUrl target,
|
void ioutils::postJson(
|
||||||
QList<QPair<QString, QString>> headers,
|
QUrl target, QList<QPair<QString, QString>> headers, QByteArray body,
|
||||||
QByteArray body,
|
std::function<void(QJsonDocument, QNetworkReply *)> callback) {
|
||||||
std::function<void(QJsonDocument, QNetworkReply *)> callback)
|
|
||||||
{
|
|
||||||
QNetworkRequest req(target);
|
QNetworkRequest req(target);
|
||||||
for (auto header : headers)
|
for (auto header : headers) {
|
||||||
{
|
|
||||||
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
||||||
}
|
}
|
||||||
QNetworkReply *reply = networkManager.post(req, body);
|
QNetworkReply *reply = networkManager.post(req, body);
|
||||||
@ -40,11 +36,11 @@ void ioutils::postJson(QUrl target,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ioutils::getData(QUrl target, QList<QPair<QString, QString>> headers, std::function<void(QByteArray, QNetworkReply *)> callback)
|
void ioutils::getData(
|
||||||
{
|
QUrl target, QList<QPair<QString, QString>> headers,
|
||||||
|
std::function<void(QByteArray, QNetworkReply *)> callback) {
|
||||||
QNetworkRequest req(target);
|
QNetworkRequest req(target);
|
||||||
for (auto header : headers)
|
for (auto header : headers) {
|
||||||
{
|
|
||||||
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
||||||
}
|
}
|
||||||
QNetworkReply *reply = networkManager.get(req);
|
QNetworkReply *reply = networkManager.get(req);
|
||||||
@ -54,14 +50,11 @@ void ioutils::getData(QUrl target, QList<QPair<QString, QString>> headers, std::
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ioutils::postData(QUrl target,
|
void ioutils::postData(
|
||||||
QList<QPair<QString, QString>> headers,
|
QUrl target, QList<QPair<QString, QString>> headers, QByteArray body,
|
||||||
QByteArray body,
|
std::function<void(QByteArray, QNetworkReply *)> callback) {
|
||||||
std::function<void(QByteArray, QNetworkReply *)> callback)
|
|
||||||
{
|
|
||||||
QNetworkRequest req(target);
|
QNetworkRequest req(target);
|
||||||
for (auto header : headers)
|
for (auto header : headers) {
|
||||||
{
|
|
||||||
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
||||||
}
|
}
|
||||||
QNetworkReply *reply = networkManager.post(req, body);
|
QNetworkReply *reply = networkManager.post(req, body);
|
||||||
|
@ -7,13 +7,18 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace ioutils
|
namespace ioutils {
|
||||||
{
|
|
||||||
extern QNetworkAccessManager networkManager;
|
extern QNetworkAccessManager networkManager;
|
||||||
void getJson(QUrl target, QList<QPair<QString, QString>> headers, std::function<void(QJsonDocument, QNetworkReply *)> callback);
|
void getJson(QUrl target, QList<QPair<QString, QString>> headers,
|
||||||
void postJson(QUrl target, QList<QPair<QString, QString>> headers, QByteArray body, std::function<void(QJsonDocument, QNetworkReply *)> callback);
|
std::function<void(QJsonDocument, QNetworkReply *)> callback);
|
||||||
void getData(QUrl target, QList<QPair<QString, QString>> headers, std::function<void(QByteArray, QNetworkReply *)> callback);
|
void postJson(QUrl target, QList<QPair<QString, QString>> headers,
|
||||||
void postData(QUrl target, QList<QPair<QString, QString>> headers, QByteArray body, std::function<void(QByteArray, QNetworkReply *)> callback);
|
QByteArray body,
|
||||||
|
std::function<void(QJsonDocument, QNetworkReply *)> callback);
|
||||||
|
void getData(QUrl target, QList<QPair<QString, QString>> headers,
|
||||||
|
std::function<void(QByteArray, QNetworkReply *)> callback);
|
||||||
|
void postData(QUrl target, QList<QPair<QString, QString>> headers,
|
||||||
|
QByteArray body,
|
||||||
|
std::function<void(QByteArray, QNetworkReply *)> callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // IOUTILS_HPP
|
#endif // IOUTILS_HPP
|
||||||
|
20
main.cpp
20
main.cpp
@ -7,13 +7,12 @@
|
|||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
|
|
||||||
void handler(QtMsgType type, const QMessageLogContext &, const QString &msg)
|
void handler(QtMsgType type, const QMessageLogContext &, const QString &msg) {
|
||||||
{
|
|
||||||
QByteArray localMsg = msg.toLocal8Bit();
|
QByteArray localMsg = msg.toLocal8Bit();
|
||||||
switch (type)
|
switch (type) {
|
||||||
{
|
|
||||||
case QtDebugMsg:
|
case QtDebugMsg:
|
||||||
if (verbose) fprintf(stderr, "DEBUG: %s\n", localMsg.constData());
|
if (verbose)
|
||||||
|
fprintf(stderr, "DEBUG: %s\n", localMsg.constData());
|
||||||
break;
|
break;
|
||||||
case QtInfoMsg:
|
case QtInfoMsg:
|
||||||
fprintf(stderr, "INFO: %s\n", localMsg.constData());
|
fprintf(stderr, "INFO: %s\n", localMsg.constData());
|
||||||
@ -30,8 +29,7 @@ void handler(QtMsgType type, const QMessageLogContext &, const QString &msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]) {
|
||||||
{
|
|
||||||
qInstallMessageHandler(handler);
|
qInstallMessageHandler(handler);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
a.setApplicationName("KShare");
|
a.setApplicationName("KShare");
|
||||||
@ -41,8 +39,9 @@ int main(int argc, char *argv[])
|
|||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
|
|
||||||
QCommandLineOption h({ "b", "background" }, "Does not show the main window, starts in tray.");
|
QCommandLineOption h({"b", "background"},
|
||||||
QCommandLineOption v({ "v", "verbose" }, "Enables QtDebugMsg outputs");
|
"Does not show the main window, starts in tray.");
|
||||||
|
QCommandLineOption v({"v", "verbose"}, "Enables QtDebugMsg outputs");
|
||||||
parser.addOption(h);
|
parser.addOption(h);
|
||||||
parser.addOption(v);
|
parser.addOption(v);
|
||||||
parser.process(a);
|
parser.process(a);
|
||||||
@ -51,7 +50,8 @@ int main(int argc, char *argv[])
|
|||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
QTimer::singleShot(0, [&] {
|
QTimer::singleShot(0, [&] {
|
||||||
if (parser.isSet(h)) w.hide();
|
if (parser.isSet(h))
|
||||||
|
w.hide();
|
||||||
});
|
});
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
123
mainwindow.cpp
123
mainwindow.cpp
@ -19,17 +19,16 @@
|
|||||||
|
|
||||||
MainWindow *MainWindow::instance;
|
MainWindow *MainWindow::instance;
|
||||||
|
|
||||||
void addHotkeyItem(QString text, QString name, std::function<void()> *func)
|
void addHotkeyItem(QString text, QString name, std::function<void()> *func) {
|
||||||
{
|
QListWidgetItem *item =
|
||||||
QListWidgetItem *item = new QListWidgetItem(text, MainWindow::inst()->ui->hotkeys);
|
new QListWidgetItem(text, MainWindow::inst()->ui->hotkeys);
|
||||||
item->setData(Qt::UserRole + 1, name);
|
item->setData(Qt::UserRole + 1, name);
|
||||||
MainWindow::inst()->fncs.insert(name, func);
|
MainWindow::inst()->fncs.insert(name, func);
|
||||||
hotkeying::load(name, *func);
|
hotkeying::load(name, *func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
|
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||||
{
|
|
||||||
instance = this;
|
instance = this;
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowIcon(QIcon(":/icons/icon.png"));
|
setWindowIcon(QIcon(":/icons/icon.png"));
|
||||||
@ -41,25 +40,32 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
QAction *shtoggle = new QAction("Show/Hide", this);
|
QAction *shtoggle = new QAction("Show/Hide", this);
|
||||||
QAction *fullscreen = new QAction("Take fullscreen shot", this);
|
QAction *fullscreen = new QAction("Take fullscreen shot", this);
|
||||||
QAction *area = new QAction("Take area shot", this);
|
QAction *area = new QAction("Take area shot", this);
|
||||||
menu->addActions({ quit, shtoggle });
|
menu->addActions({quit, shtoggle});
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addActions({ fullscreen, area });
|
menu->addActions({fullscreen, area});
|
||||||
connect(quit, &QAction::triggered, this, &MainWindow::quit);
|
connect(quit, &QAction::triggered, this, &MainWindow::quit);
|
||||||
connect(shtoggle, &QAction::triggered, this, &MainWindow::toggleVisible);
|
connect(shtoggle, &QAction::triggered, this, &MainWindow::toggleVisible);
|
||||||
connect(tray, &QSystemTrayIcon::messageClicked, this, &MainWindow::toggleVisible);
|
connect(tray, &QSystemTrayIcon::messageClicked, this,
|
||||||
connect(tray, &QSystemTrayIcon::activated, this, [this](QSystemTrayIcon::ActivationReason reason) {
|
&MainWindow::toggleVisible);
|
||||||
if (reason == QSystemTrayIcon::DoubleClick) toggleVisible();
|
connect(tray, &QSystemTrayIcon::activated, this,
|
||||||
|
[this](QSystemTrayIcon::ActivationReason reason) {
|
||||||
|
if (reason == QSystemTrayIcon::DoubleClick)
|
||||||
|
toggleVisible();
|
||||||
});
|
});
|
||||||
connect(fullscreen, &QAction::triggered, this, [] { screenshotter::fullscreenDelayed(); });
|
connect(fullscreen, &QAction::triggered, this,
|
||||||
connect(area, &QAction::triggered, this, [] { screenshotter::areaDelayed(); });
|
[] { screenshotter::fullscreenDelayed(); });
|
||||||
|
connect(area, &QAction::triggered, this,
|
||||||
|
[] { screenshotter::areaDelayed(); });
|
||||||
tray->setContextMenu(menu);
|
tray->setContextMenu(menu);
|
||||||
|
|
||||||
ui->uploaderList->setSelectionBehavior(QAbstractItemView::SelectRows);
|
ui->uploaderList->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
ui->uploaderList->setSelectionMode(QAbstractItemView::SingleSelection);
|
ui->uploaderList->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
|
||||||
// Add items to uploader selection
|
// Add items to uploader selection
|
||||||
for (Uploader *u : UploaderSingleton::inst().uploaderList()) newUploader(u);
|
for (Uploader *u : UploaderSingleton::inst().uploaderList())
|
||||||
connect(&UploaderSingleton::inst(), &UploaderSingleton::newUploader, this, &MainWindow::newUploader);
|
newUploader(u);
|
||||||
|
connect(&UploaderSingleton::inst(), &UploaderSingleton::newUploader, this,
|
||||||
|
&MainWindow::newUploader);
|
||||||
|
|
||||||
// Set filename scheme
|
// Set filename scheme
|
||||||
if ((settings::settings().contains("fileFormat")))
|
if ((settings::settings().contains("fileFormat")))
|
||||||
@ -71,7 +77,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
if (errors.length() == 1)
|
if (errors.length() == 1)
|
||||||
statusBar()->showMessage(errors.at(0).what());
|
statusBar()->showMessage(errors.at(0).what());
|
||||||
else
|
else
|
||||||
statusBar()->showMessage(QString("Errors visible in console (if present). Count: " + QString::number(errors.size())));
|
statusBar()->showMessage(
|
||||||
|
QString("Errors visible in console (if present). Count: " +
|
||||||
|
QString::number(errors.size())));
|
||||||
|
|
||||||
// Set delay
|
// Set delay
|
||||||
if ((settings::settings().contains("delay")))
|
if ((settings::settings().contains("delay")))
|
||||||
@ -81,100 +89,73 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
|
|
||||||
ui->hotkeys->setSelectionMode(QListWidget::SingleSelection);
|
ui->hotkeys->setSelectionMode(QListWidget::SingleSelection);
|
||||||
|
|
||||||
addHotkeyItem("Fullscreen image", "fullscreen", new std::function<void()>([] { screenshotter::fullscreen(); }));
|
addHotkeyItem("Fullscreen image", "fullscreen",
|
||||||
addHotkeyItem("Area image", "area", new std::function<void()>([] { screenshotter::area(); }));
|
new std::function<void()>([] { screenshotter::fullscreen(); }));
|
||||||
|
addHotkeyItem("Area image", "area",
|
||||||
|
new std::function<void()>([] { screenshotter::area(); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow() { delete ui; }
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::setScheme(QString scheme)
|
void MainWindow::setScheme(QString scheme) { ui->nameScheme->setText(scheme); }
|
||||||
{
|
|
||||||
ui->nameScheme->setText(scheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDoubleSpinBox *MainWindow::delay()
|
QDoubleSpinBox *MainWindow::delay() { return ui->delay; }
|
||||||
{
|
|
||||||
return ui->delay;
|
|
||||||
}
|
|
||||||
|
|
||||||
MainWindow *MainWindow::inst()
|
MainWindow *MainWindow::inst() { return instance; }
|
||||||
{
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event)
|
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
{
|
|
||||||
event->ignore();
|
event->ignore();
|
||||||
QTimer::singleShot(0, this, &MainWindow::hide);
|
QTimer::singleShot(0, this, &MainWindow::hide);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::quit()
|
void MainWindow::quit() { QCoreApplication::quit(); }
|
||||||
{
|
|
||||||
QCoreApplication::quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::toggleVisible()
|
void MainWindow::toggleVisible() {
|
||||||
{
|
|
||||||
this->setVisible(!this->isVisible());
|
this->setVisible(!this->isVisible());
|
||||||
if (this->isVisible())
|
if (this->isVisible()) {
|
||||||
{
|
|
||||||
this->raise();
|
this->raise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::newUploader(Uploader *u)
|
void MainWindow::newUploader(Uploader *u) {
|
||||||
{
|
|
||||||
QListWidgetItem *item = new QListWidgetItem(u->name());
|
QListWidgetItem *item = new QListWidgetItem(u->name());
|
||||||
item->setToolTip(u->description());
|
item->setToolTip(u->description());
|
||||||
ui->uploaderList->addItem(item);
|
ui->uploaderList->addItem(item);
|
||||||
if (u->name() == UploaderSingleton::inst().selectedUploader()) item->setSelected(true);
|
if (u->name() == UploaderSingleton::inst().selectedUploader())
|
||||||
|
item->setSelected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionQuit_triggered()
|
void MainWindow::on_actionQuit_triggered() { quit(); }
|
||||||
{
|
|
||||||
quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_actionFullscreen_triggered()
|
void MainWindow::on_actionFullscreen_triggered() {
|
||||||
{
|
|
||||||
screenshotter::fullscreenDelayed();
|
screenshotter::fullscreenDelayed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionArea_triggered()
|
void MainWindow::on_actionArea_triggered() { screenshotter::areaDelayed(); }
|
||||||
{
|
|
||||||
screenshotter::areaDelayed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_uploaderList_clicked(const QModelIndex &)
|
void MainWindow::on_uploaderList_clicked(const QModelIndex &) {
|
||||||
{
|
|
||||||
QList<QListWidgetItem *> index = ui->uploaderList->selectedItems();
|
QList<QListWidgetItem *> index = ui->uploaderList->selectedItems();
|
||||||
if (index.size() == 1)
|
if (index.size() == 1) {
|
||||||
{
|
|
||||||
UploaderSingleton::inst().set(index.at(0)->text());
|
UploaderSingleton::inst().set(index.at(0)->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_nameScheme_textEdited(const QString &arg1)
|
void MainWindow::on_nameScheme_textEdited(const QString &arg1) {
|
||||||
{
|
|
||||||
settings::settings().setValue("fileFormat", arg1);
|
settings::settings().setValue("fileFormat", arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_delay_valueChanged(double arg1)
|
void MainWindow::on_delay_valueChanged(double arg1) {
|
||||||
{
|
|
||||||
settings::settings().setValue("delay", arg1);
|
settings::settings().setValue("delay", arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_hotkeys_doubleClicked(const QModelIndex &)
|
void MainWindow::on_hotkeys_doubleClicked(const QModelIndex &) {
|
||||||
{
|
if (ui->hotkeys->selectedItems().length() == 1) {
|
||||||
if (ui->hotkeys->selectedItems().length() == 1)
|
|
||||||
{
|
|
||||||
QListWidgetItem *i = ui->hotkeys->selectedItems().at(0);
|
QListWidgetItem *i = ui->hotkeys->selectedItems().at(0);
|
||||||
QString str = i->data(Qt::UserRole + 1).toString();
|
QString str = i->data(Qt::UserRole + 1).toString();
|
||||||
QString seq = QInputDialog::getText(ui->centralWidget, "Hotkey Input", "Insert hotkey:", QLineEdit::Normal,
|
QString seq = QInputDialog::getText(ui->centralWidget, "Hotkey Input",
|
||||||
|
"Insert hotkey:", QLineEdit::Normal,
|
||||||
hotkeying::sequence(str));
|
hotkeying::sequence(str));
|
||||||
if (hotkeying::valid(seq)) hotkeying::hotkey(str, QKeySequence(seq), *fncs.value(str));
|
if (hotkeying::valid(seq))
|
||||||
|
hotkeying::hotkey(str, QKeySequence(seq), *fncs.value(str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,13 @@
|
|||||||
|
|
||||||
#include <uploaders/uploader.hpp>
|
#include <uploaders/uploader.hpp>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui {
|
||||||
{
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private slots:
|
private slots:
|
||||||
void quit();
|
void quit();
|
||||||
void toggleVisible();
|
void toggleVisible();
|
||||||
void newUploader(Uploader *u);
|
void newUploader(Uploader *u);
|
||||||
@ -32,7 +30,7 @@ class MainWindow : public QMainWindow
|
|||||||
|
|
||||||
void on_hotkeys_doubleClicked(const QModelIndex &index);
|
void on_hotkeys_doubleClicked(const QModelIndex &index);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = 0);
|
explicit MainWindow(QWidget *parent = 0);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
@ -44,10 +42,10 @@ class MainWindow : public QMainWindow
|
|||||||
static MainWindow *inst();
|
static MainWindow *inst();
|
||||||
QMap<QString, std::function<void()> *> fncs;
|
QMap<QString, std::function<void()> *> fncs;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static MainWindow *instance;
|
static MainWindow *instance;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
#include "mainwindow.hpp"
|
#include "mainwindow.hpp"
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
|
|
||||||
void notifications::notify(QString title, QString body, QSystemTrayIcon::MessageIcon icon)
|
void notifications::notify(QString title, QString body,
|
||||||
{
|
QSystemTrayIcon::MessageIcon icon) {
|
||||||
MainWindow::inst()->tray->showMessage(title, body, icon, 5000);
|
MainWindow::inst()->tray->showMessage(title, body, icon, 5000);
|
||||||
MainWindow::inst()->statusBar()->showMessage(title + ": " + body);
|
MainWindow::inst()->statusBar()->showMessage(title + ": " + body);
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
namespace notifications
|
namespace notifications {
|
||||||
{
|
void notify(QString title, QString body,
|
||||||
void notify(QString title, QString body, QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information);
|
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // NOTIFICATIONS_HPP
|
#endif // NOTIFICATIONS_HPP
|
||||||
|
@ -6,23 +6,23 @@
|
|||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
void screenshotter::area()
|
void screenshotter::area() {
|
||||||
{
|
|
||||||
CropEditor *editor = new CropEditor(screenshotutil::fullscreen());
|
CropEditor *editor = new CropEditor(screenshotutil::fullscreen());
|
||||||
QObject::connect(editor, &CropEditor::cropped, [&](QPixmap *pixmap) { UploaderSingleton::inst().upload(pixmap); });
|
QObject::connect(editor, &CropEditor::cropped, [&](QPixmap *pixmap) {
|
||||||
|
UploaderSingleton::inst().upload(pixmap);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void screenshotter::fullscreen()
|
void screenshotter::fullscreen() {
|
||||||
{
|
|
||||||
UploaderSingleton::inst().upload(screenshotutil::fullscreen());
|
UploaderSingleton::inst().upload(screenshotutil::fullscreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
void screenshotter::areaDelayed()
|
void screenshotter::areaDelayed() {
|
||||||
{
|
QTimer::singleShot(MainWindow::inst()->delay()->value() * 1000,
|
||||||
QTimer::singleShot(MainWindow::inst()->delay()->value() * 1000, &screenshotter::area);
|
&screenshotter::area);
|
||||||
}
|
}
|
||||||
|
|
||||||
void screenshotter::fullscreenDelayed()
|
void screenshotter::fullscreenDelayed() {
|
||||||
{
|
QTimer::singleShot(MainWindow::inst()->delay()->value() * 1000,
|
||||||
QTimer::singleShot(MainWindow::inst()->delay()->value() * 1000, &screenshotter::fullscreen);
|
&screenshotter::fullscreen);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#ifndef SCREENSHOTTER_HPP
|
#ifndef SCREENSHOTTER_HPP
|
||||||
#define SCREENSHOTTER_HPP
|
#define SCREENSHOTTER_HPP
|
||||||
|
|
||||||
namespace screenshotter
|
namespace screenshotter {
|
||||||
{
|
|
||||||
void fullscreen();
|
void fullscreen();
|
||||||
void area();
|
void area();
|
||||||
void fullscreenDelayed();
|
void fullscreenDelayed();
|
||||||
|
@ -5,13 +5,9 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
|
||||||
QPixmap *screenshotutil::fullscreen()
|
QPixmap *screenshotutil::fullscreen() { return window(0); }
|
||||||
{
|
|
||||||
return window(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap *screenshotutil::window(long wid)
|
QPixmap *screenshotutil::window(long wid) {
|
||||||
{
|
|
||||||
QScreen *w = QApplication::primaryScreen();
|
QScreen *w = QApplication::primaryScreen();
|
||||||
QPixmap screen = w->grabWindow(wid);
|
QPixmap screen = w->grabWindow(wid);
|
||||||
QPixmap *pm = new QPixmap(screen.size());
|
QPixmap *pm = new QPixmap(screen.size());
|
||||||
@ -19,7 +15,6 @@ QPixmap *screenshotutil::window(long wid)
|
|||||||
return pm;
|
return pm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void screenshotutil::toClipboard(QString value)
|
void screenshotutil::toClipboard(QString value) {
|
||||||
{
|
|
||||||
QApplication::clipboard()->setText(value);
|
QApplication::clipboard()->setText(value);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
namespace screenshotutil
|
namespace screenshotutil {
|
||||||
{
|
|
||||||
QPixmap *fullscreen();
|
QPixmap *fullscreen();
|
||||||
QPixmap *window(long wid);
|
QPixmap *window(long wid);
|
||||||
void toClipboard(QString value);
|
void toClipboard(QString value);
|
||||||
|
13
settings.cpp
13
settings.cpp
@ -2,14 +2,15 @@
|
|||||||
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
QSettings &settings::settings()
|
QSettings &settings::settings() {
|
||||||
{
|
static QDir configDir(
|
||||||
static QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
|
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
|
||||||
if (configDir.path() == QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation))
|
if (configDir.path() ==
|
||||||
{
|
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)) {
|
||||||
configDir.mkdir("KShare");
|
configDir.mkdir("KShare");
|
||||||
configDir.cd("KShare");
|
configDir.cd("KShare");
|
||||||
}
|
}
|
||||||
static QSettings settings(configDir.absoluteFilePath("settings.ini"), QSettings::IniFormat);
|
static QSettings settings(configDir.absoluteFilePath("settings.ini"),
|
||||||
|
QSettings::IniFormat);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
namespace settings
|
namespace settings {
|
||||||
{
|
|
||||||
QSettings &settings();
|
QSettings &settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
using std::runtime_error;
|
using std::runtime_error;
|
||||||
|
|
||||||
void error(QString absFilePath, QString err)
|
void error(QString absFilePath, QString err) {
|
||||||
{
|
throw runtime_error(
|
||||||
throw runtime_error((QString("Invalid file: ").append(absFilePath) + ": " + err).toStdString());
|
(QString("Invalid file: ").append(absFilePath) + ": " + err)
|
||||||
|
.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomUploader::CustomUploader(QString absFilePath)
|
CustomUploader::CustomUploader(QString absFilePath) {
|
||||||
{
|
|
||||||
types.insert("PNG", "image/png"); // This is a list of supported formats, too
|
types.insert("PNG", "image/png"); // This is a list of supported formats, too
|
||||||
types.insert("GIF", "image/gif");
|
types.insert("GIF", "image/gif");
|
||||||
types.insert("JPG", "image/jpeg");
|
types.insert("JPG", "image/jpeg");
|
||||||
@ -27,10 +27,10 @@ CustomUploader::CustomUploader(QString absFilePath)
|
|||||||
types.insert("MP4", "video/mp4");
|
types.insert("MP4", "video/mp4");
|
||||||
// Let's go
|
// Let's go
|
||||||
QFile file(absFilePath);
|
QFile file(absFilePath);
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) error(absFilePath, file.errorString());
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
|
error(absFilePath, file.errorString());
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
|
QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
|
||||||
if (!doc.isObject())
|
if (!doc.isObject()) {
|
||||||
{
|
|
||||||
error(absFilePath, "Root not an object");
|
error(absFilePath, "Root not an object");
|
||||||
}
|
}
|
||||||
QJsonObject obj = doc.object();
|
QJsonObject obj = doc.object();
|
||||||
@ -38,19 +38,17 @@ CustomUploader::CustomUploader(QString absFilePath)
|
|||||||
error(absFilePath, "name is not a string");
|
error(absFilePath, "name is not a string");
|
||||||
else
|
else
|
||||||
uName = obj["name"].toString();
|
uName = obj["name"].toString();
|
||||||
if (!obj.contains("desc"))
|
if (!obj.contains("desc")) {
|
||||||
{
|
|
||||||
if (!obj["desc"].isString())
|
if (!obj["desc"].isString())
|
||||||
/*t*/ error(absFilePath, "desc not a string");
|
/*t*/ error(absFilePath, "desc not a string");
|
||||||
else
|
else
|
||||||
desc = obj["desc"].toString();
|
desc = obj["desc"].toString();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
desc = absFilePath;
|
desc = absFilePath;
|
||||||
QJsonValue m = obj["method"];
|
QJsonValue m = obj["method"];
|
||||||
if (!m.isUndefined() && !m.isNull())
|
if (!m.isUndefined() && !m.isNull()) {
|
||||||
{
|
if (!m.isString())
|
||||||
if (!m.isString()) error(absFilePath, "method not a string");
|
error(absFilePath, "method not a string");
|
||||||
QString toCheck = m.toString().toLower();
|
QString toCheck = m.toString().toLower();
|
||||||
if (toCheck == "post")
|
if (toCheck == "post")
|
||||||
method = HttpMethod::POST;
|
method = HttpMethod::POST;
|
||||||
@ -58,18 +56,16 @@ CustomUploader::CustomUploader(QString absFilePath)
|
|||||||
error(absFilePath, "method invalid");
|
error(absFilePath, "method invalid");
|
||||||
}
|
}
|
||||||
QJsonValue url = obj["target"];
|
QJsonValue url = obj["target"];
|
||||||
if (!url.isString())
|
if (!url.isString()) {
|
||||||
{
|
|
||||||
error(absFilePath, "target missing");
|
error(absFilePath, "target missing");
|
||||||
}
|
}
|
||||||
QUrl target(url.toString());
|
QUrl target(url.toString());
|
||||||
if (!target.isValid()) error(absFilePath, "target not URL");
|
if (!target.isValid())
|
||||||
|
error(absFilePath, "target not URL");
|
||||||
this->target = target;
|
this->target = target;
|
||||||
QJsonValue formatValue = obj["format"];
|
QJsonValue formatValue = obj["format"];
|
||||||
if (!formatValue.isUndefined() && !formatValue.isNull())
|
if (!formatValue.isUndefined() && !formatValue.isNull()) {
|
||||||
{
|
if (formatValue.isString()) {
|
||||||
if (formatValue.isString())
|
|
||||||
{
|
|
||||||
QString formatString = formatValue.toString().toLower();
|
QString formatString = formatValue.toString().toLower();
|
||||||
if (formatString == "x-www-form-urlencoded")
|
if (formatString == "x-www-form-urlencoded")
|
||||||
format = RequestFormat::X_WWW_FORM_URLENCODED;
|
format = RequestFormat::X_WWW_FORM_URLENCODED;
|
||||||
@ -80,71 +76,53 @@ CustomUploader::CustomUploader(QString absFilePath)
|
|||||||
else
|
else
|
||||||
error(absFilePath, "format invalid");
|
error(absFilePath, "format invalid");
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
error(absFilePath, "format provided but not string");
|
error(absFilePath, "format provided but not string");
|
||||||
QJsonValue imageValue = obj["imageformat"];
|
QJsonValue imageValue = obj["imageformat"];
|
||||||
if (!imageValue.isString())
|
if (!imageValue.isString()) {
|
||||||
{
|
|
||||||
error(absFilePath, "imageformat not string");
|
error(absFilePath, "imageformat not string");
|
||||||
}
|
}
|
||||||
QString imageFormat = imageValue.toString();
|
QString imageFormat = imageValue.toString();
|
||||||
if (imageFormat == "base64" || QRegExp("base64\\([^+]+\\+[^+]+)").exactMatch(imageFormat)
|
if (imageFormat == "base64" ||
|
||||||
|| QRegExp("[^+]+\\+[^+]+").exactMatch(imageFormat))
|
QRegExp("base64\\([^+]+\\+[^+]+)").exactMatch(imageFormat) ||
|
||||||
{
|
QRegExp("[^+]+\\+[^+]+").exactMatch(imageFormat)) {
|
||||||
this->iFormat = imageFormat;
|
this->iFormat = imageFormat;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
error(absFilePath, "imageformat invalid");
|
error(absFilePath, "imageformat invalid");
|
||||||
QJsonValue bodyValue = obj["body"];
|
QJsonValue bodyValue = obj["body"];
|
||||||
if (format != RequestFormat::PLAIN)
|
if (format != RequestFormat::PLAIN) {
|
||||||
{
|
if (bodyValue.isUndefined())
|
||||||
if (bodyValue.isUndefined()) error(absFilePath, "body not set");
|
error(absFilePath, "body not set");
|
||||||
if (bodyValue.isObject())
|
if (bodyValue.isObject())
|
||||||
body = bodyValue;
|
body = bodyValue;
|
||||||
else
|
else
|
||||||
error(absFilePath, "body not object");
|
error(absFilePath, "body not object");
|
||||||
}
|
} else {
|
||||||
else
|
if (bodyValue.isString()) {
|
||||||
{
|
|
||||||
if (bodyValue.isString())
|
|
||||||
{
|
|
||||||
body = bodyValue;
|
body = bodyValue;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
error(absFilePath, "body not string (reason: format: PLAIN)");
|
error(absFilePath, "body not string (reason: format: PLAIN)");
|
||||||
}
|
}
|
||||||
QJsonValue headerVal = obj["headers"];
|
QJsonValue headerVal = obj["headers"];
|
||||||
if (!(headerVal.isUndefined() || headerVal.isNull()))
|
if (!(headerVal.isUndefined() || headerVal.isNull())) {
|
||||||
{
|
if (!headerVal.isObject())
|
||||||
if (!headerVal.isObject()) error(absFilePath, "headers must be object");
|
error(absFilePath, "headers must be object");
|
||||||
headers = headerVal.toObject();
|
headers = headerVal.toObject();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
headers = QJsonObject();
|
headers = QJsonObject();
|
||||||
QJsonValue returnPsVal = obj["return"];
|
QJsonValue returnPsVal = obj["return"];
|
||||||
if (returnPsVal.isString())
|
if (returnPsVal.isString()) {
|
||||||
{
|
|
||||||
returnPathspec = returnPsVal.toString();
|
returnPathspec = returnPsVal.toString();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
error(absFilePath, "return invalid");
|
error(absFilePath, "return invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CustomUploader::name()
|
QString CustomUploader::name() { return uName; }
|
||||||
{
|
|
||||||
return uName;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CustomUploader::description()
|
QString CustomUploader::description() { return desc; }
|
||||||
{
|
|
||||||
return desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString getCType(RequestFormat format, QString plainType)
|
QString getCType(RequestFormat format, QString plainType) {
|
||||||
{
|
switch (format) {
|
||||||
switch (format)
|
|
||||||
{
|
|
||||||
case RequestFormat::X_WWW_FORM_URLENCODED:
|
case RequestFormat::X_WWW_FORM_URLENCODED:
|
||||||
return "application/x-www-form-urlencoded";
|
return "application/x-www-form-urlencoded";
|
||||||
case RequestFormat::JSON:
|
case RequestFormat::JSON:
|
||||||
@ -155,24 +133,26 @@ QString getCType(RequestFormat format, QString plainType)
|
|||||||
return plainType;
|
return plainType;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QPair<QString, QString>> getHeaders(QJsonObject h, QString imageFormat, QMap<QString, QString> types, RequestFormat format)
|
QList<QPair<QString, QString>> getHeaders(QJsonObject h, QString imageFormat,
|
||||||
{
|
QMap<QString, QString> types,
|
||||||
|
RequestFormat format) {
|
||||||
QList<QPair<QString, QString>> headers;
|
QList<QPair<QString, QString>> headers;
|
||||||
for (QString s : h.keys())
|
for (QString s : h.keys()) {
|
||||||
{
|
if (s.toLower() == "content-type")
|
||||||
if (s.toLower() == "content-type") continue;
|
continue;
|
||||||
QJsonValue v = h[s];
|
QJsonValue v = h[s];
|
||||||
if (!v.isString())
|
if (!v.isString())
|
||||||
headers << QPair<QString, QString>(s, QJsonDocument::fromVariant(v.toVariant()).toJson());
|
headers << QPair<QString, QString>(
|
||||||
|
s, QJsonDocument::fromVariant(v.toVariant()).toJson());
|
||||||
else
|
else
|
||||||
headers << QPair<QString, QString>(s, v.toString());
|
headers << QPair<QString, QString>(s, v.toString());
|
||||||
}
|
}
|
||||||
headers << QPair<QString, QString>("Content-Type", getCType(format, types.value(imageFormat)));
|
headers << QPair<QString, QString>(
|
||||||
|
"Content-Type", getCType(format, types.value(imageFormat)));
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray imageBytes(QPixmap *pixmap, QString format)
|
QByteArray imageBytes(QPixmap *pixmap, QString format) {
|
||||||
{
|
|
||||||
QByteArray returnVal;
|
QByteArray returnVal;
|
||||||
QBuffer buff(&returnVal);
|
QBuffer buff(&returnVal);
|
||||||
buff.open(QIODevice::WriteOnly);
|
buff.open(QIODevice::WriteOnly);
|
||||||
@ -180,8 +160,7 @@ QByteArray imageBytes(QPixmap *pixmap, QString format)
|
|||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CustomUploader::getFormatString(bool animated)
|
QString CustomUploader::getFormatString(bool animated) {
|
||||||
{
|
|
||||||
if (iFormat == "base64")
|
if (iFormat == "base64")
|
||||||
return animated ? "GIF" : "PNG";
|
return animated ? "GIF" : "PNG";
|
||||||
else if (QRegExp("[^+]+\\+[^+]+").exactMatch(iFormat))
|
else if (QRegExp("[^+]+\\+[^+]+").exactMatch(iFormat))
|
||||||
@ -191,43 +170,37 @@ QString CustomUploader::getFormatString(bool animated)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject recurseAndReplace(QJsonObject &body, QByteArray &data, QString contentType)
|
QJsonObject recurseAndReplace(QJsonObject &body, QByteArray &data,
|
||||||
{
|
QString contentType) {
|
||||||
QJsonObject o;
|
QJsonObject o;
|
||||||
for (QString s : body.keys())
|
for (QString s : body.keys()) {
|
||||||
{
|
|
||||||
QJsonValue v = body[s];
|
QJsonValue v = body[s];
|
||||||
if (v.isObject())
|
if (v.isObject()) {
|
||||||
{
|
|
||||||
QJsonObject vo = v.toObject();
|
QJsonObject vo = v.toObject();
|
||||||
o.insert(s, recurseAndReplace(vo, data, contentType));
|
o.insert(s, recurseAndReplace(vo, data, contentType));
|
||||||
}
|
} else if (v.isString()) {
|
||||||
else if (v.isString())
|
|
||||||
{
|
|
||||||
QString str = v.toString();
|
QString str = v.toString();
|
||||||
if (str.startsWith("/") && str.endsWith("/"))
|
if (str.startsWith("/") && str.endsWith("/")) {
|
||||||
{
|
o.insert(
|
||||||
o.insert(s, str.replace("%image", data).replace("%contenttype", contentType));
|
s,
|
||||||
|
str.replace("%image", data).replace("%contenttype", contentType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString parsePathspec(QJsonDocument &response, QString &pathspec)
|
QString parsePathspec(QJsonDocument &response, QString &pathspec) {
|
||||||
{
|
if (!pathspec.startsWith(".")) {
|
||||||
if (!pathspec.startsWith("."))
|
|
||||||
{
|
|
||||||
// Does not point to anything
|
// Does not point to anything
|
||||||
return "";
|
return "";
|
||||||
}
|
} else {
|
||||||
else
|
if (!response.isObject())
|
||||||
{
|
return "";
|
||||||
if (!response.isObject()) return "";
|
QStringList fields = pathspec.right(pathspec.length() - 1)
|
||||||
QStringList fields = pathspec.right(pathspec.length() - 1).split('.', QString::SkipEmptyParts);
|
.split('.', QString::SkipEmptyParts);
|
||||||
QJsonObject o = response.object();
|
QJsonObject o = response.object();
|
||||||
if (pathspec == ".")
|
if (pathspec == ".") {
|
||||||
{
|
|
||||||
return QString::fromUtf8(response.toJson());
|
return QString::fromUtf8(response.toJson());
|
||||||
}
|
}
|
||||||
QJsonValue val = o[fields.at(0)];
|
QJsonValue val = o[fields.at(0)];
|
||||||
@ -236,15 +209,16 @@ QString parsePathspec(QJsonDocument &response, QString &pathspec)
|
|||||||
else if (val.isString())
|
else if (val.isString())
|
||||||
return val.toString();
|
return val.toString();
|
||||||
else if (!val.isObject())
|
else if (!val.isObject())
|
||||||
return QString::fromUtf8(QJsonDocument::fromVariant(val.toVariant()).toJson());
|
return QString::fromUtf8(
|
||||||
for (int i = 1; i < fields.size(); i++)
|
QJsonDocument::fromVariant(val.toVariant()).toJson());
|
||||||
{
|
for (int i = 1; i < fields.size(); i++) {
|
||||||
if (val.isUndefined() || val.isNull())
|
if (val.isUndefined() || val.isNull())
|
||||||
return "";
|
return "";
|
||||||
else if (val.isString())
|
else if (val.isString())
|
||||||
return val.toString();
|
return val.toString();
|
||||||
else if (!val.isObject())
|
else if (!val.isObject())
|
||||||
return QString::fromUtf8(QJsonDocument::fromVariant(val.toVariant()).toJson());
|
return QString::fromUtf8(
|
||||||
|
QJsonDocument::fromVariant(val.toVariant()).toJson());
|
||||||
else
|
else
|
||||||
val = val.toObject()[fields.at(i)];
|
val = val.toObject()[fields.at(i)];
|
||||||
}
|
}
|
||||||
@ -253,108 +227,101 @@ QString parsePathspec(QJsonDocument &response, QString &pathspec)
|
|||||||
else if (val.isString())
|
else if (val.isString())
|
||||||
return val.toString();
|
return val.toString();
|
||||||
else if (!val.isObject())
|
else if (!val.isObject())
|
||||||
return QString::fromUtf8(QJsonDocument::fromVariant(val.toVariant()).toJson());
|
return QString::fromUtf8(
|
||||||
|
QJsonDocument::fromVariant(val.toVariant()).toJson());
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseResult(QJsonDocument result, QString returnPathspec, QString name)
|
void parseResult(QJsonDocument result, QString returnPathspec, QString name) {
|
||||||
{
|
if (result.isObject()) {
|
||||||
if (result.isObject())
|
|
||||||
{
|
|
||||||
qDebug() << result.object()[".url"];
|
qDebug() << result.object()[".url"];
|
||||||
QString url = parsePathspec(result, returnPathspec);
|
QString url = parsePathspec(result, returnPathspec);
|
||||||
if (!url.isEmpty())
|
if (!url.isEmpty()) {
|
||||||
{
|
|
||||||
QApplication::clipboard()->setText(url);
|
QApplication::clipboard()->setText(url);
|
||||||
notifications::notify("KShare Custom Uploader " + name, "Copied upload link to clipboard!");
|
notifications::notify("KShare Custom Uploader " + name,
|
||||||
}
|
"Copied upload link to clipboard!");
|
||||||
else
|
} else
|
||||||
notifications::notify("KShare Custom Uploader " + name, "Upload done, but result empty!");
|
notifications::notify("KShare Custom Uploader " + name,
|
||||||
}
|
"Upload done, but result empty!");
|
||||||
else
|
} else
|
||||||
notifications::notify("KShare Custom Uploader " + name, "Upload done, but result is not JSON Object!");
|
notifications::notify("KShare Custom Uploader " + name,
|
||||||
|
"Upload done, but result is not JSON Object!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomUploader::doUpload(QPixmap *pixmap)
|
void CustomUploader::doUpload(QPixmap *pixmap) {
|
||||||
{
|
|
||||||
auto h = getHeaders(headers, getFormatString(false), types, this->format);
|
auto h = getHeaders(headers, getFormatString(false), types, this->format);
|
||||||
QString format = getFormatString(false); // Soon:tm:
|
QString format = getFormatString(false); // Soon:tm:
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
QByteArray imgData = imageBytes(pixmap, format);
|
QByteArray imgData = imageBytes(pixmap, format);
|
||||||
if (iFormat == "base64" || QRegExp("base64\\([^+]\\+[^+]\\)").exactMatch(iFormat)) imgData = imgData.toBase64();
|
if (iFormat == "base64" ||
|
||||||
switch (this->format)
|
QRegExp("base64\\([^+]\\+[^+]\\)").exactMatch(iFormat))
|
||||||
{
|
imgData = imgData.toBase64();
|
||||||
case RequestFormat::PLAIN:
|
switch (this->format) {
|
||||||
{
|
case RequestFormat::PLAIN: {
|
||||||
data = imgData;
|
data = imgData;
|
||||||
}
|
} break;
|
||||||
break;
|
case RequestFormat::JSON: {
|
||||||
case RequestFormat::JSON:
|
if (body.isString()) {
|
||||||
{
|
QStringList split = body.toString()
|
||||||
if (body.isString())
|
.replace("%contenttype", types.value(format))
|
||||||
{
|
.split("%imagedata");
|
||||||
QStringList split = body.toString().replace("%contenttype", types.value(format)).split("%imagedata");
|
for (int i = 0; i < split.size(); i++) {
|
||||||
for (int i = 0; i < split.size(); i++)
|
|
||||||
{
|
|
||||||
data.append(split[i]);
|
data.append(split[i]);
|
||||||
if (i < split.size() - 1) data.append(imgData);
|
if (i < split.size() - 1)
|
||||||
|
data.append(imgData);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
QJsonObject vo = body.toObject();
|
QJsonObject vo = body.toObject();
|
||||||
data = QJsonDocument::fromVariant(recurseAndReplace(vo, imgData, types.value(format)).toVariantMap()).toJson();
|
data = QJsonDocument::fromVariant(
|
||||||
|
recurseAndReplace(vo, imgData, types.value(format))
|
||||||
|
.toVariantMap())
|
||||||
|
.toJson();
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
case RequestFormat::X_WWW_FORM_URLENCODED: {
|
||||||
case RequestFormat::X_WWW_FORM_URLENCODED:
|
|
||||||
{
|
|
||||||
QJsonObject body = this->body.toObject();
|
QJsonObject body = this->body.toObject();
|
||||||
for (QString key : body.keys())
|
for (QString key : body.keys()) {
|
||||||
{
|
|
||||||
QJsonValue val = body[key];
|
QJsonValue val = body[key];
|
||||||
if (val.isString())
|
if (val.isString()) {
|
||||||
{
|
|
||||||
QString str = val.toString();
|
QString str = val.toString();
|
||||||
QByteArray strB;
|
QByteArray strB;
|
||||||
if (str.startsWith("/") && str.endsWith("/"))
|
if (str.startsWith("/") && str.endsWith("/")) {
|
||||||
{
|
|
||||||
str = str.mid(1, str.length() - 2);
|
str = str.mid(1, str.length() - 2);
|
||||||
QStringList split = str.replace("%contenttype", types.value(format)).split("%imagedata");
|
QStringList split = str.replace("%contenttype", types.value(format))
|
||||||
for (int i = 0; i < split.size(); i++)
|
.split("%imagedata");
|
||||||
{
|
for (int i = 0; i < split.size(); i++) {
|
||||||
strB.append(split[i]);
|
strB.append(split[i]);
|
||||||
if (i < split.size() - 1) strB.append(imgData);
|
if (i < split.size() - 1)
|
||||||
|
strB.append(imgData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.append(QUrl::toPercentEncoding(key)).append('=').append(strB);
|
data.append(QUrl::toPercentEncoding(key)).append('=').append(strB);
|
||||||
}
|
} else {
|
||||||
else
|
if (!data.isEmpty())
|
||||||
{
|
data.append('&');
|
||||||
if (!data.isEmpty()) data.append('&');
|
|
||||||
data.append(QUrl::toPercentEncoding(key))
|
data.append(QUrl::toPercentEncoding(key))
|
||||||
.append('=')
|
.append('=')
|
||||||
.append(QUrl::toPercentEncoding(QJsonDocument::fromVariant(body[key].toVariant()).toJson()));
|
.append(QUrl::toPercentEncoding(
|
||||||
|
QJsonDocument::fromVariant(body[key].toVariant()).toJson()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
break;
|
switch (method) {
|
||||||
}
|
|
||||||
switch (method)
|
|
||||||
{
|
|
||||||
case HttpMethod::POST:
|
case HttpMethod::POST:
|
||||||
if (returnPathspec == "|")
|
if (returnPathspec == "|") {
|
||||||
{
|
ioutils::postData(
|
||||||
ioutils::postData(target, h, data, [&](QByteArray result, QNetworkReply *) {
|
target, h, data, [&](QByteArray result, QNetworkReply *) {
|
||||||
QApplication::clipboard()->setText(QString::fromUtf8(result));
|
QApplication::clipboard()->setText(QString::fromUtf8(result));
|
||||||
notifications::notify("KShare Custom Uploader " + name(), "Copied upload result to clipboard!");
|
notifications::notify("KShare Custom Uploader " + name(),
|
||||||
|
"Copied upload result to clipboard!");
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ioutils::postJson(target, h, data,
|
ioutils::postJson(target, h, data,
|
||||||
[&](QJsonDocument result, QNetworkReply *) { parseResult(result, returnPathspec, name()); });
|
[&](QJsonDocument result, QNetworkReply *) {
|
||||||
|
parseResult(result, returnPathspec, name());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6,21 +6,12 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
enum class HttpMethod
|
enum class HttpMethod { POST };
|
||||||
{
|
|
||||||
POST
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class RequestFormat
|
enum class RequestFormat { X_WWW_FORM_URLENCODED, JSON, PLAIN };
|
||||||
{
|
|
||||||
X_WWW_FORM_URLENCODED,
|
|
||||||
JSON,
|
|
||||||
PLAIN
|
|
||||||
};
|
|
||||||
|
|
||||||
class CustomUploader : public Uploader
|
class CustomUploader : public Uploader {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
CustomUploader(QString absFilePath);
|
CustomUploader(QString absFilePath);
|
||||||
QString name();
|
QString name();
|
||||||
QString description();
|
QString description();
|
||||||
@ -28,7 +19,7 @@ class CustomUploader : public Uploader
|
|||||||
QString getFormatString(bool animated);
|
QString getFormatString(bool animated);
|
||||||
QMap<QString, QString> types;
|
QMap<QString, QString> types;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString desc;
|
QString desc;
|
||||||
QString uName;
|
QString uName;
|
||||||
RequestFormat format = RequestFormat::JSON;
|
RequestFormat format = RequestFormat::JSON;
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <notifications.hpp>
|
#include <notifications.hpp>
|
||||||
|
|
||||||
void ClipboardUploader::doUpload(QPixmap *pixmap)
|
void ClipboardUploader::doUpload(QPixmap *pixmap) {
|
||||||
{
|
|
||||||
QApplication::clipboard()->setImage(pixmap->toImage());
|
QApplication::clipboard()->setImage(pixmap->toImage());
|
||||||
notifications::notify("KShare", "Copied to clipboard!");
|
notifications::notify("KShare", "Copied to clipboard!");
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,10 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <uploaders/uploader.hpp>
|
#include <uploaders/uploader.hpp>
|
||||||
|
|
||||||
class ClipboardUploader : public Uploader
|
class ClipboardUploader : public Uploader {
|
||||||
{
|
public:
|
||||||
public:
|
QString name() { return "clipboard"; }
|
||||||
QString name()
|
QString description() { return "Copies the image to clipboard"; }
|
||||||
{
|
|
||||||
return "clipboard";
|
|
||||||
}
|
|
||||||
QString description()
|
|
||||||
{
|
|
||||||
return "Copies the image to clipboard";
|
|
||||||
}
|
|
||||||
void doUpload(QPixmap *pixmap);
|
void doUpload(QPixmap *pixmap);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,19 +7,23 @@
|
|||||||
#include <notifications.hpp>
|
#include <notifications.hpp>
|
||||||
#include <screenshotutil.hpp>
|
#include <screenshotutil.hpp>
|
||||||
|
|
||||||
void ImgurUploader::doUpload(QPixmap *pixmap)
|
void ImgurUploader::doUpload(QPixmap *pixmap) {
|
||||||
{
|
|
||||||
QByteArray byteArray;
|
QByteArray byteArray;
|
||||||
QBuffer buffer(&byteArray);
|
QBuffer buffer(&byteArray);
|
||||||
pixmap->save(&buffer, "PNG");
|
pixmap->save(&buffer, "PNG");
|
||||||
ioutils::postJson(QUrl("https://api.imgur.com/3/image"),
|
ioutils::postJson(
|
||||||
|
QUrl("https://api.imgur.com/3/image"),
|
||||||
QList<QPair<QString, QString>>()
|
QList<QPair<QString, QString>>()
|
||||||
<< QPair<QString, QString>("Content-Type", "application/x-www-form-urlencoded")
|
<< QPair<QString, QString>("Content-Type",
|
||||||
<< QPair<QString, QString>("Authorization", "Client-ID 8a98f183fc895da"),
|
"application/x-www-form-urlencoded")
|
||||||
|
<< QPair<QString, QString>("Authorization",
|
||||||
|
"Client-ID 8a98f183fc895da"),
|
||||||
byteArray, [](QJsonDocument res, QNetworkReply *) {
|
byteArray, [](QJsonDocument res, QNetworkReply *) {
|
||||||
QString result = res.object()["data"].toObject()["link"].toString();
|
QString result = res.object()["data"].toObject()["link"].toString();
|
||||||
screenshotutil::toClipboard(result);
|
screenshotutil::toClipboard(result);
|
||||||
notifications::notify("KShare imgur Uploader ",
|
notifications::notify("KShare imgur Uploader ",
|
||||||
result.isEmpty() ? "Failed upload!" : "Upload done, but result empty!");
|
result.isEmpty()
|
||||||
|
? "Failed upload!"
|
||||||
|
: "Upload done, but result empty!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,10 @@
|
|||||||
|
|
||||||
#include "../uploader.hpp"
|
#include "../uploader.hpp"
|
||||||
|
|
||||||
class ImgurUploader : public Uploader
|
class ImgurUploader : public Uploader {
|
||||||
{
|
public:
|
||||||
public:
|
QString name() { return "imgur"; }
|
||||||
QString name()
|
QString description() { return "imgur.com uploader"; }
|
||||||
{
|
|
||||||
return "imgur";
|
|
||||||
}
|
|
||||||
QString description()
|
|
||||||
{
|
|
||||||
return "imgur.com uploader";
|
|
||||||
}
|
|
||||||
void doUpload(QPixmap *pixmap);
|
void doUpload(QPixmap *pixmap);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class Uploader
|
class Uploader {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
virtual void doUpload(QPixmap *pixmap) = 0;
|
virtual void doUpload(QPixmap *pixmap) = 0;
|
||||||
virtual QString name() = 0;
|
virtual QString name() = 0;
|
||||||
virtual QString description() = 0;
|
virtual QString description() = 0;
|
||||||
|
@ -8,20 +8,16 @@
|
|||||||
#include <formatter.hpp>
|
#include <formatter.hpp>
|
||||||
#include <settings.hpp>
|
#include <settings.hpp>
|
||||||
|
|
||||||
UploaderSingleton::UploaderSingleton() : QObject()
|
UploaderSingleton::UploaderSingleton() : QObject() {
|
||||||
{
|
QDir configDir(
|
||||||
QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
|
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
|
||||||
configDir.mkpath("KShare/uploaders");
|
configDir.mkpath("KShare/uploaders");
|
||||||
configDir.cd("KShare/uploaders");
|
configDir.cd("KShare/uploaders");
|
||||||
configDir.setNameFilters({ "*.uploader" });
|
configDir.setNameFilters({"*.uploader"});
|
||||||
for (QString file : configDir.entryList())
|
for (QString file : configDir.entryList()) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
registerUploader(new CustomUploader(configDir.absoluteFilePath(file)));
|
registerUploader(new CustomUploader(configDir.absoluteFilePath(file)));
|
||||||
}
|
} catch (std::runtime_error e) {
|
||||||
catch (std::runtime_error e)
|
|
||||||
{
|
|
||||||
qWarning() << e.what();
|
qWarning() << e.what();
|
||||||
errs << e;
|
errs << e;
|
||||||
}
|
}
|
||||||
@ -36,31 +32,28 @@ UploaderSingleton::UploaderSingleton() : QObject()
|
|||||||
uploader = settings::settings().value("uploader").toString();
|
uploader = settings::settings().value("uploader").toString();
|
||||||
else
|
else
|
||||||
settings::settings().setValue("uploader", uploader);
|
settings::settings().setValue("uploader", uploader);
|
||||||
if (!uploaders.contains(uploader))
|
if (!uploaders.contains(uploader)) {
|
||||||
{
|
|
||||||
settings::settings().setValue("uploader", uploader);
|
settings::settings().setValue("uploader", uploader);
|
||||||
uploader = "imgur";
|
uploader = "imgur";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploaderSingleton::registerUploader(Uploader *uploader)
|
void UploaderSingleton::registerUploader(Uploader *uploader) {
|
||||||
{
|
if (uploaders.contains(uploader->name())) {
|
||||||
if (uploaders.contains(uploader->name()))
|
throw std::runtime_error(
|
||||||
{
|
("Ambigious uploader " + uploader->name()).toStdString());
|
||||||
throw std::runtime_error(("Ambigious uploader " + uploader->name()).toStdString());
|
|
||||||
}
|
}
|
||||||
uploaders.insert(uploader->name(), uploader);
|
uploaders.insert(uploader->name(), uploader);
|
||||||
emit newUploader(uploader);
|
emit newUploader(uploader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploaderSingleton::upload(QPixmap *pixmap)
|
void UploaderSingleton::upload(QPixmap *pixmap) {
|
||||||
{
|
if (settings::settings().contains("fileFormat")) {
|
||||||
if (settings::settings().contains("fileFormat"))
|
|
||||||
{
|
|
||||||
QString format = settings::settings().value("fileFormat").toString();
|
QString format = settings::settings().value("fileFormat").toString();
|
||||||
if (!format.isEmpty())
|
if (!format.isEmpty()) {
|
||||||
{
|
pixmap->save(QDir(QStandardPaths::writableLocation(
|
||||||
pixmap->save(QDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)).absoluteFilePath(formatter::format(format) + ".png"),
|
QStandardPaths::PicturesLocation))
|
||||||
|
.absoluteFilePath(formatter::format(format) + ".png"),
|
||||||
"PNG");
|
"PNG");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,26 +61,17 @@ void UploaderSingleton::upload(QPixmap *pixmap)
|
|||||||
delete pixmap;
|
delete pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Uploader *> UploaderSingleton::uploaderList()
|
QList<Uploader *> UploaderSingleton::uploaderList() {
|
||||||
{
|
|
||||||
return uploaders.values();
|
return uploaders.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploaderSingleton::set(QString uploader)
|
void UploaderSingleton::set(QString uploader) {
|
||||||
{
|
if (uploaders.contains(uploader)) {
|
||||||
if (uploaders.contains(uploader))
|
|
||||||
{
|
|
||||||
this->uploader = uploader;
|
this->uploader = uploader;
|
||||||
settings::settings().setValue("uploader", uploader);
|
settings::settings().setValue("uploader", uploader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UploaderSingleton::selectedUploader()
|
QString UploaderSingleton::selectedUploader() { return uploader; }
|
||||||
{
|
|
||||||
return uploader;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<std::runtime_error> UploaderSingleton::errors()
|
QList<std::runtime_error> UploaderSingleton::errors() { return errs; }
|
||||||
{
|
|
||||||
return errs;
|
|
||||||
}
|
|
||||||
|
@ -4,12 +4,10 @@
|
|||||||
#include "uploader.hpp"
|
#include "uploader.hpp"
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
class UploaderSingleton : public QObject
|
class UploaderSingleton : public QObject {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static UploaderSingleton &inst()
|
static UploaderSingleton &inst() {
|
||||||
{
|
|
||||||
static UploaderSingleton inst;
|
static UploaderSingleton inst;
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
@ -19,10 +17,10 @@ class UploaderSingleton : public QObject
|
|||||||
void set(QString uploader);
|
void set(QString uploader);
|
||||||
QString selectedUploader();
|
QString selectedUploader();
|
||||||
QList<std::runtime_error> errors();
|
QList<std::runtime_error> errors();
|
||||||
signals:
|
signals:
|
||||||
void newUploader(Uploader *u);
|
void newUploader(Uploader *u);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UploaderSingleton();
|
UploaderSingleton();
|
||||||
QMap<QString, Uploader *> uploaders;
|
QMap<QString, Uploader *> uploaders;
|
||||||
QString uploader = "imgur";
|
QString uploader = "imgur";
|
||||||
|
Loading…
Reference in New Issue
Block a user