Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
75c79f6c
Commit
75c79f6c
authored
Dec 28, 2019
by
Jean-Baptiste Mardelle
Browse files
When a clip is dropped in bin, focus on it.
Related to
#287
parent
6b603b81
Pipeline
#12553
passed with stage
in 13 minutes and 56 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/bin.cpp
View file @
75c79f6c
...
...
@@ -2787,7 +2787,14 @@ void Bin::slotItemDropped(const QList<QUrl> &urls, const QModelIndex &parent)
}
parentFolder
=
parentItem
->
clipId
();
}
ClipCreator
::
createClipsFromList
(
urls
,
true
,
parentFolder
,
m_itemModel
);
const
QString
id
=
ClipCreator
::
createClipsFromList
(
urls
,
true
,
parentFolder
,
m_itemModel
);
if
(
!
id
.
isEmpty
())
{
std
::
shared_ptr
<
AbstractProjectItem
>
item
=
m_itemModel
->
getItemByBinId
(
id
);
if
(
item
)
{
QModelIndex
ix
=
m_itemModel
->
getIndexFromItem
(
item
);
m_itemView
->
scrollTo
(
m_proxyModel
->
mapFromSource
(
ix
),
QAbstractItemView
::
PositionAtCenter
);
}
}
}
void
Bin
::
slotExpandUrl
(
const
ItemInfo
&
info
,
const
QString
&
url
,
QUndoCommand
*
command
)
...
...
src/bin/clipcreator.cpp
View file @
75c79f6c
...
...
@@ -206,9 +206,10 @@ QString ClipCreator::createTitleTemplate(const QString &path, const QString &tex
return
res
?
id
:
QStringLiteral
(
"-1"
);
}
bool
ClipCreator
::
createClipsFromList
(
const
QList
<
QUrl
>
&
list
,
bool
checkRemovable
,
const
QString
&
parentFolder
,
const
std
::
shared_ptr
<
ProjectItemModel
>
&
model
,
const
QString
ClipCreator
::
createClipsFromList
(
const
QList
<
QUrl
>
&
list
,
bool
checkRemovable
,
const
QString
&
parentFolder
,
const
std
::
shared_ptr
<
ProjectItemModel
>
&
model
,
Fun
&
undo
,
Fun
&
redo
,
bool
topLevel
)
{
QString
createdItem
;
QScopedPointer
<
QProgressDialog
>
progressDialog
;
if
(
topLevel
)
{
progressDialog
.
reset
(
new
QProgressDialog
(
pCore
->
window
()));
...
...
@@ -238,6 +239,7 @@ bool ClipCreator::createClipsFromList(const QList<QUrl> &list, bool checkRemovab
if
(
!
folderCreated
)
{
continue
;
}
createdItem
=
folderId
;
QStringList
result
=
dir
.
entryList
(
QDir
::
Files
);
QStringList
subfolders
=
dir
.
entryList
(
QDir
::
Dirs
|
QDir
::
NoDotAndDotDot
);
QList
<
QUrl
>
folderFiles
;
...
...
@@ -270,14 +272,19 @@ bool ClipCreator::createClipsFromList(const QList<QUrl> &list, bool checkRemovab
}
if
(
!
sublist
.
isEmpty
())
{
// load subfolders
created
=
created
||
createClipsFromList
(
sublist
,
checkRemovable
,
folderId
,
model
,
undo
,
redo
,
false
);
const
QString
clipId
=
createClipsFromList
(
sublist
,
checkRemovable
,
folderId
,
model
,
undo
,
redo
,
false
);
if
(
createdItem
.
isEmpty
()
&&
clipId
!=
QLatin1String
(
"-1"
))
{
createdItem
=
clipId
;
}
}
}
else
{
bool
clipsCreated
=
createClipsFromList
(
folderFiles
,
checkRemovable
,
folderId
,
model
,
local_undo
,
local_redo
,
false
);
created
=
true
;
if
(
!
clipsCreated
)
{
const
QString
clipId
=
createClipsFromList
(
folderFiles
,
checkRemovable
,
folderId
,
model
,
local_undo
,
local_redo
,
false
);
if
(
clipId
.
isEmpty
()
||
clipId
==
QLatin1String
(
"-1"
))
{
local_undo
();
}
else
{
if
(
createdItem
.
isEmpty
())
{
createdItem
=
clipId
;
}
UPDATE_UNDO_REDO_NOLOCK
(
local_redo
,
local_undo
,
undo
,
redo
)
}
// Check subfolders
...
...
@@ -305,21 +312,23 @@ bool ClipCreator::createClipsFromList(const QList<QUrl> &list, bool checkRemovab
if
(
answer
==
KMessageBox
::
Cancel
)
continue
;
}
QString
id
=
ClipCreator
::
createClipFromFile
(
file
.
toLocalFile
(),
parentFolder
,
model
,
undo
,
redo
);
created
=
created
||
(
id
!=
QStringLiteral
(
"-1"
));
const
QString
clipId
=
ClipCreator
::
createClipFromFile
(
file
.
toLocalFile
(),
parentFolder
,
model
,
undo
,
redo
);
if
(
createdItem
.
isEmpty
()
&&
clipId
!=
QLatin1String
(
"-1"
))
{
createdItem
=
clipId
;
}
}
}
qDebug
()
<<
"/////////// creatclipsfromlist return"
<<
created
;
return
created
;
return
created
Item
==
QLatin1String
(
"-1"
)
?
QString
()
:
createdItem
;
}
bool
ClipCreator
::
createClipsFromList
(
const
QList
<
QUrl
>
&
list
,
bool
checkRemovable
,
const
QString
&
parentFolder
,
std
::
shared_ptr
<
ProjectItemModel
>
model
)
const
QString
ClipCreator
::
createClipsFromList
(
const
QList
<
QUrl
>
&
list
,
bool
checkRemovable
,
const
QString
&
parentFolder
,
std
::
shared_ptr
<
ProjectItemModel
>
model
)
{
Fun
undo
=
[]()
{
return
true
;
};
Fun
redo
=
[]()
{
return
true
;
};
bool
ok
=
ClipCreator
::
createClipsFromList
(
list
,
checkRemovable
,
parentFolder
,
std
::
move
(
model
),
undo
,
redo
);
if
(
ok
)
{
const
QString
id
=
ClipCreator
::
createClipsFromList
(
list
,
checkRemovable
,
parentFolder
,
std
::
move
(
model
),
undo
,
redo
);
if
(
!
id
.
isEmpty
()
)
{
pCore
->
pushUndo
(
undo
,
redo
,
i18np
(
"Add clip"
,
"Add clips"
,
list
.
size
()));
}
return
ok
;
return
id
;
}
src/bin/clipcreator.hpp
View file @
75c79f6c
...
...
@@ -92,9 +92,9 @@ bool createClipFromFile(const QString &path, const QString &parentFolder, std::s
@param parentFolder: the binId of the containing folder
@param model: a shared pointer to the bin item model
*/
bool
createClipsFromList
(
const
QList
<
QUrl
>
&
list
,
bool
checkRemovable
,
const
QString
&
parentFolder
,
const
std
::
shared_ptr
<
ProjectItemModel
>
&
model
,
Fun
&
undo
,
const
QString
createClipsFromList
(
const
QList
<
QUrl
>
&
list
,
bool
checkRemovable
,
const
QString
&
parentFolder
,
const
std
::
shared_ptr
<
ProjectItemModel
>
&
model
,
Fun
&
undo
,
Fun
&
redo
,
bool
topLevel
=
true
);
bool
createClipsFromList
(
const
QList
<
QUrl
>
&
list
,
bool
checkRemovable
,
const
QString
&
parentFolder
,
std
::
shared_ptr
<
ProjectItemModel
>
model
);
const
QString
createClipsFromList
(
const
QList
<
QUrl
>
&
list
,
bool
checkRemovable
,
const
QString
&
parentFolder
,
std
::
shared_ptr
<
ProjectItemModel
>
model
);
/* @brief Create minimal xml description from an url
*/
...
...
src/bin/projectitemmodel.cpp
View file @
75c79f6c
...
...
@@ -357,6 +357,7 @@ void ProjectItemModel::onItemUpdated(const QString &binId, int role)
onItemUpdated
(
item
,
role
);
}
}
std
::
shared_ptr
<
ProjectClip
>
ProjectItemModel
::
getClipByBinID
(
const
QString
&
binId
)
{
READ_LOCK
();
...
...
src/dialogs/clipcreationdialog.cpp
View file @
75c79f6c
...
...
@@ -425,11 +425,11 @@ void ClipCreationDialog::createClipsCommand(KdenliveDoc *doc, const QString &par
}
Fun
undo
=
[]()
{
return
true
;
};
Fun
redo
=
[]()
{
return
true
;
};
bool
create
d
=
ClipCreator
::
createClipsFromList
(
list
,
true
,
parentFolder
,
model
,
undo
,
redo
);
const
QString
i
d
=
ClipCreator
::
createClipsFromList
(
list
,
true
,
parentFolder
,
model
,
undo
,
redo
);
// We reset the state of the "don't ask again" for the question about removable devices
KMessageBox
::
enableMessage
(
QStringLiteral
(
"removable"
));
if
(
created
)
{
if
(
!
id
.
isEmpty
()
)
{
pCore
->
pushUndo
(
undo
,
redo
,
i18np
(
"Add clip"
,
"Add clips"
,
list
.
size
()));
}
}
Eugen Mohr
@emohr
mentioned in issue
#287
·
Dec 30, 2019
mentioned in issue
#287
mentioned in issue #287
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment