Finish sharing integration (you should now be able to share rendered videos in...

Finish sharing integration (you should now be able to share rendered videos in one click with Youtube/Android phone/telegram/email)
parent 9921ee4a
......@@ -51,6 +51,7 @@
#include <QTimer>
#include <QTreeWidgetItem>
#include <QJsonObject>
#include <QJsonArray>
#include <qglobal.h>
#include <qstring.h>
......@@ -245,6 +246,11 @@ RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidg
m_infoMessage->setCloseButtonVisible(false);
m_infoMessage->hide();
m_jobInfoMessage = new KMessageWidget;
m_view.jobInfo->addWidget(m_jobInfoMessage);
m_jobInfoMessage->setCloseButtonVisible(false);
m_jobInfoMessage->hide();
m_view.encoder_threads->setMinimum(0);
m_view.encoder_threads->setMaximum(QThread::idealThreadCount());
m_view.encoder_threads->setToolTip(i18n("Encoding threads (0 is automatic)"));
......@@ -358,6 +364,7 @@ RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidg
#ifdef KF5_USE_PURPOSE
m_shareMenu = new Purpose::Menu();
m_view.shareButton->setMenu(m_shareMenu);
connect(m_shareMenu, &Purpose::Menu::finished, this, &RenderWidget::slotShareActionFinished);
#else
m_view.shareButton->setEnabled(false);
#endif
......@@ -366,6 +373,28 @@ RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidg
adjustSize();
}
#if KF5_USE_PURPOSE
void RenderWidget::slotShareActionFinished(const QJsonObject &output, int error, const QString &message)
{
m_jobInfoMessage->hide();
if (error) {
KMessageBox::error(this, i18n("There was a problem sharing the document: %1", message),
i18n("Share"));
} else {
const QString url = output["url"].toString();
if (url.isEmpty()) {
m_jobInfoMessage->setMessageType(KMessageWidget::Positive);
m_jobInfoMessage->setText(i18n("Document shared successfully"));
m_jobInfoMessage->show();
} else {
KMessageBox::information(this, i18n("You can find the shared document at: <a href=\"%1\">%1</a>", url),
i18n("Share"), QString(),
KMessageBox::Notify | KMessageBox::AllowLink);
}
}
}
#endif
QSize RenderWidget::sizeHint() const
{
// Make sure the widget has minimum size on opening
......@@ -381,6 +410,7 @@ RenderWidget::~RenderWidget()
delete m_jobsDelegate;
delete m_scriptsDelegate;
delete m_infoMessage;
delete m_jobInfoMessage;
}
void RenderWidget::slotEditItem(QTreeWidgetItem *item)
......@@ -2234,7 +2264,7 @@ void RenderWidget::setRenderStatus(const QString &dest, int status, const QStrin
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()->setInputData(QJsonObject{ {QStringLiteral("mimeType"), QMimeDatabase().mimeTypeForFile(item->text(1)).name()}, {QStringLiteral("urls"), QJsonArray({item->text(1)})}});
m_shareMenu->model()->setPluginType(QStringLiteral("Export"));
m_shareMenu->reload();
#endif
......@@ -2309,7 +2339,7 @@ void RenderWidget::slotCheckJob()
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()->setInputData(QJsonObject{ {QStringLiteral("mimeType"), QMimeDatabase().mimeTypeForFile(current->text(1)).name()}, {QStringLiteral("urls"), QJsonArray({current->text(1)})}});
m_shareMenu->model()->setPluginType(QStringLiteral("Export"));
m_shareMenu->reload();
m_view.shareButton->setEnabled(true);
......
......@@ -197,6 +197,8 @@ private slots:
void adjustSpeed(int videoQuality);
/** @brief Display warning on proxy rendering. */
void slotProxyWarn(bool enableProxy);
/** @brief User shared a rendered file, give feedback. */
void slotShareActionFinished(const QJsonObject &output, int error, const QString &message);
private:
Ui::RenderWidget_UI m_view;
......@@ -206,6 +208,7 @@ private:
bool m_blockProcessing;
QString m_renderer;
KMessageWidget *m_infoMessage;
KMessageWidget *m_jobInfoMessage;
QMap<int, QString> m_errorMessages;
#ifdef KF5_USE_PURPOSE
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1236</width>
<height>622</height>
<width>1508</width>
<height>832</height>
</rect>
</property>
<property name="windowTitle">
......@@ -58,7 +58,7 @@
</widget>
</item>
<item>
<widget class="KUrlRequester" name="out_file" native="true"/>
<widget class="KUrlRequester" name="out_file"/>
</item>
</layout>
</item>
......@@ -761,7 +761,7 @@
<string>Job Queue</string>
</attribute>
<layout class="QGridLayout" name="gridLayout2">
<item row="2" column="3">
<item row="3" column="3">
<spacer name="jobSpace">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -774,20 +774,57 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QPushButton" name="abort_job">
<property name="text">
<string>Abort Job</string>
</property>
</widget>
</item>
<item row="2" column="5">
<item row="3" column="5">
<widget class="QPushButton" name="buttonClose2">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="clean_up">
<property name="text">
<string>Clean Up</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="6">
<widget class="QCheckBox" name="shutdown">
<property name="text">
<string>Shutdown computer after renderings</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="start_job">
<property name="text">
<string>Start Job</string>
</property>
</widget>
</item>
<item row="3" 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>
<item row="0" column="0" colspan="6">
<widget class="QSplitter" name="splitter">
<property name="orientation">
......@@ -852,42 +889,8 @@
</widget>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="clean_up">
<property name="text">
<string>Clean Up</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="6">
<widget class="QCheckBox" name="shutdown">
<property name="text">
<string>Shutdown computer after renderings</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="start_job">
<property name="text">
<string>Start Job</string>
</property>
</widget>
</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>
<layout class="QHBoxLayout" name="jobInfo"/>
</item>
</layout>
</widget>
......@@ -959,17 +962,17 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>KUrlRequester</class>
<extends>QWidget</extends>
<header>kurlrequester.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
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