Commit cf377f55 authored by Nicolas Hadacek's avatar Nicolas Hadacek
Browse files

add some broken code :)

svn path=/trunk/kdegames/kmines/; revision=46347
parent ff73bac6
......@@ -4,6 +4,9 @@
* animate autoreveal with keyboard
* enable/disable and change text for pause in menu
* configuration of mouse bindings [idea of FX Duranceau]
* hack to resize correctly when menu is hidden (due to limitation
in KTMainWindow) (still broken ...)
* nicer custom level dialog (well it is broken ...)
2.0.2
* XMLify the GUI
......
......@@ -10,7 +10,7 @@ noinst_HEADERS = defines.h dialogs.h field.h status.h main.h
SUBDIRS = data bitmaps
rcdir = $(kde_datadir)/kmines
rc_DATA = ui_kmines.rc
rc_DATA = kminesui.rc
messages:
$(XGETTEXT) $(kmines_SOURCES) -o $(podir)/kmines.pot
......@@ -5,5 +5,5 @@ IDEAS:
KNOWN BUGS:
* layout bug when changing level/case size/menubar visible
[fvwm specific ? -> no !]
* occasionnal X BadMatch error in highscore (KDialogBase bug ?)
......@@ -120,118 +120,49 @@ DialogBase::DialogBase(const QString &caption, int buttonMask,
//-----------------------------------------------------------------------------
CustomDialog::CustomDialog(Level &_lev, QWidget *parent)
: DialogBase(i18n("Customize your game"), Ok|Cancel, Cancel, parent),
lev(&_lev)
lev(_lev), initLev(_lev)
{
QLabel *lab;
QScrollBar *scb;
QHBoxLayout *hbl;
/* Width */
/* labels */
hbl = new QHBoxLayout(spacingHint());
top->addLayout(hbl);
lab = new QLabel(i18n("Width"), plainPage());
lab->setFixedSize( lab->sizeHint() );
hbl->addWidget(lab);
hbl->addStretch(1);
lab = new QLabel(plainPage());
lab->setNum((int)_lev.width);
lab->setAlignment( AlignRight );
lab->setFixedSize( lab->fontMetrics().maxWidth()*2,
lab->sizeHint().height());
connect(this, SIGNAL(setWidth(int)), lab, SLOT(setNum(int)));
hbl->addWidget(lab);
/* scrollbar */
scb = new QScrollBar(8, 50, 1, 5, _lev.width,
QScrollBar::Horizontal, plainPage());
scb->setMinimumWidth( scb->sizeHint().width() );
scb->setFixedHeight( scb->sizeHint().height() );
connect(scb, SIGNAL(valueChanged(int)), SLOT(widthChanged(int)));
top->addWidget(scb);
top->addSpacing(2*spacingHint());
/* Height */
/* labels */
hbl = new QHBoxLayout(spacingHint());
top->addLayout(hbl);
lab = new QLabel(i18n("Height"), plainPage());
lab->setFixedSize( lab->sizeHint() );
hbl->addWidget(lab);
hbl->addStretch(1);
lab = new QLabel(plainPage());
lab->setNum((int)_lev.height);
lab->setAlignment( AlignRight );
lab->setFixedSize( lab->fontMetrics().maxWidth()*2,
lab->sizeHint().height());
connect(this, SIGNAL(setHeight(int)), lab, SLOT(setNum(int)));
hbl->addWidget(lab);
/* scrollbar */
scb = new QScrollBar(8, 50, 1, 5, _lev.height,
QScrollBar::Horizontal, plainPage());
scb->setMinimumWidth( scb->sizeHint().width() );
scb->setFixedHeight( scb->sizeHint().height() );
connect(scb, SIGNAL(valueChanged(int)), SLOT(heightChanged(int)));
top->addWidget(scb);
top->addSpacing(2*spacingHint());
/* Mines */
/* labels */
hbl = new QHBoxLayout(spacingHint());
top->addLayout(hbl);
lab = new QLabel(i18n("Mines"), plainPage());
lab->setFixedSize( lab->sizeHint() );
hbl->addWidget(lab);
hbl->addStretch(1);
lab = new QLabel(" ", plainPage());
lab->setAlignment( AlignRight );
lab->setFixedSize(lab->fontMetrics().maxWidth()*11,
lab->sizeHint().height());
connect(this, SIGNAL(setNbMines(const QString &)), lab,
SLOT(setText(const QString &)));
hbl->addWidget(lab);
/* scrollbar */
sm = new QScrollBar(1, _lev.width*_lev.height, 1, 5, _lev.nbMines,
QScrollBar::Horizontal, plainPage());
sm->setMinimumWidth( sm->sizeHint().width() );
sm->setFixedHeight( sm->sizeHint().height() );
connect(sm, SIGNAL(valueChanged(int)), SLOT(nbMinesChanged(int)));
top->addWidget(sm);
nbMinesChanged(_lev.nbMines);
enableButton(Ok, FALSE);
// width
KIntNumInput *ki = new KIntNumInput(lev.width, plainPage());
ki->setLabel(i18n("Width"));
ki->setRange(8, 50);
connect(ki, SIGNAL(valueChanged(int)), SLOT(widthChanged(int)));
top->addWidget(ki);
// height
ki = new KIntNumInput(lev.height, plainPage());
ki->setLabel(i18n("Height"));
ki->setRange(8, 50);
connect(ki, SIGNAL(valueChanged(int)), SLOT(heightChanged(int)));
top->addWidget(ki);
// mines
km = new KIntNumInput(lev.nbMines, plainPage());
connect(km, SIGNAL(valueChanged(int)), SLOT(nbMinesChanged(int)));
top->addWidget(km);
nbMinesChanged(lev.nbMines);
}
void CustomDialog::widthChanged(int n)
{
lev->width = (uint)n;
emit setWidth(n);
nbMinesChanged(lev->nbMines);
lev.width = (uint)n;
nbMinesChanged(lev.nbMines);
}
void CustomDialog::heightChanged(int n)
{
lev->height = (uint)n;
emit setHeight(n);
nbMinesChanged(lev->nbMines);
lev.height = (uint)n;
nbMinesChanged(lev.nbMines);
}
void CustomDialog::nbMinesChanged(int n)
{
lev->nbMines = (uint)n;
uint nb = lev->width * lev->height;
sm->setRange(1, nb - 2);
emit setNbMines(i18n("%1 (%2%)").arg(n).arg(100*n/nb));
enableButton(Ok, TRUE);
lev.nbMines = (uint)n;
uint nb = lev.width * lev.height;
km->setRange(1, nb - 2);
km->setLabel(i18n("Mines (%1%)").arg(100*n/nb));
enableButton(Ok, lev.width!=initLev.width || lev.height!=initLev.height
|| lev.nbMines!=initLev.nbMines);
}
//-----------------------------------------------------------------------------
......@@ -354,8 +285,8 @@ void WHighScores::reject()
OptionDialog::OptionDialog(QWidget *parent)
: DialogBase(i18n("Settings"), Ok|Cancel, Cancel, parent)
{
ni = new KIntNumInput(0, readCaseSize(), plainPage(), 10);
ni->setRange(MIN_CASE_SIZE, MAX_CASE_SIZE, 1, true);
ni = new KIntNumInput(readCaseSize(), plainPage());
ni->setRange(MIN_CASE_SIZE, MAX_CASE_SIZE);
ni->setLabel(i18n("Case size"));
top->addWidget(ni);
top->addSpacing(spacingHint());
......
......@@ -100,15 +100,10 @@ class CustomDialog : public DialogBase
void widthChanged(int);
void heightChanged(int);
void nbMinesChanged(int);
signals:
void setWidth(int);
void setHeight(int);
void setNbMines(const QString &);
private:
QScrollBar *sm;
Level *lev;
KIntNumInput *km;
Level &lev, &initLev;
};
//-----------------------------------------------------------------------------
......
......@@ -15,7 +15,6 @@
#include <kstdaction.h>
#include <kkeydialog.h>
#include "defines.h"
#include "version.h"
#include "status.h"
......@@ -34,12 +33,11 @@ MainWidget::MainWidget()
// File & Popup
KStdAction::openNew(status, SLOT(restartGame()),
actionCollection(), "game_new");
KAction *action
= new KAction(i18n("Pause"), Key_P, status, SLOT(pauseGame()),
(void)new KAction(i18n("Pause"), Key_P, status, SLOT(pauseGame()),
actionCollection(), "game_pause");
action = new KAction(i18n("High scores..."), Key_H,
status, SLOT(showHighScores()),
actionCollection(), "game_highscores");
(void)new KAction(i18n("High Scores..."), Key_H,
status, SLOT(showHighScores()),
actionCollection(), "game_highscores");
KStdAction::print(status, SLOT(print()), actionCollection(), "game_print");
KStdAction::quit(qApp, SLOT(quit()), actionCollection(), "game_quit");
......@@ -93,7 +91,7 @@ MainWidget::MainWidget()
for (uint i=0; i<levelAction.size(); i++)
levelAction[i]->setExclusiveGroup("level");
createGUI("ui_kmines.rc");
createGUI();
readSettings();
setView(status);
}
......@@ -145,7 +143,13 @@ void MainWidget::toggleMenubar()
{
bool b = MENUBAR_ACTION->isChecked();
if (b) menuBar()->show();
else menuBar()->hide();
else {
menuBar()->hide();
// #### sort of hack : because KTMainWindow does not manage correctly
// main widget with a fixed layout
updateRects();
adjustSize();
}
OptionDialog::writeMenuVisible(b);
}
......@@ -188,10 +192,9 @@ static const char *DESCRIPTION
int main(int argc, char **argv)
{
KAboutData aboutData("kmines", I18N_NOOP("KMines"),
LONG_VERSION, DESCRIPTION, KAboutData::License_GPL,
"(c) 1996-2000, Nicolas Hadacek",
0, "http://azhyd.free.fr/KDE/kmines.php3");
KAboutData aboutData("kmines", I18N_NOOP("KMines"), LONG_VERSION,
DESCRIPTION, KAboutData::License_GPL,
COPYLEFT, 0, HOMEPAGE);
aboutData.addAuthor("Nicolas Hadacek", 0, "hadacek@kde.org");
aboutData.addCredit("Andreas Zehender", "Smiley pixmaps");
KCmdLineArgs::init(argc, argv, &aboutData);
......
......@@ -196,8 +196,7 @@ void Status::print()
void Status::preferences()
{
OptionDialog od(this);
if ( od.exec() ) {
field->readSettings();
emit keyboardEnabled(OptionDialog::readKeyboard());
}
if ( !od.exec() ) return;
field->readSettings();
emit keyboardEnabled(OptionDialog::readKeyboard());
}
#define VERSION "2.0.2"
#define LONG_VERSION "2.0.2 (6 Apr 2000)"
#define LONG_VERSION "2.0.2 (11 Apr 2000)"
#define COPYLEFT "(c) 1996-2000, Nicolas Hadacek"
#define HOMEPAGE "http://azhyd.free.fr/KDE/kmines.php3"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment