SongEditor and BBEditor: Accept drops in toolbar
This commit is contained in:
@@ -32,6 +32,8 @@
|
||||
#include "TimeLineWidget.h"
|
||||
#include "ToolButton.h"
|
||||
|
||||
class DropToolBar;
|
||||
|
||||
/// \brief Superclass for editors with a toolbar.
|
||||
///
|
||||
/// Those editors include the Song Editor, the Automation Editor, B&B Editor,
|
||||
@@ -63,7 +65,7 @@ protected:
|
||||
virtual ~Editor();
|
||||
|
||||
|
||||
QToolBar* m_toolBar;
|
||||
DropToolBar* m_toolBar;
|
||||
|
||||
QAction* m_playAction;
|
||||
QAction* m_recordAction;
|
||||
@@ -72,4 +74,21 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
/// Small helper class: A QToolBar that accepts and exposes drop events as signals
|
||||
class DropToolBar : public QToolBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DropToolBar(QWidget* parent=0);
|
||||
|
||||
signals:
|
||||
void dragEntered(QDragEnterEvent* event);
|
||||
void dropped(QDropEvent* event);
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -124,6 +124,8 @@ public slots:
|
||||
void createTrackView( Track * _t );
|
||||
void deleteTrackView( TrackView * _tv );
|
||||
|
||||
virtual void dropEvent( QDropEvent * _de );
|
||||
virtual void dragEnterEvent( QDragEnterEvent * _dee );
|
||||
|
||||
protected:
|
||||
static const int DEFAULT_PIXELS_PER_TACT = 16;
|
||||
@@ -133,8 +135,6 @@ protected:
|
||||
return( m_trackViews );
|
||||
}
|
||||
|
||||
virtual void dragEnterEvent( QDragEnterEvent * _dee );
|
||||
virtual void dropEvent( QDropEvent * _de );
|
||||
virtual void mousePressEvent( QMouseEvent * _me );
|
||||
virtual void mouseMoveEvent( QMouseEvent * _me );
|
||||
virtual void mouseReleaseEvent( QMouseEvent * _me );
|
||||
|
||||
@@ -50,6 +50,11 @@ BBEditor::BBEditor( BBTrackContainer* tc ) :
|
||||
setWindowTitle( tr( "Beat+Bassline Editor" ) );
|
||||
setCentralWidget(m_trackContainerView);
|
||||
|
||||
setAcceptDrops(true);
|
||||
m_toolBar->setAcceptDrops(true);
|
||||
connect(m_toolBar, SIGNAL(dragEntered(QDragEnterEvent*)), m_trackContainerView, SLOT(dragEnterEvent(QDragEnterEvent*)));
|
||||
connect(m_toolBar, SIGNAL(dropped(QDropEvent*)), m_trackContainerView, SLOT(dropEvent(QDropEvent*)));
|
||||
|
||||
// TODO: Use style sheet
|
||||
if( ConfigManager::inst()->value( "ui",
|
||||
"compacttrackbuttons" ).toInt() )
|
||||
|
||||
@@ -51,7 +51,7 @@ void Editor::togglePlayStop()
|
||||
}
|
||||
|
||||
Editor::Editor(bool record) :
|
||||
m_toolBar(new QToolBar(this)),
|
||||
m_toolBar(new DropToolBar(this)),
|
||||
m_playAction(nullptr),
|
||||
m_recordAction(nullptr),
|
||||
m_recordAccompanyAction(nullptr),
|
||||
@@ -96,3 +96,21 @@ Editor::~Editor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DropToolBar::DropToolBar(QWidget* parent) : QToolBar(parent)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
void DropToolBar::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
dragEntered(event);
|
||||
}
|
||||
|
||||
void DropToolBar::dropEvent(QDropEvent* event)
|
||||
{
|
||||
dropped(event);
|
||||
}
|
||||
|
||||
@@ -626,6 +626,10 @@ SongEditorWindow::SongEditorWindow(Song* song) :
|
||||
setWindowIcon( embed::getIconPixmap( "songeditor" ) );
|
||||
|
||||
setCentralWidget(m_editor);
|
||||
setAcceptDrops(true);
|
||||
m_toolBar->setAcceptDrops(true);
|
||||
connect(m_toolBar, SIGNAL(dragEntered(QDragEnterEvent*)), m_editor, SLOT(dragEnterEvent(QDragEnterEvent*)));
|
||||
connect(m_toolBar, SIGNAL(dropped(QDropEvent*)), m_editor, SLOT(dropEvent(QDropEvent*)));
|
||||
|
||||
// Set up buttons
|
||||
m_playAction->setToolTip(tr("Play song (Space)"));
|
||||
|
||||
Reference in New Issue
Block a user