Пример #1
0
void MainWindow::createActions()
{
    ////////////////////////////////////////////////////////////////////////////
    // akcje menu File
    newAction = new QAction(tr("&New *.turtle"), this);
    newAction->setIcon(QIcon(":/images/new.png"));
    newAction->setShortcut(QKeySequence::New);
    newAction->setStatusTip(tr("Create a new turtle file"));
    connect(newAction, SIGNAL(triggered()), this, SLOT(newFile()));

    openAction = new QAction(tr("&Open *.turtle"), this);
    openAction->setIcon(QIcon(":/images/open.png"));
    openAction->setShortcut(QKeySequence::Open);
    openAction->setStatusTip(tr("Open an existing turtle command file"));
    connect(openAction, SIGNAL(triggered()), this, SLOT(open()));

    saveCmdAction = new QAction(tr("&Save *.turtle"), this);
    saveCmdAction->setIcon(QIcon(":/images/save.png"));
    saveCmdAction->setShortcut(QKeySequence::Save);
    saveCmdAction->setStatusTip(tr("Save turtle commands to file"));
    connect(saveCmdAction, SIGNAL(triggered()), this, SLOT(saveCmd()));

    saveImgAction = new QAction(tr("Save *.jpg"), this);
    saveImgAction->setStatusTip(tr("Save board as JPG file"));
    connect(saveImgAction, SIGNAL(triggered()), this, SLOT(saveImg()));

    exitAction = new QAction(tr("E&xit"), this);
    exitAction->setShortcut(tr("Ctrl+Q"));
    exitAction->setStatusTip(tr("Exit the application"));
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));

    ////////////////////////////////////////////////////////////////////////////
    // akcje menu Edit
    clearBoardAction = new QAction(tr("Clear board"), this);
    clearBoardAction->setStatusTip(tr("Clears drawing board"));
    connect(clearBoardAction, SIGNAL(triggered()), this, SLOT(clearAll()));

    drawHistoryAction = new QAction(tr("Draw history"), this);
    drawHistoryAction->setStatusTip(tr("Draws commands history"));
    connect(drawHistoryAction, SIGNAL(triggered()), this, SLOT(drawHistory()));

    ////////////////////////////////////////////////////////////////////////////
    // akcje menu Help

    ////////////////////////////////////////////////////////////////////////////
    // zad 2:
    aboutAction = new QAction(tr("&Commands"), this);
    aboutAction->setStatusTip(tr("Show the application's About box"));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));

    aboutQtAction = new QAction(tr("About &Qt"), this);
    aboutQtAction->setStatusTip(tr("Show the Qt library's About box"));
    connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
Пример #2
0
void Game::run()
{
    Area area;
    Font btnFont(L"laudcn2.ttf", 14);
    
    area.setTimer(300, watch);

    GameBackground *background = new GameBackground();
    area.add(background);
    CheatCommand cheatCmd(&area);
    area.add(new CheatAccel(L"iddqd", &cheatCmd));
    WinCommand winCmd(&area, watch, this);
    FailCommand failCmd(&area, this);
    puzzle->setCommands(&winCmd, &failCmd);
    area.add(puzzle, false);
    area.add(verHints, false);
    area.add(horHints, false);
    
    PauseGameCommand pauseGameCmd(&area, watch, background);
    BUTTON(12, 400, L"pause", &pauseGameCmd)
    ToggleHintCommand toggleHintsCmd(verHints, horHints);
    BUTTON(119, 400, L"switch", &toggleHintsCmd)
    SaveGameCommand saveCmd(&area, watch, background, this);
    BUTTON(12, 440, L"save", &saveCmd)
    GameOptionsCommand optionsCmd(&area);
    BUTTON(119, 440, L"options", &optionsCmd)
    ExitCommand exitGameCmd(area);
    BUTTON(226, 400, L"exit", &exitGameCmd)
    area.add(new KeyAccel(SDLK_ESCAPE, &exitGameCmd));
    HelpCommand helpCmd(&area, watch, background);
    BUTTON(226, 440, L"help", &helpCmd)
    area.add(watch, false);

    watch->start();
    area.run();
}