| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 3 |
* * |
| 4 |
* This file is part of the FreeCAD CAx development system. * |
| 5 |
* * |
| 6 |
* This library is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Library General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 |
* GNU Library General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Library General Public * |
| 17 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 18 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 19 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 20 |
* * |
| 21 |
***************************************************************************/ |
| 22 |
|
| 23 |
|
| 24 |
#ifndef GUI_DIALOG_DLGACTIONS_IMP_H |
| 25 |
#define GUI_DIALOG_DLGACTIONS_IMP_H |
| 26 |
|
| 27 |
#include <memory> |
| 28 |
#include "PropertyPage.h" |
| 29 |
#include <QDialog> |
| 30 |
#include <QList> |
| 31 |
#include <QPair> |
| 32 |
|
| 33 |
class QListWidgetItem; |
| 34 |
class QTreeWidgetItem; |
| 35 |
class QLabel; |
| 36 |
class QGridLayout; |
| 37 |
class QLineEdit; |
| 38 |
|
| 39 |
namespace Gui |
| 40 |
{ |
| 41 |
namespace Dialog |
| 42 |
{ |
| 43 |
|
| 44 |
class Ui_DlgCustomActions; |
| 45 |
|
| 46 |
/** This class implements the creation of user defined actions executing a recorded macro. |
| 47 |
* It is possible to use these actions in own toolbars or commandbars. |
| 48 |
* @see Gui::Action |
| 49 |
* @see MacroCommand |
| 50 |
* @see Command |
| 51 |
* \author Werner Mayer |
| 52 |
*/ |
| 53 |
class DlgCustomActionsImp: public CustomizeActionPage |
| 54 |
{ |
| 55 |
Q_OBJECT |
| 56 |
|
| 57 |
public: |
| 58 |
explicit DlgCustomActionsImp(QWidget* parent = nullptr); |
| 59 |
~DlgCustomActionsImp() override; |
| 60 |
|
| 61 |
Q_SIGNALS: |
| 62 |
void addMacroAction(const QByteArray&); |
| 63 |
void removeMacroAction(const QByteArray&); |
| 64 |
void modifyMacroAction(const QByteArray&); |
| 65 |
|
| 66 |
protected: |
| 67 |
/** Trigger for reparent event. */ |
| 68 |
bool event(QEvent* e) override; |
| 69 |
void changeEvent(QEvent* e) override; |
| 70 |
|
| 71 |
protected: |
| 72 |
void setupConnections(); |
| 73 |
/** Enables/disables buttons for deletion */ |
| 74 |
void onActionListWidgetItemActivated(QTreeWidgetItem* i); |
| 75 |
/** Opens a iconview to select a pixmap */ |
| 76 |
void onButtonChoosePixmapClicked(); |
| 77 |
/** Adds a custom action */ |
| 78 |
void onButtonAddActionClicked(); |
| 79 |
/** Deletes a custom action */ |
| 80 |
void onButtonRemoveActionClicked(); |
| 81 |
/** Shows the setup of the action */ |
| 82 |
void onButtonReplaceActionClicked(); |
| 83 |
|
| 84 |
protected Q_SLOTS: |
| 85 |
void onAddMacroAction(const QByteArray&) override; |
| 86 |
void onRemoveMacroAction(const QByteArray&) override; |
| 87 |
void onModifyMacroAction(const QByteArray&) override; |
| 88 |
|
| 89 |
private: |
| 90 |
/** Shows all actions and their pixmaps if available */ |
| 91 |
void showActions(); |
| 92 |
|
| 93 |
private: |
| 94 |
std::unique_ptr<Ui_DlgCustomActions> ui; |
| 95 |
QString m_sPixmap; /**< Name of the specified pixmap */ |
| 96 |
bool bChanged = false; |
| 97 |
}; |
| 98 |
|
| 99 |
class Ui_DlgChooseIcon; |
| 100 |
class IconDialog: public QDialog |
| 101 |
{ |
| 102 |
Q_OBJECT |
| 103 |
|
| 104 |
public: |
| 105 |
explicit IconDialog(QWidget* parent); |
| 106 |
~IconDialog() override; |
| 107 |
void resizeEvent(QResizeEvent*) override; |
| 108 |
QListWidgetItem* currentItem() const; |
| 109 |
|
| 110 |
private: |
| 111 |
void onAddIconPath(); |
| 112 |
|
| 113 |
private: |
| 114 |
Ui_DlgChooseIcon* ui; |
| 115 |
}; |
| 116 |
|
| 117 |
class IconFolders: public QDialog |
| 118 |
{ |
| 119 |
Q_OBJECT |
| 120 |
|
| 121 |
public: |
| 122 |
IconFolders(const QStringList&, QWidget* parent); |
| 123 |
~IconFolders() override; |
| 124 |
QStringList getPaths() const; |
| 125 |
|
| 126 |
private: |
| 127 |
void addFolder(); |
| 128 |
void removeFolder(); |
| 129 |
|
| 130 |
private: |
| 131 |
bool restart; |
| 132 |
int maxLines; |
| 133 |
QGridLayout* gridLayout; |
| 134 |
QLabel* textLabel; |
| 135 |
QPushButton* addButton; |
| 136 |
QList<QPair<QLineEdit*, QPushButton*>> buttonMap; |
| 137 |
}; |
| 138 |
|
| 139 |
} // namespace Dialog |
| 140 |
} // namespace Gui |
| 141 |
|
| 142 |
#endif // GUI_DIALOG_DLGACTIONS_IMP_H |