Skip to content

Commit

Permalink
[PERFECTIVE] Included information about shortcuts to tooltips for the…
Browse files Browse the repository at this point in the history
… actions that have shortcuts and were already implemented with tooltip (so there are some short cut actions left with undone tooltips because they have not had tooltip before).
  • Loading branch information
VasiliiFeshchenko committed Jul 15, 2024
1 parent e9507d5 commit 6d2b34c
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 73 deletions.
16 changes: 9 additions & 7 deletions common/views/EditableListView/editablelistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,21 @@ void EditableListView::setupActions()
{
addAction(&addAction_);
addAction_.setEnabled(true);
addAction_.setToolTip(tr("Add a new item to list"));
addAction_.setStatusTip(tr("Add a new item to list"));
addAction_.setShortcut(QKeySequence::InsertLineSeparator);
addAction_.setShortcut(QKeySequence::InsertLineSeparator);
addAction_.setShortcutContext(Qt::WidgetShortcut);
connect(&addAction_, SIGNAL(triggered()), this, SLOT(onAddAction()), Qt::UniqueConnection);
QString tooltipAdd = tr("Add a new item to list (Shortcut: %1)").arg(addAction_.shortcut().toString(QKeySequence::NativeText));
addAction_.setToolTip(tooltipAdd);
addAction_.setStatusTip(tooltipAdd);
connect(&addAction_, SIGNAL(triggered()), this, SLOT(onAddAction()), Qt::UniqueConnection);

addAction(&removeAction_);
removeAction_.setEnabled(true);
removeAction_.setToolTip(tr("Remove an item from the list"));
removeAction_.setStatusTip(tr("Remove an item from the list"));
removeAction_.setShortcut(QKeySequence::Delete);
removeAction_.setShortcutContext(Qt::WidgetShortcut);
connect(&removeAction_, SIGNAL(triggered()), this, SLOT(onRemoveAction()), Qt::UniqueConnection);
QString tooltipRemove = tr("Remove an item from the list (Shortcut: %1)").arg(removeAction_.shortcut().toString(QKeySequence::NativeText));
removeAction_.setToolTip(tooltipRemove);
removeAction_.setStatusTip(tooltipRemove);
connect(&removeAction_, SIGNAL(triggered()), this, SLOT(onRemoveAction()), Qt::UniqueConnection);
}

