Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
44b52eb
Add Editor superclass
lukas-w Dec 7, 2014
c6ee614
Clean up ToolButton class
lukas-w Dec 7, 2014
02006f9
Use Editor superclass in AutomationEditor
lukas-w Dec 7, 2014
3e9cc61
SongEditor: Use Editor superclass
lukas-w Dec 7, 2014
86f2c86
Move play, record and stop signals to superclass
lukas-w Dec 7, 2014
d8db894
Editor: Don't delete on close
lukas-w Dec 8, 2014
ec9158c
PianoRoll: Use Editor superclass
lukas-w Dec 8, 2014
e9d841d
Migrate Timeline::addToolButtons to QToolBar
lukas-w Dec 8, 2014
4b27569
ToolBar css fixes
lukas-w Dec 8, 2014
d029c85
BBEditor: Use Editor superclass
lukas-w Dec 8, 2014
11898a5
Move Timeline.cpp to gui directory
lukas-w Dec 8, 2014
7a21d69
SongEditor: Some renames
lukas-w Dec 8, 2014
f131fbd
Editors: Add to workspace in MainWindow class, not in themselves
lukas-w Dec 8, 2014
32da8cb
Editor: Don't use ToolButton
lukas-w Dec 8, 2014
968e581
Editors: Don't use ToolButton
lukas-w Dec 8, 2014
b661e08
PianoRoll: Slot renames
lukas-w Dec 8, 2014
47cbc9e
AutomationEditor + PianoRoll: Move Copy/Paste shortcuts
lukas-w Dec 8, 2014
409e8f2
AutomationEditor style updates
lukas-w Dec 8, 2014
51f5929
Rename Timeline to TimeLineWidget
lukas-w Dec 8, 2014
b25765d
Move Editors to src/gui/editors subdirectory
lukas-w Dec 8, 2014
7c508f7
Merge master into ed_refac
lukas-w Dec 8, 2014
1d07a91
PianoRoll: Coding style updates
lukas-w Dec 11, 2014
ebbec2f
Editor: Add edit mode support
lukas-w Dec 11, 2014
9b6612c
PianoRoll rename fix
lukas-w Dec 11, 2014
02869b1
Editors: Some cleanups
lukas-w Dec 11, 2014
7877888
Introduce ActionGroup subclass
lukas-w Dec 11, 2014
11cb8b5
Automation Editor tension fix
lukas-w Dec 12, 2014
657fb06
More Automation refactoring
lukas-w Dec 17, 2014
eb79701
Merge branch 'master' into ed_refac
lukas-w Dec 17, 2014
1ee9340
Move Engine' GUI code to new GuiApplication class
lukas-w Dec 17, 2014
0df3998
Move some gui initialization to GuiApplication's constructor
lukas-w Jan 6, 2015
834be94
Merge commit 'f7741f184f83e6b9e2f081d39efffb2c499962f6' into ed_refac
lukas-w Jan 6, 2015
1706279
Merge commit '25ab7260f5cc57075360c976826e13434ade058c' into ed_refac
lukas-w Jan 6, 2015
0680669
Merge commit 'b5538c7da818cbcdde5ff1c885ce4eee5b626f3b' into ed_refac
lukas-w Jan 6, 2015
23e0e0f
Merge branch 'master' into ed_refac
lukas-w Jan 6, 2015
0c4833c
Adjust automation editor flip implementation
lukas-w Jan 6, 2015
748cccd
Merge branch 'gui_application' into ed_refac
lukas-w Jan 6, 2015
e0dbfa6
Remove Engine's has_gui option
lukas-w Jan 6, 2015
7f2f9f2
Merge branch 'master' into ed_refac
lukas-w Jan 8, 2015
23dbe95
Stop on second space key press
lukas-w Jan 11, 2015
56055b3
Merge branch 'master' into ed_refac
lukas-w Jan 11, 2015
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
Prev Previous commit
Next Next commit
Introduce ActionGroup subclass
  • Loading branch information
