1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#pragma once
#include <kddockwidgets/Config.h>
#include <QObject>
#include <QKeyEvent>
// This event filter is just for examplify how to use the KDDW API to show/hide
// the drag indicators when ctrl is pressed
class CtrlKeyEventFilter : public QObject
{
public:
using QObject::QObject;
~CtrlKeyEventFilter() override;
bool eventFilter(QObject *, QEvent *ev) override
{
if (ev->type() != QEvent::KeyPress && ev->type() != QEvent::KeyRelease)
return false;
auto me = static_cast<QKeyEvent *>(ev);
if (me->key() != Qt::Key_Control)
return false;
KDDockWidgets::Config::self().setDropIndicatorsInhibited(ev->type() == QEvent::KeyRelease);
return false;
}
};
|