File indexing completed on 2024-04-28 07:29:24

0001 /*
0002     SPDX-FileCopyrightText: 2001-2008 Anne-Marie Mahfouf <annma@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 
0008 #ifndef KLETTRES_H
0009 #define KLETTRES_H
0010 
0011 #include <KXmlGuiWindow>
0012 
0013 #include "klettresview.h"
0014 #include "soundfactory.h"
0015 
0016 class QLabel;
0017 class KToggleAction;
0018 class KSelectAction;
0019 class KToolBar;
0020 class KLNewStuff;
0021 
0022 /**
0023  * @short Application Main Window
0024  * @author Anne-Marie Mahfouf <annma@kde.org>
0025  * @version 2.1
0026  */
0027 class KLettres : public KXmlGuiWindow
0028 {
0029     Q_OBJECT
0030 public:
0031 
0032     ///Constructor
0033     KLettres();
0034     ///Destructor
0035     ~KLettres() override;
0036 
0037     ///Sound class
0038     SoundFactory *soundFactory = nullptr;
0039     ///All available language names
0040     QStringList m_languageNames;
0041     /**
0042     *Load the xml file
0043     *@param layoutDocument the xml file
0044     *@return bool true if the xml document is found and well formed, false otherwise
0045     */
0046     bool loadLayout(QDomDocument &layoutDocument);
0047     ///Action that sets up the Language menu
0048     KSelectAction *m_languageAction = nullptr;
0049 
0050     public Q_SLOTS:
0051     ///Set the new language
0052     void slotChangeLanguage(int);
0053     ///Set the new level
0054     void slotChangeLevel(int);
0055 
0056 protected:
0057     ///Call an instance of the KLettresView widget
0058     KLettresView *m_view = nullptr;
0059     ///Action that enables the ShowMenuBar item in the Settings menu
0060     KToggleAction *m_menubarAction = nullptr;
0061     ///Action that sets up the Level menu
0062     KSelectAction *m_levelAction = nullptr;
0063     ///Action that sets up the Look menu
0064     KSelectAction *m_themeAction = nullptr;
0065     ///Action allowing the Kid mode
0066     KToggleAction *m_kidAction = nullptr;
0067     ///Action allowing the Grownup mode
0068     KToggleAction *m_grownupAction = nullptr;
0069     ///Label stating the language in the statusbar
0070     QLabel *m_langLabel = nullptr;
0071     ///Label stating the level in the statusbar
0072     QLabel *m_levLabel = nullptr;
0073     ///Holds the levels
0074     QStringList m_levelsNames;
0075     ///Holds the looks
0076     QStringList m_themesNames;
0077     ///Create an instance of a KToolBar
0078     KToolBar *m_mainToolbar = nullptr;
0079     ///Second toolbar with buttons of special characters per language
0080     KToolBar *specialCharToolbar;
0081     ///is false when menubar button is not shown
0082     bool menuBool;
0083     ///Build the main window menus
0084     void setupActions();
0085     ///Create and setup statusbar
0086     void setupStatusbar();
0087     ///Create main and second toolbars
0088     void setupToolbars();
0089     /**generates icons for the special characters toolbar
0090      * @param c the character that will be painted on the icon
0091      */
0092     QIcon charIcon(QChar c);
0093     /**
0094      *Update the level menu and level combobox
0095      * @param id The id of the new level
0096      */
0097     void updateLevMenu(int id);
0098     ///Create a KNewStuff instance
0099     KLNewStuff *mNewStuff = nullptr;
0100     ///Set the correct buttons on the second toolbar according to the language
0101     void loadLangToolBar();
0102     ///All the special characters from a language file, these characters will be as buttons on the Special Characters Toolbar
0103     QStringList allData;
0104 
0105     protected Q_SLOTS:
0106     ///Call the Get New Stuff dialog
0107     void slotDownloadNewStuff();
0108     ///Hide/Show the menubar
0109     void slotMenubar();
0110     ///Set the new font and the new timers
0111     void slotUpdateSettings();
0112     ///Switch to the grown-up look, menubar is shown
0113     void slotModeGrownup();
0114     ///Switch to the kid look, menubar is hidden
0115     void slotModeKid();
0116     ///Change Look from menu Look
0117     void slotChangeTheme(int);
0118     ///Display the Configure KLettres dialog
0119     void optionsPreferences();
0120     ///Load the configuration settings and apply them
0121     void loadSettings();
0122     ///When a button is clicked on the characters toolbar, the corresponding character is written in the lineedit 
0123     void slotPasteChar();
0124 };
0125 
0126 #endif // KLETTRES_H