]> git.sesse.net Git - kdenlive/commitdiff
If a file has a license (for example when imported through online resource widget),
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 2 Jan 2012 22:09:29 +0000 (23:09 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 2 Jan 2012 22:09:29 +0000 (23:09 +0100)
display license info in clip properties

src/clipproperties.cpp
src/clipproperties.h
src/projectlist.cpp
src/utils/resourcewidget.cpp
src/widgets/clipproperties_ui.ui
src/widgets/freesound_ui.ui

index db4c3bc815e8f0601d1bd60987cbc9f152b1a9a9..59dfe0c203db8302abb58b8b6fc0fa023391e4a7 100644 (file)
 #include <KStandardDirs>
 #include <KDebug>
 #include <KFileItem>
+#include <kdeversion.h>
+#include <KUrlLabel>
+#include <KRun>
+
+#ifdef USE_NEPOMUK
+#if KDE_IS_VERSION(4,6,0)
+#include <Nepomuk/Variant>
+#include <Nepomuk/Resource>
+#include <Nepomuk/ResourceManager>
+#include <Nepomuk/Vocabulary/NIE>
+#endif
+#endif
+
 
 #include <QDir>
 
@@ -454,6 +467,32 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
     m_view.marker_delete->setIcon(KIcon("trash-empty"));
     m_view.marker_delete->setToolTip(i18n("Delete marker"));
 
+        // Check for Nepomuk metadata
+#ifdef USE_NEPOMUK
+#if KDE_IS_VERSION(4,6,0)
+    if (!url.isEmpty()) {
+        Nepomuk::ResourceManager::instance()->init();
+        Nepomuk::Resource res( url.path() );
+        // Check if file has a license
+        if (res.hasProperty(Nepomuk::Vocabulary::NIE::license())) {
+            QGridLayout *l = static_cast<QGridLayout *>(layout());
+            QString ltype = res.property(Nepomuk::Vocabulary::NIE::licenseType()).toString();
+            m_view.clip_license->setText(i18n("License: %1", res.property(Nepomuk::Vocabulary::NIE::license()).toString()));
+            if (ltype.startsWith("http")) {
+                m_view.clip_license->setUrl(ltype);
+                connect(m_view.clip_license, SIGNAL(leftClickedUrl(const QString &)), this, SLOT(slotOpenUrl(const QString &)));
+            }
+        }
+        else m_view.clip_license->setHidden(true);
+    }
+    else m_view.clip_license->setHidden(true);
+#else
+    m_view.clip_license->setHidden(true);
+#endif
+#else
+    m_view.clip_license->setHidden(true);
+#endif
+    
     slotFillMarkersList();
     connect(m_view.marker_new, SIGNAL(clicked()), this, SLOT(slotAddMarker()));
     connect(m_view.marker_edit, SIGNAL(clicked()), this, SLOT(slotEditMarker()));
@@ -463,7 +502,7 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
     connect(this, SIGNAL(accepted()), this, SLOT(slotApplyProperties()));
     connect(m_view.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApplyProperties()));
     m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
-    //adjustSize();
+    adjustSize();
 }
 
 
@@ -1035,6 +1074,11 @@ void ClipProperties::slotDeleteProxy()
       if (m_proxyContainer) delete m_proxyContainer;
 }
 
+void ClipProperties::slotOpenUrl(const QString &url)
+{
+    new KRun(KUrl(url), this);
+}
+
 #include "clipproperties.moc"
 
 
index 5dad49494b04b67eb975a57bfb427c0b062cdf23..93cf57eb8a2aa919c15f905246e6dca6ea3be664 100644 (file)
@@ -69,6 +69,7 @@ private slots:
     void slotApplyProperties();
     void slotModified();
     void slotDeleteProxy();
+    void slotOpenUrl(const QString &url);
 
 private:
     Ui::ClipProperties_UI m_view;
index aea4ddfe0685515c1d3fef2cd451a1dd3b680510..8802e80aea6cf67a8a0bbcae122f7f66667b6eeb 100644 (file)
@@ -1299,11 +1299,14 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
     
     KUrl url = clip->fileURL();
 #ifdef USE_NEPOMUK
-    if (!url.isEmpty() && KdenliveSettings::activate_nepomuk()) {
+    if (!url.isEmpty() && KdenliveSettings::activate_nepomuk() && clip->getProperty("description").isEmpty()) {
         // if file has Nepomuk comment, use it
         Nepomuk::Resource f(url.path());
         QString annotation = f.description();
-        if (!annotation.isEmpty()) item->setText(1, annotation);
+        if (!annotation.isEmpty()) {
+            item->setText(1, annotation);
+            clip->setProperty("description", annotation);
+        }
         item->setText(2, QString::number(f.rating()));
     }
 #endif
index c8cb51ed1d2ee0d97972d55ac1f6eb1feab64a30..60d6fc2cad1d0336ec35560c684fb232fc1385a6 100644 (file)
@@ -315,7 +315,8 @@ void ResourceWidget::parseLicense(const QString &licenseUrl)
         licenseName = "Creative Commons 0";
     else if (licenseUrl.endsWith("/publicdomain"))
         licenseName = "Public Domain";
-    item_license->setText(i18n("License: %1", licenseName));
+    else licenseName = i18n("Unknown");
+    item_license->setText(licenseName);
     item_license->setUrl(licenseUrl);
 }
 
