forked from qt-creator/qt-creator
QmlDesigner: Add drag support to empty asset library placeholder item
Fixes: QDS-6430 Change-Id: I561f4ed51ccb1e47472adb9baa6e5594eb93eafb Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -469,50 +469,62 @@ Item {
|
|||||||
visible: assetsModel.isEmpty && searchBox.isEmpty()
|
visible: assetsModel.isEmpty && searchBox.isEmpty()
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
Column {
|
DropArea { // handles external drop (goes into default folder based on suffix)
|
||||||
id: colNoAssets
|
anchors.fill: parent
|
||||||
|
|
||||||
spacing: 20
|
onEntered: (drag)=> {
|
||||||
x: 20
|
root.updateDropExtFiles(drag)
|
||||||
width: root.width - 2 * x
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: qsTr("Looks like you don't have any assets yet.")
|
|
||||||
color: StudioTheme.Values.themeTextColor
|
|
||||||
font.pixelSize: 18
|
|
||||||
width: colNoAssets.width
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
onDropped: {
|
||||||
source: "image://qmldesigner_assets/browse"
|
rootView.handleExtFilesDrop(root.dropSimpleExtFiles, root.dropComplexExtFiles)
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
}
|
||||||
scale: maBrowse.containsMouse ? 1.2 : 1
|
|
||||||
Behavior on scale {
|
Column {
|
||||||
NumberAnimation {
|
id: colNoAssets
|
||||||
duration: 300
|
|
||||||
easing.type: Easing.OutQuad
|
spacing: 20
|
||||||
|
x: 20
|
||||||
|
width: root.width - 2 * x
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: qsTr("Looks like you don't have any assets yet.")
|
||||||
|
color: StudioTheme.Values.themeTextColor
|
||||||
|
font.pixelSize: 18
|
||||||
|
width: colNoAssets.width
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
|
||||||
|
Image {
|
||||||
|
source: "image://qmldesigner_assets/browse"
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
scale: maBrowse.containsMouse ? 1.2 : 1
|
||||||
|
Behavior on scale {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 300
|
||||||
|
easing.type: Easing.OutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: maBrowse
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
onClicked: rootView.handleAddAsset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
Text {
|
||||||
id: maBrowse
|
text: qsTr("Drag-and-drop your assets here or click the '+' button to browse assets from the file system.")
|
||||||
anchors.fill: parent
|
color: StudioTheme.Values.themeTextColor
|
||||||
hoverEnabled: true
|
font.pixelSize: 18
|
||||||
onClicked: rootView.handleAddAsset();
|
width: colNoAssets.width
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
|
||||||
text: qsTr("Drag-and-drop your assets here or click the '+' button to browse assets from the file system.")
|
|
||||||
color: StudioTheme.Values.themeTextColor
|
|
||||||
font.pixelSize: 18
|
|
||||||
width: colNoAssets.width
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -218,11 +218,16 @@ void AssetsLibraryWidget::handleExtFilesDrop(const QStringList &simpleFilesPaths
|
|||||||
const QString &targetDirPath)
|
const QString &targetDirPath)
|
||||||
{
|
{
|
||||||
if (!simpleFilesPaths.isEmpty()) {
|
if (!simpleFilesPaths.isEmpty()) {
|
||||||
AddFilesResult result = ModelNodeOperations::addFilesToProject(simpleFilesPaths, targetDirPath);
|
if (targetDirPath.isEmpty()) {
|
||||||
if (result == AddFilesResult::Failed) {
|
addResources(simpleFilesPaths);
|
||||||
Core::AsynchronousMessageBox::warning(tr("Failed to Add Files"),
|
} else {
|
||||||
tr("Could not add %1 to project.")
|
AddFilesResult result = ModelNodeOperations::addFilesToProject(simpleFilesPaths,
|
||||||
.arg(simpleFilesPaths.join(' ')));
|
targetDirPath);
|
||||||
|
if (result == AddFilesResult::Failed) {
|
||||||
|
Core::AsynchronousMessageBox::warning(tr("Failed to Add Files"),
|
||||||
|
tr("Could not add %1 to project.")
|
||||||
|
.arg(simpleFilesPaths.join(' ')));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -82,7 +82,7 @@ public:
|
|||||||
Q_INVOKABLE void handleSearchfilterChanged(const QString &filterText);
|
Q_INVOKABLE void handleSearchfilterChanged(const QString &filterText);
|
||||||
Q_INVOKABLE void handleExtFilesDrop(const QStringList &simpleFilesPaths,
|
Q_INVOKABLE void handleExtFilesDrop(const QStringList &simpleFilesPaths,
|
||||||
const QStringList &complexFilesPaths,
|
const QStringList &complexFilesPaths,
|
||||||
const QString &targetDirPath);
|
const QString &targetDirPath = {});
|
||||||
Q_INVOKABLE QSet<QString> supportedAssetSuffixes(bool complex);
|
Q_INVOKABLE QSet<QString> supportedAssetSuffixes(bool complex);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
Reference in New Issue
Block a user