material-decoration icon indicating copy to clipboard operation
material-decoration copied to clipboard

Ability to disable window move when dragging menu buttons

Open Zren opened this issue 4 years ago • 4 comments

In Issue #2, @emvaized asked if we could disable the "window drag" option.

It will need to:

  • Add config option.
  • Not call initDragMove(event->pos()); in Decoration::mousePressEvent when config says so.
    • https://github.com/Zren/material-decoration/blame/master/src/Decoration.cc#L302
  • Bind the AppMenuButton::pressed signal to the AppMenuButton::clicked signal. In the pressed signal handler, check if the config option is set, then emit the clicked signal.
    • https://github.com/Zren/material-decoration/blob/master/src/AppMenuButton.cc
    • https://invent.kde.org/plasma/kdecoration/-/blob/master/src/decorationbutton.h
    • https://invent.kde.org/plasma/kdecoration/-/blob/master/src/decorationbutton.cpp

Zren avatar Mar 24 '21 17:03 Zren

You'd need to write a new function to handle the AppMenuButton::pressed signal.

In the AppMenuButton constructor(AppMenuButton::AppMenuButton), we need to connect(...) a signal to another signal. I'm not sure if Qt's connect functions supports that, so we'll just create an anonymous "slot" function, that emits the other signal. I'll need the slot function anyways since I'll need to check the config first to see if I need to emit the clicked signal.

Here's an example which I have NOT tested.

connect(this, &AppMenuButton::pressed,
        [this] {
                emit clicked();
        }
); 

connect(this, &AppMenuButton::clicked,
        this, &AppMenuButton::trigger);

~~Eg:~~

  • ~~https://github.com/Zren/material-decoration/blob/master/src/AppMenuButtonGroup.cc#L78~~
  • ~~https://github.com/Zren/material-decoration/blob/master/src/AppMenuButtonGroup.cc#L108~~

Zren avatar Mar 24 '21 17:03 Zren

What should be changed in setCurrentIndex method (line 108)?

emvaized avatar Mar 24 '21 18:03 emvaized

Those were just examples of emit and an anonymous connect function. I wasn't planning on doing a complete example when I added the examples.

Zren avatar Mar 24 '21 18:03 Zren

Oh, okay - got it!

emvaized avatar Mar 24 '21 18:03 emvaized