index 62bf44926720421bbfa33a49339fd9c64a7c4c6e..41cb747d8347e8de9b6844ed4e0f9bda8a4ce6f1 100644 (file)
@@ -6,26 +6,23 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>280</width>
-    <height>503</height>
+    <width>298</width>
+    <height>512</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Clip Properties</string>
   </property>
   <layout class="QGridLayout" name="gridLayout_2">
-   <item row="7" column="1" colspan="2">
-    <spacer name="verticalSpacer_4">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
+   <item row="0" column="0" colspan="4">
+    <widget class="QLabel" name="clip_thumb">
+     <property name="text">
+      <string>Image preview</string>
      </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>20</width>
-       <height>17</height>
-      </size>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
      </property>
-    </spacer>
+    </widget>
    </item>
    <item row="1" column="0" colspan="4">
     <widget class="QLabel" name="label_path">
      </property>
     </widget>
    </item>
-   <item row="8" column="0" colspan="4">
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="0" colspan="4">
-    <widget class="QLabel" name="clip_thumb">
-     <property name="text">
-      <string>Image preview</string>
-     </property>
-     <property name="alignment">
-      <set>Qt::AlignCenter</set>
-     </property>
-    </widget>
-   </item>
-   <item row="6" column="0" colspan="4">
+   <item row="7" column="0" colspan="4">
     <widget class="QTabWidget" name="tabWidget">
      <property name="tabPosition">
       <enum>QTabWidget::South</enum>
      </widget>
     </widget>
    </item>
+   <item row="8" column="1" colspan="2">
+    <spacer name="verticalSpacer_4">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>17</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="9" column="0" colspan="4">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="0" colspan="4">
+    <widget class="KUrlLabel" name="clip_license">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <customwidgets>
-  <customwidget>
-   <class>KIntSpinBox</class>
-   <extends>QSpinBox</extends>
-   <header>knuminput.h</header>
-  </customwidget>
   <customwidget>
    <class>KDoubleNumInput</class>
    <extends>QWidget</extends>
    <header>knuminput.h</header>
   </customwidget>
   <customwidget>
-   <class>KLineEdit</class>
-   <extends>QLineEdit</extends>
-   <header>klineedit.h</header>
+   <class>KColorButton</class>
+   <extends>QPushButton</extends>
+   <header>kcolorbutton.h</header>
   </customwidget>
   <customwidget>
    <class>KComboBox</class>
    <header>kcombobox.h</header>
   </customwidget>
   <customwidget>
-   <class>KColorButton</class>
-   <extends>QPushButton</extends>
-   <header>kcolorbutton.h</header>
+   <class>KLineEdit</class>
+   <extends>QLineEdit</extends>
+   <header>klineedit.h</header>
+  </customwidget>
+  <customwidget>
+   <class>KUrlLabel</class>
+   <extends>QLabel</extends>
+   <header>kurllabel.h</header>
   </customwidget>
   <customwidget>
    <class>KRestrictedLine</class>
    <extends>KLineEdit</extends>
    <header>krestrictedline.h</header>
   </customwidget>
+  <customwidget>
+   <class>KIntSpinBox</class>
+   <extends>QSpinBox</extends>
+   <header>knuminput.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections>
index 5c3430203b62fc135f2dafe0c623dbfa358f5e27..d4934c59dc876e5870d96c0513082d6959111644 100644 (file)
@@ -87,7 +87,7 @@
         </property>
        </spacer>
       </item>
-      <item row="12" column="1" colspan="3">
+      <item row="13" column="1" colspan="3">
        <widget class="QPushButton" name="button_import">
         <property name="text">
          <string>Import</string>
         </property>
        </widget>
       </item>
-      <item row="12" column="0">
+      <item row="13" column="0">
        <widget class="QPushButton" name="button_preview">
         <property name="text">
          <string>Preview</string>
         </column>
        </widget>
       </item>
-      <item row="10" column="0" colspan="4">
-       <widget class="KUrlLabel" name="item_license">
-        <property name="text">
-         <string/>
-        </property>
-       </widget>
-      </item>
-      <item row="11" column="0">
+      <item row="12" column="0">
        <widget class="QCheckBox" name="sound_autoplay">
         <property name="text">
          <string>Auto play</string>
         </property>
        </widget>
       </item>
+      <item row="11" column="0">
+       <widget class="QLabel" name="label">
+        <property name="text">
+         <string>License</string>
+        </property>
+       </widget>
+      </item>
+      <item row="11" column="1" colspan="3">
+       <widget class="KUrlLabel" name="item_license">
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>