Windows fixes and adaptation
Binary will have icon Start capture with Print key Fix .rc generation
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
VERSION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
|
||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||
APP_VERSION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
|
||||
DEFINES += APP_VERSION
|
||||
|
||||
QT += core gui
|
||||
|
||||
@@ -23,6 +23,8 @@ CONFIG += link_pkgconfig
|
||||
TARGET = flameshot
|
||||
TEMPLATE = app
|
||||
|
||||
win32:RC_ICONS += img/flameshot.ico
|
||||
|
||||
#release: DESTDIR = build/release
|
||||
#debug: DESTDIR = build/debug
|
||||
|
||||
@@ -183,6 +185,12 @@ unix:!macx {
|
||||
src/utils/dbusutils.h
|
||||
}
|
||||
|
||||
win32 {
|
||||
SOURCES += src/core/globalshortcutfilter.cpp
|
||||
|
||||
HEADERS += src/core/globalshortcutfilter.h
|
||||
}
|
||||
|
||||
RESOURCES += \
|
||||
graphics.qrc
|
||||
|
||||
|
||||
BIN
img/flameshot.ico
Normal file
BIN
img/flameshot.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 119 KiB |
@@ -27,6 +27,10 @@
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include "src/core/globalshortcutfilter.h"
|
||||
#endif
|
||||
|
||||
// Controller is the core component of Flameshot, creates the trayIcon and
|
||||
// launches the capture widget
|
||||
|
||||
@@ -34,16 +38,21 @@ Controller::Controller() : m_captureWindow(nullptr)
|
||||
{
|
||||
qApp->setQuitOnLastWindowClosed(false);
|
||||
|
||||
initDefaults();
|
||||
|
||||
// init tray icon
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_LINUX)
|
||||
if (!ConfigHandler().disabledTrayIconValue()) {
|
||||
enableTrayIcon();
|
||||
}
|
||||
#else
|
||||
#elif defined(Q_OS_WIN)
|
||||
enableTrayIcon();
|
||||
#endif
|
||||
|
||||
initDefaults();
|
||||
GlobalShortcutFilter *nativeFilter = new GlobalShortcutFilter(this);
|
||||
qApp->installNativeEventFilter(nativeFilter);
|
||||
connect(nativeFilter, &GlobalShortcutFilter::printPressed,
|
||||
this, [this](){ this->createVisualCapture(); });
|
||||
#endif
|
||||
|
||||
QString StyleSheet = CaptureButton::globalStyleSheet();
|
||||
qApp->setStyleSheet(StyleSheet);
|
||||
|
||||
50
src/core/globalshortcutfilter.cpp
Normal file
50
src/core/globalshortcutfilter.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright 2017 Alejandro Sirgo Rica
|
||||
//
|
||||
// This file is part of Flameshot.
|
||||
//
|
||||
// Flameshot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Flameshot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "globalshortcutfilter.h"
|
||||
#include "src/core/controller.h"
|
||||
#include <qt_windows.h>
|
||||
|
||||
GlobalShortcutFilter::GlobalShortcutFilter(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
// Forced Print Screen
|
||||
if (RegisterHotKey(NULL, 1, 0, VK_SNAPSHOT)) {
|
||||
// ok
|
||||
}
|
||||
}
|
||||
|
||||
bool GlobalShortcutFilter::nativeEventFilter(
|
||||
const QByteArray &eventType,
|
||||
void *message,
|
||||
long *result)
|
||||
{
|
||||
Q_UNUSED(eventType);
|
||||
Q_UNUSED(result);
|
||||
|
||||
MSG* msg = static_cast<MSG*>(message);
|
||||
if (msg->message == WM_HOTKEY) {
|
||||
//const quint32 keycode = HIWORD(msg->lParam);
|
||||
//const quint32 modifiers = LOWORD(msg->lParam);
|
||||
|
||||
// TODO: this is just a temporal workwrround, proper global
|
||||
// support would need custom shortcuts defined by the user.
|
||||
Controller::getInstance()->createVisualCapture();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
25
src/core/globalshortcutfilter.h
Normal file
25
src/core/globalshortcutfilter.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef GLOBALSHORTCUTFILTER_H
|
||||
#define GLOBALSHORTCUTFILTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractNativeEventFilter>
|
||||
|
||||
class GlobalShortcutFilter : public QObject, public QAbstractNativeEventFilter {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GlobalShortcutFilter(QObject *parent = 0);
|
||||
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
|
||||
|
||||
signals:
|
||||
void printPressed();
|
||||
|
||||
private:
|
||||
quint32 getNativeModifier(Qt::KeyboardModifiers modifiers);
|
||||
quint32 nativeKeycode(Qt::Key key);
|
||||
bool registerShortcut(quint32 nativeKey, quint32 nativeMods);
|
||||
bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods);
|
||||
|
||||
};
|
||||
|
||||
#endif // GLOBALSHORTCUTFILTER_H
|
||||
Reference in New Issue
Block a user