lukas-w committed Dec 11, 2014
commit 787788870b2d76ca32dee42b3b3577c9660f8ff3
57 changes: 57 additions & 0 deletions include/ActionGroup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Editor.h - declaration of Editor class
*
* Copyright (c) 2014 Lukas W <lukaswhl/at/gmail.com>
*
* This file is part of LMMS - http://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/


#ifndef ACTION_GROUP_H
#define ACTION_GROUP_H

#include <QActionGroup>

/// \brief Convenience subclass of QActionGroup
///
/// This class provides the same functionality as QActionGroup, but in addition
/// has the actionTriggered(int) signal.
/// It also sets every added action's checkable property to true.
class ActionGroup : public QActionGroup
{
Q_OBJECT
public:
ActionGroup(QObject* parent);

QAction* addAction(QAction *a);
QAction* addAction(const QString &text);
QAction* addAction(const QIcon &icon, const QString &text);

signals:
/// This signal is emitted when the action at the given index is triggered.
void triggered(int index);

private slots:
void actionTriggered_(QAction* action);

private:
QList<QAction*> m_actions;
};

#endif
4 changes: 1 addition & 3 deletions include/AutomationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ protected slots:
void setEditMode(int mode);

void setProgressionType(AutomationPattern::ProgressionTypes type);
void setProgressionDiscrete();
void setProgressionLinear();
void setProgressionHermite();
void setProgressionType(int type);
void setTension();

void copySelectedValues();
Expand Down
26 changes: 4 additions & 22 deletions include/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
#include "TimeLineWidget.h"
#include "ToolButton.h"

// Forward declarations
class QActionGroup;

/// \brief Superclass for editors with a toolbar.
///
/// Those editors include the Song Editor, the Automation Editor, B&B Editor,
Expand All @@ -45,23 +42,11 @@ class Editor : public QMainWindow
public:
void setPauseIcon(bool displayPauseIcon=true);

int editMode() const;
void setEditMode(int mode);

signals:
void editModeChanged(int);

protected:
QAction* addEditMode(const QIcon &icon, const QString &text, const QString& whatsThis=QString());

protected slots:
virtual void play();
virtual void record();
virtual void recordAccompany();
virtual void stop();

private slots:
void setEditModeByAction(QAction* action);
virtual void play() {}
virtual void record() {}
virtual void recordAccompany() {}
virtual void stop() {}

signals:

Expand All @@ -80,9 +65,6 @@ private slots:
QAction* m_recordAction;
QAction* m_recordAccompanyAction;
QAction* m_stopAction;
private:
quint8 m_editMode;
QActionGroup* m_editModeGroup;
};


Expand Down
55 changes: 55 additions & 0 deletions src/gui/ActionGroup.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Editor.h - declaration of Editor class
*
* Copyright (c) 2014 Lukas W <lukaswhl/at/gmail.com>
*
* This file is part of LMMS - http://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/

#include "ActionGroup.h"

ActionGroup::ActionGroup(QObject* parent) : QActionGroup(parent)
{
connect(this, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered_(QAction*)));
}

QAction* ActionGroup::addAction(QAction* a)
{
a->setCheckable(true);

return QActionGroup::addAction(a);
}

QAction* ActionGroup::addAction(const QString& text)
{
return addAction(new QAction(text, this));
}

QAction* ActionGroup::addAction(const QIcon& icon, const QString& text)
{
return addAction(new QAction(icon, text, this));
}

void ActionGroup::actionTriggered_(QAction* action)
{
Q_ASSERT(action != 0);
Q_ASSERT(actions().contains(action));

emit triggered(actions().indexOf(action));
}
55 changes: 19 additions & 36 deletions src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#include <math.h>


#include "ActionGroup.h"
#include "SongEditor.h"
#include "MainWindow.h"
#include "embed.h"
Expand Down Expand Up @@ -1643,22 +1643,9 @@ void AutomationEditor::setProgressionType(AutomationPattern::ProgressionTypes ty
}
}


