Add frame for calling c++ screenshot code

This commit is contained in:
Dag Heyman 2017-02-13 13:03:58 +01:00
parent f3fe3faf61
commit 6df435663b
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
3 changed files with 20 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#ifndef Q_OS_DARWIN
#include <QtSingleApplication>
#endif
#include "screenshot.h"
int main(int argc, char *argv[])
{
@ -45,10 +46,12 @@ int main(int argc, char *argv[])
app.setWindowIcon(QIcon(path_prefix + "/images/windowicon.png"));
ScreenShot screenshot;
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("appDir", app_dir);
engine.rootContext()->setContextProperty("urlPrefix", url_prefix);
engine.rootContext()->setContextProperty("appVersion", APP_VERSION);
engine.rootContext()->setContextProperty("ScreenShot", &screenshot);
qputenv("PYTHONDONTWRITEBYTECODE", "1");

View File

@ -16,6 +16,7 @@ Dialog {
Layout.columnSpan: 2
text: qsTr("Scan a QR code")
Layout.fillWidth: true
onClicked: console.log(ScreenShot.capture());
}
Label {
text: qsTr("Name")

16
screenshot.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef SCREENSHOT_H
#define SCREENSHOT_H
#include <QObject>
class ScreenShot: public QObject
{
Q_OBJECT
public:
explicit ScreenShot () : QObject() {}
Q_INVOKABLE int capture(){
return 1;
}
};
#endif // SCREENSHOT_H