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

Transport buttons midi assignable #7583

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,12 @@ QToolButton#stopButton {

/* all tool buttons */

QToolButton, QToolButton::menu-button {
lmms--gui--TransportButton {
width: 27px;
height: 27px;
}

lmms--gui--TransportButton, QToolButton, QToolButton::menu-button {
padding: 1px 1px 1px 1px;
border-radius: 5px;
border: 1px solid rgba(63, 63, 63, 128);
Expand All @@ -531,12 +536,12 @@ QToolButton, QToolButton::menu-button {
color: black;
}

QToolButton:hover {
lmms--gui--TransportButton:hover, QToolButton:hover {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #c0cdd3, stop:1 #71797d);
color: white;
}

QToolButton:pressed {
lmms--gui--TransportButton:pressed, QToolButton:pressed {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #969696, stop:0.5 #c9c9c9, stop:1 #969696 );
padding: 2px 1px 0px 1px;
color: white;
Expand Down
11 changes: 8 additions & 3 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,12 @@ QToolBar::separator {

/* all tool buttons */

QToolButton, QToolButton::menu-button {
lmms--gui--TransportButton {
width: 27px;
height: 27px;
}

lmms--gui--TransportButton, QToolButton, QToolButton::menu-button {
margin: 1px;
padding: 2px 2px 2px 2px;
border-top: 1px solid #778394;
Expand All @@ -544,7 +549,7 @@ QToolButton, QToolButton::menu-button {
color: #fff;
}

QToolButton:hover {
lmms--gui--TransportButton:hover, QToolButton:hover {
border-top: 1px solid #909eb3;
border-bottom: 1px solid #1e2226;
border-radius: 2px;
Expand All @@ -557,7 +562,7 @@ QToolButton:hover:checked {
background: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1, stop:0 #292d33, stop:1 #22262c)
}

QToolButton:pressed {
lmms--gui--TransportButton:pressed, QToolButton:pressed {
border-top: 1px solid #778394;
border-bottom: 1px solid #1e2226;
border-radius: 2px;
Expand Down
9 changes: 5 additions & 4 deletions include/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <QMainWindow>
#include <QToolBar>
#include <QWidgetAction>

class QAction;

Expand Down Expand Up @@ -86,11 +87,11 @@ private slots:

DropToolBar* m_toolBar;

QAction* m_playAction;
QAction* m_recordAction;
QAction* m_recordAccompanyAction;
QWidgetAction* m_playAction;
QWidgetAction* m_recordAction;
QWidgetAction* m_recordAccompanyAction;
QAction* m_toggleStepRecordingAction;
QAction* m_stopAction;
QWidgetAction* m_stopAction;
};


Expand Down
25 changes: 25 additions & 0 deletions include/TransportButton.h
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;
} ;

} // namespace lmms::gui

#endif // TRANSPORTBUTTON_H
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ SET(LMMS_SRCS
gui/widgets/TextFloat.cpp
gui/widgets/TimeDisplayWidget.cpp
gui/widgets/ToolButton.cpp
gui/widgets/TransportButton.cpp

PARENT_SCOPE
)
Expand Down
39 changes: 27 additions & 12 deletions src/gui/editors/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "GuiApplication.h"
#include "MainWindow.h"
#include "Song.h"
#include "TransportButton.h"

#include "embed.h"

Expand All @@ -41,11 +42,13 @@ namespace lmms::gui

void Editor::setPauseIcon(bool displayPauseIcon)
{
QPushButton* widget = static_cast<QPushButton*> (m_playAction->defaultWidget());

// If we're playing, show a pause icon
if (displayPauseIcon)
m_playAction->setIcon(embed::getIconPixmap("pause"));
widget->setIcon(embed::getIconPixmap("pause"));
else
m_playAction->setIcon(embed::getIconPixmap("play"));
widget->setIcon(embed::getIconPixmap("play"));
}

DropToolBar * Editor::addDropToolBarToTop(QString const & windowTitle)
Expand Down Expand Up @@ -103,12 +106,23 @@ Editor::Editor(bool record, bool stepRecord) :
m_toolBar->widgetForAction(action)->setObjectName(objectName);
};

// Set up play and record actions
m_playAction = new QAction(embed::getIconPixmap("play"), tr("Play (Space)"), this);
m_stopAction = new QAction(embed::getIconPixmap("stop"), tr("Stop (Space)"), this);
auto addTransportButton = [this](QWidgetAction* action, QString objectName,const char* icon,
const char* tooltip,QString menuName)
{
TransportButton* widget = new TransportButton(nullptr,menuName);
widget->setIcon(embed::getIconPixmap(icon));
widget->setToolTip(tr(tooltip));
action->setDefaultWidget(widget);
connect(widget, SIGNAL(toggled(bool)), action, SIGNAL(triggered()));
m_toolBar->addAction(action);
m_toolBar->widgetForAction(action)->setObjectName(objectName);
};

m_recordAction = new QAction(embed::getIconPixmap("record"), tr("Record"), this);
m_recordAccompanyAction = new QAction(embed::getIconPixmap("record_accompany"), tr("Record while playing"), this);
// Set up play and record actions
m_playAction = new QWidgetAction( this);
m_stopAction = new QWidgetAction(this);
m_recordAction = new QWidgetAction(this);
m_recordAccompanyAction=new QWidgetAction(this);
m_toggleStepRecordingAction = new QAction(embed::getIconPixmap("record_step_off"), tr("Toggle Step Recording"), this);

// Set up connections
Expand All @@ -122,17 +136,18 @@ Editor::Editor(bool record, bool stepRecord) :
new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F11), this, SLOT(toggleMaximize()));

// Add actions to toolbar
addButton(m_playAction, "playButton");
addTransportButton(m_playAction,"playButton","play","Play (Space)","Play");
if (record)
{
addButton(m_recordAction, "recordButton");
addButton(m_recordAccompanyAction, "recordAccompanyButton");
addTransportButton(m_recordAction,"recordButton","record","Record","Record");
addTransportButton(m_recordAccompanyAction,"recordAccompanyButton","record_accompany",
"Record while playing","Record while playing");
}
if(stepRecord)
if (stepRecord)
{
addButton(m_toggleStepRecordingAction, "stepRecordButton");
}
addButton(m_stopAction, "stopButton");
addTransportButton(m_stopAction,"stopButton","stop","Stop (Space)","Stop");
}

QAction *Editor::playAction() const
Expand Down
75 changes: 75 additions & 0 deletions src/gui/widgets/TransportButton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#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)
{
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());
}

} // namespace lmms::gui
Loading