-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
153 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef TRANSPORTBUTTON_H | ||
#define TRANSPORTBUTTON_H | ||
|
||
#include "AutomatableButton.h" | ||
|
||
namespace lmms::gui | ||
{ | ||
|
||
class LMMS_EXPORT TransportButton : public AutomatableButton | ||
{ | ||
Q_OBJECT | ||
public: | ||
TransportButton( QWidget * _parent, | ||
const QString & _name = QString() ); | ||
~TransportButton() override = default; | ||
|
||
protected: | ||
void mousePressEvent( QMouseEvent * _me ) override; | ||
void mouseReleaseEvent( QMouseEvent * _me ) override; | ||
void contextMenuEvent( QContextMenuEvent * _me ) override; | ||
} ; | ||
|
||
} | ||
|
||
#endif // TRANSPORTBUTTON_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include "TransportButton.h" | ||
|
||
#include <QMouseEvent> | ||
|
||
#include "ControllerConnection.h" | ||
#include "CaptionMenu.h" | ||
#include "embed.h" | ||
|
||
namespace lmms::gui | ||
{ | ||
|
||
TransportButton::TransportButton(QWidget * _parent, const QString & _name) : | ||
AutomatableButton(_parent, _name) | ||
{ | ||
setCheckable(true); | ||
model()->setStrictStepSize(true); | ||
} | ||
|
||
|
||
void TransportButton::mousePressEvent(QMouseEvent * _me) | ||
{ | ||
if (_me->button() == Qt::LeftButton) | ||
{ | ||
toggle(); | ||
} | ||
QPushButton::mousePressEvent(_me); | ||
} | ||
|
||
void TransportButton::mouseReleaseEvent(QMouseEvent * _me) | ||
{ | ||
if (_me) | ||
{ | ||
QPushButton::mouseReleaseEvent(_me); | ||
} | ||
} | ||
|
||
void TransportButton::contextMenuEvent(QContextMenuEvent * _me) | ||
{ | ||
// for the case, the user clicked right while pressing left mouse- | ||
// button, the context-menu appears while mouse-cursor is still hidden | ||
// and it isn't shown again until user does something which causes | ||
// an QApplication::restoreOverrideCursor()-call... | ||
mouseReleaseEvent(nullptr); | ||
|
||
CaptionMenu contextMenu(this->model()->displayName()); | ||
AutomatableModel* model = modelUntyped(); | ||
auto amvSlots = new AutomatableModelViewSlots(this, &contextMenu); | ||
QString controllerTxt; | ||
if (model->controllerConnection()) | ||
{ | ||
Controller* cont = model->controllerConnection()->getController(); | ||
if (cont) | ||
{ | ||
controllerTxt = AutomatableModel::tr("Connected to %1").arg(cont->name()); | ||
} | ||
else | ||
{ | ||
controllerTxt = AutomatableModel::tr("Connected to controller"); | ||
} | ||
|
||
QMenu* contMenu = contextMenu.addMenu(embed::getIconPixmap("controller"), controllerTxt); | ||
|
||
contMenu->addAction(embed::getIconPixmap("controller"), | ||
AutomatableModel::tr("Edit connection..."), | ||
amvSlots, SLOT(execConnectionDialog())); | ||
contMenu->addAction(embed::getIconPixmap( "cancel" ), | ||
AutomatableModel::tr("Remove connection"), | ||
amvSlots, SLOT(removeConnection())); | ||
} | ||
else | ||
{ | ||
contextMenu.addAction( embed::getIconPixmap("controller"), | ||
AutomatableModel::tr("Connect to controller..."), | ||
amvSlots, SLOT(execConnectionDialog())); | ||
} | ||
contextMenu.exec(QCursor::pos()); | ||
} | ||
|
||
} |