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

Improve the context menu actions when multiple TCOs are selected #5601

Merged
merged 22 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
33 changes: 33 additions & 0 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,42 @@ class TrackContentObjectView : public selectableObject, public ModelView
bool needsUpdate();
void setNeedsUpdate( bool b );

// Method to get a QVector of TCOs to be affected by a context menu action
QVector<TrackContentObjectView *> getClickedTCOs();

// Methods to remove, copy, cut, paste and mute a QVector of TCO views
void copy( QVector<TrackContentObjectView *> tcovs );
void cut( QVector<TrackContentObjectView *> tcovs );
void paste();
// remove and toggleMute are static because they don't depend
// being called from a particular TCO view, but can be called anywhere as long
// as a valid TCO view list is given, while copy/cut require an instance for
// some metadata to be written to the clipboard.
static void remove( QVector<TrackContentObjectView *> tcovs );
static void toggleMute( QVector<TrackContentObjectView *> tcovs );

public slots:
virtual bool close();
void cut();
void remove();
void update() override;

protected:
enum ContextMenuAction
{
Remove,
Cut,
Copy,
Paste,
Mute
};

virtual void constructContextMenu( QMenu * )
{
}

void contextMenuEvent( QContextMenuEvent * cme ) override;
void contextMenuAction( ContextMenuAction action );
void dragEnterEvent( QDragEnterEvent * dee ) override;
void dropEvent( QDropEvent * de ) override;
void leaveEvent( QEvent * e ) override;
Expand Down Expand Up @@ -370,7 +394,9 @@ class TrackContentWidget : public QWidget, public JournallingObject
}

bool canPasteSelection( MidiTime tcoPos, const QDropEvent *de );
bool canPasteSelection( MidiTime tcoPos, const QMimeData *md, bool allowSameBar = false );
bool pasteSelection( MidiTime tcoPos, QDropEvent * de );
bool pasteSelection( MidiTime tcoPos, const QMimeData * md, bool skipSafetyCheck = false );

MidiTime endPosition( const MidiTime & posStart );

Expand All @@ -391,6 +417,13 @@ public slots:
void changePosition( const MidiTime & newPos = MidiTime( -1 ) );

protected:
enum ContextMenuAction
{
Paste
};

void contextMenuEvent( QContextMenuEvent * cme ) override;
void contextMenuAction( QContextMenuEvent * cme, ContextMenuAction action );
void dragEnterEvent( QDragEnterEvent * dee ) override;
void dropEvent( QDropEvent * de ) override;
void mousePressEvent( QMouseEvent * me ) override;
Expand Down
7 changes: 7 additions & 0 deletions src/core/Clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*
*/

#include <QApplication>
#include <QClipboard>

#include "Clipboard.h"
#include "JournallingObject.h"

Expand All @@ -35,6 +38,10 @@ void Clipboard::copy( JournallingObject * _obj )
QDomElement parent = doc.createElement( "Clipboard" );
_obj->saveState( doc, parent );
content[_obj->nodeName()] = parent.firstChild().toElement();

// Clear the QApplication clipboard, so we don't have any conflicts when LMMS has to
// decide between the QApplication clipboard and the internal clipboard data
QApplication::clipboard()->clear( QClipboard::Clipboard );
}


Expand Down
Loading