Commit 42b10c96 authored by Julius Künzel's avatar Julius Künzel
Browse files

KNewStuff: centralize code, use KNS3::QtQuickDialogWrapper if possible

parent 72161958
......@@ -25,7 +25,12 @@
#include "mltconnection.h"
#include "mainwindow.h"
/*#include <knewstuff_version.h>
#if KNEWSTUFF_VERSION < QT_VERSION_CHECK(5,78,0)
#include <kns3/downloaddialog.h>
#else
#include <kns3/qtquickdialogwrapper.h>
#endif*/
UrlListParamWidget::UrlListParamWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent)
: AbstractParamWidget(std::move(model), index, parent)
......@@ -209,22 +214,6 @@ void UrlListParamWidget::openFile()
}
}
int UrlListParamWidget::getNewStuff(const QString &configFile)
{
KNS3::Entry::List entries;
QPointer<KNS3::DownloadDialog> dialog = new KNS3::DownloadDialog(configFile);
if (dialog->exec() != 0) {
entries = dialog->changedEntries();
}
for (const KNS3::Entry &entry : qAsConst(entries)) {
if (entry.status() == KNS3::Entry::Installed) {
qCDebug(KDENLIVE_LOG) << "// Installed files: " << entry.installedFiles();
}
}
delete dialog;
return entries.size();
}
void UrlListParamWidget::downloadNewItems()
{
const QString configFile = m_model->data(m_index, AssetParameterModel::NewStuffRole).toString();
......@@ -233,7 +222,7 @@ void UrlListParamWidget::downloadNewItems()
return;
}
if (getNewStuff(configFile) > 0) {
if (pCore->getNewStuff(configFile) > 0) {
if(configFile.contains(QStringLiteral("kdenlive_wipes.knsrc"))) {
MltConnection::refreshLumas();
}
......
......@@ -77,11 +77,6 @@ public:
private:
QStringList m_fileExt;
/** @brief Instantiates a "Get Hot New Stuff" dialog.
* @param configFile configuration file for KNewStuff
* @return number of installed items */
int getNewStuff(const QString &configFile = QString());
public slots:
/** @brief Toggle the comments on or off
*/
......
......@@ -1093,3 +1093,8 @@ void Core::cleanup()
disconnect(m_mainWindow->getMainTimeline()->controller(), &TimelineController::durationChanged, m_projectManager, &ProjectManager::adjustProjectDuration);
m_mainWindow->getMainTimeline()->controller()->clipActions.clear();
}
int Core::getNewStuff(const QString &config)
{
return m_mainWindow->getNewStuff(config);
}
......@@ -264,6 +264,10 @@ public:
MixAlignment getMixAlign(int cid) const;
/** @brief Closing current document, do some cleanup */
void cleanup();
/** @brief Instantiates a "Get Hot New Stuff" dialog.
* @param configFile configuration file for KNewStuff
* @return number of installed items */
int getNewStuff(const QString &configFile);
private:
explicit Core();
......
......@@ -805,27 +805,11 @@ void RenderWidget::slotCopyToFavorites()
void RenderWidget::slotDownloadNewRenderProfiles()
{
if (getNewStuff(QStringLiteral(":data/kdenlive_renderprofiles.knsrc")) > 0) {
if (pCore->getNewStuff(QStringLiteral(":data/kdenlive_renderprofiles.knsrc")) > 0) {
reloadProfiles();
}
}
int RenderWidget::getNewStuff(const QString &configFile)
{
KNS3::Entry::List entries;
QPointer<KNS3::DownloadDialog> dialog = new KNS3::DownloadDialog(configFile);
if (dialog->exec() != 0) {
entries = dialog->changedEntries();
}
for (const KNS3::Entry &entry : qAsConst(entries)) {
if (entry.status() == KNS3::Entry::Installed) {
qCDebug(KDENLIVE_LOG) << "// Installed files: " << entry.installedFiles();
}
}
delete dialog;
return entries.size();
}
void RenderWidget::slotEditProfile()
{
QTreeWidgetItem *item = m_view.formats->currentItem();
......
......@@ -236,7 +236,6 @@ private:
/** @brief Create a rendering profile from MLT preset. */
QTreeWidgetItem *loadFromMltPreset(const QString &groupName, const QString &path, const QString &profileName);
void checkCodecs();
int getNewStuff(const QString &configFile);
void prepareRendering(bool delayedRendering, const QString &chapterFile);
void generateRenderFiles(QDomDocument doc, const QString &playlistPath, int in, int out, bool delayedRendering);
......
......@@ -100,7 +100,12 @@
#include <KToolBar>
#include <KXMLGUIFactory>
#include <klocalizedstring.h>
#include <knewstuff_version.h>
#if KNEWSTUFF_VERSION < QT_VERSION_CHECK(5,78,0)
#include <kns3/downloaddialog.h>
#else
#include <kns3/qtquickdialogwrapper.h>
#endif
#include <kns3/knewstuffaction.h>
#include <ktogglefullscreenaction.h>
#include <kwidgetsaddons_version.h>
......@@ -3401,17 +3406,22 @@ void MainWindow::slotResizeItemEnd()
int MainWindow::getNewStuff(const QString &configFile)
{
#if KNEWSTUFF_VERSION < QT_VERSION_CHECK(5,78,0)
KNS3::Entry::List entries;
QPointer<KNS3::DownloadDialog> dialog = new KNS3::DownloadDialog(configFile);
if (dialog->exec() != 0) {
entries = dialog->changedEntries();
}
for (const KNS3::Entry &entry : qAsConst(entries)) {
delete dialog;
#else
KNS3::QtQuickDialogWrapper dialog(configFile );
const QList<KNSCore::EntryInternal> entries = dialog.exec();
#endif
for (const auto &entry : qAsConst(entries)) {
if (entry.status() == KNS3::Entry::Installed) {
qCDebug(KDENLIVE_LOG) << "// Installed files: " << entry.installedFiles();
}
}
delete dialog;
return entries.size();
}
......
......@@ -159,6 +159,11 @@ public:
/** @brief Show a key binding in status bar */
void showKeyBinding(const QString &text = QString());
/** @brief Instantiates a "Get Hot New Stuff" dialog.
* @param configFile configuration file for KNewStuff
* @return number of installed items */
int getNewStuff(const QString &configFile);
protected:
/** @brief Closes the window.
* @return false if the user presses "Cancel" on a confirmation dialog or
......@@ -267,10 +272,6 @@ private:
void saveOptions();
void loadGenerators();
/** @brief Instantiates a "Get Hot New Stuff" dialog.
* @param configFile configuration file for KNewStuff
* @return number of installed items */
int getNewStuff(const QString &configFile = QString());
QStringList m_pluginFileNames;
QByteArray m_timelineState;
void buildDynamicActions();
......
......@@ -22,6 +22,7 @@
#include "titlewidget.h"
#include "core.h"
#include "mainwindow.h"
#include "bin/bin.h"
#include "doc/kthumb.h"
#include "gradientwidget.h"
......@@ -37,7 +38,12 @@
#include <KMessageWidget>
#include <KRecentDirs>
#include <klocalizedstring.h>
/*#include <knewstuff_version.h>
#if KNEWSTUFF_VERSION < QT_VERSION_CHECK(5,78,0)
#include <kns3/downloaddialog.h>
#else
#include <kns3/qtquickdialogwrapper.h>
#endif*/
#include "kdenlive_debug.h"
#include <QButtonGroup>
......@@ -2212,28 +2218,12 @@ QUrl TitleWidget::saveTitle(QUrl url)
void TitleWidget::downloadTitleTemplates()
{
if (getNewStuff(QStringLiteral(":data/kdenlive_titles.knsrc")) > 0) {
if (pCore->getNewStuff(QStringLiteral(":data/kdenlive_titles.knsrc")) > 0) {
refreshTitleTemplates(m_projectTitlePath);
refreshTemplateBoxContents();
}
}
int TitleWidget::getNewStuff(const QString &configFile)
{
KNS3::Entry::List entries;
QPointer<KNS3::DownloadDialog> dialog = new KNS3::DownloadDialog(configFile);
if (dialog->exec() != 0) {
entries = dialog->changedEntries();
}
for (const KNS3::Entry &entry : qAsConst(entries)) {
if (entry.status() == KNS3::Entry::Installed) {
qCDebug(KDENLIVE_LOG) << "// Installed files: " << entry.installedFiles();
}
}
delete dialog;
return entries.size();
}
QDomDocument TitleWidget::xml()
{
QDomDocument doc = m_titledocument.xml(m_startViewport, m_endViewport);
......
......@@ -238,9 +238,8 @@ private:
void loadGradients();
void storeGradient(const QString &gradientData);
/** Open title download dialog */
/** @brief Open title download dialog */
void downloadTitleTemplates();
int getNewStuff(const QString &configFile);
/** @brief Read patterns from config file
*/
......
......@@ -23,13 +23,19 @@
#include "../model/transitiontreemodel.hpp"
#include "assets/assetlist/view/qmltypes/asseticonprovider.hpp"
#include "dialogs/profilesdialog.h"
#include "core.h"
#include "mainwindow.h"
#include "mltconnection.h"
#include "transitions/transitionlist/model/transitionfilter.hpp"
#include "transitions/transitionsrepository.hpp"
#include <QQmlContext>
#include <knewstuff_version.h>
/*#if KNEWSTUFF_VERSION < QT_VERSION_CHECK(5,78,0)
#include <kns3/downloaddialog.h>
#else
#include <kns3/qtquickdialogwrapper.h>
#endif*/
TransitionListWidget::TransitionListWidget(QWidget *parent)
: AssetListWidget(parent)
......@@ -80,25 +86,9 @@ void TransitionListWidget::setFilterType(const QString &type)
}
}
int TransitionListWidget::getNewStuff(const QString &configFile)
{
KNS3::Entry::List entries;
QPointer<KNS3::DownloadDialog> dialog = new KNS3::DownloadDialog(configFile);
if (dialog->exec() != 0) {
entries = dialog->changedEntries();
}
for (const KNS3::Entry &entry : qAsConst(entries)) {
if (entry.status() == KNS3::Entry::Installed) {
qCDebug(KDENLIVE_LOG) << "// Installed files: " << entry.installedFiles();
}
}
delete dialog;
return entries.size();
}
void TransitionListWidget::downloadNewLumas()
{
if (getNewStuff(QStringLiteral(":data/kdenlive_wipes.knsrc")) > 0) {
if (pCore->getNewStuff(QStringLiteral(":data/kdenlive_wipes.knsrc")) > 0) {
MltConnection::refreshLumas();
// TODO: refresh currently displayed trans ?
}
......
......@@ -47,7 +47,6 @@ public:
void editCustomAsset(const QModelIndex &index) override;
private:
TransitionListWidgetProxy *m_proxy;
int getNewStuff(const QString &configFile);
signals:
void reloadFavorites();
......
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