QtiPlot 0.9.8.2
|
00001 /*************************************************************************** 00002 File : CustomActionDialog.h 00003 Project : QtiPlot 00004 -------------------------------------------------------------------- 00005 Copyright : (C) 2007 by Ion Vasilief 00006 Email (use @ for *) : ion_vasilief*yahoo.fr 00007 Description : Custom Action dialog 00008 00009 ***************************************************************************/ 00010 00011 /*************************************************************************** 00012 * * 00013 * This program is free software; you can redistribute it and/or modify * 00014 * it under the terms of the GNU General Public License as published by * 00015 * the Free Software Foundation; either version 2 of the License, or * 00016 * (at your option) any later version. * 00017 * * 00018 * This program is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00021 * GNU General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU General Public License * 00024 * along with this program; if not, write to the Free Software * 00025 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00026 * Boston, MA 02110-1301 USA * 00027 * * 00028 ***************************************************************************/ 00029 #ifndef CustomActionDialog_H 00030 #define CustomActionDialog_H 00031 00032 #include <QDialog> 00033 #include <QXmlDefaultHandler> 00034 00035 class QGroupBox; 00036 class QPushButton; 00037 class QRadioButton; 00038 class QComboBox; 00039 class QListWidget; 00040 class QLineEdit; 00041 class QMenu; 00042 class QToolBar; 00043 00044 class CustomActionDialog : public QDialog 00045 { 00046 Q_OBJECT 00047 00048 public: 00050 00054 CustomActionDialog( QWidget* parent, Qt::WFlags fl = 0 ); 00055 00056 private slots: 00057 void chooseIcon(); 00058 void chooseFile(); 00059 void chooseFolder(); 00060 QAction* addAction(); 00061 void removeAction(); 00062 void setCurrentAction(int); 00063 void saveCurrentAction(); 00064 void addMenu(); 00065 void removeMenu(); 00066 void enableDeleteMenuBtn(const QString &); 00067 00068 private: 00069 void init(); 00070 void updateDisplayList(); 00071 QAction* actionAt(int row); 00072 void saveAction(QAction *action); 00073 void customizeAction(QAction *action); 00074 bool validUserInput(); 00075 void saveMenu(QMenu *menu); 00076 00077 QStringList d_app_shortcut_keys; 00078 00079 QList<QMenu *> d_menus; 00080 QList<QToolBar *> d_app_toolbars; 00081 00082 QListWidget *itemsList; 00083 QPushButton *buttonCancel, *buttonAdd, *buttonRemove, *buttonSave; 00084 QPushButton *folderBtn, *fileBtn, *iconBtn; 00085 QLineEdit *folderBox, *fileBox, *iconBox, *textBox, *toolTipBox, *shortcutBox; 00086 QRadioButton *menuBtn, *toolBarBtn; 00087 QComboBox *menuBox, *toolBarBox; 00088 QPushButton *newMenuBtn, *removeMenuBtn; 00089 }; 00090 00091 class CustomActionHandler : public QXmlDefaultHandler 00092 { 00093 public: 00094 CustomActionHandler(QAction *action); 00095 00096 bool startElement(const QString &namespaceURI, const QString &localName, 00097 const QString &qName, const QXmlAttributes &attributes); 00098 bool endElement(const QString &namespaceURI, const QString &localName, 00099 const QString &qName); 00100 bool characters(const QString &str){currentText += str; return true;}; 00101 bool fatalError(const QXmlParseException &){return false;}; 00102 QString errorString() const {return errorStr;}; 00103 QString parentName(){return d_widget_name;}; 00104 00105 private: 00106 bool metFitTag; 00107 QString currentText; 00108 QString errorStr; 00109 QString filePath; 00110 QString d_widget_name; 00111 QAction *d_action; 00112 }; 00113 00114 class CustomMenuHandler : public QXmlDefaultHandler 00115 { 00116 public: 00117 CustomMenuHandler(); 00118 00119 bool startElement(const QString &namespaceURI, const QString &localName, 00120 const QString &qName, const QXmlAttributes &attributes); 00121 bool endElement(const QString &namespaceURI, const QString &localName, 00122 const QString &qName); 00123 bool characters(const QString &str){currentText += str; return true;}; 00124 bool fatalError(const QXmlParseException &){return false;}; 00125 QString errorString() const {return errorStr;}; 00126 QString location(){return d_location;}; 00127 QString title(){return d_title;}; 00128 00129 private: 00130 bool metFitTag; 00131 QString currentText; 00132 QString errorStr; 00133 QString d_location, d_title; 00134 }; 00135 #endif