Skip to content

Commit

Permalink
Compatibility with Qt 5.3 and Debian 8
Browse files Browse the repository at this point in the history
  • Loading branch information
lupoDharkael committed Aug 21, 2017
1 parent d884b38 commit 6c68d35
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ If you are not using any of these distros you'll need to compile the program :(
but don't worry, it's pretty easy!

## Compilation
The compilation requires Qt version 5.3 or higher (this is the version that Debian 8 has in its repos, so most modern distros should be able to compile without installing newer Qt versions).

### Debian
Compilation Dependencies:
````
Expand Down
23 changes: 20 additions & 3 deletions src/core/flameshotdbusadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@
#include "src/core/controller.h"
#include "src/core/resourceexporter.h"
#include <QTimer>
#include <functional>

namespace {
using std::function;
using lambda = function<void(void)>;

// replace QTimer::singleShot introduced in QT 5.4
// the actual target QT version is QT 5.3
void doLater(int msec, QObject *receiver, lambda func) {
QTimer *timer = new QTimer(receiver);
QObject::connect(timer, &QTimer::timeout, receiver,
[timer, func](){ func(); timer->deleteLater(); });
timer->setInterval(msec);
timer->start();
}
}

FlameshotDBusAdapter::FlameshotDBusAdapter(QObject *parent)
: QDBusAbstractAdaptor(parent)
Expand All @@ -37,7 +53,8 @@ void FlameshotDBusAdapter::graphicCapture(QString path, int delay) {
auto f = [controller, path, this]() {
controller->createVisualCapture(path);
};
QTimer::singleShot(delay, controller, f);
// QTimer::singleShot(delay, controller, f); // requires Qt 5.4
doLater(delay, controller, f);
}

void FlameshotDBusAdapter::fullScreen(QString path, bool toClipboard, int delay) {
Expand All @@ -52,8 +69,8 @@ void FlameshotDBusAdapter::fullScreen(QString path, bool toClipboard, int delay)
ResourceExporter().captureToFile(p, path);
}
};
QTimer::singleShot(delay, this, f);

//QTimer::singleShot(delay, this, f); // // requires Qt 5.4
doLater(delay, this, f);
}

void FlameshotDBusAdapter::openConfig() {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/filenamehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <QDir>

FileNameHandler::FileNameHandler(QObject *parent) : QObject(parent) {
std::locale::global(std::locale(std::locale("").name()));
std::locale::global(std::locale(""));
}

QString FileNameHandler::parsedPattern() {
Expand Down

0 comments on commit 6c68d35

Please sign in to comment.