void AutomationEditor::setProgressionDiscrete()
{
setProgressionType(AutomationPattern::DiscreteProgression);
}


void AutomationEditor::setProgressionLinear()
{
setProgressionType(AutomationPattern::LinearProgression);
}


void AutomationEditor::setProgressionHermite()
void AutomationEditor::setProgressionType(int type)
{
setProgressionType(AutomationPattern::CubicHermiteProgression);
setProgressionType((AutomationPattern::ProgressionTypes) type);
}


Expand Down Expand Up @@ -2005,17 +1992,18 @@ AutomationEditorWindow::AutomationEditorWindow() :
"current pattern." ) );

// Edit mode buttons
QAction* drawAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)"));
ActionGroup* editModeGroup = new ActionGroup(this);
QAction* drawAction = editModeGroup->addAction(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)"));
drawAction->setShortcut(Qt::SHIFT | Qt::Key_D);

QAction* eraseAction = addEditMode(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)"));
QAction* eraseAction = editModeGroup->addAction(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)"));
eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E);

drawAction->setChecked(true);

// TODO: m_selectButton and m_moveButton are broken.
// m_selectButton = addEditMode(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)"));
// m_moveButton = addEditMode(embed::getIconPixmap("edit_move"), tr("Move selection mode (Shift+M)"));
// m_selectButton = new QAction(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)"), editModeGroup);
// m_moveButton = new QAction(embed::getIconPixmap("edit_move"), tr("Move selection mode (Shift+M)"), editModeGroup);

drawAction->setWhatsThis(
tr( "Click here and draw-mode will be activated. In this "
Expand All @@ -2039,26 +2027,21 @@ AutomationEditorWindow::AutomationEditorWindow() :
"mode. You can also press 'Shift+M' on your keyboard "
"to activate this mode." ) );*/

connect(this, SIGNAL(editModeChanged(int)), m_editor, SLOT(setEditMode(int)));
connect(editModeGroup, SIGNAL(triggered(int)), m_editor, SLOT(setEditMode(int)));

// Progression type buttons
QActionGroup* progression_type_group = new QActionGroup(this);

m_discreteAction = new QAction(embed::getIconPixmap("progression_discrete"),
tr("Discrete progression"), progression_type_group);
m_linearAction = new QAction(embed::getIconPixmap("progression_linear"),
tr("Linear progression"), progression_type_group);
m_cubicHermiteAction = new QAction(embed::getIconPixmap("progression_cubic_hermite"),
tr( "Cubic Hermite progression"), progression_type_group);

m_linearAction->setCheckable( true );
m_cubicHermiteAction->setCheckable( true );
m_discreteAction->setCheckable( true );
ActionGroup* progression_type_group = new ActionGroup(this);

m_discreteAction = progression_type_group->addAction(
embed::getIconPixmap("progression_discrete"), tr("Discrete progression"));
m_linearAction = progression_type_group->addAction(
embed::getIconPixmap("progression_linear"), tr("Linear progression"));
m_cubicHermiteAction = progression_type_group->addAction(
embed::getIconPixmap("progression_cubic_hermite"), tr( "Cubic Hermite progression"));

m_discreteAction->setChecked( true );

connect(m_discreteAction, SIGNAL(triggered()), m_editor, SLOT(setProgressionDiscrete()));
connect(m_linearAction, SIGNAL(triggered()), m_editor, SLOT(setProgressionLinear()));
connect(m_cubicHermiteAction, SIGNAL(triggered()), m_editor, SLOT(setProgressionHermite()));
connect(progression_type_group, SIGNAL(triggered(int)), m_editor, SLOT(setProgressionType(int)));

// setup tension-stuff
m_tensionKnob = new Knob( knobSmall_17, this, "Tension" );
Expand Down
52 changes: 1 addition & 51 deletions src/gui/editors/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,59 +41,12 @@ void Editor::setPauseIcon(bool displayPauseIcon)
m_playAction->setIcon(embed::getIconPixmap("play"));
}