//-----------------------------------------------------------------------------
Expand Down
45 changes: 29 additions & 16 deletions common/views/EditableTableView/editabletableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,52 +865,65 @@ void EditableTableView::setModel(QAbstractItemModel* model)
//-----------------------------------------------------------------------------
void EditableTableView::setupActions()
{
QList<QKeySequence> addRowShortcuts{
QKeySequence::InsertLineSeparator,
QKeySequence(Qt::SHIFT | Qt::Key_Return)
QList<QKeySequence> addRowShortcuts{
QKeySequence::InsertLineSeparator,
QKeySequence(Qt::SHIFT | Qt::Key_Return)
};

addAction(&addAction_);
addAction_.setToolTip(tr("Add a new row to table"));
addAction_.setStatusTip(tr("Add a new row to table"));
addAction_.setShortcuts(addRowShortcuts);
addAction_.setShortcutContext(Qt::WidgetShortcut);
QString tooltipAddRow = tr("Add a new row to table (Shortcuts: %1, %2)")
.arg(addAction_.shortcuts().at(0).toString(QKeySequence::NativeText))
.arg(addAction_.shortcuts().at(1).toString(QKeySequence::NativeText));
addAction_.setToolTip(tooltipAddRow);
addAction_.setStatusTip(tooltipAddRow);
connect(&addAction_, SIGNAL(triggered()), this, SLOT(onAddAction()), Qt::UniqueConnection);

addAction(&removeAction_);
removeAction_.setToolTip(tr("Remove a row from the table"));
removeAction_.setStatusTip(tr("Remove a row from the table"));
removeAction_.setShortcut(Qt::SHIFT | Qt::Key_Delete);
removeAction_.setShortcutContext(Qt::WidgetShortcut);
QString tooltipRemoveRow = tr("Remove a row from the table (Shortcut: %1)")
.arg(removeAction_.shortcut().toString(QKeySequence::NativeText));
removeAction_.setToolTip(tooltipRemoveRow);
removeAction_.setStatusTip(tooltipRemoveRow);
connect(&removeAction_, SIGNAL(triggered()), this, SLOT(onRemoveAction()), Qt::UniqueConnection);

addAction(&cutAction_);
cutAction_.setToolTip(tr("Cut the contents of a cell from the table"));
cutAction_.setStatusTip(tr("Cut the contents of a cell from the table"));
cutAction_.setShortcut(QKeySequence::Cut);
cutAction_.setShortcutContext(Qt::WidgetShortcut);
QString tooltipCut = tr("Cut the contents of a cell from the table (Shortcut: %1)")
.arg(cutAction_.shortcut().toString(QKeySequence::NativeText));
cutAction_.setToolTip(tooltipCut);
cutAction_.setStatusTip(tooltipCut);
connect(&cutAction_, SIGNAL(triggered()), this, SLOT(onCutAction()), Qt::UniqueConnection);

addAction(&copyAction_);
copyAction_.setToolTip(tr("Copy the contents of a cell from the table"));
copyAction_.setStatusTip(tr("Copy the contents of a cell from the table"));
copyAction_.setShortcut(QKeySequence::Copy);
copyAction_.setShortcutContext(Qt::WidgetShortcut);
QString tooltipCopy = tr("Copy the contents of a cell from the table (Shortcut: %1)")
.arg(copyAction_.shortcut().toString(QKeySequence::NativeText));
copyAction_.setToolTip(tooltipCopy);
copyAction_.setStatusTip(tooltipCopy);
connect(&copyAction_, SIGNAL(triggered()), this, SLOT(onCopyAction()), Qt::UniqueConnection);

addAction(&pasteAction_);
pasteAction_.setToolTip(tr("Paste the contents of a cell to the table"));
pasteAction_.setStatusTip(tr("Paste the contents of a cell to the table"));
pasteAction_.setShortcut(QKeySequence::Paste);
pasteAction_.setShortcutContext(Qt::WidgetShortcut);
QString tooltipPaste = tr("Paste the contents of a cell to the table (Shortcut: %1)")
.arg(pasteAction_.shortcut().toString(QKeySequence::NativeText));
pasteAction_.setToolTip(tooltipPaste);
pasteAction_.setStatusTip(tooltipPaste);
connect(&pasteAction_, SIGNAL(triggered()), this, SLOT(onPasteAction()), Qt::UniqueConnection);

addAction(&clearAction_);
clearAction_.setToolTip(tr("Clear the contents of a cell"));
clearAction_.setStatusTip(tr("Clear the contents of a cell"));
clearAction_.setShortcut(QKeySequence::Delete);
clearAction_.setShortcutContext(Qt::WidgetShortcut);
connect(&clearAction_, SIGNAL(triggered()), this, SLOT(onClearAction()), Qt::UniqueConnection);
QString tooltipClear = tr("Clear the contents of a cell (Shortcut: %1)")
.arg(clearAction_.shortcut().toString(QKeySequence::NativeText));
clearAction_.setToolTip(tooltipClear);
clearAction_.setStatusTip(tooltipClear);
connect(&clearAction_, SIGNAL(triggered()), this, SLOT(onClearAction()), Qt::UniqueConnection);

addAction(&importAction_);
importAction_.setToolTip(tr("Import a csv-file to table"));
Expand Down
5 changes: 3 additions & 2 deletions common/views/EditableTreeView/EditableTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ void EditableTreeView::setupActions(QString const& addItemText, QString const& a
removeAction_->setStatusTip(removeItemText);
removeAllSubItemsAction_->setToolTip(removeSubItemsText);
removeAllSubItemsAction_->setStatusTip(removeSubItemsText);
clearAction_->setToolTip(tr("Clear the contents of a cell."));
clearAction_->setStatusTip(tr("Clear the contents of a cell."));

expandAllItemsAction_->setToolTip(tr("Expand all port maps."));
expandAllItemsAction_->setStatusTip(tr("Expand all port maps."));
Expand All @@ -66,6 +64,9 @@ void EditableTreeView::setupActions(QString const& addItemText, QString const& a
addAction(clearAction_);
clearAction_->setShortcut(QKeySequence::Delete);
clearAction_->setShortcutContext(Qt::WidgetShortcut);
QString tooltipClear = tr("Clear the contents of a cell (Shortcut: %1)").arg(clearAction_->shortcut().toString(QKeySequence::NativeText));
clearAction_->setToolTip(tooltipClear);
clearAction_->setStatusTip(tooltipClear);

connectActions();
}
Expand Down
46 changes: 27 additions & 19 deletions editors/PythonSourceEditor/PythonSourceEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,61 +389,69 @@ void PythonSourceEditor::setupToolbar(bool enableRun)
toolBar_.setOrientation(Qt::Horizontal);
toolBar_.setIconSize(QSize(20, 20));

QAction* newAction = toolBar_.addAction(QIcon(":/icons/common/graphics/script-new.png"), QString(),
this, SLOT(onNewAction()));
newAction->setToolTip(tr("New script (Ctrl+N)"));
QAction* newAction = toolBar_.addAction(QIcon(":/icons/common/graphics/script-new.png"), QString(), this, SLOT(onNewAction()));
newAction->setShortcut(QKeySequence::New);
newAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
QString tooltipNew = tr("New script (Shortcut: %1)").arg(newAction->shortcut().toString(QKeySequence::NativeText));
newAction->setToolTip(tooltipNew);
newAction->setStatusTip(tooltipNew);
addAction(newAction);

QAction* openAction = toolBar_.addAction(QIcon(":/icons/common/graphics/opened-folder.png"), QString(),
this, SLOT(onOpenAction()));
openAction->setToolTip(tr("Open script from file... (Ctrl+O)"));
QAction* openAction = toolBar_.addAction(QIcon(":/icons/common/graphics/opened-folder.png"), QString(), this, SLOT(onOpenAction()));
openAction->setShortcut(QKeySequence::Open);
openAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
QString tooltipOpen = tr("Open script from file... (Shortcut: %1)").arg(openAction->shortcut().toString(QKeySequence::NativeText));
openAction->setToolTip(tooltipOpen);
openAction->setStatusTip(tooltipOpen);
addAction(openAction);

QAction* saveAction = toolBar_.addAction(QIcon(":/icons/common/graphics/script-save.png"), QString(),
this, SLOT(onSaveAction()));
saveAction->setToolTip(tr("Save script (Ctrl+S"));
QAction* saveAction = toolBar_.addAction(QIcon(":/icons/common/graphics/script-save.png"), QString(), this, SLOT(onSaveAction()));
saveAction->setShortcut(QKeySequence::Save);
saveAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
QString tooltipSave = tr("Save script (Shortcut: %1)").arg(saveAction->shortcut().toString(QKeySequence::NativeText));
saveAction->setToolTip(tooltipSave);
saveAction->setStatusTip(tooltipSave);
addAction(saveAction);

QAction* saveAsAction = toolBar_.addAction(QIcon(":/icons/common/graphics/script-save-as.png"), QString(),
this, SLOT(onSaveAsAction()));
QAction* saveAsAction = toolBar_.addAction(QIcon(":/icons/common/graphics/script-save-as.png"), QString(), this, SLOT(onSaveAsAction()));
saveAsAction->setToolTip(tr("Save script as..."));
addAction(saveAsAction);

toolBar_.addSeparator();

undoAction_ = toolBar_.addAction(QIcon(":/icons/common/graphics/edit-undo.png"), QString());
undoAction_->setToolTip(tr("Undo (Ctrl+Z)"));
undoAction_->setShortcut(QKeySequence::Undo);
undoAction_->setShortcutContext(Qt::WidgetWithChildrenShortcut);
QString tooltipUndo = tr("Undo (Shortcut: %1)").arg(undoAction_->shortcut().toString(QKeySequence::NativeText));
undoAction_->setToolTip(tooltipUndo);
undoAction_->setStatusTip(tooltipUndo);
addAction(undoAction_);

redoAction_ = toolBar_.addAction(QIcon(":/icons/common/graphics/edit-redo.png"), QString());
redoAction_->setToolTip(tr("Redo (Ctrl+Y)"));
redoAction_->setShortcut(QKeySequence::Redo);
redoAction_->setShortcutContext(Qt::WidgetWithChildrenShortcut);
QString tooltipRedo = tr("Redo (Shortcut: %1)").arg(redoAction_->shortcut().toString(QKeySequence::NativeText));
redoAction_->setToolTip(tooltipRedo);
redoAction_->setStatusTip(tooltipRedo);
addAction(redoAction_);

toolBar_.addSeparator();

QAction* runAction = toolBar_.addAction(QIcon(":/icons/common/graphics/control-play.png"), QString(),
this, SLOT(onRunAction()));
runAction->setToolTip(tr("Run selected line(s) (Ctrl+R)"));
QAction* runAction = toolBar_.addAction(QIcon(":/icons/common/graphics/control-play.png"), QString(), this, SLOT(onRunAction()));
runAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R));
runAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
QString tooltipRun = tr("Run selected line(s) (Shortcut: %1)").arg(runAction->shortcut().toString(QKeySequence::NativeText));
runAction->setToolTip(tooltipRun);
runAction->setStatusTip(tooltipRun);
runAction->setEnabled(enableRun);
addAction(runAction);

QAction* runAllAction = toolBar_.addAction(QIcon(":/icons/common/graphics/script-run-all.png"), QString(),
this, SLOT(onRunAllAction()));
runAllAction->setToolTip(tr("Run all (Ctrl+Shift+R)"));
QAction* runAllAction = toolBar_.addAction(QIcon(":/icons/common/graphics/script-run-all.png"), QString(), this, SLOT(onRunAllAction()));
runAllAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_R));
runAllAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
QString tooltipRunAll = tr("Run all (Shortcut: %1)").arg(runAllAction->shortcut().toString(QKeySequence::NativeText));
runAllAction->setToolTip(tooltipRunAll);
runAllAction->setStatusTip(tooltipRunAll);
runAllAction->setEnabled(enableRun);
addAction(runAllAction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,31 @@ void AutoConnectorConnectionTable::setupActions()
addRowShortcuts << QKeySequence::InsertLineSeparator << QKeySequence(Qt::SHIFT | Qt::Key_Return);

addAction(addRowAction_);
addRowAction_->setToolTip(tr("Add a new row to table"));
addRowAction_->setStatusTip(tr("Add a new row to table"));
addRowAction_->setShortcuts(addRowShortcuts);
addRowAction_->setShortcutContext(Qt::WidgetShortcut);
QString tooltipAddRow = tr("Add a new row to table (Shortcuts: %1, %2)")
.arg(addRowAction_->shortcuts().at(0).toString(QKeySequence::NativeText))
.arg(addRowAction_->shortcuts().at(1).toString(QKeySequence::NativeText));
addRowAction_->setToolTip(tooltipAddRow);
addRowAction_->setStatusTip(tooltipAddRow);
connect(addRowAction_, SIGNAL(triggered()), this, SLOT(onAddRow()), Qt::UniqueConnection);

addAction(removeRowAction_);
removeRowAction_->setToolTip(tr("Remove a connection from the table"));
removeRowAction_->setStatusTip(tr("Remove a connection from the table"));
removeRowAction_->setShortcut(Qt::SHIFT | Qt::Key_Delete);
removeRowAction_->setShortcutContext(Qt::WidgetShortcut);
QString tooltipRemoveRow = tr("Remove a connection from the table (Shortcut: %1)")
.arg(removeRowAction_->shortcut().toString(QKeySequence::NativeText));
removeRowAction_->setToolTip(tooltipRemoveRow);
removeRowAction_->setStatusTip(tooltipRemoveRow);
connect(removeRowAction_, SIGNAL(triggered()), this, SLOT(onRemoveRow()), Qt::UniqueConnection);

addAction(clearAction_);
clearAction_->setToolTip(tr("Clear the contents of a cell"));
clearAction_->setStatusTip(tr("Clear the contents of a cell"));
clearAction_->setShortcut(QKeySequence::Delete);
clearAction_->setShortcutContext(Qt::WidgetShortcut);
QString tooltipClear = tr("Clear the contents of a cell (Shortcut: %1)")
.arg(clearAction_->shortcut().toString(QKeySequence::NativeText));
clearAction_->setToolTip(tooltipClear);
clearAction_->setStatusTip(tooltipClear);
connect(clearAction_, SIGNAL(triggered()), this, SLOT(onClearCells()), Qt::UniqueConnection);
}

Expand Down
Loading

0 comments on commit 6d2b34c

Please sign in to comment.