Skip to content
GitLab
Menu
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
892483c0
Commit
892483c0
authored
Sep 29, 2017
by
Jean-Baptiste Mardelle
Browse files
Restore add track dialog and fix track sorting in timeline
parent
bae5f156
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/timeline2/CMakeLists.txt
View file @
892483c0
...
...
@@ -10,6 +10,7 @@ set(kdenlive_SRCS
timeline2/model/snapmodel.cpp
timeline2/model/builders/meltBuilder.cpp
timeline2/view/dialogs/spacerdialog.cpp
timeline2/view/dialogs/trackdialog.cpp
timeline2/view/previewmanager.cpp
timeline2/view/timelinetabs.cpp
timeline2/view/timelinecontroller.cpp
...
...
src/timeline2/model/builders/meltBuilder.cpp
View file @
892483c0
...
...
@@ -27,6 +27,7 @@
#include "../undohelper.hpp"
#include "bin/bin.h"
#include "core.h"
#include "kdenlivesettings.h"
#include "mltcontroller/bincontroller.h"
#include <QDebug>
#include <QSet>
...
...
@@ -75,7 +76,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
qDebug
()
<<
"Adding track: "
<<
track
->
get
(
"id"
);
int
tid
;
ok
=
timeline
->
requestTrackInsertion
(
-
1
,
tid
,
undo
,
redo
);
timeline
->
setTrackProperty
(
tid
,
"kdenlive:trackheight"
,
"100"
);
timeline
->
setTrackProperty
(
tid
,
"kdenlive:trackheight"
,
QString
::
number
(
KdenliveSettings
::
trackheight
())
);
Mlt
::
Playlist
local_playlist
(
*
track
);
ok
=
ok
&&
constructTrackFromMelt
(
timeline
,
tid
,
local_playlist
,
undo
,
redo
);
QString
trackName
=
local_playlist
.
get
(
"kdenlive:track_name"
);
...
...
@@ -85,7 +86,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
int
audioTrack
=
local_playlist
.
get_int
(
"kdenlive:audio_track"
);
if
(
audioTrack
==
1
)
{
// This is an audio track
timeline
->
setTrackProperty
(
tid
,
QStringLiteral
(
""
),
QStringLiteral
(
"1"
));
timeline
->
setTrackProperty
(
tid
,
QStringLiteral
(
"
kdenlive:audio_track
"
),
QStringLiteral
(
"1"
));
}
break
;
}
...
...
src/timeline2/model/timelineitemmodel.cpp
View file @
892483c0
...
...
@@ -194,6 +194,7 @@ QHash<int, QByteArray> TimelineItemModel::roleNames() const
roles
[
ItemATrack
]
=
"a_track"
;
roles
[
HasAudio
]
=
"hasAudio"
;
roles
[
ReloadThumb
]
=
"reloadThumb"
;
roles
[
TrackPositionRole
]
=
"trackPosition"
;
return
roles
;
}
...
...
@@ -277,6 +278,8 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
QString
tName
=
getTrackById_const
(
id
)
->
getProperty
(
"kdenlive:track_name"
).
toString
();
return
tName
;
}
case
TrackPositionRole
:
return
getTrackMltIndex
(
id
);
case
DurationRole
:
// qDebug() << "DATA yielding duration" << m_tractor->get_playtime();
return
m_tractor
->
get_playtime
();
...
...
src/timeline2/model/timelinemodel.hpp
View file @
892483c0
...
...
@@ -121,6 +121,7 @@ public:
IsAudioRole
,
AudioLevelsRole
,
/// clip only
IsCompositeRole
,
/// track only
TrackPositionRole
,
/// track only
IsLockedRole
,
/// track only
HeightRole
,
/// track only
FadeInRole
,
/// clip only
...
...
src/timeline2/view/dialogs/trackdialog.cpp
View file @
892483c0
/***************************************************************************
* Copyright (C) 20
08
by Jean-Baptiste Mardelle (jb@kdenlive.org) *
* Copyright (C) 20
17
by Jean-Baptiste Mardelle (jb@kdenlive.org) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
...
...
@@ -20,21 +20,55 @@
#include "trackdialog.h"
#include "kdenlivesettings.h"
#include "timeline.h"
#include <QIcon>
TrackDialog
::
TrackDialog
(
Timeline
*
timeline
,
QWidget
*
parent
)
:
TrackDialog
::
TrackDialog
(
std
::
shared_ptr
<
TimelineItemModel
>
model
,
int
trackIndex
,
QWidget
*
parent
)
:
QDialog
(
parent
)
{
//setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
QIcon
videoIcon
=
QIcon
::
fromTheme
(
QStringLiteral
(
"kdenlive-show-video"
));
QIcon
audioIcon
=
QIcon
::
fromTheme
(
QStringLiteral
(
"kdenlive-show-audio"
));
setupUi
(
this
);
for
(
int
i
=
timeline
->
tracksCount
()
-
1
;
i
>
0
;
i
--
)
{
TrackInfo
info
=
timeline
->
getTrackInfo
(
i
);
comboTracks
->
addItem
(
info
.
type
==
VideoTrack
?
videoIcon
:
audioIcon
,
info
.
trackName
.
isEmpty
()
?
QString
::
number
(
i
)
:
info
.
trackName
);
QStringList
existingTrackNames
;
for
(
int
i
=
model
->
getTracksCount
()
-
1
;
i
>=
0
;
i
--
)
{
int
tid
=
model
->
getTrackIndexFromPosition
(
i
);
bool
audioTrack
=
model
->
getTrackProperty
(
tid
,
QStringLiteral
(
"kdenlive:audio_track"
))
==
QLatin1String
(
"1"
);
const
QString
trackName
=
model
->
getTrackProperty
(
tid
,
QStringLiteral
(
"kdenlive:track_name"
)).
toString
();
existingTrackNames
<<
trackName
;
// Track index in in MLT, so add + 1 to compensate black track
comboTracks
->
addItem
(
audioTrack
?
audioIcon
:
videoIcon
,
trackName
.
isEmpty
()
?
QString
::
number
(
i
)
:
trackName
,
i
+
1
);
}
if
(
trackIndex
>
-
1
)
{
int
ix
=
comboTracks
->
findData
(
trackIndex
);
comboTracks
->
setCurrentIndex
(
ix
);
}
trackIndex
--
;
QString
proposedName
=
i18n
(
"Video %1"
,
trackIndex
);
while
(
existingTrackNames
.
contains
(
proposedName
))
{
proposedName
=
i18n
(
"Video %1"
,
++
trackIndex
);
}
track_name
->
setText
(
proposedName
);
}
int
TrackDialog
::
selectedTrack
()
const
{
if
(
comboTracks
->
count
()
>
0
)
{
int
ix
=
comboTracks
->
currentData
().
toInt
();
if
(
before_select
->
currentIndex
()
==
1
)
{
ix
++
;
}
return
ix
;
}
return
-
1
;
}
bool
TrackDialog
::
addAudioTrack
()
const
{
return
!
video_track
->
isChecked
();
}
const
QString
TrackDialog
::
trackName
()
const
{
return
track_name
->
text
();
}
src/timeline2/view/dialogs/trackdialog.h
View file @
892483c0
...
...
@@ -17,19 +17,27 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef TRACKDIALOG_H
#define TRACKDIALOG_H
#ifndef TRACKDIALOG
2
_H
#define TRACKDIALOG
2
_H
#include "ui_addtrack_ui.h"
class
Timeline
;
#include "timeline2/model/timelineitemmodel.hpp"
class
TrackDialog
:
public
QDialog
,
public
Ui
::
AddTrack_UI
{
Q_OBJECT
public:
explicit
TrackDialog
(
Timeline
*
timeline
,
QWidget
*
parent
=
nullptr
);
explicit
TrackDialog
(
std
::
shared_ptr
<
TimelineItemModel
>
model
,
int
trackIndex
=
-
1
,
QWidget
*
parent
=
nullptr
);
/** @brief: returns the selected track's trackId
*/
int
selectedTrack
()
const
;
/** @brief: returns true if we want to insert an audio track
*/
bool
addAudioTrack
()
const
;
/** @brief: returns the newly created track name
*/
const
QString
trackName
()
const
;
};
#endif
src/timeline2/view/qml/timeline.qml
View file @
892483c0
...
...
@@ -331,12 +331,12 @@ Rectangle {
MenuItem
{
text
:
i18n
(
'
Add Track
'
)
shortcut
:
'
Ctrl+U
'
onTriggered
:
timeline
.
addTrack
(
currentTrack
);
onTriggered
:
timeline
.
addTrack
(
tracksRepeater
.
itemAt
(
currentTrack
)
.
trackId
)
;
}
MenuItem
{
text
:
i18n
(
'
Delete Track
'
)
//shortcut: 'Ctrl+U'
onTriggered
:
timeline
.
deleteTrack
(
currentTrack
);
onTriggered
:
timeline
.
deleteTrack
(
tracksRepeater
.
itemAt
(
currentTrack
)
.
trackId
)
;
}
}
...
...
@@ -357,7 +357,7 @@ Rectangle {
anchors.fill
:
parent
acceptedButtons
:
Qt
.
LeftButton
onClicked
:
{
timeline
.
selectMultitrack
()
//
timeline.selectMultitrack()
}
}
}
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
892483c0
...
...
@@ -36,6 +36,7 @@
#include "timeline2/model/compositionmodel.hpp"
#include "timeline2/model/groupsmodel.hpp"
#include "transitions/transitionsrepository.hpp"
#include "timeline2/view/dialogs/trackdialog.h"
#include "dialogs/spacerdialog.h"
#include "timelinewidget.h"
#include "utils/KoIconUtils.h"
...
...
@@ -339,7 +340,33 @@ bool TimelineController::showWaveforms() const
void
TimelineController
::
addTrack
(
int
tid
)
{
qDebug
()
<<
"Adding track: "
<<
tid
;
qDebug
()
<<
"Adding track: "
<<
tid
<<
" = "
<<
m_model
->
getTrackMltIndex
(
tid
);
QPointer
<
TrackDialog
>
d
=
new
TrackDialog
(
m_model
,
m_model
->
getTrackMltIndex
(
tid
),
qApp
->
activeWindow
());
if
(
d
->
exec
()
==
QDialog
::
Accepted
)
{
int
mltIndex
=
d
->
selectedTrack
();
int
tid
;
qDebug
()
<<
"// INSERT TRACK: "
<<
mltIndex
;
m_model
->
requestTrackInsertion
(
mltIndex
,
tid
);
m_model
->
setTrackProperty
(
tid
,
"kdenlive:trackheight"
,
QString
::
number
(
KdenliveSettings
::
trackheight
()));
m_model
->
setTrackProperty
(
tid
,
QStringLiteral
(
"kdenlive:track_name"
),
d
->
trackName
().
toUtf8
().
constData
());
if
(
d
->
addAudioTrack
())
{
m_model
->
setTrackProperty
(
tid
,
QStringLiteral
(
"kdenlive:audio_track"
),
QStringLiteral
(
"1"
));
}
}
/*d->comboTracks->setCurrentIndex(m_timeline->visibleTracksCount() - ix);
d->label->setText(i18n("Insert track"));
QStringList existingTrackNames = m_timeline->getTrackNames();
int i = 1;
QString proposedName = i18n("Video %1", i);
while (existingTrackNames.contains(proposedName)) {
proposedName = i18n("Video %1", ++i);
}
d->track_name->setText(proposedName);
d->setWindowTitle(i18n("Insert New Track"));*/
//info.trackName = d->track_name->text();
//auto *addTrack = new AddTrackCommand(this, ix, info, true);
//m_commandStack->push(addTrack);
}
void
TimelineController
::
deleteTrack
(
int
tid
)
...
...
src/timeline2/view/timelinewidget.cpp
View file @
892483c0
...
...
@@ -78,12 +78,12 @@ TimelineWidget::~TimelineWidget()
void
TimelineWidget
::
setModel
(
std
::
shared_ptr
<
TimelineItemModel
>
model
)
{
m_thumbnailer
->
resetProject
();
auto
*
proxy
Model
=
new
QSortFilterProxyModel
(
this
);
proxy
Model
->
setSourceModel
(
model
.
get
());
proxy
Model
->
setSortRole
(
TimelineItemModel
::
ItemId
Role
);
proxy
Model
->
sort
(
0
,
Qt
::
DescendingOrder
);
auto
sort
Model
=
new
QSortFilterProxyModel
(
this
);
sort
Model
->
setSourceModel
(
model
.
get
());
sort
Model
->
setSortRole
(
TimelineItemModel
::
TrackPosition
Role
);
sort
Model
->
sort
(
0
,
Qt
::
DescendingOrder
);
m_proxy
->
setModel
(
model
);
rootContext
()
->
setContextProperty
(
"multitrack"
,
proxy
Model
);
rootContext
()
->
setContextProperty
(
"multitrack"
,
sort
Model
);
rootContext
()
->
setContextProperty
(
"controller"
,
model
.
get
());
rootContext
()
->
setContextProperty
(
"timeline"
,
m_proxy
);
rootContext
()
->
setContextProperty
(
"transitionModel"
,
m_transitionProxyModel
.
get
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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