int Editor::editMode() const
{
return m_editMode;
}

void Editor::setEditMode(int mode)
{
if (mode <= m_editModeGroup->actions().size())
{
m_editMode = mode;
}
emit(editModeChanged(mode));
}

QAction* Editor::addEditMode(const QIcon& icon, const QString& text, const QString& whatsThis)
{
QAction* editModeAction = new QAction(icon, text, m_editModeGroup);
editModeAction->setWhatsThis(whatsThis);
editModeAction->setCheckable(true);
return editModeAction;
}

void Editor::play()
{
}

void Editor::record()
{
}

void Editor::recordAccompany()
{
}

void Editor::stop()
{
}

void Editor::setEditModeByAction(QAction* action)
{
int index = m_editModeGroup->actions().indexOf(action);
if (index != -1)
setEditMode(index);
}

Editor::Editor(bool record) :
m_toolBar(new QToolBar(this)),
m_playAction(nullptr),
m_recordAction(nullptr),
m_recordAccompanyAction(nullptr),
m_stopAction(nullptr),
m_editMode(0),
m_editModeGroup(new QActionGroup(this))
m_stopAction(nullptr)
{
m_toolBar->setContextMenuPolicy(Qt::PreventContextMenu);
m_toolBar->setMovable(false);
Expand All @@ -118,9 +71,6 @@ Editor::Editor(bool record) :
connect(m_recordAccompanyAction, SIGNAL(triggered()), this, SLOT(recordAccompany()));
connect(m_stopAction, SIGNAL(triggered()), this, SLOT(stop()));

// Connect edit mode
connect(m_editModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(setEditModeByAction(QAction*)));

// Add toolbar to window
addToolBar(Qt::TopToolBarArea, m_toolBar);

Expand Down
17 changes: 9 additions & 8 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <math.h>
#include <algorithm>

#include "ActionGroup.h"
#include "ConfigManager.h"
#include "PianoRoll.h"
#include "BBTrackContainer.h"
Expand Down Expand Up @@ -3939,17 +3940,17 @@ PianoRollWindow::PianoRollWindow() :
tr( "Click here to stop playback of current pattern." ) );

// init edit-buttons at the top
QAction* drawAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)"));
drawAction->setShortcut(Qt::SHIFT | Qt::Key_D);
ActionGroup* editModeGroup = new ActionGroup(this);
QAction* drawAction = editModeGroup->addAction(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)"));
QAction* eraseAction = editModeGroup->addAction(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)"));
QAction* selectAction = editModeGroup->addAction(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)"));
QAction* detuneAction = editModeGroup->addAction(embed::getIconPixmap("automation"), tr("Detune mode (Shift+T)"));

drawAction->setChecked( true );

QAction* eraseAction = addEditMode(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)"));
drawAction->setShortcut(Qt::SHIFT | Qt::Key_D);
eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E);

QAction* selectAction = addEditMode(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)"));
selectAction->setShortcut(Qt::SHIFT | Qt::Key_S);

QAction* detuneAction = addEditMode(embed::getIconPixmap("automation"), tr("Detune mode (Shift+T)"));
detuneAction->setShortcut(Qt::SHIFT | Qt::Key_T);

drawAction->setWhatsThis(
Expand All @@ -3975,7 +3976,7 @@ PianoRollWindow::PianoRollWindow() :
"notes from one to another. You can also press "
"'Shift+T' on your keyboard to activate this mode." ) );

connect(this, SIGNAL(editModeChanged(int)), m_editor, SLOT(setEditMode(int)));
connect(editModeGroup, SIGNAL(triggered(int)), m_editor, SLOT(setEditMode(int)));

// Copy + paste actions
QAction* cutAction = new QAction(embed::getIconPixmap("edit_cut"),
Expand Down
Loading