Make project folders have a smaller icon, disable titles if the MLT...

Make project folders have a smaller icon, disable titles if the MLT kdenlivetitle module is not installed:
http://kdenlive.org/mantis/view.php?id=1201

svn path=/trunk/kdenlive/; revision=4087
parent 99c751f3
......@@ -174,6 +174,7 @@ set(kdenlive_SRCS
positionedit.cpp
trackdialog.cpp
subprojectitem.cpp
folderprojectitem.cpp
addclipcutcommand.cpp
)
......
......@@ -23,13 +23,17 @@
#include "gentime.h"
#include <QTreeWidgetItem>
#include <KLocale>
const int FRAME_SIZE = 90;
const int MAXCLIPDURATION = 15000;
enum OPERATIONTYPE { NONE = 0, MOVE = 1, RESIZESTART = 2, RESIZEEND = 3, FADEIN = 4, FADEOUT = 5, TRANSITIONSTART = 6, TRANSITIONEND = 7, MOVEGUIDE = 8, KEYFRAME = 9, SEEK = 10, SPACER = 11, RUBBERSELECTION = 12};
enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9, FOLDER = 10};
enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9 };
enum PROJECTITEMTYPE { PROJECTCLIPTYPE = QTreeWidgetItem::UserType, PROJECTFOLDERTYPE, PROJECTSUBCLIPTYPE };
enum GRAPHICSRECTITEM { AVWIDGET = 70000 , LABELWIDGET , TRANSITIONWIDGET , GROUPWIDGET};
enum PROJECTTOOL { SELECTTOOL = 0 , RAZORTOOL = 1 , SPACERTOOL = 2 };
......
/***************************************************************************
* Copyright (C) 2007 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "folderprojectitem.h"
#include "definitions.h"
#include <KDebug>
#include <KLocale>
#include <KIcon>
FolderProjectItem::FolderProjectItem(QTreeWidget * parent, const QStringList & strings, const QString &clipId) :
QTreeWidgetItem(parent, strings, PROJECTFOLDERTYPE),
m_groupName(strings.at(1)),
m_clipId(clipId)
{
setSizeHint(0, QSize(65, QFontInfo(font(1)).pixelSize() * 2));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
setIcon(0, KIcon("folder").pixmap(sizeHint(0)));
setToolTip(1, "<b>" + i18n("Folder"));
//setFlags(Qt::NoItemFlags);
//kDebug() << "Constructed with clipId: " << m_clipId;
}
FolderProjectItem::~FolderProjectItem()
{
}
QString FolderProjectItem::clipId() const
{
return m_clipId;
}
const QString FolderProjectItem::groupName() const
{
return m_groupName;
}
void FolderProjectItem::setGroupName(const QString name)
{
m_groupName = name;
setText(1, name);
}
/***************************************************************************
* Copyright (C) 2007 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef FOLDERPROJECTITEM_H
#define FOLDERPROJECTITEM_H
#include <QTreeWidgetItem>
#include <QTreeWidget>
/** \brief Represents a clip or a folder in the projecttree
*
* This class represents a clip or folder in the projecttree and in the document(?) */
class FolderProjectItem : public QTreeWidgetItem
{
public:
FolderProjectItem(QTreeWidget* parent, const QStringList & strings, const QString &clipId);
virtual ~FolderProjectItem();
QString clipId() const;
const QString groupName() const;
void setGroupName(const QString name);
private:
QString m_groupName;
QString m_clipId;
};
#endif
......@@ -466,6 +466,11 @@
<default></default>
</entry>
<entry name="hastitleproducer" type="Bool">
<label>Is MLT compiled with Qt4 Kdenlive title support.</label>
<default>true</default>
</entry>
<entry name="producerslist" type="StringList">
<label>List of available MLT producers.</label>
<default></default>
......
......@@ -997,7 +997,7 @@ void MainWindow::setupActions()
switchMon->setText(i18n("Switch monitor"));
switchMon->setShortcut(Qt::Key_T);
connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
collection->addAction("resize_timeline_clip_start", resizeStart);
resizeStart->setShortcut(Qt::Key_1);
......@@ -1423,7 +1423,7 @@ void MainWindow::newFile(bool showProjectSettings)
ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
if (w->exec() != QDialog::Accepted) return;
if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
profileName = w->selectedProfile();
projectFolder = w->selectedFolder();
......@@ -1791,7 +1791,7 @@ void MainWindow::slotEditProjectSettings()
QString profile = w->selectedProfile();
m_activeDocument->setProjectFolder(w->selectedFolder());
if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
if (m_activeDocument->profilePath() != profile) {
// Profile was changed
......
......@@ -29,23 +29,8 @@
const int DurationRole = Qt::UserRole + 1;
// folder
ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, const QString &clipId) :
QTreeWidgetItem(parent, strings),
m_groupname(strings.at(1)),
m_clipType(FOLDER),
m_clipId(clipId),
m_clip(NULL)
{
setSizeHint(0, QSize(65, 45));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
setIcon(0, KIcon("folder"));
setToolTip(1, "<b>" + i18n("Folder"));
//kDebug() << "Constructed as folder, with clipId: " << m_clipId << ", and groupname: " << m_groupname;
}
ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip) :
QTreeWidgetItem(parent)
QTreeWidgetItem(parent, PROJECTCLIPTYPE)
{
setSizeHint(0, QSize(65, 45));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
......@@ -65,7 +50,7 @@ ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip) :
}
ProjectItem::ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip) :
QTreeWidgetItem(parent)
QTreeWidgetItem(parent, PROJECTCLIPTYPE)
{
setSizeHint(0, QSize(65, 45));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
......@@ -109,11 +94,6 @@ int ProjectItem::clipMaxDuration() const
return m_clip->getProperty("duration").toInt();
}
bool ProjectItem::isGroup() const
{
return m_clipType == FOLDER;
}
QStringList ProjectItem::names() const
{
QStringList result;
......@@ -130,7 +110,7 @@ QDomElement ProjectItem::toXml() const
const KUrl ProjectItem::clipUrl() const
{
if (m_clipType != COLOR && m_clipType != VIRTUAL && m_clipType != UNKNOWN && m_clipType != FOLDER)
if (m_clipType != COLOR && m_clipType != VIRTUAL && m_clipType != UNKNOWN)
return KUrl(m_clip->getProperty("resource"));
else return KUrl();
}
......@@ -164,17 +144,6 @@ void ProjectItem::clearProperty(const QString &key)
m_clip->clearProperty(key);
}
const QString ProjectItem::groupName() const
{
return m_groupname;
}
void ProjectItem::setGroupName(const QString name)
{
m_groupname = name;
setText(1, name);
}
DocClipBase *ProjectItem::referencedClip()
{
return m_clip;
......
......@@ -38,8 +38,6 @@ class DocClipBase;
class ProjectItem : public QTreeWidgetItem
{
public:
/** Create folder item */
ProjectItem(QTreeWidget * parent, const QStringList & strings, const QString &clipId);
ProjectItem(QTreeWidget * parent, DocClipBase *clip);
ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip);
virtual ~ProjectItem();
......@@ -53,7 +51,6 @@ public:
* The clipId is used both to identify clips and folders (groups) */
const QString &clipId() const;
QStringList names() const;
bool isGroup() const;
const KUrl clipUrl() const;
int clipMaxDuration() const;
CLIPTYPE clipType() const;
......@@ -62,12 +59,9 @@ public:
void setProperties(QMap <QString, QString> props);
void setProperty(const QString &key, const QString &value);
void clearProperty(const QString &key);
const QString groupName() const;
void setGroupName(const QString name);
QString getClipHash() const;
private:
QString m_groupname;
CLIPTYPE m_clipType;
QString m_clipId;
void slotSetToolTip();
......
This diff is collapsed.
......@@ -38,6 +38,7 @@
#include "definitions.h"
#include "timecode.h"
#include "kdenlivesettings.h"
#include "folderprojectitem.h"
namespace Mlt
{
......@@ -75,7 +76,7 @@ public:
}
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
if (index.column() == 1) {
if (index.column() == 1 && !index.data(DurationRole).isNull()) {
QRect r1 = option.rect;
painter->save();
if (option.state & (QStyle::State_Selected)) {
......@@ -174,7 +175,7 @@ private:
void selectItemById(const QString &clipId);
ProjectItem *getItemById(const QString &id);
QTreeWidgetItem *getAnyItemById(const QString &id);
ProjectItem *getFolderItemById(const QString &id);
FolderProjectItem *getFolderItemById(const QString &id);
QAction *m_editAction;
QAction *m_deleteAction;
QAction *m_openAction;
......
......@@ -21,6 +21,7 @@
#include "projectlistview.h"
#include "projectitem.h"
#include "subprojectitem.h"
#include "folderprojectitem.h"
#include "kdenlivesettings.h"
#include <KDebug>
......@@ -117,23 +118,23 @@ void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event)
{
QTreeWidgetItem *it = itemAt(event->pos());
if (!it) {
emit addClip();
return;
emit addClip();
return;
}
ProjectItem *item;
if (it->type() == QTreeWidgetItem::UserType + 1) {
if (it->type() == PROJECTFOLDERTYPE) {
if ((columnAt(event->pos().x()) == 1)) QTreeWidget::mouseDoubleClickEvent(event);
return;
}
if (it->type() == PROJECTSUBCLIPTYPE) {
// subitem
item = static_cast <ProjectItem *>(it->parent());
} else item = static_cast <ProjectItem *>(it);
if (!(item->flags() & Qt::ItemIsDragEnabled)) return;
if (item->isGroup()) {
if ((columnAt(event->pos().x()) == 1)) QTreeWidget::mouseDoubleClickEvent(event);
} else {
if ((columnAt(event->pos().x()) == 1) && (item->clipType() == SLIDESHOW || item->clipType() == TEXT || item->clipType() == COLOR)) QTreeWidget::mouseDoubleClickEvent(event);
else if ((columnAt(event->pos().x()) == 2) && it->type() != QTreeWidgetItem::UserType + 1) QTreeWidget::mouseDoubleClickEvent(event);
else emit showProperties(item->referencedClip());
}
if ((columnAt(event->pos().x()) == 1) && (item->clipType() == SLIDESHOW || item->clipType() == TEXT || item->clipType() == COLOR)) QTreeWidget::mouseDoubleClickEvent(event);
else if ((columnAt(event->pos().x()) == 2) && it->type() != PROJECTSUBCLIPTYPE) QTreeWidget::mouseDoubleClickEvent(event);
else emit showProperties(item->referencedClip());
}
// virtual
......@@ -148,24 +149,18 @@ void ProjectListView::dragEnterEvent(QDragEnterEvent *event)
// virtual
void ProjectListView::dropEvent(QDropEvent *event)
{
ProjectItem *item = NULL;
FolderProjectItem *item = NULL;
QTreeWidgetItem *it = itemAt(event->pos());
if (it) {
if (it->type() == QTreeWidgetItem::UserType + 1) {
// subitem
item = static_cast <ProjectItem *>(it->parent());
} else item = static_cast <ProjectItem *>(it);
while (it && it->type() != PROJECTFOLDERTYPE) {
it = it->parent();
}
if (it) item = static_cast <FolderProjectItem *>(it);
if (event->mimeData()->hasUrls()) {
QString groupName;
QString groupId;
if (item) {
if (item->parent()) item = static_cast <ProjectItem *>(item->parent());
if (item->isGroup()) {
groupName = item->groupName();
groupId = item->clipId();
}
groupName = item->groupName();
groupId = item->clipId();
}
emit addClip(event->mimeData()->urls(), groupName, groupId);
event->setDropAction(Qt::CopyAction);
......@@ -173,29 +168,25 @@ void ProjectListView::dropEvent(QDropEvent *event)
return;
} else if (event->mimeData()->hasFormat("kdenlive/producerslist")) {
if (item) {
if (item->parent()) item = static_cast <ProjectItem *>(item->parent());
if (item->isGroup()) {
//emit addClip(event->mimeData->text());
const QList <QTreeWidgetItem *> list = selectedItems();
ProjectItem *clone;
QString parentId = item->clipId();
foreach(QTreeWidgetItem *it, list) {
// TODO allow dragging of folders ?
if (!((ProjectItem *) it)->isGroup()/* && ((ProjectItem *) it)->clipId() < 10000*/) {
if (it->parent()) clone = (ProjectItem*) it->parent()->takeChild(it->parent()->indexOfChild(it));
else clone = (ProjectItem*) takeTopLevelItem(indexOfTopLevelItem(it));
if (clone) {
item->addChild(clone);
QMap <QString, QString> props;
props.insert("groupname", item->groupName());
props.insert("groupid", parentId);
clone->setProperties(props);
}
//emit addClip(event->mimeData->text());
const QList <QTreeWidgetItem *> list = selectedItems();
ProjectItem *clone;
QString parentId = item->clipId();
foreach(QTreeWidgetItem *it, list) {
// TODO allow dragging of folders ?
if (it->type() == PROJECTCLIPTYPE) {
if (it->parent()) clone = (ProjectItem*) it->parent()->takeChild(it->parent()->indexOfChild(it));
else clone = (ProjectItem*) takeTopLevelItem(indexOfTopLevelItem(it));
if (clone) {
item->addChild(clone);
QMap <QString, QString> props;
props.insert("groupname", item->groupName());
props.insert("groupid", parentId);
clone->setProperties(props);
}
}
} else item = NULL;
}
if (!item) {
} else item = NULL;
}
} else {
// item dropped in empty zone, move it to top level
const QList <QTreeWidgetItem *> list = selectedItems();
ProjectItem *clone;
......@@ -251,7 +242,7 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event)
QTreeWidgetItem *it = itemAt(m_DragStartPosition);
if (!it) return;
if (it->type() == QTreeWidgetItem::UserType + 1) {
if (it->type() == PROJECTSUBCLIPTYPE) {
// subitem
SubProjectItem *clickItem = static_cast <SubProjectItem *>(it);
if (clickItem && (clickItem->flags() & Qt::ItemIsDragEnabled)) {
......@@ -273,20 +264,20 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event)
drag->exec();
}
} else {
ProjectItem *clickItem = static_cast <ProjectItem *>(it);
if (clickItem && (clickItem->flags() & Qt::ItemIsDragEnabled)) {
if (it && (it->flags() & Qt::ItemIsDragEnabled)) {
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
const QList <QTreeWidgetItem *> list = selectedItems();
QStringList ids;
foreach(const QTreeWidgetItem *item, list) {
const ProjectItem *clip = static_cast <const ProjectItem *>(item);
if (!clip->isGroup()) ids.append(clip->clipId());
else {
if (item->type() == PROJECTFOLDERTYPE) {
const int children = item->childCount();
for (int i = 0; i < children; i++) {
ids.append(static_cast <ProjectItem *>(item->child(i))->clipId());
}
} else {
const ProjectItem *clip = static_cast <const ProjectItem *>(item);
ids.append(clip->clipId());
}
}
if (ids.isEmpty()) return;
......@@ -296,7 +287,7 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event)
//mimeData->setText(ids.join(";")); //doc.toString());
//mimeData->setImageData(image);
drag->setMimeData(mimeData);
drag->setPixmap(clickItem->icon(0).pixmap(iconSize()));
drag->setPixmap(it->icon(0).pixmap(iconSize()));
drag->setHotSpot(QPoint(0, 50));
drag->exec();
}
......
......@@ -163,7 +163,7 @@ void ProjectSettings::slotUpdateFiles(bool cacheOnly)
usedSize += clip->fileSize();
}
}
#if QT_VERSION >= 0x040500
#if QT_VERSION >= 0x040500
allFiles.removeDuplicates();
#endif
files_count->setText(QString::number(allFiles.count()));
......
......@@ -294,10 +294,10 @@ void RenderWidget::slotUpdateButtons(KUrl url)
}
if (url != 0) {
QListWidgetItem *item = m_view.size_list->currentItem();
if (!item) {
m_view.buttonStart->setEnabled(false);
return;
}
if (!item) {
m_view.buttonStart->setEnabled(false);
return;
}
QString extension = item->data(ExtensionRole).toString();
url = filenameWithExtension(url, extension);
m_view.out_file->setUrl(url);
......
......@@ -20,6 +20,7 @@
#include "subprojectitem.h"
#include "timecode.h"
#include "definitions.h"
#include "kdenlivesettings.h"
#include "docclipbase.h"
......@@ -30,7 +31,7 @@
const int DurationRole = Qt::UserRole + 1;
SubProjectItem::SubProjectItem(QTreeWidgetItem * parent, int in, int out) :
QTreeWidgetItem(parent, QTreeWidgetItem::UserType + 1), m_in(in), m_out(out)
QTreeWidgetItem(parent, PROJECTSUBCLIPTYPE), m_in(in), m_out(out)
{
setSizeHint(0, QSize(65, 30));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
......
......@@ -296,6 +296,8 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render
initAnimation();
connect(anim_start, SIGNAL(toggled(bool)), this, SLOT(slotAnimStart(bool)));
connect(anim_end, SIGNAL(toggled(bool)), this, SLOT(slotAnimEnd(bool)));
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(KdenliveSettings::hastitleproducer());
}
TitleWidget::~TitleWidget()
......
......@@ -299,6 +299,18 @@ void Wizard::checkMltComponents()
} else {
imageItem->setIcon(0, m_okIcon);
}
// Check MLT title module
QTreeWidgetItem *titleItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Title module"));
titleItem->setData(1, Qt::UserRole, i18n("Required to work with titles"));
titleItem->setSizeHint(0, itemSize);
if (!result.contains("- kdenlivetitle")) {
KdenliveSettings::setHastitleproducer(false);
titleItem->setIcon(0, m_badIcon);
} else {
titleItem->setIcon(0, m_okIcon);
KdenliveSettings::setHastitleproducer(true);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment