Add URI handler in deb
This commit is contained in:
36
src/main.cpp
36
src/main.cpp
@@ -1,4 +1,6 @@
|
|||||||
|
#ifndef _WIN32
|
||||||
#include <singleapplication.h>
|
#include <singleapplication.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
@@ -45,9 +47,7 @@ private:
|
|||||||
// There can be only ONE SignalHandler per process
|
// There can be only ONE SignalHandler per process
|
||||||
SignalHandler* g_handler(NULL);
|
SignalHandler* g_handler(NULL);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
#else //_WIN32
|
|
||||||
|
|
||||||
void POSIX_handleFunc(int);
|
void POSIX_handleFunc(int);
|
||||||
int POSIX_physicalToLogical(int);
|
int POSIX_physicalToLogical(int);
|
||||||
@@ -60,18 +60,12 @@ SignalHandler::SignalHandler(int mask) : _mask(mask)
|
|||||||
assert(g_handler == NULL);
|
assert(g_handler == NULL);
|
||||||
g_handler = this;
|
g_handler = this;
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
#endif //_WIN32
|
|
||||||
|
|
||||||
for (int i=0;i<numSignals;i++)
|
for (int i=0;i<numSignals;i++)
|
||||||
{
|
{
|
||||||
int logical = 0x1 << i;
|
int logical = 0x1 << i;
|
||||||
if (_mask & logical)
|
if (_mask & logical)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
#else
|
|
||||||
int sig = POSIX_logicalToPhysical(logical);
|
int sig = POSIX_logicalToPhysical(logical);
|
||||||
bool failed = signal(sig, POSIX_handleFunc) == SIG_ERR;
|
bool failed = signal(sig, POSIX_handleFunc) == SIG_ERR;
|
||||||
assert(!failed);
|
assert(!failed);
|
||||||
@@ -85,9 +79,7 @@ SignalHandler::SignalHandler(int mask) : _mask(mask)
|
|||||||
|
|
||||||
SignalHandler::~SignalHandler()
|
SignalHandler::~SignalHandler()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
#else
|
|
||||||
for (int i=0;i<numSignals;i++)
|
for (int i=0;i<numSignals;i++)
|
||||||
{
|
{
|
||||||
int logical = 0x1 << i;
|
int logical = 0x1 << i;
|
||||||
@@ -100,9 +92,7 @@ SignalHandler::~SignalHandler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
#else
|
|
||||||
int POSIX_logicalToPhysical(int signal)
|
int POSIX_logicalToPhysical(int signal)
|
||||||
{
|
{
|
||||||
switch (signal)
|
switch (signal)
|
||||||
@@ -120,8 +110,7 @@ int POSIX_logicalToPhysical(int signal)
|
|||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifndef _WIN32
|
||||||
#else
|
|
||||||
int POSIX_physicalToLogical(int signal)
|
int POSIX_physicalToLogical(int signal)
|
||||||
{
|
{
|
||||||
switch (signal)
|
switch (signal)
|
||||||
@@ -135,8 +124,7 @@ int POSIX_physicalToLogical(int signal)
|
|||||||
}
|
}
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifndef _WIN32
|
||||||
#else
|
|
||||||
void POSIX_handleFunc(int signal)
|
void POSIX_handleFunc(int signal)
|
||||||
{
|
{
|
||||||
if (g_handler)
|
if (g_handler)
|
||||||
@@ -158,7 +146,11 @@ public:
|
|||||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
SingleApplication a(argc, argv, true);
|
SingleApplication a(argc, argv, true);
|
||||||
|
#else
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
#endif //_WIN32
|
||||||
|
|
||||||
// Command line parser
|
// Command line parser
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
@@ -178,6 +170,7 @@ public:
|
|||||||
|
|
||||||
parser.process(a);
|
parser.process(a);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
// Check for a positional argument indicating a zcash payment URI
|
// Check for a positional argument indicating a zcash payment URI
|
||||||
if (a.isSecondary()) {
|
if (a.isSecondary()) {
|
||||||
if (parser.positionalArguments().length() > 0) {
|
if (parser.positionalArguments().length() > 0) {
|
||||||
@@ -186,6 +179,7 @@ public:
|
|||||||
a.exit( 0 );
|
a.exit( 0 );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
QCoreApplication::setOrganizationName("zec-qt-wallet-org");
|
QCoreApplication::setOrganizationName("zec-qt-wallet-org");
|
||||||
QCoreApplication::setApplicationName("zec-qt-wallet");
|
QCoreApplication::setApplicationName("zec-qt-wallet");
|
||||||
@@ -239,6 +233,7 @@ public:
|
|||||||
w->payZcashURI(parser.positionalArguments()[0]);
|
w->payZcashURI(parser.positionalArguments()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
// Listen for any secondary instances telling us about a zcash payment URI
|
// Listen for any secondary instances telling us about a zcash payment URI
|
||||||
QObject::connect(&a, &SingleApplication::receivedMessage, [=] (quint32, QByteArray msg) {
|
QObject::connect(&a, &SingleApplication::receivedMessage, [=] (quint32, QByteArray msg) {
|
||||||
QString uri(msg);
|
QString uri(msg);
|
||||||
@@ -246,6 +241,7 @@ public:
|
|||||||
// We need to execute this async, otherwise the app seems to crash for some reason.
|
// We need to execute this async, otherwise the app seems to crash for some reason.
|
||||||
QTimer::singleShot(1, [=]() { w->payZcashURI(uri); });
|
QTimer::singleShot(1, [=]() { w->payZcashURI(uri); });
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check if starting headless
|
// Check if starting headless
|
||||||
if (parser.isSet(headlessOption)) {
|
if (parser.isSet(headlessOption)) {
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
Name=ZecWallet
|
Name=ZecWallet
|
||||||
Comment=Full node and wallet for Zcash
|
Comment=Full node and wallet for Zcash
|
||||||
GenericName=Wallet
|
GenericName=Wallet
|
||||||
Exec=/usr/local/bin/zecwallet
|
Exec=/usr/local/bin/zecwallet %u
|
||||||
Icon=zecwallet.xpm
|
Icon=zecwallet.xpm
|
||||||
Type=Application
|
Type=Application
|
||||||
StartupNotify=true
|
StartupNotify=true
|
||||||
StartupWMClass=zecwallet
|
StartupWMClass=zecwallet
|
||||||
Categories=Utility;
|
Categories=Utility;
|
||||||
MimeType=text/plain;inode/directory;
|
MimeType=x-scheme-handler/zcash;
|
||||||
Keywords=zecwallet;
|
Keywords=zecwallet;
|
||||||
|
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ TRANSLATIONS = res/zec_qt_wallet_es.ts \
|
|||||||
res/zec_qt_wallet_pt.ts \
|
res/zec_qt_wallet_pt.ts \
|
||||||
res/zec_qt_wallet_it.ts
|
res/zec_qt_wallet_it.ts
|
||||||
|
|
||||||
include(singleapplication/singleapplication.pri)
|
unix: include(singleapplication/singleapplication.pri)
|
||||||
DEFINES += QAPPLICATION_CLASS=QApplication
|
unix: DEFINES += QAPPLICATION_CLASS=QApplication
|
||||||
|
|
||||||
win32: RC_ICONS = res/icon.ico
|
win32: RC_ICONS = res/icon.ico
|
||||||
ICON = res/logo.icns
|
ICON = res/logo.icns
|
||||||
|
|||||||
Reference in New Issue
Block a user