From 32da8cb677388a9e2d27f94315505049b7e900dc Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 21:22:52 +0100 Subject: [PATCH] Editor: Don't use ToolButton --- include/Editor.h | 8 ++++---- src/gui/AutomationEditor.cpp | 8 ++++---- src/gui/BBEditor.cpp | 10 +++++----- src/gui/Editor.cpp | 38 ++++++++++++++++++------------------ src/gui/PianoRoll.cpp | 16 +++++++-------- src/gui/SongEditor.cpp | 14 ++++++------- 6 files changed, 47 insertions(+), 47 deletions(-) diff --git a/include/Editor.h b/include/Editor.h index 0b4fa96bb..ffd2f4ae1 100644 --- a/include/Editor.h +++ b/include/Editor.h @@ -60,10 +60,10 @@ protected: QToolBar* m_toolBar; - QAbstractButton* m_playButton; - QAbstractButton* m_recordButton; - QAbstractButton* m_recordAccompanyButton; - QAbstractButton* m_stopButton; + QAction* m_playAction; + QAction* m_recordAction; + QAction* m_recordAccompanyAction; + QAction* m_stopAction; private: }; diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index b949b3396..abf0e3225 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -2029,14 +2029,14 @@ AutomationEditorWindow::AutomationEditorWindow() : // Play/stop buttons - m_playButton->setToolTip(tr( "Play/pause current pattern (Space)" )); - m_playButton->setWhatsThis( + m_playAction->setToolTip(tr( "Play/pause current pattern (Space)" )); + m_playAction->setWhatsThis( tr( "Click here if you want to play the current pattern. " "This is useful while editing it. The pattern is " "automatically looped when the end is reached." ) ); - m_stopButton->setToolTip(tr("Stop playing of current pattern (Space)")); - m_stopButton->setWhatsThis( + m_stopAction->setToolTip(tr("Stop playing of current pattern (Space)")); + m_stopAction->setWhatsThis( tr( "Click here if you want to stop playing of the " "current pattern." ) ); diff --git a/src/gui/BBEditor.cpp b/src/gui/BBEditor.cpp index ef3291f32..03499cb87 100644 --- a/src/gui/BBEditor.cpp +++ b/src/gui/BBEditor.cpp @@ -65,8 +65,8 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : } - m_playButton->setToolTip(tr( "Play/pause current beat/bassline (Space)" )); - m_stopButton->setToolTip(tr( "Stop playback of current beat/bassline (Space)" )); + m_playAction->setToolTip(tr( "Play/pause current beat/bassline (Space)" )); + m_stopAction->setToolTip(tr( "Stop playback of current beat/bassline (Space)" )); ToolButton * add_bb_track = new ToolButton( embed::getIconPixmap( "add_bb_track" ), @@ -90,11 +90,11 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : m_trackContainerView, SLOT( addSteps() ), m_toolBar ); - m_playButton->setWhatsThis( + m_playAction->setWhatsThis( tr( "Click here to play the current " "beat/bassline. The beat/bassline is automatically " "looped when its end is reached." ) ); - m_stopButton->setWhatsThis( + m_stopAction->setWhatsThis( tr( "Click here to stop playing of current " "beat/bassline." ) ); @@ -136,7 +136,7 @@ BBEditor::~BBEditor() QSize BBEditor::sizeHint() const { - return {minimumWidth(), 300}; + return {minimumWidth()+10, 300}; } diff --git a/src/gui/Editor.cpp b/src/gui/Editor.cpp index 0e911b960..778a303a9 100644 --- a/src/gui/Editor.cpp +++ b/src/gui/Editor.cpp @@ -36,9 +36,9 @@ void Editor::setPauseIcon(bool displayPauseIcon) { // If we're playing, show a pause icon if (displayPauseIcon) - m_playButton->setIcon(embed::getIconPixmap("pause")); + m_playAction->setIcon(embed::getIconPixmap("pause")); else - m_playButton->setIcon(embed::getIconPixmap("play")); + m_playAction->setIcon(embed::getIconPixmap("play")); } void Editor::play() @@ -59,45 +59,45 @@ void Editor::stop() Editor::Editor(bool record) : m_toolBar(new QToolBar(this)), - m_playButton(nullptr), - m_recordButton(nullptr), - m_recordAccompanyButton(nullptr), - m_stopButton(nullptr) + m_playAction(nullptr), + m_recordAction(nullptr), + m_recordAccompanyAction(nullptr), + m_stopAction(nullptr) { m_toolBar->setContextMenuPolicy(Qt::PreventContextMenu); + m_toolBar->setMovable(false); auto addButton = [this](const char* pixmap_name, QString text, QString objectName) { - ToolButton* button = new ToolButton(embed::getIconPixmap(pixmap_name), text); - button->setObjectName(objectName); - m_toolBar->addWidget(button); - return button; + QAction* action = m_toolBar->addAction(embed::getIconPixmap(pixmap_name), text); + m_toolBar->widgetForAction(action)->setObjectName(objectName); + return action; }; // Set up play button - m_playButton = addButton("play", tr("Play (Space)"), "playButton"); - m_playButton->setShortcut(Qt::Key_Space); + m_playAction = addButton("play", tr("Play (Space)"), "playButton"); + m_playAction->setShortcut(Qt::Key_Space); // Set up record buttons if wanted if (record) { - m_recordButton = addButton("record", tr("Record"), "recordButton"); - m_recordAccompanyButton = addButton("record_accompany", tr("Record while playing"), "recordAccompanyButton"); + m_recordAction = addButton("record", tr("Record"), "recordButton"); + m_recordAccompanyAction = addButton("record_accompany", tr("Record while playing"), "recordAccompanyButton"); } // Set up stop button - m_stopButton = addButton("stop", tr("Stop (Space)"), "stopButton"); + m_stopAction = addButton("stop", tr("Stop (Space)"), "stopButton"); // Add toolbar to window addToolBar(Qt::TopToolBarArea, m_toolBar); // Set up connections - connect(m_playButton, SIGNAL(clicked()), this, SLOT(play())); + connect(m_playAction, SIGNAL(triggered()), this, SLOT(play())); if (record) { - connect(m_recordButton, SIGNAL(clicked()), this, SLOT(record())); - connect(m_recordAccompanyButton, SIGNAL(clicked()), this, SLOT(recordAccompany())); + connect(m_recordAction, SIGNAL(triggered()), this, SLOT(record())); + connect(m_recordAccompanyAction, SIGNAL(triggered()), this, SLOT(recordAccompany())); } - connect(m_stopButton, SIGNAL(clicked()), this, SLOT(stop())); + connect(m_stopAction, SIGNAL(triggered()), this, SLOT(stop())); } Editor::~Editor() diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index 81cb01ae7..8c66eb6f8 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -3978,28 +3978,28 @@ PianoRollWindow::PianoRollWindow() : { setCentralWidget(m_editor); - m_playButton->setToolTip(tr("Play/pause current pattern (Space)")); - m_recordButton->setToolTip(tr("Record notes from MIDI-device/channel-piano")); - m_recordAccompanyButton->setToolTip(tr("Record notes from MIDI-device/channel-piano while playing song or BB track")); - m_stopButton->setToolTip(tr("Stop playing of current pattern (Space)")); + m_playAction->setToolTip(tr("Play/pause current pattern (Space)")); + m_recordAction->setToolTip(tr("Record notes from MIDI-device/channel-piano")); + m_recordAccompanyAction->setToolTip(tr("Record notes from MIDI-device/channel-piano while playing song or BB track")); + m_stopAction->setToolTip(tr("Stop playing of current pattern (Space)")); - m_playButton->setWhatsThis( + m_playAction->setWhatsThis( tr( "Click here to play the current pattern. " "This is useful while editing it. The pattern is " "automatically looped when its end is reached." ) ); - m_recordButton->setWhatsThis( + m_recordAction->setWhatsThis( tr( "Click here to record notes from a MIDI-" "device or the virtual test-piano of the according " "channel-window to the current pattern. When recording " "all notes you play will be written to this pattern " "and you can play and edit them afterwards." ) ); - m_recordAccompanyButton->setWhatsThis( + m_recordAccompanyAction->setWhatsThis( tr( "Click here to record notes from a MIDI-" "device or the virtual test-piano of the according " "channel-window to the current pattern. When recording " "all notes you play will be written to this pattern " "and you will hear the song or BB track in the background." ) ); - m_stopButton->setWhatsThis( + m_stopAction->setWhatsThis( tr( "Click here to stop playback of current pattern." ) ); // init edit-buttons at the top diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index adb6747c8..3b63a4bf0 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -611,13 +611,13 @@ SongEditorWindow::SongEditorWindow(Song* song) : setCentralWidget(m_editor); // Set up buttons - m_playButton->setToolTip(tr("Play song (Space)")); - if (m_recordButton && m_recordAccompanyButton) + m_playAction->setToolTip(tr("Play song (Space)")); + if (m_recordAction && m_recordAccompanyAction) { - m_recordButton->setToolTip(tr("Record samples from Audio-device")); - m_recordAccompanyButton->setToolTip(tr( "Record samples from Audio-device while playing song or BB track")); + m_recordAction->setToolTip(tr("Record samples from Audio-device")); + m_recordAccompanyAction->setToolTip(tr( "Record samples from Audio-device while playing song or BB track")); } - m_stopButton->setToolTip(tr( "Stop song (Space)" )); + m_stopAction->setToolTip(tr( "Stop song (Space)" )); m_addBBTrackButton = new ToolButton( embed::getIconPixmap("add_bb_track"), @@ -649,11 +649,11 @@ SongEditorWindow::SongEditorWindow(Song* song) : tool_button_group->addButton(m_editModeButton); tool_button_group->setExclusive(true); - m_playButton->setWhatsThis( + m_playAction->setWhatsThis( tr("Click here, if you want to play your whole song. " "Playing will be started at the song-position-marker (green). " "You can also move it while playing.")); - m_stopButton->setWhatsThis( + m_stopAction->setWhatsThis( tr("Click here, if you want to stop playing of your song. " "The song-position-marker will be set to the start of your song."));