Skip to content
This repository has been archived by the owner on Jun 15, 2020. It is now read-only.

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
r52 committed Dec 18, 2019
1 parent 3c9a62a commit 3603121
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions PTA/pta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

namespace
{
const std::wstring g_poeCls = L"POEWindowClass";
bool g_CtrlDown = false;
const std::wstring g_poeCls = L"POEWindowClass";
}

INPUT createInput(WORD vk, bool isDown)
Expand Down Expand Up @@ -342,7 +341,7 @@ void PTA::setupFunctionality()
}
}

void PTA::handleScrollHotkey(quint16 data)
void PTA::handleScrollHotkey(bool ctrldown, quint16 data)
{
// Check for PoE window
HWND hwnd = GetForegroundWindow();
Expand All @@ -358,7 +357,7 @@ void PTA::handleScrollHotkey(quint16 data)

qint16 dirdat = (qint16) data;

if (g_CtrlDown)
if (ctrldown)
{
QSettings settings;
bool scrollEnabled = settings.value(PTA_CONFIG_CTRL_SCROLL_HOTKEY_ENABLED, true).toBool();
Expand Down Expand Up @@ -510,7 +509,7 @@ void PTA::handleClipboard()
}
}

PTA::InputHandler::InputHandler(QObject* parent) : m_parent(parent) {}
PTA::InputHandler::InputHandler(QObject* parent) : m_parent(parent), m_ctrldown(false) {}

bool PTA::InputHandler::nativeEventFilter(const QByteArray& eventType, void* message, long* result)
{
Expand Down Expand Up @@ -539,9 +538,10 @@ bool PTA::InputHandler::nativeEventFilter(const QByteArray& eventType, void* mes
{
if (raw->data.mouse.usButtonFlags == RI_MOUSE_WHEEL)
{
if (m_parent)
if (m_parent && m_ctrldown)
{
QMetaObject::invokeMethod(m_parent, "handleScrollHotkey", Qt::AutoConnection, Q_ARG(quint16, raw->data.mouse.usButtonData));
QMetaObject::invokeMethod(
m_parent, "handleScrollHotkey", Qt::AutoConnection, Q_ARG(bool, m_ctrldown), Q_ARG(quint16, raw->data.mouse.usButtonData));
}
}
}
Expand All @@ -553,7 +553,7 @@ bool PTA::InputHandler::nativeEventFilter(const QByteArray& eventType, void* mes

if (keyCode == VK_CONTROL)
{
g_CtrlDown = !keyUp;
m_ctrldown = !keyUp;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion PTA/pta.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class PTA : public QMainWindow

private:
QObject* m_parent;
bool m_ctrldown;
};

public:
Expand All @@ -56,7 +57,7 @@ public slots:
private slots:
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);

void handleScrollHotkey(quint16 data);
void handleScrollHotkey(bool ctrldown, quint16 data);
void handlePriceCheckHotkey(uint32_t flag);
void handleClipboard();

Expand Down

0 comments on commit 3603121

Please sign in to comment.