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
f82a08ea
Commit
f82a08ea
authored
Dec 23, 2019
by
Jean-Baptiste Mardelle
Browse files
Add Audio/Video drag icons in icon view.
CCBUG: 415454
parent
48069b06
Pipeline
#12374
passed with stage
in 20 minutes and 11 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/bin.cpp
View file @
f82a08ea
...
...
@@ -283,7 +283,7 @@ public:
}
}
}
else
{
// Folder
or Folder Up items
// Folder
int
decoWidth
=
0
;
if
(
opt
.
decorationSize
.
height
()
>
0
)
{
r
.
setWidth
(
r
.
height
()
*
m_dar
);
...
...
@@ -338,17 +338,56 @@ public:
connect
(
this
,
&
QStyledItemDelegate
::
closeEditor
,
[
&
]()
{
m_editorOpen
=
false
;
});
}
void
setDar
(
double
dar
)
{
m_dar
=
dar
;
}
bool
editorEvent
(
QEvent
*
event
,
QAbstractItemModel
*
model
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
override
{
Q_UNUSED
(
model
);
Q_UNUSED
(
option
);
Q_UNUSED
(
index
);
if
(
event
->
type
()
==
QEvent
::
MouseButtonPress
)
{
auto
*
me
=
(
QMouseEvent
*
)
event
;
if
(
m_audioDragRect
.
contains
(
me
->
pos
()))
{
dragType
=
PlaylistState
::
AudioOnly
;
}
else
if
(
m_videoDragRect
.
contains
(
me
->
pos
()))
{
dragType
=
PlaylistState
::
VideoOnly
;
}
else
{
dragType
=
PlaylistState
::
Disabled
;
}
}
event
->
ignore
();
return
false
;
}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
override
{
if
(
!
index
.
data
().
isNull
())
{
QStyleOptionViewItem
opt
=
option
;
QStyleOptionViewItem
opt
(
option
)
;
initStyleOption
(
&
opt
,
index
);
QStyledItemDelegate
::
paint
(
painter
,
option
,
index
);
int
adjust
=
(
opt
.
rect
.
width
()
-
opt
.
decorationSize
.
width
())
/
2
;
QRect
rect
(
0
,
0
,
opt
.
r
ec
t
.
width
(),
opt
.
r
ec
t
.
height
());
QRect
rect
(
opt
.
rect
.
x
(),
opt
.
rect
.
y
()
,
opt
.
d
ec
orationSize
.
width
(),
opt
.
d
ec
orationSize
.
height
());
m_thumbRect
=
adjust
>
0
&&
adjust
<
rect
.
width
()
?
rect
.
adjusted
(
adjust
,
0
,
-
adjust
,
0
)
:
rect
;
QStyledItemDelegate
::
paint
(
painter
,
option
,
index
);
// Add audio/video icons for selective drag
int
cType
=
index
.
data
(
AbstractProjectItem
::
ClipType
).
toInt
();
bool
hasAudioAndVideo
=
index
.
data
(
AbstractProjectItem
::
ClipHasAudioAndVideo
).
toBool
();
if
(
hasAudioAndVideo
&&
(
cType
==
ClipType
::
AV
||
cType
==
ClipType
::
Playlist
)
&&
(
opt
.
state
&
QStyle
::
State_MouseOver
))
{
QRect
thumbRect
=
m_thumbRect
;
int
iconSize
=
painter
->
boundingRect
(
thumbRect
,
Qt
::
AlignLeft
,
QStringLiteral
(
"O"
)).
height
();
thumbRect
.
setLeft
(
opt
.
rect
.
right
()
-
iconSize
-
4
);
thumbRect
.
setWidth
(
iconSize
);
thumbRect
.
setBottom
(
m_thumbRect
.
top
()
+
iconSize
);
QIcon
aDrag
=
QIcon
::
fromTheme
(
QStringLiteral
(
"audio-volume-medium"
));
m_audioDragRect
=
thumbRect
;
aDrag
.
paint
(
painter
,
m_audioDragRect
,
Qt
::
AlignRight
);
m_videoDragRect
=
m_audioDragRect
;
m_videoDragRect
.
moveTop
(
thumbRect
.
bottom
());
QIcon
vDrag
=
QIcon
::
fromTheme
(
QStringLiteral
(
"kdenlive-show-video"
));
vDrag
.
paint
(
painter
,
m_videoDragRect
,
Qt
::
AlignRight
);
}
else
{
//m_audioDragRect = QRect();
//m_videoDragRect = QRect();
}
}
}
...
...
@@ -394,6 +433,22 @@ void MyListView::focusInEvent(QFocusEvent *event)
}
}
void
MyListView
::
mousePressEvent
(
QMouseEvent
*
event
)
{
QListView
::
mousePressEvent
(
event
);
if
(
event
->
button
()
==
Qt
::
LeftButton
)
{
m_startPos
=
event
->
pos
();
QModelIndex
ix
=
indexAt
(
m_startPos
);
if
(
ix
.
isValid
())
{
QAbstractItemDelegate
*
del
=
itemDelegate
(
ix
);
m_dragType
=
static_cast
<
BinListItemDelegate
*>
(
del
)
->
dragType
;
}
else
{
m_dragType
=
PlaylistState
::
Disabled
;
}
emit
updateDragMode
(
m_dragType
);
}
}
void
MyListView
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
if
(
event
->
modifiers
()
==
Qt
::
ShiftModifier
)
{
...
...
@@ -1498,6 +1553,7 @@ void Bin::slotInitView(QAction *action)
}
else
if
(
m_listType
==
BinIconView
)
{
m_itemView
->
setItemDelegate
(
m_binListViewDelegate
);
auto
*
view
=
static_cast
<
MyListView
*>
(
m_itemView
);
connect
(
view
,
&
MyListView
::
updateDragMode
,
m_itemModel
.
get
(),
&
ProjectItemModel
::
setDragType
,
Qt
::
DirectConnection
);
view
->
setGridSize
(
QSize
(
zoom
.
width
()
*
1.2
,
zoom
.
width
()));
connect
(
view
,
&
MyListView
::
focusView
,
this
,
&
Bin
::
slotGotFocus
);
connect
(
view
,
&
MyListView
::
displayBinFrame
,
this
,
&
Bin
::
showBinFrame
);
...
...
src/bin/bin.h
View file @
f82a08ea
...
...
@@ -72,12 +72,16 @@ public:
explicit
MyListView
(
QWidget
*
parent
=
nullptr
);
protected:
void
mousePressEvent
(
QMouseEvent
*
event
)
override
;
void
focusInEvent
(
QFocusEvent
*
event
)
override
;
void
mouseMoveEvent
(
QMouseEvent
*
event
)
override
;
signals:
void
focusView
();
void
updateDragMode
(
ClipType
::
ProducerTyp
e
type
);
void
updateDragMode
(
PlaylistState
::
ClipStat
e
type
);
void
displayBinFrame
(
QModelIndex
ix
,
int
frame
);
private:
QPoint
m_startPos
;
PlaylistState
::
ClipState
m_dragType
;
};
class
MyTreeView
:
public
QTreeView
...
...
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