Skip to content

Commit

Permalink
Simplified some QMenu::addAction calls
Browse files Browse the repository at this point in the history
This new signature is available since Qt 5.6.
  • Loading branch information
bjorn committed Mar 18, 2020
1 parent d3badef commit 079ab20
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
21 changes: 7 additions & 14 deletions src/tiled/commanddatamodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,27 +284,20 @@ QMenu *CommandDataModel::contextMenu(QWidget *parent, const QModelIndex &index)
if (row >= 0 && row < mCommands.size()) {
menu = new QMenu(parent);

if (row > 0) {
connect(menu->addAction(tr("Move Up")), &QAction::triggered,
[=] { moveUp(row); });
}
if (row > 0)
menu->addAction(tr("Move Up"), [=] { moveUp(row); });

if (row + 1 < mCommands.size()) {
connect(menu->addAction(tr("Move Down")), &QAction::triggered,
[=] { moveUp(row + 1); });
}
if (row + 1 < mCommands.size())
menu->addAction(tr("Move Down"), [=] { moveUp(row + 1); });

menu->addSeparator();
connect(menu->addAction(tr("Execute")), &QAction::triggered,
[=] { execute(row); });
menu->addAction(tr("Execute"), [=] { execute(row); });
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
connect(menu->addAction(tr("Execute in Terminal")), &QAction::triggered,
[=] { executeInTerminal(row); });
menu->addAction(tr("Execute in Terminal"), [=] { executeInTerminal(row); });
#endif

menu->addSeparator();
connect(menu->addAction(tr("Delete")), &QAction::triggered,
[=] { remove(row); });
menu->addAction(tr("Delete"), [=] { remove(row); });
}

return menu;
Expand Down
4 changes: 2 additions & 2 deletions src/tiled/tilesetdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,8 @@ void TilesetDock::refreshTilesetMenu()
const int currentIndex = mTabBar->currentIndex();

for (int i = 0; i < mTabBar->count(); ++i) {
QAction *action = mTilesetMenu->addAction(mTabBar->tabText(i));
connect(action, &QAction::triggered, [=] { mTabBar->setCurrentIndex(i); });
QAction *action = mTilesetMenu->addAction(mTabBar->tabText(i),
[=] { mTabBar->setCurrentIndex(i); });

action->setCheckable(true);
mTilesetActionGroup->addAction(action);
Expand Down

0 comments on commit 079ab20

Please sign in to comment.