File indexing completed on 2024-04-28 15:14:03

0001 /***************************************************************************
0002     File                 : TemplateHandler.h
0003     Project              : LabPlot
0004     Description          : Widget for handling saving and loading of templates
0005     --------------------------------------------------------------------
0006     Copyright            : (C) 2012 by Stefan Gerlach (stefan.gerlach@uni-konstanz.de)
0007     Copyright            : (C) 2012-2019 by Alexander Semke (alexander.semke@web.de)
0008 
0009  ***************************************************************************/
0010 
0011 /***************************************************************************
0012  *                                                                         *
0013  *  This program is free software; you can redistribute it and/or modify   *
0014  *  it under the terms of the GNU General Public License as published by   *
0015  *  the Free Software Foundation; either version 2 of the License, or      *
0016  *  (at your option) any later version.                                    *
0017  *                                                                         *
0018  *  This program is distributed in the hope that it will be useful,        *
0019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0021  *  GNU General Public License for more details.                           *
0022  *                                                                         *
0023  *   You should have received a copy of the GNU General Public License     *
0024  *   along with this program; if not, write to the Free Software           *
0025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0026  *   Boston, MA  02110-1301  USA                                           *
0027  *                                                                         *
0028  ***************************************************************************/
0029 
0030 #ifndef TEMPLATEHANDLER_H
0031 #define TEMPLATEHANDLER_H
0032 
0033 #include <QWidget>
0034 
0035 class QMenu;
0036 class QToolButton;
0037 class KConfig;
0038 
0039 class TemplateHandler : public QWidget {
0040     Q_OBJECT
0041 
0042 public:
0043     enum class ClassName {Spreadsheet, Matrix, Worksheet, CartesianPlot, CartesianPlotLegend, Histogram, XYCurve, Axis, CustomPoint};
0044 
0045     TemplateHandler(QWidget* parent, ClassName);
0046     void setToolButtonStyle(Qt::ToolButtonStyle);
0047 
0048 private:
0049     void retranslateUi();
0050     bool eventFilter(QObject*, QEvent*) override;
0051 
0052     QString m_dirName;
0053     ClassName m_className;
0054     QList<QString> m_subDirNames;
0055 
0056     QMenu* m_textPositionMenu{nullptr};
0057     QToolButton* m_tbLoad;
0058     QToolButton* m_tbSave;
0059     QToolButton* m_tbSaveDefault;
0060 //  QToolButton* m_tbCopy;
0061 //  QToolButton* m_tbPaste;
0062 
0063 private slots:
0064     void loadMenu();
0065     void saveMenu();
0066     void loadMenuSelected(QAction*);
0067     void saveMenuSelected(QAction*);
0068     void saveNewSelected(const QString&);
0069     void saveDefaults();
0070     void updateTextPosition(QAction*);
0071 
0072 signals:
0073     void loadConfigRequested(KConfig&);
0074     void saveConfigRequested(KConfig&);
0075     void info(const QString&);
0076 };
0077 
0078 #endif