Skip to content

More shortcuts! #177

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ project is compiled with with _catkin_.
rosdep install --from-paths src --ignore-src
catkin_make

# Shortcuts
| Key | Action |
| :-: | :-: |
| CTRL-S | Save Tree |
| CTRL-L | Load Tree |
| CTRL-O | Load Tree |
| CTRL-Z | Undo |
| CTRL-Y | Redo |
| CTRL-SHIFT-Z | Redo |
| CTRL-A | Reorder (Arrange) Nodes |
| R | Reorder (Arrange) Nodes |
| L | Toggle Layout |
| C | Center View |
| N | New Node |
| + | Zoom In |
| - | Zoom Out |

# Licence

Copyright (c) 2018-2019 FUNDACIO EURECAT
Expand Down
10 changes: 10 additions & 0 deletions bt_editor/graphic_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ void GraphicContainer::zoomHomeView()
_view->scale(0.9, 0.9);
}

void GraphicContainer::zoomIn()
{
_view->scale(1.1, 1.1);
}

void GraphicContainer::zoomOut()
{
_view->scale(0.9, 0.9);
}

bool GraphicContainer::containsValidTree() const
{
if( _scene->nodes().empty())
Expand Down
4 changes: 4 additions & 0 deletions bt_editor/graphic_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class GraphicContainer : public QObject

void zoomHomeView();

void zoomIn();

void zoomOut();

bool containsValidTree() const;

void clearScene();
Expand Down
64 changes: 57 additions & 7 deletions bt_editor/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,57 @@ MainWindow::MainWindow(GraphicMode initial_mode, QWidget *parent) :
ui->actionMonitor_mode->setVisible(false);
#endif

_load_shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_L), this);
updateCurrentMode();

dynamic_cast<QVBoxLayout*>(ui->leftFrame->layout())->setStretch(1,1);

auto arrange_shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_A), this);

connect( arrange_shortcut, &QShortcut::activated,
this, &MainWindow::onAutoArrange );

ui->splitter->setStretchFactor(0, 1);
ui->splitter->setStretchFactor(1, 4);

// Shortcuts
QShortcut* arrange_shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_A), this);
QShortcut* rearrange_shortcut = new QShortcut(QKeySequence(Qt::Key_R), this);
QShortcut* centerview_shortcut = new QShortcut(QKeySequence(Qt::Key_C), this);
QShortcut* layout_shortcut = new QShortcut(QKeySequence(Qt::Key_L), this);
QShortcut* newnode_shortcut = new QShortcut(QKeySequence(Qt::Key_N), this);

connect( arrange_shortcut, &QShortcut::activated,
this, &MainWindow::onAutoArrange );
connect( rearrange_shortcut, &QShortcut::activated,
this, &MainWindow::onAutoArrange );
connect( centerview_shortcut, &QShortcut::activated,
this, &MainWindow::on_toolButtonCenterView_pressed );
connect( layout_shortcut, &QShortcut::activated,
this, &MainWindow::on_toolButtonLayout_clicked );
connect( newnode_shortcut, &QShortcut::activated,
_editor_widget, &SidepanelEditor::addNode );

QShortcut* zoomin_shortcut = new QShortcut(QKeySequence(Qt::Key_Plus), this);
QShortcut* zoomout_shortcut = new QShortcut(QKeySequence(Qt::Key_Minus), this);

connect( zoomin_shortcut, &QShortcut::activated,
this, [this] () { currentTabInfo()->zoomIn(); } );
connect( zoomout_shortcut, &QShortcut::activated,
this, [this] () { currentTabInfo()->zoomOut(); } );

QShortcut* undo_shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z), this);
connect( undo_shortcut, &QShortcut::activated, this, &MainWindow::onUndoInvoked );

QShortcut* redo_shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z), this);
connect( redo_shortcut, &QShortcut::activated, this, &MainWindow::onRedoInvoked );

QShortcut* save_shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S), this);
connect( save_shortcut, &QShortcut::activated, this, &MainWindow::on_actionSave_triggered );

QShortcut* load_shortcut_option = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_O), this);
connect(load_shortcut_option, &QShortcut::activated, _load_shortcut, &QShortcut::activated);

QShortcut* redo_shortcut_option = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Y), this);
connect(redo_shortcut_option, &QShortcut::activated, redo_shortcut, &QShortcut::activated);


