Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the drop indicators #334 #337 #346

Closed
tlaemmlein opened this issue Feb 28, 2023 · 3 comments
Closed

Hide the drop indicators #334 #337 #346

tlaemmlein opened this issue Feb 28, 2023 · 3 comments

Comments

@tlaemmlein
Copy link

Hi,
Unfortunately the fix #337 is not working in every situation. If you move a floating window the event filter doesn't catch the ctrl key event.
If you don't move any window the key event is working.

But the most important use case is to move the floating window and pressing the ctrl key.

Regards,
Thomas

@iamsergio
Copy link
Contributor

The API is KDDockWidgets::Config::setDropIndicatorsInhibited(bool), that needs to be called whenever Ctrl is pressed/released.

The event filter in MyMainWindow.cpp is not part of the API, it's for example purposes. As it will differ from application to application.

Knowing your application I think you're using native titlebars, if Windows doesn't send the Ctrl event to Qt in that case you can use a timer and check if key is pressed (with win32 api if Qt one doesn't work)

@iamsergio
Copy link
Contributor

KDDockWidgets::DragController::isDraggingChanged() signal can be useful, to stop/start the timer.
For getting key state, maybe GetKeyState().

@tlaemmlein
Copy link
Author

I found a good solution which works under Linux and Windows.

#include <kddockwidgets/Config.h>
#include <kddockwidgets/private/DragController_p.h>
#if defined(Q_OS_WIN)
#include <windows.h>
#endif
...

   connect(&m_timer, &QTimer::timeout, this, [this]() {
#if defined(Q_OS_WIN)        
        const bool ctrlIsReallyDown = (GetKeyState(VK_CONTROL) & 0x8000);
#else
        const bool ctrlIsReallyDown = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
#endif
        static int i = 0;
        
        qDebug() << "Timeout " << ctrlIsReallyDown << " " << i++;
        
        KDDockWidgets::Config::self().setDropIndicatorsInhibited(ctrlIsReallyDown);
    });

    connect(KDDockWidgets::DragController::instance(), &KDDockWidgets::DragController::isDraggingChanged, [this]() {
        static int i = 0;
        qDebug() << "isDraggingChanged "  << i++;
        if (KDDockWidgets::DragController::instance()->isDragging() && !m_timer.isActive()) {
            m_timer.start(300);
        } else {
            m_timer.stop();
            KDDockWidgets::Config::self().setDropIndicatorsInhibited(false);
        }
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants