Some fun with the KF5 Purpose framework (new share button in render widget)

parent 396940c2
...@@ -95,7 +95,7 @@ else() ...@@ -95,7 +95,7 @@ else()
set(KF5_ICON_COMPATIBILITY TRUE) set(KF5_ICON_COMPATIBILITY TRUE)
endif() endif()
find_package(KF5 REQUIRED COMPONENTS Archive Bookmarks CoreAddons Config ConfigWidgets DBusAddons KIO WidgetsAddons NotifyConfig NewStuff XmlGui Notifications GuiAddons TextWidgets IconThemes Crash Declarative Solid OPTIONAL_COMPONENTS DocTools FileMetaData) find_package(KF5 REQUIRED COMPONENTS Archive Bookmarks CoreAddons Config ConfigWidgets DBusAddons KIO WidgetsAddons NotifyConfig NewStuff XmlGui Notifications GuiAddons TextWidgets IconThemes Crash Declarative Solid OPTIONAL_COMPONENTS DocTools FileMetaData Purpose PurposeWidgets)
if (KF5FileMetaData_FOUND) if (KF5FileMetaData_FOUND)
message(STATUS "Found KF5 FileMetadata to extract file metadata") message(STATUS "Found KF5 FileMetadata to extract file metadata")
...@@ -104,6 +104,13 @@ else() ...@@ -104,6 +104,13 @@ else()
message(STATUS "KF5 FileMetadata not found, file metadata will not be available") message(STATUS "KF5 FileMetadata not found, file metadata will not be available")
endif() endif()
if (KF5Purpose_FOUND)
message(STATUS "Found KF5 Purpose, filesharing enabled")
set(KF5_PURPOSE TRUE)
else()
message(STATUS "KF5 Purpose not found, filesharing disabled")
endif()
# Search MLT package. # Search MLT package.
find_package(MLT ${MLT_MIN_VERSION} REQUIRED) find_package(MLT ${MLT_MIN_VERSION} REQUIRED)
set_package_properties(MLT PROPERTIES set_package_properties(MLT PROPERTIES
......
...@@ -308,6 +308,11 @@ if (KF5_FILEMETADATA) ...@@ -308,6 +308,11 @@ if (KF5_FILEMETADATA)
target_link_libraries(kdenliveLib KF5::FileMetaData) target_link_libraries(kdenliveLib KF5::FileMetaData)
endif() endif()
if (KF5_PURPOSE)
add_definitions(-DKF5_USE_PURPOSE)
target_link_libraries(kdenliveLib KF5::Purpose KF5::PurposeWidgets)
endif()
if (Qt5WebKitWidgets_FOUND) if (Qt5WebKitWidgets_FOUND)
message(STATUS "Found Qt5 WebKitWidgets. You can use your Freesound.org credentials to download files") message(STATUS "Found Qt5 WebKitWidgets. You can use your Freesound.org credentials to download files")
add_definitions(-DQT5_USE_WEBKIT) add_definitions(-DQT5_USE_WEBKIT)
......
...@@ -50,9 +50,15 @@ ...@@ -50,9 +50,15 @@
#include <QThread> #include <QThread>
#include <QTimer> #include <QTimer>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QJsonObject>
#include <qglobal.h> #include <qglobal.h>
#include <qstring.h> #include <qstring.h>
#ifdef KF5_USE_PURPOSE
#include <Purpose/AlternativesModel>
#include <PurposeWidgets/Menu>
#endif
#include <locale> #include <locale>
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
#include <xlocale.h> #include <xlocale.h>
...@@ -348,6 +354,13 @@ RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidg ...@@ -348,6 +354,13 @@ RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidg
(!interface->isServiceRegistered(QStringLiteral("org.kde.ksmserver")) && !interface->isServiceRegistered(QStringLiteral("org.gnome.SessionManager")))) { (!interface->isServiceRegistered(QStringLiteral("org.kde.ksmserver")) && !interface->isServiceRegistered(QStringLiteral("org.gnome.SessionManager")))) {
m_view.shutdown->setEnabled(false); m_view.shutdown->setEnabled(false);
} }
#ifdef KF5_USE_PURPOSE
m_shareMenu = new Purpose::Menu();
m_view.shareButton->setMenu(m_shareMenu);
#else
m_view.shareButton->setEnabled(false);
#endif
refreshView(); refreshView();
focusFirstVisibleItem(); focusFirstVisibleItem();
adjustSize(); adjustSize();
...@@ -2219,6 +2232,12 @@ void RenderWidget::setRenderStatus(const QString &dest, int status, const QStrin ...@@ -2219,6 +2232,12 @@ void RenderWidget::setRenderStatus(const QString &dest, int status, const QStrin
est.append(when.toString(QStringLiteral("hh:mm:ss"))); est.append(when.toString(QStringLiteral("hh:mm:ss")));
QString t = i18n("Rendering finished in %1", est); QString t = i18n("Rendering finished in %1", est);
item->setData(1, Qt::UserRole, t); item->setData(1, Qt::UserRole, t);
#ifdef KF5_USE_PURPOSE
m_shareMenu->model()->setInputData(QJsonObject{ {QStringLiteral("mimeType"), QStringLiteral("video/mp4")}, {QStringLiteral("urls"), item->text(1)}});
m_shareMenu->model()->setPluginType(QStringLiteral("Export"));
m_shareMenu->reload();
#endif
QString notif = i18n("Rendering of %1 finished in %2", item->text(1), est); QString notif = i18n("Rendering of %1 finished in %2", item->text(1), est);
KNotification *notify = new KNotification(QStringLiteral("RenderFinished")); KNotification *notify = new KNotification(QStringLiteral("RenderFinished"));
notify->setText(notif); notify->setText(notif);
...@@ -2288,6 +2307,16 @@ void RenderWidget::slotCheckJob() ...@@ -2288,6 +2307,16 @@ void RenderWidget::slotCheckJob()
m_view.start_job->setEnabled(current->status() == WAITINGJOB); m_view.start_job->setEnabled(current->status() == WAITINGJOB);
} }
activate = true; activate = true;
#ifdef KF5_USE_PURPOSE
if (current->status() == FINISHEDJOB) {
m_shareMenu->model()->setInputData(QJsonObject{ {QStringLiteral("mimeType"), QMimeDatabase().mimeTypeForFile(current->text(1)).name()}, {QStringLiteral("urls"), current->text(1)}});
m_shareMenu->model()->setPluginType(QStringLiteral("Export"));
m_shareMenu->reload();
m_view.shareButton->setEnabled(true);
} else {
m_view.shareButton->setEnabled(false);
}
#endif
} }
m_view.abort_job->setEnabled(activate); m_view.abort_job->setEnabled(activate);
/* /*
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
#include <QPushButton> #include <QPushButton>
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#ifdef KF5_USE_PURPOSE
namespace Purpose { class Menu; }
#endif
#include "definitions.h" #include "definitions.h"
#include "ui_renderwidget_ui.h" #include "ui_renderwidget_ui.h"
...@@ -204,6 +208,9 @@ private: ...@@ -204,6 +208,9 @@ private:
KMessageWidget *m_infoMessage; KMessageWidget *m_infoMessage;
QMap<int, QString> m_errorMessages; QMap<int, QString> m_errorMessages;
#ifdef KF5_USE_PURPOSE
Purpose::Menu *m_shareMenu;
#endif
void parseMltPresets(); void parseMltPresets();
void parseProfiles(const QString &selectedProfile = QString()); void parseProfiles(const QString &selectedProfile = QString());
void parseFile(const QString &exportFile, bool editable); void parseFile(const QString &exportFile, bool editable);
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1504</width> <width>1236</width>
<height>816</height> <height>622</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -58,11 +58,7 @@ ...@@ -58,11 +58,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="KUrlRequester" name="out_file"> <widget class="KUrlRequester" name="out_file" native="true"/>
<property name="mode">
<set>KFile::File|KFile::LocalOnly</set>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
...@@ -785,14 +781,14 @@ ...@@ -785,14 +781,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="4"> <item row="2" column="5">
<widget class="QPushButton" name="buttonClose2"> <widget class="QPushButton" name="buttonClose2">
<property name="text"> <property name="text">
<string>Close</string> <string>Close</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="5"> <item row="0" column="0" colspan="6">
<widget class="QSplitter" name="splitter"> <widget class="QSplitter" name="splitter">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -863,7 +859,7 @@ ...@@ -863,7 +859,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="5"> <item row="1" column="0" colspan="6">
<widget class="QCheckBox" name="shutdown"> <widget class="QCheckBox" name="shutdown">
<property name="text"> <property name="text">
<string>Shutdown computer after renderings</string> <string>Shutdown computer after renderings</string>
...@@ -877,6 +873,22 @@ ...@@ -877,6 +873,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="4">
<widget class="QToolButton" name="shareButton">
<property name="text">
<string>Share</string>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="arrowType">
<enum>Qt::DownArrow</enum>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="scriptsTab"> <widget class="QWidget" name="scriptsTab">
......
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