#pragma once #include "lts_widgets_export.h" #include #include #include #include #include #include #include #include QT_BEGIN_NAMESPACE class QAction; class QComboBox; class QFontComboBox; class QTextEdit; class QTextCharFormat; class QMenu; class QPrinter; QT_END_NAMESPACE namespace LtsWidgets { class LTSWIDGETS_EXPORT LtsTextEditor2 : public QMainWindow { Q_OBJECT public: explicit LtsTextEditor2(QWidget* parent = nullptr); ~LtsTextEditor2(); static QString rsrcPath() { return (QStringLiteral(":/images/win")); } QColor m_backgroundColor{Qt::white}; QColor m_foregroundColor{Qt::black}; QTextEdit* textEdit(); QColor backgroundColor() const; void enableBackgroundColor(bool onOff); void setInitialBackgroundColor(const QColor& bgColor); bool load(const QString& f); Q_SIGNALS: void backgroundColorChanged(const QColor& bgColor); public slots: private slots: void onFileNew(); void onFileOpen(); bool onFileSave(); bool onFileSaveAs(); void onFilePrint(); void onFilePrintPreview(); void onFilePrintPdf(); void onTextBold(); void onTextUnderline(); void onTextItalic(); void onTextFamily(const QString& f); void onTextSize(const QString& p); void onTextStyle(int styleIndex); void onTextColor(); void onTextAlign(QAction* a); void setChecked(bool checked); void indent(); void unindent(); void slotBackgroundColorChanged(const QColor& bgColor); void slotBackgroundColor(); void currentCharFormatChanged(const QTextCharFormat& format); void cursorPositionChanged(); void clipboardDataChanged(); void about(); void printPreview(QPrinter*); private: void setupFileActions(); void setupEditActions(); void setupTextActions(); bool maybeSave(); void setCurrentFileName(const QString& fileName); void modifyIndentation(int amount); void mergeFormatOnWordOrSelection(const QTextCharFormat& format); void fontChanged(const QFont& f); void colorChanged(const QColor& c); void alignmentChanged(Qt::Alignment a); QAction* m_actionSave; QAction* m_actionOpen; QAction* m_actionQuit; QAction* m_actionSaveAs; QAction* m_actionNew; QAction* m_actionPrint; QAction* m_actionPreview; QAction* m_actionExport; QAction* m_actionTextBold; QAction* m_actionTextUnderline; QAction* m_actionTextItalic; QAction* m_actionTextColor; QAction* m_actionBackgroundColor; QAction* m_actionAlignLeft; QAction* m_actionAlignCenter; QAction* m_actionAlignRight; QAction* m_actionAlignJustify; QAction* m_actionIndentLess; QAction* m_actionIndentMore; QAction* m_actionToggleCheckState; QAction* m_actionUndo; QAction* m_actionRedo; #ifndef QT_NO_CLIPBOARD QAction* m_actionCut; QAction* m_actionCopy; QAction* m_actionPaste; #endif QComboBox* m_comboStyle; QAction* m_comboStyleAction; QFontComboBox* m_comboFont; QComboBox* m_comboSize; QToolBar* m_tb; QString m_fileName; QTextEdit* m_textEdit; }; } // namespace LtsWidgets