1
0
Fork 0

GUI: do not show reload+edit menus when loading script from clipboard

This commit is contained in:
Duncan Ogilvie 2019-11-26 13:24:08 +01:00
parent b6b1cce7ba
commit 537c4e42d5
1 changed files with 8 additions and 3 deletions

View File

@ -398,9 +398,13 @@ void ScriptView::setupContextMenu()
{ {
return getRowCount() != 0; return getRowCount() != 0;
}; };
mMenu->addAction(makeShortcutAction(DIcon("arrow-restart.png"), tr("Re&load Script"), SLOT(reload()), "ActionReloadScript"), isempty); auto isemptyclipboard = [this](QMenu*)
{
return getRowCount() != 0 && !filename.isEmpty();
};
mMenu->addAction(makeShortcutAction(DIcon("arrow-restart.png"), tr("Re&load Script"), SLOT(reload()), "ActionReloadScript"), isemptyclipboard);
mMenu->addAction(makeShortcutAction(DIcon("control-exit.png"), tr("&Unload Script"), SLOT(unload()), "ActionUnloadScript"), isempty); mMenu->addAction(makeShortcutAction(DIcon("control-exit.png"), tr("&Unload Script"), SLOT(unload()), "ActionUnloadScript"), isempty);
mMenu->addAction(makeShortcutAction(DIcon("edit-script.png"), tr("&Edit Script"), SLOT(edit()), "ActionEditScript"), isempty); mMenu->addAction(makeShortcutAction(DIcon("edit-script.png"), tr("&Edit Script"), SLOT(edit()), "ActionEditScript"), isemptyclipboard);
mMenu->addSeparator(); mMenu->addSeparator();
mMenu->addAction(makeShortcutAction(DIcon("breakpoint_toggle.png"), tr("Toggle &BP"), SLOT(bpToggle()), "ActionToggleBreakpointScript"), isempty); mMenu->addAction(makeShortcutAction(DIcon("breakpoint_toggle.png"), tr("Toggle &BP"), SLOT(bpToggle()), "ActionToggleBreakpointScript"), isempty);
mMenu->addAction(makeShortcutAction(DIcon("arrow-run-cursor.png"), tr("Ru&n until selection"), SLOT(runCursor()), "ActionRunToCursorScript"), isempty); mMenu->addAction(makeShortcutAction(DIcon("arrow-run-cursor.png"), tr("Ru&n until selection"), SLOT(runCursor()), "ActionRunToCursorScript"), isempty);
@ -512,7 +516,8 @@ void ScriptView::paste()
void ScriptView::reload() void ScriptView::reload()
{ {
openRecentFile(filename); if(!filename.isEmpty())
openRecentFile(filename);
} }
void ScriptView::unload() void ScriptView::unload()