/** * create the action events create the gui. */ void KJezzball::initXMLUI() { m_newAction = KStdGameAction::gameNew( this, SLOT(newGame()), actionCollection() ); // AB: originally KBounce/KJezzball used Space for new game - but Ctrl+N is // default. We solve this by providing space as an alternative key KShortcut s = m_newAction->shortcut(); s.append(KKeySequence(QKeySequence(Key_Space))); m_newAction->setShortcut(s); KStdGameAction::quit(this, SLOT(close()), actionCollection() ); KStdGameAction::highscores(this, SLOT(showHighscore()), actionCollection() ); m_pauseButton = KStdGameAction::pause(this, SLOT(pauseGame()), actionCollection()); KStdGameAction::end(this, SLOT(closeGame()), actionCollection()); KStdGameAction::configureHighscores(this, SLOT(configureHighscores()),actionCollection()); new KAction( i18n("&Select Background Folder..."), 0, this, SLOT(selectBackground()), actionCollection(), "background_select" ); m_backgroundShowAction = new KToggleAction( i18n("Show &Backgrounds"), 0, this, SLOT(showBackground()), actionCollection(), "background_show" ); m_backgroundShowAction->setCheckedState(i18n("Hide &Backgrounds")); m_backgroundShowAction->setEnabled( !m_backgroundDir.isEmpty() ); m_backgroundShowAction->setChecked( m_showBackground ); m_soundAction = new KToggleAction( i18n("&Play Sounds"), 0, 0, 0, actionCollection(), "toggle_sound"); }
MainWindow::MainWindow(QWidget *parent, const char* name, WFlags /*fl*/) : KMainWindow(parent, name, WStyle_NoBorder) { m_clickcount = 0; contrdirs[Cell::U] = Cell::D; contrdirs[Cell::R] = Cell::L; contrdirs[Cell::D] = Cell::U; contrdirs[Cell::L] = Cell::R; KNotifyClient::startDaemon(); KStdGameAction::gameNew(this, SLOT(slotNewGame()), actionCollection()); KStdGameAction::highscores(this, SLOT(showHighscores()), actionCollection()); KStdGameAction::quit(this, SLOT(close()), actionCollection()); KStdGameAction::configureHighscores(this, SLOT(configureHighscores()), actionCollection()); m_levels = KStdGameAction::chooseGameType(0, 0, actionCollection()); QStringList lst; lst += i18n("Novice"); lst += i18n("Normal"); lst += i18n("Expert"); lst += i18n("Master"); m_levels->setItems(lst); setFixedSize(minimumSizeHint()); statusBar()->insertItem("abcdefghijklmnopqrst: 0 ",1); setAutoSaveSettings(); createGUI(); connect(m_levels, SIGNAL(activated(int)), this, SLOT(newGame(int))); QWhatsThis::add(this, i18n("<h3>Rules of the Game</h3>" "<p>You are the system administrator and your goal" " is to connect each computer to the central server." "<p>Click the right mouse button to turn the cable" " in a clockwise direction, and the left mouse button" " to turn it in a counter-clockwise direction." "<p>Start the LAN with as few turns as possible!")); //const int cellsize = KGlobal::iconLoader()->loadIcon("knetwalk/background.png", KIcon::User, 32).width(); const int cellsize = 32; const int gridsize = cellsize * MasterBoardSize + 2; QGrid* grid = new QGrid(MasterBoardSize, this); grid->setFrameStyle(QFrame::Panel | QFrame::Sunken); grid->setFixedSize(gridsize, gridsize); setCentralWidget(grid); Cell::initPixmaps(); for(int i = 0; i < MasterBoardSize * MasterBoardSize; i++) { board[i] = new Cell(grid, i); board[i]->setFixedSize(cellsize, cellsize); connect(board[i], SIGNAL(lClicked(int)), SLOT(lClicked(int))); connect(board[i], SIGNAL(rClicked(int)), SLOT(rClicked(int))); connect(board[i], SIGNAL(mClicked(int)), SLOT(mClicked(int))); } srand(time(0)); slotNewGame(); }