File indexing completed on 2024-06-23 07:15:09

0001 /***************************************************************************
0002  *   Copyright (C) 2002 by Gunnar Schmi Dt <kmouth@schmi-dt.de             *
0003  *             (C) 2015 by Jeremy Whiting <jpwhiting@kde.org>              *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
0019  ***************************************************************************/
0020 
0021 #ifndef KMOUTH_H
0022 #define KMOUTH_H
0023 
0024 // include files for Qt
0025 #include <QAction>
0026 #include <QPrinter>
0027 
0028 // include files for KDE
0029 #include <KSharedConfig>
0030 #include <QUrl>
0031 #include <kxmlguiwindow.h>
0032 
0033 // forward declaration of the KMouth classes
0034 class PhraseList;
0035 class OptionsDialog;
0036 class TextToSpeechSystem;
0037 
0038 class QLabel;
0039 
0040 class KToggleAction;
0041 class KActionCollection;
0042 
0043 /**
0044  * The base class for KMouth application windows. It sets up the main
0045  * window and reads the config file as well as providing a menubar, toolbar
0046  * and statusbar.
0047  * KMouthApp reimplements the methods that KXmlGuiWindow provides for main window handling and supports
0048  * full session management as well as using KActions.
0049  * @see KXmlGuiWindow
0050  *
0051  * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
0052  * @version KDevelop version 1.2 code generation
0053  */
0054 class KMouthApp : public KXmlGuiWindow
0055 {
0056     Q_OBJECT
0057 
0058 public:
0059     /** construtor of KMouthApp, calls all init functions to create the application.
0060      */
0061     explicit KMouthApp(QWidget *parent = nullptr, const QString &name = QString());
0062     ~KMouthApp() override;
0063     /** Returns true if the configuration wizard was not needed or when it
0064      * was successfully completed.
0065      */
0066     bool configured();
0067     /** opens a file specified by commandline option
0068      */
0069     void openDocumentFile(const QUrl &url = QUrl());
0070 
0071     TextToSpeechSystem *getTTSSystem() const;
0072 
0073     /** called by PhraseList in order to enable or disable the actions depending
0074      * on the contents of the phrase list.
0075      */
0076     void enableMenuEntries(bool existSelectedEntries, bool existDeselectedEntries);
0077 
0078 protected:
0079     /** save general Options like all bar positions and status as well as the geometry and the recent file list to the configuration
0080      * file
0081      */
0082     void saveOptions();
0083     /** read general Options again and initialize all variables like the recent file list
0084      */
0085     void readOptions();
0086     /** initializes the phrase list */
0087     void initPhraseList();
0088     /** initializes the KActions of the application */
0089     void initActions();
0090     /** sets up the statusbar for the main window by initialzing a statuslabel.
0091      */
0092     void initStatusBar();
0093     /** queryClose is called by KMainWindow on each closeEvent of a window. Against the
0094      * default implementation (only returns true), this calles saveModified() on the document object to ask if the document shall
0095      * be saved if Modified; on cancel the closeEvent is rejected.
0096      * @see KMainWindow#queryClose
0097      * @see KMainWindow#closeEvent
0098      */
0099     bool queryClose() override;
0100 
0101 public Q_SLOTS:
0102     /** open a file and load it into the history */
0103     void slotFileOpen();
0104     /** save a document */
0105     void slotFileSaveAs();
0106     /** print the actual file */
0107     void slotFilePrint();
0108     /** closes all open windows by calling close() on each memberList item until the list is empty, then quits the application.
0109      * If queryClose() returns false because the user canceled the saveModified() dialog, the closing breaks.
0110      */
0111     void slotFileQuit();
0112     /** edits the phrase books
0113      */
0114     void slotEditPhrasebook();
0115     /** toggles the menu bar
0116      */
0117     void slotViewMenuBar();
0118     /** toggles the toolbar
0119      */
0120     void slotViewToolBar();
0121     /** toggles the phrasebook bar
0122      */
0123     void slotViewPhrasebookBar();
0124     /** toggles the statusbar
0125      */
0126     void slotViewStatusBar();
0127     /** configures the TTS system
0128      */
0129     void slotConfigureTTS();
0130     /** changes the statusbar contents for the standard label permanently, used to indicate current actions.
0131      * @param text the text that is displayed in the statusbar
0132      */
0133     void slotStatusMsg(const QString &text);
0134 
0135     void slotPhrasebookConfirmed();
0136 
0137     void slotConfigurationChanged();
0138 
0139     void slotPhraseSelected(const QString &phrase);
0140 
0141 private:
0142     bool isConfigured;
0143     /** The phrase list */
0144     PhraseList *phraseList;
0145     /** The configuration dialog */
0146     OptionsDialog *optionsDialog;
0147 
0148     // QAction pointers to enable/disable actions
0149     QAction *fileOpen;
0150     QAction *fileSaveAs;
0151     QAction *filePrint;
0152     QAction *fileQuit;
0153 
0154     QAction *editCut;
0155     QAction *editCopy;
0156     QAction *editPaste;
0157     QAction *editSpeak;
0158 
0159     KActionCollection *phrases;
0160     QAction *phrasebookEdit;
0161 
0162     KToggleAction *viewMenuBar;
0163     KToggleAction *viewToolBar;
0164     KToggleAction *viewPhrasebookBar;
0165     KToggleAction *viewStatusBar;
0166     QAction *configureTTS;
0167 
0168     QAction *phraseListSpeak;
0169     QAction *phraseListRemove;
0170     QAction *phraseListCut;
0171     QAction *phraseListCopy;
0172     QAction *phraselistSelectAll;
0173     QAction *phraselistDeselectAll;
0174 
0175     QLabel *m_statusLabel;
0176 
0177     // Keep QPrinter so settings persist
0178     QPrinter *printer;
0179 };
0180 
0181 #endif // KMOUTH_H