File indexing completed on 2024-05-12 15:28:20

0001 /***************************************************************************
0002     File                 : LabelWidget.h
0003     Project              : LabPlot
0004     --------------------------------------------------------------------
0005     Copyright            : (C) 2008-2020 Alexander Semke (alexander.semke@web.de)
0006     Copyright            : (C) 2012-2014 Stefan Gerlach (stefan.gerlach@uni-konstanz.de)
0007     Description          : label settings widget
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 #ifndef LABELWIDGET_H
0030 #define LABELWIDGET_H
0031 
0032 #include "ui_labelwidget.h"
0033 #include "backend/worksheet/TextLabel.h"
0034 #include "kdefrontend/dockwidgets/BaseDock.h"
0035 #include <KConfigGroup>
0036 
0037 #ifdef HAVE_KF5_SYNTAX_HIGHLIGHTING
0038 #include <repository.h>
0039 namespace KSyntaxHighlighting {
0040     class SyntaxHighlighter;
0041 }
0042 #endif
0043 
0044 class Label;
0045 class Axis;
0046 class QMenu;
0047 
0048 class LabelWidget : public QWidget {
0049     Q_OBJECT
0050 
0051 public:
0052     explicit LabelWidget(QWidget*);
0053 
0054     void setLabels(QList<TextLabel*>);
0055     void setAxes(QList<Axis*>);
0056     void updateUnits();
0057     void updateLocale();
0058 
0059     void load();
0060     void loadConfig(KConfigGroup&);
0061     void saveConfig(KConfigGroup&);
0062 
0063     void setGeometryAvailable(bool);
0064     void setFixedLabelMode(bool);
0065     void setBorderAvailable(bool);
0066 
0067 private:
0068     Ui::LabelWidget ui;
0069     TextLabel* m_label{nullptr};
0070     QList<TextLabel*> m_labelsList;
0071     QList<Axis*> m_axesList;
0072     bool m_initializing{false};
0073     QMenu* m_dateTimeMenu;
0074     bool m_teXEnabled{false};
0075     BaseDock::Units m_units{BaseDock::Units::Metric};
0076     Worksheet::Unit m_worksheetUnit{Worksheet::Unit::Centimeter};
0077 #ifdef HAVE_KF5_SYNTAX_HIGHLIGHTING
0078     KSyntaxHighlighting::SyntaxHighlighter* m_highlighter;
0079     KSyntaxHighlighting::Repository m_repository;
0080 #endif
0081 
0082     void initConnections() const;
0083 
0084 signals:
0085     void dataChanged(bool);
0086 
0087 private slots:
0088     //SLOTs for changes triggered in LabelWidget
0089     void textChanged();
0090     void charFormatChanged(const QTextCharFormat&);
0091     void teXUsedChanged(bool);
0092     void fontColorChanged(const QColor&);
0093     void updateBackground() const;
0094     void backgroundColorChanged(const QColor&);
0095     void fontBoldChanged(bool);
0096     void fontItalicChanged(bool);
0097     void fontUnderlineChanged(bool);
0098     void fontStrikeOutChanged(bool);
0099     void fontSuperScriptChanged(bool);
0100     void fontSubScriptChanged(bool);
0101     void charMenu();
0102     void insertChar(QChar);
0103     void fontChanged(const QFont&);
0104     void teXFontChanged(const QFont&);
0105     void fontSizeChanged(int);
0106     void dateTimeMenu();
0107     void insertDateTime(QAction*);
0108 
0109     void positionXChanged(int);
0110     void positionYChanged(int);
0111     void customPositionXChanged(double);
0112     void customPositionYChanged(double);
0113     void horizontalAlignmentChanged(int);
0114     void verticalAlignmentChanged(int);
0115     void rotationChanged(int);
0116     void offsetXChanged(double);
0117     void offsetYChanged(double);
0118 
0119     void borderShapeChanged(int);
0120     void borderStyleChanged(int);
0121     void borderColorChanged(const QColor&);
0122     void borderWidthChanged(double);
0123     void borderOpacityChanged(int);
0124 
0125     void visibilityChanged(bool);
0126 
0127     //SLOTs for changes triggered in TextLabel
0128     void labelTextWrapperChanged(const TextLabel::TextWrapper&);
0129     void labelTeXImageUpdated(bool);
0130     void labelTeXFontChanged(const QFont&);
0131     void labelFontColorChanged(const QColor);
0132     void labelBackgroundColorChanged(const QColor);
0133     void labelPositionChanged(const TextLabel::PositionWrapper&);
0134     void labelHorizontalAlignmentChanged(TextLabel::HorizontalAlignment);
0135     void labelVerticalAlignmentChanged(TextLabel::VerticalAlignment);
0136     void labelOffsetxChanged(qreal);
0137     void labelOffsetyChanged(qreal);
0138     void labelRotationAngleChanged(qreal);
0139 
0140     void labelBorderShapeChanged(TextLabel::BorderShape);
0141     void labelBorderPenChanged(const QPen&);
0142     void labelBorderOpacityChanged(float);
0143 
0144     void labelVisibleChanged(bool);
0145 };
0146 
0147 #endif //LABELWIDGET_H