shortcut refactor for songeditor (#3649)
* shortcut refactor for songeditor * Ctrl-modifier for copy Tcos * QAction()::trigger methode qt4 compatible
This commit is contained in:
committed by
GitHub
parent
e387e77445
commit
9b5d3790b0
@@ -79,13 +79,13 @@ public:
|
||||
virtual ~RubberBand();
|
||||
|
||||
QVector<selectableObject *> selectedObjects() const;
|
||||
QVector<selectableObject *> selectableObjects() const;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent( QResizeEvent * _re );
|
||||
|
||||
private:
|
||||
QVector<selectableObject *> selectableObjects() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#include "ActionGroup.h"
|
||||
#include "Editor.h"
|
||||
#include "TrackContainerView.h"
|
||||
|
||||
@@ -82,6 +83,7 @@ public slots:
|
||||
|
||||
void updatePosition( const MidiTime & t );
|
||||
void updatePositionLine();
|
||||
void selectAllTcos( bool select );
|
||||
|
||||
protected:
|
||||
virtual void closeEvent( QCloseEvent * ce );
|
||||
@@ -135,6 +137,7 @@ private:
|
||||
bool m_smoothScroll;
|
||||
|
||||
EditMode m_mode;
|
||||
EditMode m_ctrlMode; // mode they were in before they hit ctrl
|
||||
|
||||
friend class SongEditorWindow;
|
||||
|
||||
@@ -169,12 +172,17 @@ signals:
|
||||
void resized();
|
||||
|
||||
private:
|
||||
virtual void keyPressEvent( QKeyEvent * ke );
|
||||
virtual void keyReleaseEvent( QKeyEvent * ke );
|
||||
|
||||
QAction* m_addBBTrackAction;
|
||||
QAction* m_addSampleTrackAction;
|
||||
QAction* m_addAutomationTrackAction;
|
||||
|
||||
ActionGroup * m_editModeGroup;
|
||||
QAction* m_drawModeAction;
|
||||
QAction* m_selectModeAction;
|
||||
QAction* m_crtlAction;
|
||||
|
||||
ComboBox * m_zoomingComboBox;
|
||||
};
|
||||
|
||||
@@ -370,7 +370,6 @@ public slots:
|
||||
void update();
|
||||
void changePosition( const MidiTime & newPos = MidiTime( -1 ) );
|
||||
|
||||
|
||||
protected:
|
||||
virtual void dragEnterEvent( QDragEnterEvent * dee );
|
||||
virtual void dropEvent( QDropEvent * de );
|
||||
|
||||
@@ -85,11 +85,7 @@ public:
|
||||
|
||||
inline QVector<selectableObject *> selectedObjects()
|
||||
{
|
||||
if( allowRubberband() == true )
|
||||
{
|
||||
return( m_rubberBand->selectedObjects() );
|
||||
}
|
||||
return( QVector<selectableObject *>() );
|
||||
return( m_rubberBand->selectedObjects() );
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +122,8 @@ public:
|
||||
}
|
||||
|
||||
|
||||
RubberBand *rubberBand() const;
|
||||
|
||||
public slots:
|
||||
void realignTracks();
|
||||
TrackView * createTrackView( Track * _t );
|
||||
|
||||
@@ -688,99 +688,87 @@ void TrackContentObjectView::paintTextLabel(QString const & text, QPainter & pai
|
||||
void TrackContentObjectView::mousePressEvent( QMouseEvent * me )
|
||||
{
|
||||
setInitialMousePos( me->pos() );
|
||||
if( m_trackView->trackContainerView()->allowRubberband() == true &&
|
||||
me->button() == Qt::LeftButton )
|
||||
if( me->button() == Qt::LeftButton )
|
||||
{
|
||||
if( m_trackView->trackContainerView()->rubberBandActive() == true )
|
||||
if( me->modifiers() & Qt::ControlModifier )
|
||||
{
|
||||
// Propagate to trackView for rubberbanding
|
||||
selectableObject::mousePressEvent( me );
|
||||
}
|
||||
else if ( me->modifiers() & Qt::ControlModifier )
|
||||
{
|
||||
if( isSelected() == true )
|
||||
if( isSelected() )
|
||||
{
|
||||
m_action = CopySelection;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_action = ToggleSelected;
|
||||
gui->songEditor()->m_editor->selectAllTcos( false );
|
||||
QVector<TrackContentObjectView *> tcoViews;
|
||||
tcoViews.push_back( this );
|
||||
DataFile dataFile = createTCODataFiles( tcoViews );
|
||||
QPixmap thumbnail = QPixmap::grabWidget( this ).scaled(
|
||||
128, 128,
|
||||
Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation );
|
||||
new StringPairDrag( QString( "tco_%1" ).arg(
|
||||
m_tco->getTrack()->type() ),
|
||||
dataFile.toString(), thumbnail, this );
|
||||
}
|
||||
}
|
||||
else if( !me->modifiers() )
|
||||
else
|
||||
{
|
||||
if( isSelected() == true )
|
||||
if( isSelected() )
|
||||
{
|
||||
m_action = MoveSelection;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( me->button() == Qt::LeftButton &&
|
||||
me->modifiers() & Qt::ControlModifier )
|
||||
{
|
||||
// start drag-action
|
||||
QVector<TrackContentObjectView *> tcoViews;
|
||||
tcoViews.push_back( this );
|
||||
DataFile dataFile = createTCODataFiles( tcoViews );
|
||||
QPixmap thumbnail = QPixmap::grabWidget( this ).scaled(
|
||||
128, 128,
|
||||
Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation );
|
||||
new StringPairDrag( QString( "tco_%1" ).arg(
|
||||
m_tco->getTrack()->type() ),
|
||||
dataFile.toString(), thumbnail, this );
|
||||
}
|
||||
else if( me->button() == Qt::LeftButton &&
|
||||
/* engine::mainWindow()->isShiftPressed() == false &&*/
|
||||
fixedTCOs() == false )
|
||||
{
|
||||
m_tco->addJournalCheckPoint();
|
||||
else
|
||||
{
|
||||
gui->songEditor()->m_editor->selectAllTcos( false );
|
||||
m_tco->addJournalCheckPoint();
|
||||
|
||||
// move or resize
|
||||
m_tco->setJournalling( false );
|
||||
// move or resize
|
||||
m_tco->setJournalling( false );
|
||||
|
||||
setInitialMousePos( me->pos() );
|
||||
setInitialMousePos( me->pos() );
|
||||
|
||||
if( me->x() < width() - RESIZE_GRIP_WIDTH )
|
||||
{
|
||||
m_action = Move;
|
||||
m_oldTime = m_tco->startPosition();
|
||||
QCursor c( Qt::SizeAllCursor );
|
||||
QApplication::setOverrideCursor( c );
|
||||
s_textFloat->setTitle( tr( "Current position" ) );
|
||||
delete m_hint;
|
||||
m_hint = TextFloat::displayMessage( tr( "Hint" ),
|
||||
tr( "Press <%1> and drag to make "
|
||||
"a copy." ).arg(
|
||||
#ifdef LMMS_BUILD_APPLE
|
||||
"⌘"),
|
||||
#else
|
||||
"Ctrl"),
|
||||
#endif
|
||||
embed::getIconPixmap( "hint" ), 0 );
|
||||
if( me->x() < width() - RESIZE_GRIP_WIDTH )
|
||||
{
|
||||
m_action = Move;
|
||||
m_oldTime = m_tco->startPosition();
|
||||
QCursor c( Qt::SizeAllCursor );
|
||||
QApplication::setOverrideCursor( c );
|
||||
s_textFloat->setTitle( tr( "Current position" ) );
|
||||
delete m_hint;
|
||||
m_hint = TextFloat::displayMessage( tr( "Hint" ),
|
||||
tr( "Press <%1> and drag to make "
|
||||
"a copy." ).arg(
|
||||
#ifdef LMMS_BUILD_APPLE
|
||||
"⌘"),
|
||||
#else
|
||||
"Ctrl"),
|
||||
#endif
|
||||
embed::getIconPixmap( "hint" ), 0 );
|
||||
}
|
||||
else if( !m_tco->getAutoResize() )
|
||||
{
|
||||
m_action = Resize;
|
||||
m_oldTime = m_tco->length();
|
||||
QCursor c( Qt::SizeHorCursor );
|
||||
QApplication::setOverrideCursor( c );
|
||||
s_textFloat->setTitle( tr( "Current length" ) );
|
||||
delete m_hint;
|
||||
m_hint = TextFloat::displayMessage( tr( "Hint" ),
|
||||
tr( "Press <%1> for free "
|
||||
"resizing." ).arg(
|
||||
#ifdef LMMS_BUILD_APPLE
|
||||
"⌘"),
|
||||
#else
|
||||
"Ctrl"),
|
||||
#endif
|
||||
embed::getIconPixmap( "hint" ), 0 );
|
||||
}
|
||||
// s_textFloat->reparent( this );
|
||||
// setup text-float as if TCO was already moved/resized
|
||||
mouseMoveEvent( me );
|
||||
s_textFloat->show();
|
||||
}
|
||||
}
|
||||
else if( !m_tco->getAutoResize() )
|
||||
{
|
||||
m_action = Resize;
|
||||
m_oldTime = m_tco->length();
|
||||
QCursor c( Qt::SizeHorCursor );
|
||||
QApplication::setOverrideCursor( c );
|
||||
s_textFloat->setTitle( tr( "Current length" ) );
|
||||
delete m_hint;
|
||||
m_hint = TextFloat::displayMessage( tr( "Hint" ),
|
||||
tr( "Press <%1> for free "
|
||||
"resizing." ).arg(
|
||||
#ifdef LMMS_BUILD_APPLE
|
||||
"⌘"),
|
||||
#else
|
||||
"Ctrl"),
|
||||
#endif
|
||||
embed::getIconPixmap( "hint" ), 0 );
|
||||
}
|
||||
// s_textFloat->reparent( this );
|
||||
// setup text-float as if TCO was already moved/resized
|
||||
mouseMoveEvent( me );
|
||||
s_textFloat->show();
|
||||
}
|
||||
else if( me->button() == Qt::RightButton )
|
||||
{
|
||||
@@ -826,10 +814,7 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me )
|
||||
{
|
||||
if( m_action == CopySelection )
|
||||
{
|
||||
if( mouseMovedDistance( me, 2 ) == true &&
|
||||
m_trackView->trackContainerView()->allowRubberband() == true &&
|
||||
m_trackView->trackContainerView()->rubberBandActive() == false &&
|
||||
( me->modifiers() & Qt::ControlModifier ) )
|
||||
if( mouseMovedDistance( me, 2 ) == true )
|
||||
{
|
||||
// Clear the action here because mouseReleaseEvent will not get
|
||||
// triggered once we go into drag.
|
||||
@@ -923,7 +908,7 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me )
|
||||
t = ( *it )->startPosition() +
|
||||
static_cast<int>( dx *MidiTime::ticksPerTact() /
|
||||
ppt )-smallest_pos;
|
||||
if( ! ( me->modifiers() & Qt::AltModifier )
|
||||
if( ! ( me->modifiers() & Qt::ControlModifier )
|
||||
&& me->button() == Qt::NoButton )
|
||||
{
|
||||
t = t.toNearestTact();
|
||||
@@ -1464,11 +1449,9 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, QDropEvent * de )
|
||||
const TrackContainer::TrackList tracks = getTrack()->trackContainer()->tracks();
|
||||
const int currentTrackIndex = tracks.indexOf( getTrack() );
|
||||
|
||||
bool allowRubberband = m_trackView->trackContainerView()->allowRubberband();
|
||||
bool wasSelection = m_trackView->trackContainerView()->rubberBand()->selectedObjects().count();
|
||||
|
||||
// Unselect the old group
|
||||
if( allowRubberband == true )
|
||||
{
|
||||
const QVector<selectableObject *> so =
|
||||
m_trackView->trackContainerView()->selectedObjects();
|
||||
for( QVector<selectableObject *>::const_iterator it = so.begin();
|
||||
@@ -1476,7 +1459,7 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, QDropEvent * de )
|
||||
{
|
||||
( *it )->setSelected( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO -- Need to draw the hovericon either way, or ghost the TCOs
|
||||
// onto their final position.
|
||||
@@ -1501,10 +1484,11 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, QDropEvent * de )
|
||||
TrackContentObject * tco = t->createTCO( pos );
|
||||
tco->restoreState( tcoElement );
|
||||
tco->movePosition( pos );
|
||||
if( allowRubberband == true )
|
||||
if( wasSelection )
|
||||
{
|
||||
tco->selectViewOnCreate( true );
|
||||
}
|
||||
|
||||
//check tco name, if the same as source track name dont copy
|
||||
if( tco->name() == tracks[trackIndex]->name() )
|
||||
{
|
||||
@@ -1551,6 +1535,11 @@ void TrackContentWidget::mousePressEvent( QMouseEvent * me )
|
||||
else if( me->button() == Qt::LeftButton &&
|
||||
!m_trackView->trackContainerView()->fixedTCOs() )
|
||||
{
|
||||
QVector<selectableObject*> so = m_trackView->trackContainerView()->rubberBand()->selectedObjects();
|
||||
for( int i = 0; i < so.count(); ++i )
|
||||
{
|
||||
so.at( i )->setSelected( false);
|
||||
}
|
||||
getTrack()->addJournalCheckPoint();
|
||||
const MidiTime pos = getPosition( me->x() ).getTact() *
|
||||
MidiTime::ticksPerTact();
|
||||
|
||||
@@ -472,6 +472,11 @@ void TrackContainerView::resizeEvent( QResizeEvent * _re )
|
||||
QWidget::resizeEvent( _re );
|
||||
}
|
||||
|
||||
RubberBand *TrackContainerView::rubberBand() const
|
||||
{
|
||||
return m_rubberBand;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <QMdiSubWindow>
|
||||
#include <QPainter>
|
||||
|
||||
#include "ActionGroup.h"
|
||||
#include "AutomatableSlider.h"
|
||||
#include "ComboBox.h"
|
||||
#include "ConfigManager.h"
|
||||
@@ -102,7 +101,6 @@ SongEditor::SongEditor( Song * song ) :
|
||||
this, SLOT( stopRubberBand() ) );
|
||||
|
||||
m_positionLine = new positionLine( this );
|
||||
|
||||
static_cast<QVBoxLayout *>( layout() )->insertWidget( 1, m_timeLine );
|
||||
|
||||
|
||||
@@ -312,14 +310,12 @@ void SongEditor::setEditModeSelect()
|
||||
|
||||
void SongEditor::keyPressEvent( QKeyEvent * ke )
|
||||
{
|
||||
if( /*_ke->modifiers() & Qt::ShiftModifier*/
|
||||
gui->mainWindow()->isShiftPressed() == true &&
|
||||
if( ke->modifiers() & Qt::ShiftModifier &&
|
||||
ke->key() == Qt::Key_Insert )
|
||||
{
|
||||
m_song->insertBar();
|
||||
}
|
||||
else if(/* _ke->modifiers() & Qt::ShiftModifier &&*/
|
||||
gui->mainWindow()->isShiftPressed() == true &&
|
||||
else if( ke->modifiers() & Qt::ShiftModifier &&
|
||||
ke->key() == Qt::Key_Delete )
|
||||
{
|
||||
m_song->removeBar();
|
||||
@@ -344,6 +340,26 @@ void SongEditor::keyPressEvent( QKeyEvent * ke )
|
||||
{
|
||||
m_song->setPlayPos( 0, Song::Mode_PlaySong );
|
||||
}
|
||||
else if( ke->key() == Qt::Key_Delete )
|
||||
{
|
||||
QVector<TrackContentObjectView *> tcoViews;
|
||||
QVector<selectableObject *> so = selectedObjects();
|
||||
for( QVector<selectableObject *>::iterator it = so.begin();
|
||||
it != so.end(); ++it )
|
||||
{
|
||||
TrackContentObjectView * tcov =
|
||||
dynamic_cast<TrackContentObjectView *>( *it );
|
||||
tcov->remove();
|
||||
}
|
||||
}
|
||||
else if( ke->key() == Qt::Key_A && ke->modifiers() & Qt::ControlModifier )
|
||||
{
|
||||
selectAllTcos( !(ke->modifiers() & Qt::ShiftModifier) );
|
||||
}
|
||||
else if( ke->key() == Qt::Key_Escape )
|
||||
{
|
||||
selectAllTcos( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
QWidget::keyPressEvent( ke );
|
||||
@@ -355,7 +371,7 @@ void SongEditor::keyPressEvent( QKeyEvent * ke )
|
||||
|
||||
void SongEditor::wheelEvent( QWheelEvent * we )
|
||||
{
|
||||
if( gui->mainWindow()->isCtrlPressed() == true )
|
||||
if( we->modifiers() & Qt::ControlModifier )
|
||||
{
|
||||
int z = m_zoomingModel->value();
|
||||
|
||||
@@ -377,7 +393,7 @@ void SongEditor::wheelEvent( QWheelEvent * we )
|
||||
// and make sure, all TCO's are resized and relocated
|
||||
realignTracks();
|
||||
}
|
||||
else if( gui->mainWindow()->isShiftPressed() == true || we->orientation() == Qt::Horizontal )
|
||||
else if( we->modifiers() & Qt::ShiftModifier || we->orientation() == Qt::Horizontal )
|
||||
{
|
||||
m_leftRightScroll->setValue( m_leftRightScroll->value() -
|
||||
we->delta() / 30 );
|
||||
@@ -606,6 +622,18 @@ void SongEditor::zoomingChanged()
|
||||
|
||||
|
||||
|
||||
void SongEditor::selectAllTcos( bool select )
|
||||
{
|
||||
QVector<selectableObject *> so = select ? rubberBand()->selectableObjects() : rubberBand()->selectedObjects();
|
||||
for( int i = 0; i < so.count(); ++i )
|
||||
{
|
||||
so.at(i)->setSelected( select );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool SongEditor::allowRubberband() const
|
||||
{
|
||||
return m_mode == SelectMode;
|
||||
@@ -674,10 +702,9 @@ SongEditorWindow::SongEditorWindow(Song* song) :
|
||||
// Edit actions
|
||||
DropToolBar *editActionsToolBar = addDropToolBarToTop(tr("Edit actions"));
|
||||
|
||||
ActionGroup* editModeGroup = new ActionGroup(this);
|
||||
m_drawModeAction = editModeGroup->addAction(embed::getIconPixmap("edit_draw"), tr("Draw mode"));
|
||||
m_selectModeAction = editModeGroup->addAction(embed::getIconPixmap("edit_select"), tr("Edit mode (select and move)"));
|
||||
|
||||
m_editModeGroup = new ActionGroup(this);
|
||||
m_drawModeAction = m_editModeGroup->addAction(embed::getIconPixmap("edit_draw"), tr("Draw mode"));
|
||||
m_selectModeAction = m_editModeGroup->addAction(embed::getIconPixmap("edit_select"), tr("Edit mode (select and move)"));
|
||||
m_drawModeAction->setChecked(true);
|
||||
|
||||
connect(m_drawModeAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeDraw()));
|
||||
@@ -763,3 +790,31 @@ void SongEditorWindow::adjustUiAfterProjectLoad()
|
||||
qobject_cast<QMdiSubWindow *>( parentWidget() ) );
|
||||
m_editor->scrolled(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SongEditorWindow::keyPressEvent( QKeyEvent *ke )
|
||||
{
|
||||
if( ke->key() == Qt::Key_Control )
|
||||
{
|
||||
m_crtlAction = m_editModeGroup->checkedAction();
|
||||
m_selectModeAction->setChecked( true );
|
||||
m_selectModeAction->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SongEditorWindow::keyReleaseEvent( QKeyEvent *ke )
|
||||
{
|
||||
if( ke->key() == Qt::Key_Control )
|
||||
{
|
||||
if( m_crtlAction )
|
||||
{
|
||||
m_crtlAction->setChecked( true );
|
||||
m_crtlAction->trigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user