Commit 8b803ede authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Rename properties to kdenlive: scheme, some Bin fixes

parent b9204d28
......@@ -161,10 +161,10 @@ bool AbstractProjectItem::isFolder() const
bool AbstractProjectItem::rename(const QString &name)
{
if (m_name == name) return false;
QMap <QString, QString> newProperites;
QMap <QString, QString> oldProperites;
if (!isFolder()) {
// Rename clip
QMap <QString, QString> newProperites;
QMap <QString, QString> oldProperites;
oldProperites.insert("kdenlive:clipname", m_name);
newProperites.insert("kdenlive:clipname", name);
bin()->slotEditClipCommand(m_id, oldProperites, newProperites);
......@@ -204,6 +204,9 @@ QVariant AbstractProjectItem::data(DataType type) const
case ClipStatus:
data = QVariant(m_clipStatus);
break;
case ClipToolTip:
data = QVariant(getToolTip());
break;
default:
break;
}
......
......@@ -116,16 +116,17 @@ public:
virtual QPoint zone() const;
enum DataType {
DataName = 0,
DataDescription = 1,
DataDate = 2,
DataThumbnail = 3,
ItemTypeRole = 4,
DataDuration = 5,
JobType = Qt::UserRole + 1,
JobProgress = Qt::UserRole + 2,
JobMessage = Qt::UserRole + 3,
ClipStatus = Qt::UserRole + 4,
DataName = Qt::DisplayRole,
DataThumbnail = Qt::DecorationRole,
DataDescription = Qt::UserRole,
DataDate,
ItemTypeRole,
DataDuration,
JobType,
JobProgress,
JobMessage,
ClipStatus,
ClipToolTip = Qt::ToolTipRole
};
enum CLIPSTATUS {
......@@ -165,6 +166,7 @@ public:
virtual void setCurrent(bool current, bool notify = true);
virtual QDomElement toXml(QDomDocument &document) = 0;
virtual QString getToolTip() const = 0;
bool rename(const QString &name);
signals:
......
......@@ -107,6 +107,7 @@ Bin::Bin(QWidget* parent) :
m_proxyModel = new ProjectSortProxyModel(this);
m_proxyModel->setDynamicSortFilter(true);
QLineEdit *searchLine = new QLineEdit(this);
searchLine->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
searchLine->setClearButtonEnabled(true);
connect(searchLine, SIGNAL(textChanged(const QString &)), m_proxyModel, SLOT(slotSetSearchString(const QString &)));
m_toolbar->addWidget(searchLine);
......@@ -129,10 +130,12 @@ Bin::Bin(QWidget* parent) :
// Zoom slider
m_slider = new QSlider(Qt::Horizontal, this);
m_slider->setMaximumWidth(100);
m_slider->setMinimumWidth(40);
m_slider->setRange(0, 10);
m_slider->setValue(4);
connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSetIconSize(int)));
m_toolbar->addWidget(m_slider);
QWidgetAction * widgetslider = new QWidgetAction(this);
widgetslider->setDefaultWidget(m_slider);
// View type
KSelectAction *listType = new KSelectAction(QIcon::fromTheme("view-list-tree"), i18n("View Mode"), this);
......@@ -148,7 +151,19 @@ Bin::Bin(QWidget* parent) :
}
listType->setToolBarMode(KSelectAction::MenuMode);
connect(listType, SIGNAL(triggered(QAction*)), this, SLOT(slotInitView(QAction*)));
m_toolbar->addAction(listType);
// Settings menu
QMenu *settingsMenu = new QMenu(i18n("Settings"), this);
settingsMenu->addAction(listType);
QMenu *sliderMenu = new QMenu(i18n("Zoom"), this);
sliderMenu->setIcon(QIcon::fromTheme("file-zoom-in"));
sliderMenu->addAction(widgetslider);
settingsMenu->addMenu(sliderMenu);
QToolButton *button = new QToolButton;
button->setIcon(QIcon::fromTheme("configure"));
button->setMenu(settingsMenu);
button->setPopupMode(QToolButton::InstantPopup);
m_toolbar->addWidget(button);
m_eventEater = new EventEater(this);
connect(m_eventEater, SIGNAL(addClip()), this, SLOT(slotAddClip()));
......
......@@ -117,10 +117,10 @@ public:
QRect r2 = option.rect;
r2.adjust(decoWidth, mid, 0, 0);
QRectF bounding;
painter->drawText(r1, Qt::AlignLeft | Qt::AlignTop, index.data().toString(), &bounding);
painter->drawText(r1, Qt::AlignLeft | Qt::AlignTop, index.data(AbstractProjectItem::DataName).toString(), &bounding);
font.setBold(false);
painter->setFont(font);
QString subText = index.data(Qt::UserRole).toString();
QString subText = index.data(AbstractProjectItem::DataDuration).toString();
//int usage = index.data(UsageRole).toInt();
//if (usage != 0) subText.append(QString(" (%1)").arg(usage));
//if (option.state & (QStyle::State_Selected)) painter->setPen(option.palette.color(QPalette::Mid));
......
......@@ -76,6 +76,11 @@ ProjectClip::~ProjectClip()
// controller is deleted in bincontroller
}
QString ProjectClip::getToolTip() const
{
return url().toLocalFile();
}
QString ProjectClip::getXmlProperty(const QDomElement &producer, const QString &propertyName)
{
QString value;
......@@ -362,7 +367,7 @@ const QString ProjectClip::getFileHash() const
bool ProjectClip::hasProxy() const
{
QString proxy = getProducerProperty("proxy");
QString proxy = getProducerProperty("kdenlive:proxy");
if (proxy.isEmpty() || proxy == "-") return false;
return true;
}
......@@ -378,8 +383,8 @@ void ProjectClip::setProperties(QMap <QString, QString> properties, bool refresh
setProducerProperty(i.key().toUtf8().data(), i.value().toUtf8().data());
if (clipType() == SlideShow && keys.contains(i.key())) refreshProducer = true;
}
if (properties.contains("proxy")) {
QString value = properties.value("proxy");
if (properties.contains("kdenlive:proxy")) {
QString value = properties.value("kdenlive:proxy");
// If value is "-", that means user manually disabled proxy on this clip
if (value.isEmpty() || value == "-") {
// reset proxy
......@@ -392,7 +397,7 @@ void ProjectClip::setProperties(QMap <QString, QString> properties, bool refresh
}
else {
// A proxy was requested, make sure to keep original url
setProducerProperty("kdenlive_originalUrl", url().toLocalFile().toUtf8().data());
setProducerProperty("kdenlive:originalurl", url().toLocalFile().toUtf8().data());
bin()->startJob(m_id, AbstractClipJob::PROXYJOB);
}
}
......
......@@ -138,6 +138,8 @@ public:
/** @brief Get an XML property from MLT produced xml. */
static QString getXmlProperty(const QDomElement &producer, const QString &propertyName);
virtual QString getToolTip() const;
/** @brief The clip hash created from the clip's resource. */
const QString hash();
......
......@@ -71,6 +71,11 @@ ProjectClip* ProjectFolder::clip(const QString &id)
return NULL;
}
QString ProjectFolder::getToolTip() const
{
return QString(i18n("%1 clips", size()));
}
ProjectFolder* ProjectFolder::folder(const QString &id)
{
if (m_id == id) return this;
......
......@@ -77,6 +77,7 @@ public:
/** @brief Returns an xml description of the folder. */
QDomElement toXml(QDomDocument &document);
virtual QString getToolTip() const;
protected:
......
......@@ -73,16 +73,11 @@ QVariant ProjectItemModel::data(const QModelIndex& index, int role) const
icon = QIcon(pix);
}
return icon;
}
if (role == Qt::UserRole) {
AbstractProjectItem *item = static_cast<AbstractProjectItem *>(index.internalPointer());
return item->data(AbstractProjectItem::DataDuration);
}
if (role == AbstractProjectItem::JobType || role == AbstractProjectItem::JobProgress || role == AbstractProjectItem::JobMessage || role == AbstractProjectItem::ItemTypeRole || role == AbstractProjectItem::ClipStatus) {
else {
AbstractProjectItem *item = static_cast<AbstractProjectItem *>(index.internalPointer());
return item->data((AbstractProjectItem::DataType) role);
}
return QVariant();
}
......
......@@ -1877,7 +1877,7 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy)
// Prepare updated properties
QMap <QString, QString> newProps;
QMap <QString, QString> oldProps;
if (!doProxy) newProps.insert("proxy", "-");
if (!doProxy) newProps.insert("kdenlive:proxy", "-");
// Parse clips
for (int i = 0; i < clipList.count(); ++i) {
......@@ -1896,7 +1896,7 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy)
QString path = proxydir + item->hash() + '.' + (t == Image ? "png" : getDocumentProperty("proxyextension"));
// insert required duration for proxy
newProps.insert("proxy_out", item->getProducerProperty("out"));
newProps.insert("proxy", path);
newProps.insert("kdenlive:proxy", path);
}
else if (!pCore->binController()->hasClip(item->clipId())) {
// Force clip reload
......@@ -1905,7 +1905,7 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy)
// We need to insert empty proxy so that undo will work
//TODO: how to handle clip properties
//oldProps = clip->currentProperties(newProps);
if (doProxy) oldProps.insert("proxy", "-");
if (doProxy) oldProps.insert("kdenlive:proxy", "-");
new EditClipCommand(this, item->clipId(), oldProps, newProps, true, command);
}
}
......
......@@ -38,10 +38,10 @@ ClipController::ClipController(BinController *bincontroller, Mlt::Producer& prod
m_masterProducer = &producer;
if (!m_masterProducer->is_valid()) qDebug()<<"// WARNING, USING INVALID PRODUCER";
else {
QString proxy = m_properties->get("proxy");
QString proxy = m_properties->get("kdenlive:proxy");
if (proxy.length() > 2) {
// This is a proxy producer, read original url from kdenlive property
m_url = QUrl::fromLocalFile(m_properties->get("kdenlive_originalUrl"));
m_url = QUrl::fromLocalFile(m_properties->get("kdenlive:originalurl"));
}
else m_url = QUrl::fromLocalFile(m_properties->get("resource"));
m_service = m_properties->get("mlt_service");
......@@ -74,10 +74,10 @@ void ClipController::addMasterProducer(Mlt::Producer &producer)
m_masterProducer = &producer;
if (!m_masterProducer->is_valid()) qDebug()<<"// WARNING, USING INVALID PRODUCER";
else {
QString proxy = m_properties->get("proxy");
QString proxy = m_properties->get("kdenlive:proxy");
if (proxy.length() > 2) {
// This is a proxy producer, read original url from kdenlive property
m_url = QUrl::fromLocalFile(m_properties->get("kdenlive_originalUrl"));
m_url = QUrl::fromLocalFile(m_properties->get("kdenlive:originalurl"));
}
else m_url = QUrl::fromLocalFile(m_properties->get("resource"));
m_service = m_properties->get("mlt_service");
......@@ -150,7 +150,7 @@ const QString ClipController::clipId()
const char *ClipController::getPassPropertiesList() const
{
return "proxy,kdenlive_originalUrl,force_aspect_ratio,force_aspect_num,force_aspect_den,force_aspect_ratio,force_fps,force_progressive,force_tff,threads,force_colorspace,set.force_full_luma,templatetext,file_hash";
return "kdenlive:proxy,kdenlive:originalurl,force_aspect_ratio,force_aspect_num,force_aspect_den,force_aspect_ratio,force_fps,force_progressive,force_tff,threads,force_colorspace,set.force_full_luma,templatetext,file_hash";
}
void ClipController::updateProducer(const QString &id, Mlt::Producer* producer)
......
......@@ -599,7 +599,7 @@ void Monitor::slotExtractCurrentFrame()
{
QImage frame;
// check if we are using a proxy
if (m_controller && !m_controller->property("proxy").isEmpty() && m_controller->property("proxy") != "-") {
if (m_controller && !m_controller->property("kdenlive:proxy").isEmpty() && m_controller->property("kdenlive:proxy") != "-") {
// using proxy, use original clip url to get frame
frame = render->extractFrame(render->seekFramePosition(), m_controller->property("resource"));
}
......
......@@ -252,8 +252,8 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps
ClipType t = m_clip->clipType();
if (props.contains("proxy") && props.value("proxy") != "-") {
KFileItem f(QUrl(props.value("proxy")));
if (props.contains("kdenlive:proxy") && props.value("kdenlive:proxy") != "-") {
KFileItem f(QUrl(props.value("kdenlive:proxy")));
f.setDelayedMimeTypes(true);
QFrame* line = new QFrame();
line->setFrameShape(QFrame::HLine);
......@@ -1226,7 +1226,7 @@ void ClipProperties::slotUpdateDurationFormat(int ix)
void ClipProperties::slotDeleteProxy()
{
const QString proxy = m_clip->getProperty("proxy");
const QString proxy = m_clip->getProperty("kdenlive:proxy");
if (proxy.isEmpty())
return;
emit deleteProxy(proxy);
......
......@@ -138,7 +138,7 @@ ArchiveWidget::ArchiveWidget(const QString &projectName, const QDomDocument &doc
else {
videoUrls.insert(id, clip->clipUrl().path());
// Check if we have a proxy
QString proxy = clip->property("proxy");
QString proxy = clip->property("kdenlive:proxy");
if (!proxy.isEmpty() && proxy != "-" && QFile::exists(proxy)) proxyUrls.insert(id, proxy);
}
}
......@@ -722,10 +722,10 @@ bool ArchiveWidget::processProjectFile()
QUrl dest = m_replacementList.value(src);
if (!dest.isEmpty()) e.setAttribute("resource", dest.path());
}
if (e.hasAttribute("proxy") && e.attribute("proxy") != "-") {
QUrl src(e.attribute("proxy"));
if (e.hasAttribute("kdenlive:proxy") && e.attribute("kdenlive:proxy") != "-") {
QUrl src(e.attribute("kdenlive:proxy"));
QUrl dest = m_replacementList.value(src);
if (!dest.isEmpty()) e.setAttribute("proxy", dest.path());
if (!dest.isEmpty()) e.setAttribute("kdenlive:proxy", dest.path());
}
}
......
......@@ -233,7 +233,7 @@ const QString ProxyJob::destination() const
stringMap ProxyJob::cancelProperties()
{
QMap <QString, QString> props;
props.insert(QLatin1String("proxy"), QLatin1String("-"));
props.insert(QLatin1String("kdenlive:proxy"), QLatin1String("-"));
return props;
}
......@@ -278,7 +278,7 @@ QMap <ProjectClip *, AbstractClipJob *> ProxyJob::prepareJob(Bin *bin, QList <Pr
for (int i = 0; i < clips.count(); i++) {
ProjectClip *item = clips.at(i);
QString id = item->clipId();
QString path = item->getProducerProperty("proxy");
QString path = item->getProducerProperty("kdenlive:proxy");
if (path.isEmpty()) {
item->setJobStatus(AbstractClipJob::PROXYJOB, JobCrashed, -1, i18n("Failed to create proxy, empty path."));
continue;
......
......@@ -258,7 +258,7 @@ void ProjectItem::setConditionalJobStatus(ClipJobStatus status, AbstractClipJob:
bool ProjectItem::hasProxy() const
{
if (m_clip == NULL) return false;
if (m_clip->getProperty("proxy").size() < 2 || data(0, JobProgressRole).toInt() == JobCrashed) return false;
if (m_clip->getProperty("kdenlive:proxy").size() < 2 || data(0, JobProgressRole).toInt() == JobCrashed) return false;
return true;
}
......@@ -300,7 +300,7 @@ bool ProjectItem::playlistHasProxies(const QString& path)
QString root = doc.documentElement().attribute("root");
QDomNodeList kdenliveProducers = doc.elementsByTagName("kdenlive_producer");
for (int i = 0; i < kdenliveProducers.count(); ++i) {
QString proxy = kdenliveProducers.at(i).toElement().attribute("proxy");
QString proxy = kdenliveProducers.at(i).toElement().attribute("kdenlive:proxy");
if (!proxy.isEmpty() && proxy != "-") return true;
}
return false;
......
......@@ -858,8 +858,8 @@ void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap <QString, QSt
if (!clip)
return;
clip->setProperties(properties);
if (properties.contains("proxy")) {
if (properties.value("proxy") == "-" || properties.value("proxy").isEmpty())
if (properties.contains("kdenlive:proxy")) {
if (properties.value("kdenlive:proxy") == "-" || properties.value("kdenlive:proxy").isEmpty())
// this should only apply to proxy jobs
clip->setConditionalJobStatus(NoJob, AbstractClipJob::PROXYJOB);
}
......
......@@ -656,10 +656,10 @@ void Render::processFileProperties()
QString path;
bool proxyProducer;
QString proxy = ProjectClip::getXmlProperty(info.xml, "proxy");
QString proxy = ProjectClip::getXmlProperty(info.xml, "kdenlive:proxy");
if (!proxy.isEmpty()) {
if (proxy == "-") {
path = ProjectClip::getXmlProperty(info.xml, "kdenlive_originalUrl");
path = ProjectClip::getXmlProperty(info.xml, "kdenlive:originalurl");
proxyProducer = false;
}
else {
......
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