File indexing completed on 2024-12-22 04:15:11

0001 /*
0002  *  SPDX-FileCopyrightText: 2023 Srirupa Datta <srirupa.sps@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef PAGE_RESOURCE_CHOOSER_H
0008 #define PAGE_RESOURCE_CHOOSER_H
0009 
0010 #include "wdg_resource_preview.h"
0011 #include "ResourceListViewModes.h"
0012 
0013 #include <QPainter>
0014 #include <QWizardPage>
0015 
0016 #include <KoResourceBundle.h>
0017 #include "KisResourceItemListView.h"
0018 #include <KisResourceModel.h>
0019 #include <KisResourceItemDelegate.h>
0020 #include "KisResourceItemListWidget.h"
0021 #include "KisBundleStorage.h"
0022 
0023 namespace Ui {
0024 class PageResourceChooser;
0025 }
0026 
0027 class PageResourceChooser : public QWizardPage
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     explicit PageResourceChooser(KoResourceBundleSP bundle = nullptr, QWidget *parent = nullptr);
0033     ~PageResourceChooser();
0034 
0035 Q_SIGNALS:
0036     void countUpdated();
0037 
0038 private Q_SLOTS:
0039     void slotResourcesSelectionChanged(QModelIndex selected);
0040     void slotresourceTypeSelected(int);
0041     void slotRemoveSelected(bool);
0042     void slotViewThumbnail();
0043     void slotViewDetails();
0044 
0045 public:
0046     QPixmap imageToIcon(const QImage &img, Qt::AspectRatioMode aspectRatioMode);
0047     QList<int> getSelectedResourcesIds();
0048     void updateCount(bool);
0049     void updateResources(QString resourceType, int count);
0050 
0051 
0052 private:
0053     Ui::PageResourceChooser *m_ui;
0054     WdgResourcePreview *m_wdgResourcePreview;
0055     QList<int> m_selectedResourcesIds;
0056     QList<QString> m_existingResources;
0057     QMap<QString, QList<QPair<QString, QImage>>> m_existingResourcesImageMap;
0058 
0059     KoResourceBundleSP m_bundle;
0060     ListViewMode m_mode;
0061     KisResourceItemDelegate *m_kisResourceItemDelegate;
0062     KisResourceItemListWidget *m_resourceItemWidget;
0063 
0064     KisBundleStorage *m_bundleStorage;
0065 };
0066 
0067 #endif // PAGE_RESOURCE_CHOOSER_H