[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdenlive/frameworks] src: Basic work on clip properties panel, fix crash on folder double click
From: Jean-Baptiste Mardelle <jb () kdenlive ! org>
Date: 2014-12-31 21:10:50
Message-ID: E1Y6QXa-0001hu-5N () scm ! kde ! org
[Download RAW message or body]
Git commit dc64f03d4d4006233c903a69dd90e61ad64119d4 by Jean-Baptiste Mardelle.
Committed on 31/12/2014 at 21:10.
Pushed by mardelle into branch 'frameworks'.
Basic work on clip properties panel, fix crash on folder double click
M +80 -49 src/bin/bin.cpp
M +7 -2 src/bin/bin.h
M +15 -2 src/bin/projectclip.cpp
M +1 -1 src/bin/projectclip.h
M +1 -1 src/mainwindow.cpp
http://commits.kde.org/kdenlive/dc64f03d4d4006233c903a69dd90e61ad64119d4
diff --git a/src/bin/bin.cpp b/src/bin/bin.cpp
index 773f122..6fe0560 100644
--- a/src/bin/bin.cpp
+++ b/src/bin/bin.cpp
@@ -43,7 +43,7 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include <QMenu>
#include <QDebug>
#include <QTableWidget>
-
+#include <KSplitterCollapserButton>
EventEater::EventEater(QObject *parent) : QObject(parent)
{
@@ -167,10 +167,22 @@ Bin::Bin(QWidget* parent) :
m_splitter = new QSplitter(this);
m_headerInfo = QByteArray::fromBase64(KdenliveSettings::treeviewheaders().toLatin1());
- connect(m_eventEater, SIGNAL(editItem(QModelIndex)), this, \
SLOT(showClipProperties(QModelIndex)), Qt::UniqueConnection); + \
connect(m_eventEater, SIGNAL(editItem(QModelIndex)), this, \
SLOT(slotSwitchClipProperties(QModelIndex)), Qt::UniqueConnection);
connect(m_eventEater, SIGNAL(showMenu(QString)), this, \
SLOT(showClipMenu(QString)), Qt::UniqueConnection);
layout->addWidget(m_splitter);
+ m_propertiesPanel = new QWidget(m_splitter);
+ QVBoxLayout *lay = new QVBoxLayout;
+ m_propertiesPanel->setLayout(lay);
+ m_propertiesTable = new QTableWidget(this);
+ m_propertiesTable->setColumnCount(2);
+ QHeaderView *header = m_propertiesTable->horizontalHeader();
+ header->setStretchLastSection(true);
+ lay->addWidget(m_propertiesTable);
+
+ m_splitter->addWidget(m_propertiesPanel);
+ m_collapser = new KSplitterCollapserButton(m_propertiesPanel, m_splitter);
+ connect(m_collapser, SIGNAL(clicked(bool)), this, \
SLOT(slotRefreshClipProperties())); }
Bin::~Bin()
@@ -395,9 +407,18 @@ void Bin::selectProxyModel(const QModelIndex &id)
if (id.isValid()) {
ProjectClip *currentItem = \
static_cast<ProjectClip*>(m_proxyModel->mapToSource(id).internalPointer()); if \
(currentItem) {
- m_openedProducer = currentItem->clipId();
- currentItem->setCurrent(true);
- m_editAction->setEnabled(true);
+ if (!currentItem->isFolder()) {
+ m_openedProducer = currentItem->clipId();
+ currentItem->setCurrent(true);
+ m_editAction->setEnabled(true);
+ if (m_propertiesPanel->width() > 0) {
+ // if info panel is displayed, update info
+ if (!currentItem->isFolder()) showClipProperties(currentItem);
+ }
+ } else {
+ // A folder was selected, disable editing clip
+ m_editAction->setEnabled(false);
+ }
m_deleteAction->setEnabled(true);
} else {
m_editAction->setEnabled(false);
@@ -452,11 +473,11 @@ void Bin::slotInitView(QAction *action)
}
m_listType = static_cast<BinViewType>(viewType);
}
-
+
if (m_itemView) {
delete m_itemView;
}
-
+
switch (m_listType) {
case BinIconView:
m_itemView = new QListView(m_splitter);
@@ -471,6 +492,9 @@ void Bin::slotInitView(QAction *action)
m_itemView->setModel(m_proxyModel);
m_itemView->setSelectionModel(m_proxyModel->selectionModel());
m_splitter->addWidget(m_itemView);
+ m_splitter->insertWidget(2, m_propertiesPanel);
+ m_splitter->setSizes(QList <int>() << 4 << 2);
+ m_collapser->collapse();
// setup some default view specific parameters
if (m_listType == BinTreeView) {
@@ -504,7 +528,6 @@ void Bin::slotSetIconSize(int size)
QSize zoom = m_iconSize;
zoom = zoom * (size / 4.0);
m_itemView->setIconSize(zoom);
- m_itemModel->setIconSize(zoom);
}
@@ -520,8 +543,8 @@ void Bin::slotMarkersNeedUpdate(const QString &id, const \
QList<int> &markers)
void Bin::closeEditing()
{
- delete m_propertiesPanel;
- m_propertiesPanel = NULL;
+ //delete m_propertiesPanel;
+ //m_propertiesPanel = NULL;
}
@@ -548,63 +571,71 @@ void Bin::contextMenuEvent(QContextMenuEvent *event)
m_menu->exec(event->globalPos());
}
-void Bin::slotShowClipProperties()
+
+void Bin::slotRefreshClipProperties()
{
QModelIndex current = m_proxyModel->selectionModel()->currentIndex();
if (current.isValid()) {
- ProjectClip *currentItem = static_cast<ProjectClip \
*>(m_proxyModel->mapToSource(current).internalPointer());
- showClipProperties(currentItem);
+ ProjectClip *clip = static_cast<ProjectClip \
*>(m_proxyModel->mapToSource(current).internalPointer()); + if (clip && \
!clip->isFolder()) { + showClipProperties(clip);
+ }
}
}
-void Bin::showClipProperties(const QModelIndex &ix)
+void Bin::slotSwitchClipProperties()
{
- ProjectClip *clip = static_cast<ProjectClip \
*>(m_proxyModel->mapToSource(ix).internalPointer());
- showClipProperties(clip);
+ QModelIndex current = m_proxyModel->selectionModel()->currentIndex();
+ slotSwitchClipProperties(current);
+}
+
+void Bin::slotSwitchClipProperties(const QModelIndex &ix)
+{
+ if (ix.isValid()) {
+ if (m_collapser->isWidgetCollapsed()) {
+ ProjectClip *clip = static_cast<ProjectClip \
*>(m_proxyModel->mapToSource(ix).internalPointer()); + if (clip && \
!clip->isFolder()) { + m_collapser->restore();
+ showClipProperties(clip);
+ }
+ }
+ else m_collapser->collapse();
+ }
+ else m_collapser->collapse();
}
void Bin::showClipProperties(ProjectClip *clip)
{
closeEditing();
- if (!clip) return;
- m_propertiesPanel = new QWidget(m_splitter);
- QVBoxLayout *lay = new QVBoxLayout;
- m_propertiesPanel->setLayout(lay);
+ if (!clip || m_propertiesPanel->width() == 0) return;
+ QMap <QString, QString> props = clip->properties();
+ m_propertiesTable->clearContents();
+ if (props.isEmpty()) {
+ // Producer for this clip is not ready yet or no properties in this clip
+ return;
+ }
// TODO: Build proper clip properties widget
//PropertiesView *view = new PropertiesView(clip, m_propertiesPanel);
- QTableWidget *table = new QTableWidget(this);
- table->setColumnCount(2);
- table->setRowCount(2);
- table->horizontalHeader()->hide();
- table->verticalHeader()->hide();
- QTableWidgetItem *key;
- QTableWidgetItem *value;
- Mlt::Properties *props = clip->properties();
- int video_index = props->get_int("video_index");
- int audio_index = props->get_int("audio_index");
- QString codecKey = "meta.media." + QString::number(video_index) + \
".codec.long_name";
- QString codec = props->get(codecKey.toUtf8().constData());
- key = new QTableWidgetItem(i18n("Video codec"));
- table->setItem(0, 0, key);
- value = new QTableWidgetItem(codec);
- table->setItem(0, 1, value);
-
- codecKey = "meta.media." + QString::number(audio_index) + ".codec.long_name";
- codec = props->get(codecKey.toUtf8().constData());
- key = new QTableWidgetItem(i18n("Audio codec"));
- table->setItem(1, 0, key);
- value = new QTableWidgetItem(codec);
- table->setItem(1, 1, value);
-
+
+ m_propertiesTable->setRowCount(props.size());
+ m_propertiesTable->horizontalHeader()->hide();
+ m_propertiesTable->verticalHeader()->hide();
+ QTableWidgetItem *keyitem;
+ QTableWidgetItem *valueitem;
+ QMapIterator<QString, QString> i(props);
+ int ix = 0;
+ while (i.hasNext()) {
+ i.next();
+ keyitem = new QTableWidgetItem(i.key());
+ m_propertiesTable->setItem(ix, 0, keyitem);
+ valueitem = new QTableWidgetItem(i.value());
+ m_propertiesTable->setItem(ix, 1, valueitem);
+ ix++;
+ }
//m_editedProducer= new Producer(producer, desc, pCore->clipPluginManager());
//connect(m_editedProducer, SIGNAL(updateClip()), this, \
SLOT(refreshEditedClip()));
//connect(m_editedProducer, SIGNAL(reloadClip(QString)), this, \
SLOT(reloadClip(QString)));
//connect(m_editedProducer, SIGNAL(editingDone()), this, SLOT(closeEditing()));
-
- lay->addWidget(table);
- m_splitter->addWidget(m_propertiesPanel);
- m_splitter->setStretchFactor(m_splitter->indexOf(m_itemView), 1);
- m_splitter->setStretchFactor(m_splitter->indexOf(m_propertiesPanel), 20);
}
void Bin::reloadClip(const QString &id)
diff --git a/src/bin/bin.h b/src/bin/bin.h
index 13a4e42..9317e9e 100644
--- a/src/bin/bin.h
+++ b/src/bin/bin.h
@@ -35,6 +35,7 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. class KdenliveDoc;
class QSplitter;
class KToolBar;
+class KSplitterCollapserButton;
class QMenu;
class ProjectItemModel;
class ProjectClip;
@@ -44,6 +45,7 @@ class Monitor;
class QItemSelectionModel;
class ProjectSortProxyModel;
class JobManager;
+class QTableWidget;
namespace Mlt {
class Producer;
@@ -302,7 +304,6 @@ private slots:
void slotSaveHeaders();
public slots:
- void showClipProperties(const QModelIndex &ix);
void slotThumbnailReady(const QString &id, const QImage &img);
/** @brief The producer for this clip is ready.
* @param id the clip id
@@ -311,7 +312,9 @@ public slots:
*/
void slotProducerReady(requestClipInfo info, Mlt::Producer *producer);
void slotDeleteClip();
- void slotShowClipProperties();
+ void slotRefreshClipProperties();
+ void slotSwitchClipProperties(const QModelIndex &ix);
+ void slotSwitchClipProperties();
void slotAddFolder();
protected:
@@ -339,6 +342,8 @@ private:
QByteArray m_headerInfo;
EventEater *m_eventEater;
QWidget *m_propertiesPanel;
+ QTableWidget *m_propertiesTable;
+ KSplitterCollapserButton *m_collapser;
Monitor *m_monitor;
QMenu *m_menu;
QAction *m_openAction;
diff --git a/src/bin/projectclip.cpp b/src/bin/projectclip.cpp
index de32a5b..348a090 100644
--- a/src/bin/projectclip.cpp
+++ b/src/bin/projectclip.cpp
@@ -243,9 +243,22 @@ bool ProjectClip::hasProducer() const
return m_producer!= NULL;
}
-Mlt::Properties *ProjectClip::properties()
+QMap <QString, QString> ProjectClip::properties()
{
- return new Mlt::Properties(m_producer->get_properties());
+ //TODO: move into its own class that creates its own widget (reuse \
clipproperties) + QMap <QString, QString> result;
+ if (m_producer) {
+ mlt_properties props = m_producer->get_properties();
+ QString key = "video_index";
+ int video_index = mlt_properties_get_int(props, key.toUtf8().constData());
+ QString codecKey = "meta.media." + QString::number(video_index) + \
".codec.long_name"; + result.insert(i18n("Video codec"), \
mlt_properties_get(props, codecKey.toUtf8().constData())); + key = \
"audio_index"; + int audio_index = mlt_properties_get_int(props, \
key.toUtf8().constData()); + codecKey = "meta.media." + \
QString::number(audio_index) + ".codec.long_name"; + result.insert(i18n("Audio \
codec"), mlt_properties_get(props, codecKey.toUtf8().constData())); + }
+ return result;
}
void ProjectClip::setZone(const QPoint &zone)
diff --git a/src/bin/projectclip.h b/src/bin/projectclip.h
index 7a4582f..0b276a1 100644
--- a/src/bin/projectclip.h
+++ b/src/bin/projectclip.h
@@ -130,7 +130,7 @@ public:
Mlt::Producer *producer();
//TODO
- Mlt::Properties *properties();
+ QMap <QString, QString> properties();
/** @brief Set properties on this clip. TODO: should we store all in MLT or use \
extra m_properties ?. */ void setProperties(QMap <QString, QString> properties);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index a77a64c..3a84445 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1133,7 +1133,7 @@ void MainWindow::setupActions()
addClips->addAction(addAction("download_resource", i18n("Online Resources"), \
this, SLOT(slotDownloadResources()), QIcon::fromTheme("download")));
- QAction *clipProperties = addAction("clip_properties", i18n("Clip Properties"), \
pCore->bin(), SLOT(slotShowClipProperties()), QIcon::fromTheme("document-edit")); + \
QAction *clipProperties = addAction("clip_properties", i18n("Clip Properties"), \
pCore->bin(), SLOT(slotSwitchClipProperties()), QIcon::fromTheme("document-edit")); \
clipProperties->setData("clip_properties"); clipProperties->setEnabled(false);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic