Commit b9085edc authored by Juku Trump's avatar Juku Trump Committed by Jean-Baptiste Mardelle

Move Download dialogs (GHNS) to more relevant places

Differential revision: https://phabricator.kde.org/D15736
parent 943c39c5
......@@ -132,6 +132,15 @@ Rectangle {
assetlist.setFilterType("favorites")
}
}
ToolButton {
id: downloadTransitions
visible: !isEffectList
iconName: "edit-download"
tooltip: i18n('Download New Wipes...')
onClicked: {
assetlist.downloadNewLumas()
}
}
Rectangle {
//This is a spacer
Layout.fillHeight: false
......
......@@ -36,6 +36,7 @@
#include <KRun>
#include <kio_version.h>
#include <knotifications_version.h>
#include <kns3/downloaddialog.h>
#include "kdenlive_debug.h"
#include <QDBusConnectionInterface>
......@@ -187,6 +188,7 @@ RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidg
m_view.buttonEdit->setIconSize(iconSize);
m_view.buttonSave->setIconSize(iconSize);
m_view.buttonFavorite->setIconSize(iconSize);
m_view.buttonDownload->setIconSize(iconSize);
m_view.buttonDelete->setIcon(QIcon::fromTheme(QStringLiteral("trash-empty")));
m_view.buttonDelete->setToolTip(i18n("Delete profile"));
......@@ -204,6 +206,9 @@ RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidg
m_view.buttonFavorite->setIcon(QIcon::fromTheme(QStringLiteral("favorite")));
m_view.buttonFavorite->setToolTip(i18n("Copy profile to favorites"));
m_view.buttonDownload->setIcon(QIcon::fromTheme(QStringLiteral("edit-download")));
m_view.buttonDownload->setToolTip(i18n("Download New Render Profiles..."));
m_view.out_file->button()->setToolTip(i18n("Select output destination"));
m_view.advanced_params->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
......@@ -289,6 +294,7 @@ RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidg
connect(m_view.buttonEdit, &QAbstractButton::clicked, this, &RenderWidget::slotEditProfile);
connect(m_view.buttonDelete, &QAbstractButton::clicked, this, &RenderWidget::slotDeleteProfile);
connect(m_view.buttonFavorite, &QAbstractButton::clicked, this, &RenderWidget::slotCopyToFavorites);
connect(m_view.buttonDownload, &QAbstractButton::clicked, this, &RenderWidget::slotDownloadNewRenderProfiles);
connect(m_view.abort_job, &QAbstractButton::clicked, this, &RenderWidget::slotAbortCurrentJob);
connect(m_view.start_job, &QAbstractButton::clicked, this, &RenderWidget::slotStartCurrentJob);
......@@ -762,6 +768,29 @@ void RenderWidget::slotCopyToFavorites()
}
}
void RenderWidget::slotDownloadNewRenderProfiles()
{
if (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 : 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();
......
......@@ -183,6 +183,7 @@ private slots:
void slotPlayRendering(QTreeWidgetItem *item, int);
void slotStartCurrentJob();
void slotCopyToFavorites();
void slotDownloadNewRenderProfiles();
void slotUpdateEncodeThreads(int);
void slotUpdateRescaleHeight(int);
void slotUpdateRescaleWidth(int);
......@@ -228,6 +229,7 @@ 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);
signals:
void abortProcess(const QString &url);
......
......@@ -215,11 +215,7 @@
<ActionList name="dock_actions" />
</Menu>
<Menu name="settings" >
<Action name="get_new_lumas" />
<Action name="get_new_keyboardschemes" />
<Action name="get_new_profiles" />
<Action name="get_new_mlt_profiles" />
<Action name="get_new_titles" />
<Action name="run_wizard" />
<Action name="force_icon_theme" />
<Action name="themes_menu" />
......
......@@ -1156,11 +1156,6 @@ void MainWindow::setupActions()
addAction(QStringLiteral("zoom_in"), m_zoomIn);
addAction(QStringLiteral("zoom_out"), m_zoomOut);
KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
KNS3::standardAction(i18n("Download New Keyboard Schemes..."), this, SLOT(slotGetNewKeyboardStuff()), actionCollection(), "get_new_keyboardschemes");
KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
addAction(QStringLiteral("run_wizard"), i18n("Run Config Wizard"), this, SLOT(slotRunWizard()), QIcon::fromTheme(QStringLiteral("tools-wizard")));
addAction(QStringLiteral("project_settings"), i18n("Project Settings"), this, SLOT(slotEditProjectSettings()),
QIcon::fromTheme(QStringLiteral("configure")));
......@@ -2073,6 +2068,29 @@ void MainWindow::slotGuidesUpdated()
void MainWindow::slotEditKeys()
{
KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
// Find the combobox inside KShortcutsDialog for choosing keyboard scheme
QComboBox *schemesList = nullptr;
foreach (QLabel *label, dialog.findChildren<QLabel *>()) {
if (label->text() == i18n("Current scheme:")) {
schemesList = qobject_cast<QComboBox *>(label->buddy());
break;
}
}
// If scheme choosing combobox was found, find the "More Actions" button in the same
// dialog that provides a dropdown menu with additional actions, and add
// "Download New Keyboard Schemes..." button into that menu
if (schemesList) {
foreach (QPushButton *button, dialog.findChildren<QPushButton *>()) {
if (button->text() == i18n("More Actions")) {
QMenu *moreActionsMenu = button->menu();
moreActionsMenu->addAction(i18n("Download New Keyboard Schemes..."), this,
[this, schemesList]{slotGetNewKeyboardStuff(schemesList);});
break;
}
}
} else {
qWarning() << "Could not get list of schemes. Downloading new schemes is not available.";
}
dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
dialog.configure();
}
......@@ -2936,36 +2954,24 @@ int MainWindow::getNewStuff(const QString &configFile)
return entries.size();
}
void MainWindow::slotGetNewTitleStuff()
{
if (getNewStuff(QStringLiteral(":data/kdenlive_titles.knsrc")) > 0) {
// get project title path
QString titlePath = pCore->currentDoc()->projectDataFolder() + QStringLiteral("/titles/");
TitleWidget::refreshTitleTemplates(titlePath);
}
}
void MainWindow::slotGetNewLumaStuff()
{
if (getNewStuff(QStringLiteral(":data/kdenlive_wipes.knsrc")) > 0) {
initEffects::refreshLumas();
// TODO: refresh currently displayd trans ?
}
}
void MainWindow::slotGetNewKeyboardStuff()
void MainWindow::slotGetNewKeyboardStuff(QComboBox *schemesList)
{
if (getNewStuff(QStringLiteral(":data/kdenlive_keyboardschemes.knsrc")) > 0) {
// Is there something to do ?
}
}
void MainWindow::slotGetNewRenderStuff()
{
if (getNewStuff(QStringLiteral(":data/kdenlive_renderprofiles.knsrc")) > 0)
if (m_renderWidget) {
m_renderWidget->reloadProfiles();
// Refresh keyboard schemes list (schemes list creation code copied from KShortcutSchemesEditor)
QStringList schemes;
schemes << QStringLiteral("Default");
// List files in the shortcuts subdir, each one is a scheme. See KShortcutSchemesHelper::{shortcutSchemeFileName,exportActionCollection}
const QStringList shortcutsDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QCoreApplication::applicationName() + QStringLiteral("/shortcuts"), QStandardPaths::LocateDirectory);
qCDebug(KDENLIVE_LOG) << "shortcut scheme dirs:" << shortcutsDirs;
Q_FOREACH (const QString &dir, shortcutsDirs) {
Q_FOREACH (const QString &file, QDir(dir).entryList(QDir::Files | QDir::NoDotAndDotDot)) {
qCDebug(KDENLIVE_LOG) << "shortcut scheme file:" << file;
schemes << file;
}
}
schemesList->clear();
schemesList->addItems(schemes);
}
}
void MainWindow::slotAutoTransition()
......
......@@ -371,10 +371,7 @@ private slots:
/** @brief Select all clips in timeline. */
void slotSelectAllTracks();
void slotUnselectAllTracks();
void slotGetNewLumaStuff();
void slotGetNewKeyboardStuff();
void slotGetNewTitleStuff();
void slotGetNewRenderStuff();
void slotGetNewKeyboardStuff(QComboBox *schemesList);
void slotAutoTransition();
void slotRunWizard();
void slotZoneMoved(int start, int end);
......
......@@ -28,6 +28,7 @@
#include <KMessageBox>
#include <KRecentDirs>
#include <klocalizedstring.h>
#include <kns3/downloaddialog.h>
#include "kdenlive_debug.h"
#include <QCryptographicHash>
......@@ -68,6 +69,15 @@ const int BLUREFFECT = 1;
const int SHADOWEFFECT = 2;
const int TYPEWRITEREFFECT = 3;
void TitleWidget::refreshTemplateBoxContents()
{
templateBox->clear();
templateBox->addItem(QString());
for (const TitleTemplate &t : titletemplates) {
templateBox->addItem(t.icon, t.name, t.file);
}
}
TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, const QString &projectTitlePath, Monitor *monitor, QWidget *parent)
: QDialog(parent)
, Ui::TitleWidget_UI()
......@@ -415,6 +425,12 @@ TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, const QString &pro
m_buttonSave->setToolTip(i18n("Save As") + QLatin1Char(' ') + m_buttonSave->shortcut().toString());
connect(m_buttonSave, SIGNAL(triggered()), this, SLOT(saveTitle()));
m_buttonDownload = m_toolbar->addAction(QIcon::fromTheme(QStringLiteral("edit-download")), i18n("Download New Title Templates..."));
m_buttonDownload->setCheckable(false);
m_buttonDownload->setShortcut(Qt::ALT + Qt::Key_D);
m_buttonDownload->setToolTip(i18n("Download New Title Templates...") + QLatin1Char(' ') + m_buttonDownload->shortcut().toString());
connect(m_buttonDownload, &QAction::triggered, this, &TitleWidget::downloadTitleTemplates);
layout->addWidget(m_toolbar);
// initialize graphic scene
......@@ -520,11 +536,7 @@ TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, const QString &pro
refreshTitleTemplates(m_projectTitlePath);
}
// templateBox->setIconSize(QSize(60,60));
templateBox->clear();
templateBox->addItem(QString());
for (const TitleTemplate &t : titletemplates) {
templateBox->addItem(t.icon, t.name, t.file);
}
refreshTemplateBoxContents();
lastDocumentHash = QCryptographicHash::hash(xml().toString().toLatin1(), QCryptographicHash::Md5).toHex();
}
......@@ -1921,6 +1933,30 @@ void TitleWidget::saveTitle(QUrl url)
}
}
void TitleWidget::downloadTitleTemplates()
{
if (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 : 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);
......
......@@ -135,6 +135,7 @@ private:
QAction *m_buttonCursor;
QAction *m_buttonSave;
QAction *m_buttonLoad;
QAction *m_buttonDownload;
QAction *m_unicodeAction;
QAction *m_zUp;
......@@ -205,6 +206,9 @@ private:
/** @brief Removes the "start" and "end" info text from animation viewports. */
void deleteAnimInfoText();
/** @brief Refreshes the contents of combobox based on list of title templates. */
void refreshTemplateBoxContents();
qreal maxZIndex();
/** @brief Gets the minimum/maximum Z index of items.
......@@ -223,6 +227,10 @@ private:
void loadGradients();
void storeGradient(const QString &gradientData);
/** Open title download dialog */
void downloadTitleTemplates();
int getNewStuff(const QString &configFile);
public slots:
void slotNewText(MyTextItem *tt);
void slotNewRect(QGraphicsRectItem *rect);
......
......@@ -23,8 +23,11 @@
#include "transitions/transitionlist/model/transitionfilter.hpp"
#include "../model/transitiontreemodel.hpp"
#include "transitions/transitionsrepository.hpp"
#include "effectslist/initeffects.h"
#include "dialogs/profilesdialog.h"
#include <QQmlContext>
#include <kns3/downloaddialog.h>
TransitionListWidget::TransitionListWidget(QWidget *parent)
: AssetListWidget(parent)
......@@ -75,3 +78,27 @@ void TransitionListWidget::setFilterType(const QString &type)
static_cast<TransitionFilter *>(m_proxyModel.get())->setFilterType(false, TransitionType::Favorites);
}
}
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 : 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) {
initEffects::refreshLumas();
// TODO: refresh currently displayd trans ?
}
}
......@@ -42,9 +42,11 @@ public:
or kdenlive/transition*/
QString getMimeType(const QString &assetId) const override;
void updateFavorite(const QModelIndex &index);
void downloadNewLumas();
private:
TransitionListWidgetProxy *m_proxy;
int getNewStuff(const QString &configFile);
signals:
void reloadFavorites();
......@@ -72,6 +74,7 @@ public:
Q_INVOKABLE void setFilterName(const QString &pattern) { q->setFilterName(pattern); }
Q_INVOKABLE QString getMimeType(const QString &assetId) const { return q->getMimeType(assetId); }
Q_INVOKABLE void downloadNewLumas() { q->downloadNewLumas(); }
bool showDescription() const { return KdenliveSettings::showeffectinfo(); }
void setShowDescription(bool show)
......
......@@ -127,6 +127,13 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonDownload">
<property name="text">
<string>&amp;Download</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonSave">
<property name="text">
......
......@@ -128,7 +128,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>94</width>
<width>82</width>
<height>20</height>
</size>
</property>
......@@ -287,7 +287,11 @@
</widget>
</item>
<item>
<widget class="KComboBox" name="templateBox"/>
<widget class="KComboBox" name="templateBox">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
......
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