From 3a2f497995094f5c93d0f41d9916afac2e9d7217 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 11 Feb 2013 23:56:06 +0100 Subject: [PATCH] Show clip size & fps in project tree tooltip --- src/docclipbase.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++ src/docclipbase.h | 2 ++ src/projectitem.cpp | 44 +++++++------------------------------- 3 files changed, 60 insertions(+), 37 deletions(-) diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index dcf4ca82..938cdb7e 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -299,6 +299,57 @@ QDomElement DocClipBase::toXML(bool hideTemporaryProperties) const return doc.documentElement(); } +const QString DocClipBase::shortInfo() const +{ + + QString info; + if (m_clipType == AV || m_clipType == VIDEO || m_clipType == IMAGE || m_clipType == PLAYLIST) { + info = m_properties.value("frame_size") + " "; + if (m_properties.contains("fps")) { + info.append(i18n("%1 fps", m_properties.value("fps").left(5))); + } + if (!info.simplified().isEmpty()) info.prepend(" - "); + } + else if (m_clipType == AUDIO) { + info = " - " + m_properties.value("frequency") + i18n("Hz"); + } + QString tip = ""; + switch (m_clipType) { + case AUDIO: + tip.append(i18n("Audio clip") + "" + info + "
" + fileURL().path()); + break; + case VIDEO: + tip.append(i18n("Mute video clip") + "" + info + "
" + fileURL().path()); + break; + case AV: + tip.append(i18n("Video clip") + "" + info + "
" + fileURL().path()); + break; + case COLOR: + tip.append(i18n("Color clip")); + break; + case IMAGE: + tip.append(i18n("Image clip") + "" + info + "
" + fileURL().path()); + break; + case TEXT: + if (!fileURL().isEmpty() && getProperty("xmldata").isEmpty()) tip.append(i18n("Template text clip") + "
" + fileURL().path()); + else tip.append(i18n("Text clip") + "
" + fileURL().path()); + break; + case SLIDESHOW: + tip.append(i18n("Slideshow clip") + "
" + fileURL().directory()); + break; + case VIRTUAL: + tip.append(i18n("Virtual clip")); + break; + case PLAYLIST: + tip.append(i18n("Playlist clip") + "" + info + "
" + fileURL().path()); + break; + default: + tip.append(i18n("Unknown clip")); + break; + } + return tip; +} + void DocClipBase::setAudioThumbCreated(bool isDone) { diff --git a/src/docclipbase.h b/src/docclipbase.h index 9eb12719..c56af717 100644 --- a/src/docclipbase.h +++ b/src/docclipbase.h @@ -211,6 +211,8 @@ Q_OBJECT public: /** Return the current values for a set of properties */ QMap currentProperties(QMap props); QMap metadata() const; + /** @brief Returns a short info string about the clip to display in tooltip */ + const QString shortInfo() const; private: // Private attributes /** The number of times this clip is used in the project - the number of references to this clip diff --git a/src/projectitem.cpp b/src/projectitem.cpp index d1508f2e..aeb4a870 100644 --- a/src/projectitem.cpp +++ b/src/projectitem.cpp @@ -194,40 +194,7 @@ void ProjectItem::slotSetToolTip() if (hasProxy() && data(0, JobTypeRole).toInt() != PROXYJOB) { tip.append(i18n("Proxy clip") + " | "); } - tip.append(""); - switch (m_clipType) { - case AUDIO: - tip.append(i18n("Audio clip") + "
" + clipUrl().path()); - break; - case VIDEO: - tip.append(i18n("Mute video clip") + "
" + clipUrl().path()); - break; - case AV: - tip.append(i18n("Video clip") + "
" + clipUrl().path()); - break; - case COLOR: - tip.append(i18n("Color clip")); - break; - case IMAGE: - tip.append(i18n("Image clip") + "
" + clipUrl().path()); - break; - case TEXT: - if (!clipUrl().isEmpty() && m_clip->getProperty("xmldata").isEmpty()) tip.append(i18n("Template text clip") + "
" + clipUrl().path()); - else tip.append(i18n("Text clip") + "
" + clipUrl().path()); - break; - case SLIDESHOW: - tip.append(i18n("Slideshow clip") + "
" + clipUrl().directory()); - break; - case VIRTUAL: - tip.append(i18n("Virtual clip")); - break; - case PLAYLIST: - tip.append(i18n("Playlist clip") + "
" + clipUrl().path()); - break; - default: - tip.append(i18n("Unknown clip")); - break; - } + tip.append(m_clip->shortInfo()); setToolTip(0, tip); } @@ -237,6 +204,10 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con if (m_clip == NULL) return; QString prefix; + + m_clip->setProperties(attributes); + m_clip->setMetadata(metadata); + if (m_clipType == UNKNOWN) { QString cliptype = attributes.value("type"); if (cliptype == "audio") m_clipType = AUDIO; @@ -254,6 +225,8 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con } } } + else if (attributes.contains("frame_size")) slotSetToolTip(); + if (attributes.contains("duration")) { GenTime duration = GenTime(attributes.value("duration").toInt(), KdenliveSettings::project_fps()); QString itemdata = data(0, DurationRole).toString(); @@ -266,9 +239,6 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con // No duration known, use an arbitrary one until it is. } - m_clip->setProperties(attributes); - m_clip->setMetadata(metadata); - if (m_clip->description().isEmpty()) { if (metadata.contains("description")) { m_clip->setProperty("description", metadata.value("description")); -- 2.39.2