1 /******************************************************************* 2 KNotes -- Notes for the KDE project 3 4 SPDX-FileCopyrightText: 1997-2013 The KNotes Developers 5 6 SPDX-License-Identifier: GPL-2.0-or-later 7 *******************************************************************/ 8 9 #pragma once 10 11 #include "knotes_export.h" 12 #include <QTextCharFormat> 13 #include <QWidget> 14 15 #include <KTextEdit> 16 class QFont; 17 18 class QAction; 19 class KActionCollection; 20 class KFontAction; 21 class KFontSizeAction; 22 class KToggleAction; 23 class KNote; 24 namespace PimCommon 25 { 26 class KActionMenuChangeCase; 27 } 28 class KNOTES_EXPORT KNoteEdit : public KTextEdit 29 { 30 Q_OBJECT 31 public: 32 explicit KNoteEdit(KActionCollection *actions, QWidget *parent = nullptr); 33 ~KNoteEdit() override; 34 35 void setNote(KNote *_note); 36 37 void setText(const QString &text); 38 QString text() const; 39 40 void setTextFont(const QFont &font); 41 void setTabStop(int tabs); 42 void setAutoIndentMode(bool newmode); 43 44 void setColor(const QColor &fg, const QColor &bg); 45 void setCursorPositionFromStart(int pos); 46 int cursorPositionFromStart() const; 47 QMenu *mousePopupMenu() override; 48 public Q_SLOTS: 49 void setRichText(bool); 50 51 void textBold(bool); 52 void textStrikeOut(bool); 53 54 void slotTextColor(); 55 56 void textAlignLeft(); 57 void textAlignCenter(); 58 void textAlignRight(); 59 void textAlignBlock(); 60 61 void textList(); 62 63 void textSuperScript(); 64 void textSubScript(); 65 66 void textIncreaseIndent(); 67 void textDecreaseIndent(); 68 void setTextFontSize(int); 69 70 void slotTextBackgroundColor(); 71 void slotInsertDate(); 72 73 protected: 74 void keyPressEvent(QKeyEvent *) override; 75 void focusInEvent(QFocusEvent *) override; 76 void focusOutEvent(QFocusEvent *) override; 77 78 private Q_SLOTS: 79 void slotCurrentCharFormatChanged(const QTextCharFormat &); 80 void slotCursorPositionChanged(); 81 void slotUpperCase(); 82 void slotLowerCase(); 83 void slotSentenceCase(); 84 void slotInsertCheckMark(); 85 void slotReverseCase(); 86 87 private: 88 void autoIndent(); 89 90 void enableRichTextActions(bool enabled); 91 92 private: 93 QColor mDefaultBackgroundColor; 94 QColor mDefaultForegroundColor; 95 96 KToggleAction *m_textBold = nullptr; 97 KToggleAction *m_textItalic = nullptr; 98 KToggleAction *m_textUnderline = nullptr; 99 KToggleAction *m_textStrikeOut = nullptr; 100 101 KToggleAction *m_textAlignLeft = nullptr; 102 KToggleAction *m_textAlignCenter = nullptr; 103 KToggleAction *m_textAlignRight = nullptr; 104 KToggleAction *m_textAlignBlock = nullptr; 105 106 KToggleAction *m_textList = nullptr; 107 KToggleAction *m_textSuper = nullptr; 108 KToggleAction *m_textSub = nullptr; 109 110 QAction *m_textIncreaseIndent = nullptr; 111 QAction *m_textDecreaseIndent = nullptr; 112 113 QAction *m_textColor = nullptr; 114 KFontAction *m_textFont = nullptr; 115 KFontSizeAction *m_textSize = nullptr; 116 KNote *m_note = nullptr; 117 KActionCollection *m_actions = nullptr; 118 PimCommon::KActionMenuChangeCase *mChangeCaseActionMenu = nullptr; 119 bool m_autoIndentMode = false; 120 }; 121 122