Commit ebffc055 authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Tim Jenssen

QmlDesigner: Making adding signal handlers more user friendly

The "Go to implementation" context menu was adding a new signal
handler if no signal handler was already present.
This does not change, but I add "Add new Signal Handler" that always
adds a new signal handler, even if one already exists.

Change-Id: I7d1f012fda114d22598a9dd650ee14d97d48cd1d
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent a63c4319
......@@ -72,6 +72,7 @@ const char resetPositionDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMen
const char goIntoComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go into Component");
const char goToImplementationDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go to Implementation");
const char addSignalHandlerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add New Signal Handler");
const char moveToComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Move to Component");
const char setIdDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Set Id");
......
......@@ -509,10 +509,11 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new ModelNodeAction
(goIntoComponentDisplayName, rootCategory, priorityGoIntoComponent, &goIntoComponent, &selectionIsComponent));
addDesignerAction(new ModelNodeAction
(goToImplementationDisplayName, rootCategory, 42, &gotoImplementation, &singleSelectedAndUiFile, &singleSelectedAndUiFile));
(goToImplementationDisplayName, rootCategory, 42, &goImplementation, &singleSelectedAndUiFile, &singleSelectedAndUiFile));
addDesignerAction(new ModelNodeAction
(addSignalHandlerDisplayName, rootCategory, 42, &addNewSignalHandler, &singleSelectedAndUiFile, &singleSelectedAndUiFile));
addDesignerAction(new ModelNodeAction
(moveToComponentDisplayName, rootCategory, 44, &moveToComponent, &singleSelection, &singleSelection));
}
void DesignerActionManager::addDesignerAction(ActionInterface *newAction)
......
......@@ -637,7 +637,7 @@ static QStringList getSortedSignalNameList(const ModelNode &modelNode)
return signalNames;
}
void gotoImplementation(const SelectionContext &selectionState)
void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState, bool addAlwaysNewSlot)
{
ModelNode modelNode;
if (selectionState.singleNodeIsSelected())
......@@ -687,7 +687,7 @@ void gotoImplementation(const SelectionContext &selectionState)
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
if (usages.count() == 1) {
if (usages.count() > 0 && (addAlwaysNewSlot || usages.count()< 2)) {
Core::EditorManager::openEditorAt(usages.first().path, usages.first().line, usages.first().col);
if (!signalNames.isEmpty()) {
......@@ -782,6 +782,16 @@ void moveToComponent(const SelectionContext &selectionContext)
selectionContext.view()->model()->rewriterView()->moveToComponent(modelNode);
}
void goImplementation(const SelectionContext &selectionState)
{
addSignalHandlerOrGotoImplementation(selectionState, false);
}
void addNewSignalHandler(const SelectionContext &selectionState)
{
addSignalHandlerOrGotoImplementation(selectionState, true);
}
} // namespace Mode
} //QmlDesigner
......@@ -63,7 +63,9 @@ void layoutFlowPositioner(const SelectionContext &selectionState);
void layoutRowLayout(const SelectionContext &selectionState);
void layoutColumnLayout(const SelectionContext &selectionState);
void layoutGridLayout(const SelectionContext &selectionState);
void gotoImplementation(const SelectionContext &selectionState);
void goImplementation(const SelectionContext &selectionState);
void addNewSignalHandler(const SelectionContext &selectionState);
void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState, bool addAlwaysNewSlot);
void removeLayout(const SelectionContext &selectionContext);
void removePositioner(const SelectionContext &selectionContext);
void moveToComponent(const SelectionContext &selectionContext);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment