File indexing completed on 2024-05-19 04:53:52
0001 /* 0002 SPDX-FileCopyrightText: 2021 Julius Künzel <jk.kdedev@smartlab.uber.space> 0003 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #pragma once 0007 0008 #include "assets/view/widgets/abstractparamwidget.hpp" 0009 #include "ui_urllistparamwidget_ui.h" 0010 #include <KNSWidgets/Button> 0011 #include <QFutureWatcher> 0012 #include <QVariant> 0013 #include <QWidget> 0014 #include <knewstuff_version.h> 0015 0016 class AssetParameterModel; 0017 0018 /** @brief This class represents a parameter that requires 0019 the user to choose a value from a list 0020 */ 0021 class UrlListParamWidget : public AbstractParamWidget, public Ui::UrlListParamWidget_UI 0022 { 0023 Q_OBJECT 0024 public: 0025 /** @brief Constructor for the widgetComment 0026 @param name String containing the name of the parameter 0027 @param comment Optional string containing the comment associated to the parameter 0028 @param parent Parent widget 0029 */ 0030 UrlListParamWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent); 0031 ~UrlListParamWidget() override; 0032 0033 /** @brief Set the index of the current displayed element 0034 @param index Integer holding the index of the target element (0-indexed) 0035 */ 0036 void setCurrentIndex(int index); 0037 0038 /** @brief Set the text currently displayed on the list 0039 @param text String containing the text of the element to show 0040 */ 0041 void setCurrentText(const QString &text); 0042 0043 /** @brief Add an item to the list. 0044 @param text String to be displayed in the list 0045 @param value Underlying value corresponding to the text 0046 */ 0047 void addItem(const QString &text, const QVariant &value = QVariant()); 0048 0049 /** @brief Set the icon of a given element 0050 @param index Integer holding the index of the target element (0-indexed) 0051 @param icon The corresponding icon 0052 */ 0053 void setItemIcon(int index, const QIcon &icon); 0054 0055 /** @brief Set the size of the icons shown in the list 0056 @param size Target size of the icon 0057 */ 0058 void setIconSize(const QSize &size); 0059 0060 /** @brief Returns the current value of the parameter 0061 */ 0062 QString getValue(); 0063 0064 private: 0065 QStringList m_fileExt; 0066 int m_currentIndex; 0067 bool m_isLutList; 0068 bool m_isLumaList; 0069 QFutureWatcher<void> m_watcher; 0070 QFuture<void> m_thumbJob; 0071 bool m_abortJobs{false}; 0072 0073 /** @brief Reads the first 30 lines of a .cube LUT file and check for validity 0074 */ 0075 bool isValidCubeFile(const QString &path); 0076 /** @brief Build a list of thumbnails for extra lumas 0077 */ 0078 void buildThumbnails(const QStringList files); 0079 0080 public Q_SLOTS: 0081 /** @brief Toggle the comments on or off 0082 */ 0083 void slotShowComment(bool show) override; 0084 0085 /** @brief refresh the properties to reflect changes in the model 0086 */ 0087 void slotRefresh() override; 0088 0089 /** @brief Open fileopen dialog 0090 */ 0091 void openFile(); 0092 /** @brief A thumb was created, update list 0093 */ 0094 void updateItemThumb(const QString &path); 0095 };