diff --git a/src/dialogs/titletemplatedialog.cpp b/src/dialogs/titletemplatedialog.cpp index a5cd88f4a..4da84962b 100644 --- a/src/dialogs/titletemplatedialog.cpp +++ b/src/dialogs/titletemplatedialog.cpp @@ -1,94 +1,100 @@ /* Copyright (C) 2016 Jean-Baptiste Mardelle This file is part of Kdenlive. See www.kdenlive.org. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "titletemplatedialog.h" #include "doc/kthumb.h" #include "kdenlivesettings.h" #include "utils/KoIconUtils.h" #include "klocalizedstring.h" #include #include #include TitleTemplateDialog::TitleTemplateDialog(const QString &folder, QWidget *parent) : QDialog(parent) { m_view.setupUi(this); // Get the list of existing templates const QStringList filter = {QStringLiteral("*.kdenlivetitle")}; const QString path = folder + QStringLiteral("/titles/"); // Project templates QDir dir(path); const QStringList templateFiles = dir.entryList(filter, QDir::Files); for (const QString &fname : templateFiles) { m_view.template_list->comboBox()->addItem(fname, dir.absoluteFilePath(fname)); } // System templates const QStringList titleTemplates = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, QStringLiteral("titles/"), QStandardPaths::LocateDirectory); for (const QString &folderpath : titleTemplates) { QDir sysdir(folderpath); const QStringList filesnames = sysdir.entryList(filter, QDir::Files); for (const QString &fname : filesnames) { m_view.template_list->comboBox()->addItem(fname, sysdir.absoluteFilePath(fname)); } } if (m_view.template_list->comboBox()->count() > 0) { m_view.buttonBox->button(QDialogButtonBox::Ok)->setFocus(); } int current = m_view.template_list->comboBox()->findText(KdenliveSettings::selected_template()); if (current > -1) { m_view.template_list->comboBox()->setCurrentIndex(current); } const QStringList mimeTypeFilters = {QStringLiteral("application/x-kdenlivetitle")}; m_view.template_list->setFilter(mimeTypeFilters.join(' ')); connect(m_view.template_list->comboBox(), static_cast(&KComboBox::currentIndexChanged), this, &TitleTemplateDialog::updatePreview); updatePreview(); } QString TitleTemplateDialog::selectedTemplate() const { QString textTemplate = m_view.template_list->comboBox()->itemData(m_view.template_list->comboBox()->currentIndex()).toString(); if (textTemplate.isEmpty()) { textTemplate = m_view.template_list->comboBox()->currentText(); } return textTemplate; } QString TitleTemplateDialog::selectedText() const { return m_view.description->toPlainText(); } +void TitleTemplateDialog::resizeEvent(QResizeEvent *event) +{ + updatePreview(); + QWidget::resizeEvent(event); +} + void TitleTemplateDialog::updatePreview() { QString textTemplate = m_view.template_list->comboBox()->itemData(m_view.template_list->comboBox()->currentIndex()).toString(); if (textTemplate.isEmpty()) { textTemplate = m_view.template_list->comboBox()->currentText(); } QPixmap pix = KThumb::getImage(QUrl::fromLocalFile(textTemplate), m_view.preview->width()); m_view.preview->setPixmap(pix); KdenliveSettings::setSelected_template(m_view.template_list->comboBox()->currentText()); } diff --git a/src/dialogs/titletemplatedialog.h b/src/dialogs/titletemplatedialog.h index 3c5b8adbf..81bf551f2 100644 --- a/src/dialogs/titletemplatedialog.h +++ b/src/dialogs/titletemplatedialog.h @@ -1,43 +1,48 @@ /* Copyright (C) 2016 Jean-Baptiste Mardelle This file is part of Kdenlive. See www.kdenlive.org. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef TITLETEMPLATEDIALOG_H #define TITLETEMPLATEDIALOG_H #include "ui_templateclip_ui.h" +class QResizeEvent; + class TitleTemplateDialog : public QDialog { Q_OBJECT public: explicit TitleTemplateDialog(const QString &folder, QWidget *parent = nullptr); QString selectedTemplate() const; QString selectedText() const; +protected: + void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + private: Ui::TemplateClip_UI m_view; private slots: void updatePreview(); }; #endif diff --git a/src/ui/templateclip_ui.ui b/src/ui/templateclip_ui.ui index c84009e57..13faa06bd 100644 --- a/src/ui/templateclip_ui.ui +++ b/src/ui/templateclip_ui.ui @@ -1,130 +1,123 @@ TemplateClip_UI 0 0 680 352 Template 0 0 Text + + + 0 + 0 + + 300 0 - - - Qt::Vertical - - - - 20 - 28 - - - - - Qt::Horizontal QDialogButtonBox::Cancel|QDialogButtonBox::Ok KUrlRequester QFrame
kurlrequester.h
1
KUrlComboRequester KUrlRequester
kurlrequester.h
1
buttonBox accepted() TemplateClip_UI accept() 248 254 157 274 buttonBox rejected() TemplateClip_UI reject() 316 260 286 274