1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/***************************************************************************
* Copyright (C) 2001-2005 Anne-Marie Mahfouf <annma@kde.org> *
* annemarie.mahfouf@free.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef _KHANGMAN_H_
#define _KHANGMAN_H_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <kmainwindow.h>
#include "khangmanview.h"
class KSelectAction;
class KToggleAction;
class KHNewStuff;
class advanced;
// Id tags for the status bar.
const int IDS_LEVEL = 100;
const int IDS_LANG = 101;
const int IDS_ACCENTS = 102;
const int IDS_HINT = 103;
/**
* @short Application Main Window
* @author Anne-Marie Mahfouf <annemarie.mahfouf@free.fr>
* @version 0.1
*/
class KHangMan : public KMainWindow
{
Q_OBJECT
public:
/**
* Default Constructor
*/
KHangMan();
/**
* Default Destructor
*/
virtual ~KHangMan();
/**
Update the text in the Statusbar
@param text the text that will be written in the statusbar
@param id the label in which the text will be written
*/
void changeStatusbar(const TQString& text, int id);
///Action that sets up the Language menu
KSelectAction *m_languageAction;
///Method to set the current language into the Statusbar and to pass it to KHangManView
void setLanguages();
///Translated names of languages
TQStringList m_languageNames;
///Language codes of available languages
TQStringList m_languages;
///Display the correct messages in the statusbar
void setMessages();
private:
///Create the actions
void setupActions();
///Create the Statusbar
void setupStatusbar();
///Selected language
TQString selectedLanguage;
///Translated and sorted names of languages
TQStringList m_sortedNames;
///the different data files in each language dir
TQStringList levels;
///Current level ID
uint currentLevel;
///hold the current level
TQString levelString;
///At start, restore settings from config file and apply them
void loadSettings();
///Set the level and make sure it exists
void setLevel();
///Scan the files in the selected language dir to set the levels
void loadLevels();
///Set a bool variable to true if the language allowa accented letters to be displayed with corresponding letter
void setAccent();
// Populate the second toolbar with the correct buttons if the
// current language has special characters.
void loadLangToolBar();
///Create a png image with the argument (special character) and return the path to this png image
TQString charIcon(const TQChar &);
public slots:
///When the langugae is changed in the Language menu
void slotChangeLanguage(int);
private slots:
// Slots for when the user changes level, setting, etc.
void slotChangeLevel(int);
void slotChangeMode();
///In Settings menu, Configure KHangMan... menu item
void optionsPreferences();
///access the KNewStuff class to install new data
void slotDownloadNewStuff();
///update settings after Settings->Configure KHangMan dialog is closed
void updateSettings();
///When a button is clicked on the toolbar, the corresponding character is written in the lineedit
void slotPasteChar();
///Quit the application and save special toolbar settings
void slotQuit();
private:
// Some important members: the view and newStuff.
KHangManView *m_view;
KHNewStuff *m_newStuff;
// Actions in the Game menu
KSelectAction *m_levelAction;
KSelectAction *m_modeAction;
///Create the Special Characters Toolbar
KToolBar *secondToolbar;
// True if the language has no special chars, such as en, it and nl.
// FIXME: Reverse the bool. Negated bools are difficult to read.
bool m_noSpecialChars;
// Contains all the words that are read from the data file.
TQStringList m_allData;
///Instance of an advanced page of the config dialog
advanced *mAdvanced;
};
#endif // _KHANGMAN_H_
|