25 #include <QTextStream>
26 #include <QVBoxLayout>
28 #include <QButtonGroup>
30 #include <KGlobalSettings>
40 setCaption (i18n (
"Edit Name & Hint"));
41 setButtons (KDialog::Ok | KDialog::Cancel);
42 setDefaultButton (KDialog::Ok);
43 int margin = marginHint();
44 int spacing = spacingHint();
45 QWidget * dad =
new QWidget (
this);
48 QVBoxLayout * mainLayout =
new QVBoxLayout (dad);
49 mainLayout->setSpacing (spacing);
50 mainLayout->setMargin (margin);
52 QLabel * nameL =
new QLabel (i18n (
"Name of level:"), dad);
53 mainLayout->addWidget (nameL);
54 nhName =
new QLineEdit (dad);
55 mainLayout->addWidget (nhName);
57 QLabel * mleL =
new QLabel (i18n (
"Hint for level:"), dad);
58 mainLayout->addWidget (mleL);
61 mle =
new QTextEdit (dad);
62 mle-> setAcceptRichText (
false);
63 mainLayout->addWidget (mle);
66 QPoint p = parent->mapToGlobal (QPoint (0,0));
68 dad-> move (p.x()+4*c, p.y()+4*c);
72 mle-> setAlignment (Qt::AlignLeft);
74 nhName-> setText (levelName);
75 mle-> setText (levelHint);
87 QList<KGrGameData *> & gamesList,
91 myGameList = gamesList;
92 defaultGame = gameIndex;
94 setCaption (i18n (
"Edit Game Info"));
95 setButtons (KDialog::Ok | KDialog::Cancel);
96 setDefaultButton (KDialog::Ok);
97 int margin = marginHint();
98 int spacing = spacingHint();
99 QWidget * dad =
new QWidget (
this);
102 QVBoxLayout * mainLayout =
new QVBoxLayout (dad);
103 mainLayout->setSpacing (spacing);
104 mainLayout->setMargin (margin);
106 QHBoxLayout *hboxLayout5 =
new QHBoxLayout();
107 hboxLayout5->setSpacing (spacing);
108 nameL =
new QLabel (i18n (
"Name of game:"), dad);
109 hboxLayout5->addWidget (nameL);
110 ecName =
new QLineEdit (dad);
111 hboxLayout5->addWidget (ecName);
112 mainLayout->addLayout (hboxLayout5);
114 QHBoxLayout *hboxLayout6 =
new QHBoxLayout();
115 hboxLayout6->setSpacing (spacing);
116 prefixL =
new QLabel (i18n (
"File name prefix:"), dad);
117 hboxLayout6->addWidget (prefixL);
118 ecPrefix =
new QLineEdit (dad);
119 hboxLayout6->addWidget (ecPrefix);
120 mainLayout->addLayout (hboxLayout6);
123 ecGrp =
new QButtonGroup (dad);
124 ecTradB =
new QRadioButton (i18n (
"Traditional rules"), dad);
125 ecKGrB =
new QRadioButton (i18n (
"KGoldrunner rules"), dad);
126 ecGrp->addButton (ecTradB);
127 ecGrp->addButton (ecKGrB);
130 mainLayout->addWidget (ecTradB);
131 mainLayout->addWidget (ecKGrB);
134 nLevL =
new QLabel (i18np (
"1 level",
"%1 levels", 0), dad);
135 mainLayout->addWidget (nLevL);
137 mleL =
new QLabel (i18n (
"About this game:"), dad);
138 mainLayout->addWidget (mleL);
141 mle =
new QTextEdit (dad);
142 mle-> setAcceptRichText (
false);
143 mainLayout->addWidget (mle);
145 QPoint p = parent->mapToGlobal (QPoint (0,0));
149 dad-> move (p.x()+2*cell, p.y()+2*cell);
153 setCaption (i18n (
"Create Game"));
156 setCaption (i18n (
"Edit Game Info"));
161 ecName-> setText (myGameList.at (defaultGame)->name);
162 ecPrefix-> setText (myGameList.at (defaultGame)->prefix);
163 if (myGameList.at (defaultGame)->nLevels > 0) {
165 ecPrefix-> setEnabled (
false);
168 nLevL-> setText (i18np (
"1 level",
"%1 levels",
169 myGameList.at (defaultGame)->nLevels));
170 OKText = i18n (
"Save Changes");
173 ecName-> setText (
"");
174 ecPrefix-> setText (
"");
175 nLevL-> setText (i18n (
"0 levels"));
176 OKText = i18n (
"Save New");
178 setButtonGuiItem (KDialog::Ok, KGuiItem (OKText));
181 (myGameList.at (defaultGame)->rules ==
'T')) {
189 mle-> setAlignment (Qt::AlignLeft);
192 (myGameList.at (defaultGame)->about.length() > 0)) {
194 mle->setPlainText (QString::fromUtf8
195 (myGameList.at (defaultGame)->about.constData()));
198 mle->setPlainText (
"");
201 connect (ecKGrB, SIGNAL (clicked()),
this, SLOT (ecSetKGr()));
202 connect (ecTradB, SIGNAL (clicked()),
this, SLOT (ecSetTrad()));
209 void KGrECDialog::ecSetRules (
const char rules)
211 ecKGrB-> setChecked (
false);
212 ecTradB-> setChecked (
false);
214 ecKGrB-> setChecked (
true);
216 ecTradB-> setChecked (
true);
219 void KGrECDialog::ecSetKGr() {ecSetRules (
'K');}
220 void KGrECDialog::ecSetTrad() {ecSetRules (
'T');}
227 QList<KGrGameData *> & gameList,
231 setCaption (i18n (
"Select Saved Game"));
232 setButtons (KDialog::Ok | KDialog::Cancel);
233 setDefaultButton (KDialog::Ok);
234 int margin = marginHint();
235 int spacing = spacingHint();
236 QWidget * dad =
new QWidget (
this);
239 QVBoxLayout * mainLayout =
new QVBoxLayout (dad);
240 mainLayout->setSpacing (spacing);
241 mainLayout->setMargin (margin);
243 QLabel * lgHeader =
new QLabel (
244 i18n (
"Game Level/Lives/Score "
245 "Day Date Time "), dad);
247 lgList =
new QListWidget (dad);
248 QFont f = KGlobalSettings::fixedFont();
249 f.setFixedPitch (
true);
250 lgList-> setFont (f);
252 lgHeader-> setFont (f);
254 mainLayout-> addWidget (lgHeader);
255 mainLayout-> addWidget (lgList);
258 QPoint p = parent->mapToGlobal (QPoint (0,0));
260 dad-> move (p.x()+2*c, p.y()+2*c);
265 QTextStream gameText (savedGames);
269 int imax = gameList.count();
272 while (! gameText.atEnd()) {
273 s = gameText.readLine();
274 pr = s.left (s.indexOf (
" ", 0,
275 Qt::CaseInsensitive));
276 for (i = 0; i < imax; i++) {
277 if (gameList.at (i)->prefix == pr) {
279 gameList.at (i)->name.leftJustified (20,
' ',
true) +
' ');
283 lgList-> addItem (s);
288 lgList-> setSelectionMode (QAbstractItemView::SingleSelection);
289 lgList-> setCurrentRow (0);
290 lgList-> setItemSelected (lgList->currentItem(),
true);
293 connect (lgList, SIGNAL (itemClicked(QListWidgetItem*)),
294 this, SLOT (lgSelect(QListWidgetItem*)));
297 void KGrLGDialog::lgSelect (QListWidgetItem * item)
299 lgHighlight = lgList->row (item);
307 const QString & caption,
const QString & text,
308 const QString & dontShowAgain)
311 KMessageBox::information (parent, text, caption, dontShowAgain);
315 const QString &text,
const QString &label0,
316 const QString &label1,
const QString &label2)
320 if (label2.isEmpty()) {
322 ans = KMessageBox::questionYesNo (parent, text, caption,
323 KGuiItem (label0), KGuiItem (label1));
324 ans = (ans == KMessageBox::Yes) ? 0 : 1;
328 ans = KMessageBox::questionYesNoCancel (parent, text, caption,
329 KGuiItem (label0), KGuiItem (label1),
331 if (ans == KMessageBox::Cancel)
334 ans = (ans == KMessageBox::Yes) ? 0 : 1;
339 #include "kgrdialog.moc"
static int warning(QWidget *parent, const QString &caption, const QString &text, const QString &label0, const QString &label1, const QString &label2="")
KGrNHDialog(const QString &levelName, const QString &levelHint, QWidget *parent=0)
KGrLGDialog(QFile *savedGames, QList< KGrGameData * > &gameList, QWidget *parent)
static void information(QWidget *parent, const QString &caption, const QString &text, const QString &dontShowAgain=QString())
KGrECDialog(int action, int collnIndex, QList< KGrGameData * > &gameList, QWidget *parent=0)