File indexing completed on 2024-04-21 04:52:24

0001 /*
0002 SPDX-FileCopyrightText: 2016 Jean-Baptiste Mardelle <jb@kdenlive.org>
0003 This file is part of Kdenlive. See www.kdenlive.org.
0004 
0005 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #pragma once
0009 
0010 #include "ui_gradientedit_ui.h"
0011 
0012 #include <QDialog>
0013 
0014 /** @class GradientWidget
0015  *  @brief Title creation dialog
0016  *  Instances of TitleWidget classes are instantiated by KdenliveDoc::slotCreateTextClip ()
0017 */
0018 class GradientWidget : public QDialog, public Ui::GradientEdit_UI
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     /** @brief Draws the dialog and loads a title document (if any).
0024      * @param url title document to load
0025      * @param tc timecode of the project
0026      * @param projectPath default path to save to or load from title documents
0027      * @param render project renderer
0028      * @param parent (optional) parent widget */
0029     explicit GradientWidget(const QMap<QString, QString> &gradients = QMap<QString, QString>(), int ix = 0, QWidget *parent = nullptr);
0030     void resizeEvent(QResizeEvent *event) override;
0031     QString gradientToString() const;
0032     static QLinearGradient gradientFromString(const QString &str, int width, int height);
0033     QMap<QString, QString> gradients() const;
0034     QList<QIcon> icons() const;
0035     int selectedGradient() const;
0036 
0037 private:
0038     QLinearGradient m_gradient;
0039     int m_height;
0040     QStringList getNames() const;
0041     void loadGradients(QMap<QString, QString> gradients = QMap<QString, QString>());
0042 
0043 private Q_SLOTS:
0044     void updatePreview();
0045     void saveGradient(const QString &name = QString());
0046     void loadGradient();
0047     void deleteGradient();
0048 };