File indexing completed on 2024-06-16 04:17:53
0001 /* This file is part of the KDE project 0002 * 0003 * SPDX-FileCopyrightText: 2017 Boudewijn Rempt <boud@valdyas.org> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef TEXTNGSHAPECONFIGWIDGET_H 0009 #define TEXTNGSHAPECONFIGWIDGET_H 0010 0011 #include <QWidget> 0012 #include <QTextEdit> 0013 0014 #include <kxmlguiwindow.h> 0015 #include <KoColor.h> 0016 #include <KoSvgText.h>//for the enums 0017 0018 #include <BasicXMLSyntaxHighlighter.h> 0019 0020 #include "ui_WdgSvgTextEditor.h" 0021 #include "ui_WdgSvgTextSettings.h" 0022 0023 class KoSvgTextShape; 0024 class KoDialog; 0025 0026 class SvgTextEditor : public KXmlGuiWindow 0027 { 0028 Q_OBJECT 0029 public: 0030 SvgTextEditor(QWidget *parent = 0, Qt::WindowFlags f = Qt::WindowFlags()); 0031 ~SvgTextEditor(); 0032 0033 //tiny enum to keep track of the tab on which editor something happens while keeping the code readable. 0034 enum Editor { 0035 Richtext, // 0 0036 SVGsource // 1 0037 }; 0038 0039 void setInitialShape(KoSvgTextShape *shape); 0040 0041 private Q_SLOTS: 0042 /** 0043 * switch the text editor tab. 0044 */ 0045 void switchTextEditorTab(bool convertData = true); 0046 0047 void slotCloseEditor(); 0048 0049 /** 0050 * in rich text, check the current format, and toggle the given buttons. 0051 */ 0052 void checkFormat(); 0053 void checkDocumentFormat(); 0054 0055 void slotFixUpEmptyTextBlock(); 0056 0057 void save(); 0058 0059 void undo(); 0060 void redo(); 0061 0062 void cut(); 0063 void copy(); 0064 void paste(); 0065 0066 void selectAll(); 0067 void deselect(); 0068 0069 void find(); 0070 void findNext(); 0071 void findPrev(); 0072 void replace(); 0073 0074 void zoomOut(); 0075 void zoomIn(); 0076 #ifndef Q_OS_WIN 0077 void showInsertSpecialCharacterDialog(); 0078 void insertCharacter(const QChar &c); 0079 #endif 0080 void setTextBold(QFont::Weight weight = QFont::Bold); 0081 void setTextWeightLight(); 0082 void setTextWeightNormal(); 0083 void setTextWeightDemi(); 0084 void setTextWeightBlack(); 0085 0086 void setTextItalic(QFont::Style style = QFont::StyleOblique); 0087 void setTextDecoration(KoSvgText::TextDecoration decor); 0088 void setTextUnderline(); 0089 void setTextOverline(); 0090 void setTextStrikethrough(); 0091 void setTextSubscript(); 0092 void setTextSuperScript(); 0093 void increaseTextSize(); 0094 void decreaseTextSize(); 0095 0096 void setLineHeight(double lineHeightPercentage); 0097 void setLetterSpacing(double letterSpacing); 0098 void alignLeft(); 0099 void alignRight(); 0100 void alignCenter(); 0101 void alignJustified(); 0102 0103 void setFont(const QString &fontName); 0104 void setFontSize(qreal size); 0105 void setBaseline(KoSvgText::BaselineShiftMode baseline); 0106 void setKerning(bool enable); 0107 0108 void setWrappingLegacy(); 0109 void setWrappingPre(); 0110 void setWrappingPreWrap(); 0111 0112 void setSettings(); 0113 void slotToolbarToggled(bool); 0114 0115 void setFontColor(const KoColor &c); 0116 void setBackgroundColor(const KoColor &c); 0117 0118 void setModified(bool modified); 0119 void dialogButtonClicked(QAbstractButton *button); 0120 0121 Q_SIGNALS: 0122 void textUpdated(KoSvgTextShape *shape, const QString &svg, const QString &defs); 0123 void textEditorClosed(); 0124 0125 protected: 0126 void wheelEvent(QWheelEvent *event) override; 0127 bool eventFilter(QObject *watched, QEvent *event) override; 0128 /** 0129 * Selects all if there is no selection 0130 * @returns a copy of the previous cursor. 0131 */ 0132 QTextCursor setTextSelection(); 0133 0134 private: 0135 void applySettings(); 0136 0137 QAction *createAction(const QString &name, 0138 const char *member); 0139 void createActions(); 0140 void enableRichTextActions(bool enable); 0141 void enableSvgTextActions(bool enable); 0142 bool isRichTextEditorTabActive(); 0143 bool isSvgSourceEditorTabActive(); 0144 0145 Ui_WdgSvgTextEditor m_textEditorWidget; 0146 QTextEdit *m_currentEditor {0}; 0147 QWidget *m_page {0}; 0148 QList<QAction*> m_richTextActions; 0149 QList<QAction*> m_svgTextActions; 0150 0151 KoSvgTextShape *m_shape {0}; 0152 #ifndef Q_OS_WIN 0153 KoDialog *m_charSelectDialog {0}; 0154 #endif 0155 BasicXMLSyntaxHighlighter *m_syntaxHighlighter; 0156 0157 QString m_searchKey; 0158 0159 class Private; 0160 QScopedPointer<Private> d; 0161 }; 0162 0163 #endif //TEXTNGSHAPECONFIGWIDGET_H