File indexing completed on 2025-03-09 04:54:44
0001 /* 0002 * 0003 * This file is part of KMail, the KDE mail client. 0004 * 0005 * SPDX-FileCopyrightText: 2002-2003 Carsten Pfeiffer <pfeiffer@kde.org> 0006 * SPDX-FileCopyrightText: 2003 Zack Rusin <zack@kde.org> 0007 * 0008 * SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 #pragma once 0011 0012 #include <KSyntaxHighlighting/Repository> 0013 #include <QPlainTextEdit> 0014 #include <QSyntaxHighlighter> 0015 namespace TextAddonsWidgets 0016 { 0017 class SlideContainer; 0018 } 0019 0020 #ifdef HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT 0021 namespace TextEditTextToSpeech 0022 { 0023 class TextToSpeechContainerWidget; 0024 } 0025 #endif 0026 0027 namespace MessageViewer 0028 { 0029 class FindBarSourceView; 0030 0031 /** 0032 * A tiny little class to use for displaying raw messages, textual 0033 * attachments etc. 0034 * 0035 * Auto-deletes itself when closed. 0036 * 0037 * @author Carsten Pfeiffer <pfeiffer@kde.org> 0038 */ 0039 class MailSourceViewTextBrowser; 0040 0041 class MailSourceViewTextBrowserWidget : public QWidget 0042 { 0043 Q_OBJECT 0044 public: 0045 explicit MailSourceViewTextBrowserWidget(const QString &syntax, QWidget *parent = nullptr); 0046 0047 void setText(const QString &text); 0048 void setPlainText(const QString &text); 0049 void setFixedFont(); 0050 [[nodiscard]] MessageViewer::MailSourceViewTextBrowser *textBrowser() const; 0051 0052 private: 0053 void slotFind(); 0054 KSyntaxHighlighting::Repository mRepo; 0055 MailSourceViewTextBrowser *mTextBrowser = nullptr; 0056 FindBarSourceView *mFindBar = nullptr; 0057 TextAddonsWidgets::SlideContainer *const mSliderContainer; 0058 #ifdef HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT 0059 TextEditTextToSpeech::TextToSpeechContainerWidget *const mTextToSpeechContainerWidget; 0060 #endif 0061 }; 0062 0063 class MailSourceViewTextBrowser : public QPlainTextEdit 0064 { 0065 Q_OBJECT 0066 public: 0067 #ifdef HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT 0068 explicit MailSourceViewTextBrowser(TextEditTextToSpeech::TextToSpeechContainerWidget *TextToSpeechContainerWidget, QWidget *parent = nullptr); 0069 #endif 0070 explicit MailSourceViewTextBrowser(QWidget *parent); 0071 0072 protected: 0073 void contextMenuEvent(QContextMenuEvent *event) override; 0074 Q_SIGNALS: 0075 void findText(); 0076 0077 private: 0078 void slotSpeakText(); 0079 void slotSaveAs(); 0080 #ifdef HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT 0081 TextEditTextToSpeech::TextToSpeechContainerWidget *mTextToSpeechContainerWidget = nullptr; 0082 #endif 0083 }; 0084 }