mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-16 18:59:39 +08:00

Ctrl+O was assigned as a shortcut in two places: 1. To the "File->Open File(s)" menu item, which is visible when only the local file provider is enabled (i.e. the DF file provider is disabled) 2. To the "File->Open File(s)->From Disk" menu item, which is visible when there are more than one file providers enabled. This was creating an ambiguous shortcut, thus never opening the local file dialog. This is now fixed by disabling the shortcuts when the respective items are not visible. CURA-7868
47 lines
1.4 KiB
QML
47 lines
1.4 KiB
QML
// Copyright (c) 2020 Ultimaker B.V.
|
|
// Cura is released under the terms of the LGPLv3 or higher.
|
|
|
|
import QtQuick 2.2
|
|
import QtQuick.Controls 1.1
|
|
|
|
import UM 1.6 as UM
|
|
import Cura 1.0 as Cura
|
|
|
|
import "../Dialogs"
|
|
|
|
Menu
|
|
{
|
|
id: openFilesMenu
|
|
title: catalog.i18nc("@title:menu menubar:file", "Open File(s)...")
|
|
iconName: "document-open-recent";
|
|
|
|
Instantiator
|
|
{
|
|
id: fileProviders
|
|
model: CuraApplication.getFileProviderModel()
|
|
MenuItem
|
|
{
|
|
text:
|
|
{
|
|
return model.displayText;
|
|
}
|
|
onTriggered:
|
|
{
|
|
if (model.index == 0) // The 0th element is the "From Disk" option, which should activate the open local file dialog
|
|
{
|
|
Cura.Actions.open.trigger()
|
|
}
|
|
else
|
|
{
|
|
CuraApplication.getFileProviderModel().trigger(model.name);
|
|
}
|
|
}
|
|
// Unassign the shortcuts when the submenu is invisible (i.e. when there is only one file provider) to avoid ambiguous shortcuts.
|
|
// When there is a signle file provider, the openAction is assigned with the Ctrl+O shortcut instead.
|
|
shortcut: openFilesMenu.visible ? model.shortcut : ""
|
|
}
|
|
onObjectAdded: openFilesMenu.insertItem(index, object)
|
|
onObjectRemoved: openFilesMenu.removeItem(object)
|
|
}
|
|
}
|