frontend: Add renamed Qt UI components
This commit only contains Qt UI components that are self-contained, i.e. the translation units only contain code for a single class or interface and don't mix implementations.
This commit is contained in:
parent
3e32a9fcbf
commit
3bbda4803e
26 changed files with 74 additions and 62 deletions
36
frontend/components/MenuButton.cpp
Normal file
36
frontend/components/MenuButton.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "MenuButton.hpp"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "moc_MenuButton.cpp"
|
||||
|
||||
void MenuButton::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (menu()) {
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Enter:
|
||||
case Qt::Key_Return:
|
||||
emit clicked();
|
||||
return;
|
||||
case Qt::Key_Down:
|
||||
case Qt::Key_Space:
|
||||
showMenu();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QPushButton::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void MenuButton::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (menu()) {
|
||||
if (width() - event->pos().x() <= 30)
|
||||
showMenu();
|
||||
else
|
||||
setDown(true);
|
||||
} else {
|
||||
QPushButton::mousePressEvent(event);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue