File indexing completed on 2024-05-12 16:01:52

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2005 Peter Simonsson <psn@linux.se>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 #ifndef KISOPENPANE_H
0007 #define KISOPENPANE_H
0008 
0009 #include <QDialog>
0010 #include <QWidget>
0011 #include <QPixmap>
0012 #include <QList>
0013 
0014 class KisDetailsPane;
0015 class KisDocument;
0016 class KisOpenPanePrivate;
0017 class KisTemplatesPane;
0018 class QPixmap;
0019 class QString;
0020 class QStringList;
0021 class QTreeWidgetItem;
0022 class QUrl;
0023 
0024 /// \internal
0025 class KisOpenPane : public QDialog
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     /**
0031      * Constructor
0032      * @param parent the parent widget.
0033      * @param mimeFilter the template-type (group) that should be selected on creation.
0034      * @param templatesResourcePath the path to the templates.
0035      */
0036     KisOpenPane(QWidget *parent, const QStringList& mimeFilter, const QString& templatesResourcePath = QString());
0037     ~KisOpenPane() override;
0038 
0039     QTreeWidgetItem* addPane(const QString &title, const QString &untranslatedName, const QString &iconName, QWidget *widget, int sortWeight);
0040     QTreeWidgetItem* addPane(const QString &title, const QString &untranslatedName, const QPixmap& icon, QWidget* widget, int sortWeight);
0041 
0042     /**
0043      * If the application has a way to create a document not based on a template, but on user
0044      * provided settings, the widget showing these gets set here.
0045      * @see KisDocument::createCustomDocumentWidget()
0046      * @param widget the widget.
0047      * @param title the title shown in the sidebar
0048      * @param icon the icon shown in the sidebar
0049      */
0050     void addCustomDocumentWidget(QWidget *widget, const QString& title, const QString &untranslatedName, const QString& icon = QString());
0051 
0052 
0053 Q_SIGNALS:
0054     /// this signal is emitted (as defined by KisDocument) the moment the document is 'ready'
0055     void documentSelected(KisDocument*);
0056 
0057 protected Q_SLOTS:
0058     void updateSelectedWidget();
0059     void itemClicked(QTreeWidgetItem* item);
0060 
0061     /// Saves the splitter sizes for KisDetailsPaneBase based panes
0062     void saveSplitterSizes(KisDetailsPane* sender, const QList<int>& sizes);
0063 
0064 private Q_SLOTS:
0065     /// when clicked "Open Existing Document" button
0066     void openFileDialog();
0067     void slotOpenTemplate(const QUrl &url);
0068     
0069 Q_SIGNALS:
0070     void openExistingFile(const QUrl&);
0071     void openTemplate(const QUrl&);
0072 
0073     /// Emitted when the always use template has changed
0074     void alwaysUseChanged(KisTemplatesPane* sender, const QString& alwaysUse);
0075 
0076     /// Emitted when one of the detail panes have changed it's splitter
0077     void splitterResized(KisDetailsPane* sender, const QList<int>& sizes);
0078     void cancelButton();
0079 
0080 protected:
0081     /**
0082      * Populate the list with all templates the user can choose.
0083      * @param templatesResourcePath the template-type (group) that should be selected on creation.
0084      */
0085     void initTemplates(const QString& templatesResourcePath);
0086 
0087     // QWidget overrides
0088     void dragEnterEvent(QDragEnterEvent * event) override;
0089     void dropEvent(QDropEvent * event) override;
0090 
0091 private:
0092     QStringList m_mimeFilter;
0093 
0094     KisOpenPanePrivate * const d;
0095 };
0096 
0097 #endif //KOOPENPANE_H