Warning, file /office/calligra/libs/kross/KoScriptManagerAdd.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /***************************************************************************
0002  * KoScriptManagerAdd.h
0003  * This file is part of the KDE project
0004  * copyright (C) 2006-2007 Sebastian Sauer <mail@dipe.org>
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Library General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2 of the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Library General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Library General Public License
0017  * along with this program; see the file COPYING.  If not, write to
0018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020  ***************************************************************************/
0021 
0022 #ifndef KOKROSS_KOSCRIPTMANAGERADD_H
0023 #define KOKROSS_KOSCRIPTMANAGERADD_H
0024 
0025 #include <kassistantdialog.h>
0026 class KoScriptManagerAddWizard;
0027 
0028 class QRadioButton;
0029 class KPageWidgetItem;
0030 class KFileWidget;
0031 
0032 namespace Kross {
0033     class ActionCollection;
0034     class ActionCollectionEditor;
0035 }
0036 
0037 /**
0038 * The KoScriptManagerAddTypeWidget widget is the first page within
0039 * the \a KoScriptManagerAddWizard dialog that displays the different
0040 * ways to add resources.
0041 *
0042 * There exist 4 ways to add resources:
0043 *     \li Add script file.
0044 *         The next widget will be a \a KoScriptManagerAddFileWidget
0045 *         widget to choose a script file and then the
0046 *         \a KoScriptManagerAddScriptWidget widget is displayed to
0047 *         tweak the settings for the new \a Action instance before
0048 *         it's added.
0049 *     \li Add collection folder.
0050 *         The next widget will be a \a KoScriptManagerAddCollectionWidget
0051 *         widget to define the settings for the new \a ActionCollection
0052 *         instance before it's added.
0053 *     \li Install script package file.
0054 *         Not done yet. The idea is to allow to add script packages which
0055 *         are simple tarballs + a scripts.rc file that contains the
0056 *         settings for the new \a Action and/or \a ActionCollection
0057 *         instances that should be added.
0058 *     \li Install online script package.
0059 *         Not done yet. Same as the "Install script package file" above
0060 *         except that GetHotNewStuff is used to fetch the script package
0061 *         from an online address.
0062 */
0063 class KoScriptManagerAddTypeWidget : public QWidget
0064 {
0065     Q_OBJECT
0066 public:
0067     explicit KoScriptManagerAddTypeWidget(KoScriptManagerAddWizard *wizard);
0068     ~KoScriptManagerAddTypeWidget() override;
0069 
0070 public Q_SLOTS:
0071     void slotUpdate();
0072 
0073 private:
0074     KoScriptManagerAddWizard *m_wizard;
0075     QRadioButton *m_scriptCheckbox, *m_collectionCheckbox, *m_installCheckBox, *m_onlineCheckbox;
0076 };
0077 
0078 /**
0079 * The KoScriptManagerAddFileWidget widget displays a simple embedded
0080 * KFileDialog to choose a script file (*.py, *.rb, *.js, etc.).
0081 */
0082 class KoScriptManagerAddFileWidget : public QWidget
0083 {
0084     Q_OBJECT
0085 public:
0086     explicit KoScriptManagerAddFileWidget(KoScriptManagerAddWizard *wizard, const QString &startDirOrVariable = QString());
0087     ~KoScriptManagerAddFileWidget() override;
0088     /// \return the currently selected file.
0089     QString selectedFile() const;
0090 
0091 public Q_SLOTS:
0092     void slotUpdate();
0093     void slotFileHighlighted(const QString &file);
0094 
0095 private:
0096     KoScriptManagerAddWizard *const m_wizard;
0097     KFileWidget *m_filewidget;
0098     QString m_file;
0099 };
0100 
0101 /**
0102 * The KoScriptManagerAddScriptWidget widget displays a \a ActionCollectionEditor
0103 * widget to configure the settings of the new \a Action instance.
0104 */
0105 class KoScriptManagerAddScriptWidget : public QWidget
0106 {
0107     Q_OBJECT
0108 public:
0109     explicit KoScriptManagerAddScriptWidget(KoScriptManagerAddWizard *wizard);
0110     ~KoScriptManagerAddScriptWidget() override;
0111 public Q_SLOTS:
0112     void slotUpdate();
0113     //bool back();
0114     //bool next();
0115     bool accept();
0116 
0117 private:
0118     void showEvent(QShowEvent* event) override;
0119 
0120 private:
0121     KoScriptManagerAddWizard *const m_wizard;
0122     Kross::ActionCollectionEditor *m_editor;
0123 };
0124 
0125 /**
0126 * The KoScriptManagerAddScriptWidget widget displays a \a ActionCollectionEditor
0127 * widget to configure the settings of the new \a ActionCollection instance.
0128 */
0129 class KoScriptManagerAddCollectionWidget : public QWidget
0130 {
0131     Q_OBJECT
0132 public:
0133     explicit KoScriptManagerAddCollectionWidget(KoScriptManagerAddWizard *wizard);
0134     ~KoScriptManagerAddCollectionWidget() override;
0135 
0136     QString uniqueName() const;
0137 
0138 public Q_SLOTS:
0139     void slotUpdate();
0140     bool accept();
0141 
0142 private:
0143     KoScriptManagerAddWizard *m_wizard;
0144     Kross::ActionCollectionEditor *m_editor;
0145 };
0146 
0147 /**
0148 * The KoScriptManagerAddWizard dialog implements a wizard that
0149 * guides the user through the process of adding a new resource
0150 * like a new \a Action or \a ActionCollection instance to
0151 * the scripts-collection.
0152 */
0153 class KoScriptManagerAddWizard : public KAssistantDialog
0154 {
0155     Q_OBJECT
0156 public:
0157     explicit KoScriptManagerAddWizard(QWidget* parent, Kross::ActionCollection* collection = 0);
0158     ~KoScriptManagerAddWizard() override;
0159 
0160 public Q_SLOTS:
0161     /// Show the modal wizard dialog.
0162     int exec() override;
0163     /// Called when the user clicks the Back button.
0164     void back() override;
0165     /// Called when the user clicks the Next button.
0166     void next() override;
0167     /// Called when the user clicks the Finish button.
0168     void accept() override;
0169 
0170 private:
0171     bool invokeWidgetMethod(const char* member);
0172 
0173 private:
0174     friend class KoScriptManagerAddTypeWidget;
0175     friend class KoScriptManagerAddFileWidget;
0176     friend class KoScriptManagerAddScriptWidget;
0177     friend class KoScriptManagerAddCollectionWidget;
0178 
0179     Kross::ActionCollection *m_collection;
0180     KPageWidgetItem *m_typeItem, *m_fileItem, *m_scriptItem, *m_collectionItem;
0181     KoScriptManagerAddTypeWidget *m_typewidget;
0182     KoScriptManagerAddFileWidget *m_filewidget;
0183     KoScriptManagerAddScriptWidget *m_scriptwidget;
0184     KoScriptManagerAddCollectionWidget *m_collectionwidget;
0185 };
0186 
0187 #endif