Source Code (Use browser search to find items of interest.)

Class Index

kpoker'PokerWindow (./kdegames/kpoker/top.h:14)

class PokerWindow : public KTMainWindow
{
	Q_OBJECT
private:
	KMenuBar        *menu;
	
	QPopupMenu      *optionsPopup;
/*	QPopupMenu      *helpPopup;*/
	QPopupMenu      *filePopup;

	kpok            *_kpok;
	
protected slots:
	int toggleSound();
        void saveProperties(KConfig*);
        void readProperties(KConfig*);

	
public:
	PokerWindow();
	~PokerWindow();
};

kpoker'PokerWindow::PokerWindow() (./kdegames/kpoker/top.cpp:44)

PokerWindow::PokerWindow() :   KTMainWindow()
{
        int i;

	_kpok = new kpok(this,0);
	setView( _kpok, FALSE );
	_kpok->show();
	
	
	menu = new KMenuBar(this, "_mainMenu" );
	menu->show();
	
	
	filePopup = new QPopupMenu(0,"fpopup");
	filePopup->insertItem(i18n("&New game"),_kpok,SLOT(initPoker()));
	filePopup->insertSeparator();
	filePopup->insertItem(i18n("&Quit"), qApp, SLOT(quit()));

       	optionsPopup = new QPopupMenu(0,"oppup");
	
	soId = optionsPopup->insertItem(i18n("&Sound"), this, SLOT(toggleSound()));
	optionsPopup->setCheckable(TRUE);

	QPopupMenu *help = helpMenu( i18n("Poker")
					 + " " + KPOKER_VERSION + " released " + KPOKER_RELEASE_DATE
                                         + i18n("\n\nby Jochen Tuchbreiter")
                                         + " (whynot@mabi.de)"
					 + i18n("\n\nFor a list of credits see helpfile")
					 + i18n("\nSuggestions, bug reports etc. are welcome")
					     );

	menu->insertItem(i18n("&File"), filePopup);
	menu->insertItem(i18n("&Options"), optionsPopup);
	
	menu->insertSeparator();
	menu->insertItem(i18n("&Help"), help);

	setMenu( menu );

	if (_kpok->initSound() == 1) {
	  optionsPopup->setItemChecked(soId, TRUE);
	}
	else {
	  optionsPopup->setItemEnabled(soId, FALSE);
	}
	conf = kapp->config();

	if (conf !=0) {
	  if ((i = conf->readNumEntry("Sound", -1)) != -1) {
	    if (i==0) {
	      optionsPopup->setItemChecked(soId, FALSE);
	      _kpok->setSound(0);
	    }
	    if (i==1) {
	      optionsPopup->setItemChecked(soId, TRUE);
	      _kpok->setSound(1);
            	    }
	  }
	}
}


kpoker'PokerWindow::~PokerWindow() (./kdegames/kpoker/top.cpp:105)

PokerWindow::~PokerWindow()
{
        if (optionsPopup->isItemChecked(soId)) 
	  conf->writeEntry("Sound",1);
	else
	  conf->writeEntry("Sound",0);
	delete menu;
}



kpoker'PokerWindow::saveProperties() (./kdegames/kpoker/top.cpp:115)

void PokerWindow::saveProperties(KConfig* conf)
{
  conf->writeEntry("cash", _kpok->getCash());
  if (optionsPopup->isItemChecked(soId)) 
    conf->writeEntry("Sound",1);
  else
    conf->writeEntry("Sound",0);
}


kpoker'PokerWindow::readProperties() (./kdegames/kpoker/top.cpp:124)

void PokerWindow::readProperties(KConfig* conf)
{
  int i;
  if ((i = conf->readNumEntry("cash", -1)) != -1) {
    _kpok->setCash(i);
  }
  if ((i = conf->readNumEntry("Sound", -1)) != -1) {
    if (i==0) {
      optionsPopup->setItemChecked(soId, FALSE);
      _kpok->setSound(0);
    }
    if (i==1) {
      optionsPopup->setItemChecked(soId, TRUE);
      _kpok->setSound(1);
    }
  }
}


kpoker'PokerWindow::toggleSound() (./kdegames/kpoker/top.cpp:142)

int PokerWindow::toggleSound()
{
  if (optionsPopup->isItemChecked(soId) == TRUE) {
      _kpok->setSound(0);
    optionsPopup->setItemChecked(soId, FALSE);
  }
  else {
    optionsPopup->setItemChecked(soId, TRUE);
    _kpok->setSound(1);
  }
  return 1;
}