// Other connections
connect( _editor_widget, &SidepanelEditor::nodeModelEdited,
this, &MainWindow::onTreeNodeEdited);

Expand Down Expand Up @@ -178,8 +209,6 @@ MainWindow::MainWindow(GraphicMode initial_mode, QWidget *parent) :
connect( ui->toolButtonSaveFile, &QToolButton::clicked,
this, &MainWindow::on_actionSave_triggered );

connect( save_shortcut, &QShortcut::activated, this, &MainWindow::on_actionSave_triggered );

connect( _replay_widget, &SidepanelReplay::changeNodeStyle,
this, &MainWindow::onChangeNodesStatus);

Expand Down Expand Up @@ -1278,18 +1307,39 @@ void MainWindow::updateCurrentMode()

if( _current_mode == GraphicMode::EDITOR )
{
// Load Button
connect( ui->toolButtonLoadFile, &QToolButton::clicked,
this, &MainWindow::on_actionLoad_triggered );
disconnect( ui->toolButtonLoadFile, &QToolButton::clicked,
_replay_widget, &SidepanelReplay::on_LoadLog );
// Load Shortcut
disconnect( _load_shortcut, &QShortcut::activated,
_replay_widget, &SidepanelReplay::on_LoadLog);
connect( _load_shortcut, &QShortcut::activated,
this, &MainWindow::on_actionLoad_triggered );
}
else if( _current_mode == GraphicMode::REPLAY )
{
// Load Button
disconnect( ui->toolButtonLoadFile, &QToolButton::clicked,
this, &MainWindow::on_actionLoad_triggered );
connect( ui->toolButtonLoadFile, &QToolButton::clicked,
_replay_widget, &SidepanelReplay::on_LoadLog );
// Load Shortcut
disconnect( _load_shortcut, &QShortcut::activated,
this, &MainWindow::on_actionLoad_triggered );
connect( _load_shortcut, &QShortcut::activated,
_replay_widget, &SidepanelReplay::on_LoadLog);
}
else if( _current_mode == GraphicMode::MONITOR )
{
// Load Shortcut
disconnect( _load_shortcut, &QShortcut::activated,
this, &MainWindow::on_actionLoad_triggered );
disconnect( _load_shortcut, &QShortcut::activated,
_replay_widget, &SidepanelReplay::on_LoadLog);
}

lockEditing( NOT_EDITOR );

if( _current_mode == GraphicMode::EDITOR)
Expand Down
4 changes: 3 additions & 1 deletion bt_editor/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ private slots:
#ifdef ZMQ_FOUND
SidepanelMonitor* _monitor_widget;
#endif


QShortcut* _load_shortcut;

MainWindow::SavedState saveCurrentState();
void clearUndoStacks();
};
Expand Down
27 changes: 16 additions & 11 deletions bt_editor/sidepanel_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ void SidepanelEditor::clear()

}

void SidepanelEditor::addNode()
{
CustomNodeDialog dialog(_tree_nodes_model, QString(), this);
if( dialog.exec() == QDialog::Accepted)
{
auto new_model = dialog.getTreeNodeModel();
if( new_model.type == NodeType::SUBTREE )
{
emit addSubtree( new_model.registration_ID );
}
emit addNewModel( new_model );
}
updateTreeView();
}

void SidepanelEditor::on_paletteTreeWidget_itemSelectionChanged()
{
auto selected_items = ui->paletteTreeWidget->selectedItems();
Expand Down Expand Up @@ -150,17 +165,7 @@ void SidepanelEditor::on_lineEditFilter_textChanged(const QString &text)

void SidepanelEditor::on_buttonAddNode_clicked()
{
CustomNodeDialog dialog(_tree_nodes_model, QString(), this);
if( dialog.exec() == QDialog::Accepted)
{
auto new_model = dialog.getTreeNodeModel();
if( new_model.type == NodeType::SUBTREE )
{
emit addSubtree( new_model.registration_ID );
}
emit addNewModel( new_model );
}
updateTreeView();
addNode();
}

void SidepanelEditor::onRemoveModel(QString selected_name)
Expand Down
2 changes: 2 additions & 0 deletions bt_editor/sidepanel_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class SidepanelEditor : public QFrame

void clear();

void addNode();

public slots:
void onRemoveModel(QString selected_name);

Expand Down