File indexing completed on 2025-07-13 03:33:01
0001 /* 0002 File : LabelWidget.h 0003 Project : LabPlot 0004 Description : label settings widget 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2008-2020 Alexander Semke <alexander.semke@web.de> 0007 SPDX-FileCopyrightText: 2012-2014 Stefan Gerlach <stefan.gerlach@uni-konstanz.de> 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #ifndef LABELWIDGET_H 0012 #define LABELWIDGET_H 0013 0014 #include "backend/worksheet/TextLabel.h" 0015 #include "kdefrontend/dockwidgets/BaseDock.h" 0016 #include "ui_labelwidget.h" 0017 #include <KConfigGroup> 0018 0019 #ifdef HAVE_KF5_SYNTAX_HIGHLIGHTING 0020 #include <KSyntaxHighlighting/repository.h> 0021 namespace KSyntaxHighlighting { 0022 class SyntaxHighlighter; 0023 } 0024 #endif 0025 0026 class Label; 0027 class Axis; 0028 class QMenu; 0029 class KMessageWidget; 0030 0031 class TextLabelTest; 0032 0033 class LabelWidget : public BaseDock { 0034 Q_OBJECT 0035 0036 public: 0037 explicit LabelWidget(QWidget*); 0038 0039 void setLabels(QList<TextLabel*>); 0040 void setAxes(QList<Axis*>); 0041 void updateUnits() override; 0042 void updateLocale() override; 0043 0044 void load(); 0045 void loadConfig(KConfigGroup&); 0046 void saveConfig(KConfigGroup&); 0047 0048 void setGeometryAvailable(bool); 0049 void setFixedLabelMode(bool); 0050 void setBorderAvailable(bool); 0051 0052 private: 0053 Ui::LabelWidget ui; 0054 TextLabel* m_label{nullptr}; 0055 QList<TextLabel*> m_labelsList; 0056 QList<Axis*> m_axesList; 0057 QMenu* m_dateTimeMenu; 0058 bool m_initializing{false}; 0059 bool m_teXEnabled{false}; 0060 BaseDock::Units m_units{BaseDock::Units::Metric}; 0061 Worksheet::Unit m_worksheetUnit{Worksheet::Unit::Centimeter}; 0062 #ifdef HAVE_KF5_SYNTAX_HIGHLIGHTING 0063 KSyntaxHighlighting::SyntaxHighlighter* m_highlighter; 0064 KSyntaxHighlighting::Repository m_repository; 0065 #endif 0066 KMessageWidget* m_messageWidget; 0067 0068 QVector<QMetaObject::Connection> m_connections; 0069 0070 void initConnections(); 0071 0072 Q_SIGNALS: 0073 void dataChanged(bool); 0074 /*! 0075 * \brief fontColorChangedSignal 0076 * Used to send out that font color has changed. So in the case of the axis 0077 * the axisdock can update the axis color widget 0078 */ 0079 void labelFontColorChangedSignal(const QColor&); 0080 0081 private Q_SLOTS: 0082 // SLOTs for changes triggered in LabelWidget 0083 void textChanged(); 0084 void charFormatChanged(const QTextCharFormat&); 0085 void modeChanged(int); 0086 void updateMode(TextLabel::Mode mode); 0087 void fontColorChanged(const QColor&); 0088 void updateBackground() const; 0089 void backgroundColorChanged(const QColor&); 0090 void fontBoldChanged(bool); 0091 void fontItalicChanged(bool); 0092 void fontUnderlineChanged(bool); 0093 void fontStrikeOutChanged(bool); 0094 void fontSuperScriptChanged(bool); 0095 void fontSubScriptChanged(bool); 0096 void charMenu(); 0097 void insertChar(QChar); 0098 void fontChanged(const QFont&); 0099 void teXFontChanged(const QFont&); 0100 void fontSizeChanged(int); 0101 void dateTimeMenu(); 0102 void insertDateTime(QAction*); 0103 0104 void positionXChanged(int); 0105 void positionYChanged(int); 0106 void customPositionXChanged(double); 0107 void customPositionYChanged(double); 0108 void horizontalAlignmentChanged(int); 0109 void verticalAlignmentChanged(int); 0110 0111 void positionXLogicalChanged(double); 0112 void positionXLogicalDateTimeChanged(qint64); 0113 void positionYLogicalChanged(double); 0114 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 lockChanged(bool); 0126 void bindingChanged(bool checked); 0127 void showPlaceholderTextChanged(bool checked); 0128 0129 // SLOTs for changes triggered in TextLabel 0130 void labelTextWrapperChanged(const TextLabel::TextWrapper&); 0131 void labelTeXImageUpdated(const TeXRenderer::Result&); 0132 void labelTeXFontChanged(const QFont&); 0133 void labelFontColorChanged(const QColor&); 0134 void labelBackgroundColorChanged(const QColor&); 0135 void labelPositionChanged(const TextLabel::PositionWrapper&); 0136 void labelHorizontalAlignmentChanged(TextLabel::HorizontalAlignment); 0137 void labelVerticalAlignmentChanged(TextLabel::VerticalAlignment); 0138 void labelPositionLogicalChanged(QPointF); 0139 void labelCoordinateBindingEnabledChanged(bool); 0140 void labelOffsetXChanged(qreal); 0141 void labelOffsetYChanged(qreal); 0142 void labelRotationAngleChanged(qreal); 0143 0144 void labelBorderShapeChanged(TextLabel::BorderShape); 0145 void labelBorderPenChanged(const QPen&); 0146 void labelBorderOpacityChanged(float); 0147 0148 void labelLockChanged(bool); 0149 void labelCartesianPlotParent(bool on); 0150 void labelModeChanged(TextLabel::Mode); 0151 0152 friend class AxisDock; // fontColorChanged() and labelFontColorChanged() are private methods of LabelWidget 0153 friend class TextLabelTest; 0154 friend class AxisTest; 0155 friend class AxisTest2; 0156 friend class WorksheetElementTest; 0157 }; 0158 0159 #endif // LABELWIDGET_H