Ejemplo n.º 1
0
void MainWindow::createMainWindowMenu(){
    // Creates the 3 buttons that go on the main window
    start = new QPushButton(tr("&Start"));
    start->setFixedSize(140,40);
    start->setFont(QFont("MS Shell Dlg 2", 10, QFont::Bold));
    start->setStyleSheet("QPushButton{background-image:url(:/Resource/images/Default.png); color: white; border-width: 3px; border-color: #181D1F; border-style: outset; border-radius: 7;}"
                             "QPushButton:hover{background-image:url(:/Resource/images/Hover.png);}"
                             "QPushButton:pressed{background-image:url(:/Resource/images/Clicked.png);}");
    connect(start, SIGNAL(clicked()), this, SLOT(startButtonClicked()));

    viewHighScores = new QPushButton(tr("&View High Scores"));
    viewHighScores->setFixedSize(140,40);
    viewHighScores->setFont(QFont("MS Shell Dlg 2", 10, QFont::Bold));
    viewHighScores->setStyleSheet("QPushButton{background-image:url(:/Resource/images/Default.png); color: white; border-width: 3px; border-color: #181D1F; border-style: outset; border-radius: 7;}"
                                  "QPushButton:hover{background-image:url(:/Resource/images/Hover.png);}"
                                  "QPushButton:pressed{background-image:url(:/Resource/images/Clicked.png);}");
    connect(viewHighScores, SIGNAL(clicked()), this, SLOT(viewHighScoresButtonClicked()));

    quit = new QPushButton(tr("&Quit"));
    quit->setFixedSize(140,40);
    quit->setFont(QFont("MS Shell Dlg 2", 10, QFont::Bold));
    quit->setStyleSheet("QPushButton{background-image:url(:/Resource/images/Exit.png); color: white; border-width: 3px; border-color: #181D1F; border-style: outset; border-radius: 7;}"
                             "QPushButton:hover{background-image:url(:/Resource/images/Exit-Hover.png);}"
                             "QPushButton:pressed{background-image:url(:/Resource/images/Exit-Clicked.png);}");
    connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));

    // Creates a label for the game's name
    QPixmap titleImage(":/Resource/images/BrickBreak.png");
    titleName = new QLabel(tr(""));
    titleName->setPixmap(titleImage);
    titleName->setFixedSize(476,148);

    // Sets up the layout for the main window
    QVBoxLayout *buttonLayout = new QVBoxLayout;
    buttonLayout->addWidget(titleName, 10, Qt::AlignHCenter);
    buttonLayout->addWidget(start, 0, Qt::AlignHCenter);
    buttonLayout->addWidget(viewHighScores, 0, Qt::AlignHCenter);
    buttonLayout->addWidget(quit, 0, Qt::AlignHCenter);
    menuWidget = new QWidget;
    menuWidget->setLayout(buttonLayout);
}
Ejemplo n.º 2
0
void MainWindow::createMainMenuWidget() {
    // Sets up each menu button along with their styleSheet
    QPushButton *start = new QPushButton(tr("Start"));
    start->setFixedSize(172,48);
    start->setFont(QFont("MS Shell Dlg 2", 11, QFont::Bold));
    start->setStyleSheet("QPushButton{background-image:url(:/program/images/Default.png); color: white; border-width: 3px; border-color: #181D1F; border-style: outset; border-radius: 7;}"
                         "QPushButton:hover{background-image:url(:/program/images/Hover.png);}"
                         "QPushButton:pressed{background-image:url(:/program/images/Clicked.png);}");
    connect(start, SIGNAL(clicked()), this, SLOT(startButtonClicked()));

    QPushButton *howToPlay = new QPushButton(tr("How to Play"));
    howToPlay->setFixedSize(172,48);
    howToPlay->setFont(QFont("MS Shell Dlg 2", 11, QFont::Bold));
    howToPlay->setStyleSheet("QPushButton{background-image:url(:/program/images/About.png); color: white; border-width: 3px; border-color: #181D1F; border-style: outset; border-radius: 7;}"
                             "QPushButton:hover{background-image:url(:/program/images/About-Hover.png);}"
                             "QPushButton:pressed{background-image:url(:/program/images/About-Clicked.png);}"
                             "QPushButton:disabled{background-image:url(:/program/images/Quit.png);};");
    connect(howToPlay, SIGNAL(clicked()), this, SLOT(howToPlayButtonClicked()));

    QPushButton *about = new QPushButton(tr("About Guess Who"));
    about->setFixedSize(172,48);
    about->setFont(QFont("MS Shell Dlg 2", 11, QFont::Bold));
    about->setStyleSheet("QPushButton{background-image:url(:/program/images/About.png); color: white; border-width: 3px; border-color: #181D1F; border-style: outset; border-radius: 7;}"
                         "QPushButton:hover{background-image:url(:/program/images/About-Hover.png);}"
                         "QPushButton:pressed{background-image:url(:/program/images/About-Clicked.png);}");
    connect(about, SIGNAL(clicked()), this, SLOT(aboutButtonClicked()));

    QPushButton *quit = new QPushButton(tr("Quit"));
    quit->setFixedSize(172,48);
    quit->setFont(QFont("MS Shell Dlg 2", 11, QFont::Bold));
    quit->setStyleSheet("QPushButton{background-image:url(:/program/images/Quit.png); color: white; border-width: 3px; border-color: #181D1F; border-style: outset; border-radius: 7;}"
                        "QPushButton:hover{background-image:url(:/program/images/Quit-Hover.png);}"
                        "QPushButton:pressed{background-image:url(:/program/images/Quit-Clicked.png);}");
    connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));

    // Creates the layout for the buttons
    QVBoxLayout *buttonLayout = new QVBoxLayout;
    buttonLayout->addSpacing(20);
    buttonLayout->addWidget(start, 0, Qt::AlignHCenter);
    buttonLayout->addSpacing(15);
    buttonLayout->addWidget(howToPlay, 0, Qt::AlignHCenter);
    buttonLayout->addSpacing(15);
    buttonLayout->addWidget(about, 0, Qt::AlignHCenter);
    buttonLayout->addSpacing(15);
    buttonLayout->addWidget(quit, 0, Qt::AlignHCenter);
    buttonLayout->addSpacing(20);

    QGroupBox *choiceGroupBox = new QGroupBox(tr(""));
    choiceGroupBox->setStyleSheet("QGroupBox{color:white}");
    choiceGroupBox->setLayout(buttonLayout);
    choiceGroupBox->setFixedSize(260, 400);

    // Creates 2 labels that will hold images for the menu screen
    QLabel *leftLabel = new QLabel(tr(""));
    QPixmap leftImage(":/program/images/Left.png");
    leftLabel->setPixmap(leftImage);
    leftLabel->setFixedSize(480,570);

    QLabel *rightLabel = new QLabel(tr(""));
    QPixmap rightImage(":/program/images/Right.png");
    rightLabel->setPixmap(rightImage);
    rightLabel->setFixedSize(480,570);

    // Creates the bottom layout for the page
    QHBoxLayout *bottomLayout = new QHBoxLayout;
    bottomLayout->addWidget(leftLabel, 0, Qt::AlignHCenter);
    bottomLayout->addWidget(choiceGroupBox);
    bottomLayout->addWidget(rightLabel, 0, Qt::AlignHCenter);

    // Creates the main layout for the page
    QVBoxLayout *mainLayout = new QVBoxLayout;

    QPixmap titleImage(":/program/images/Title.png");
    QLabel *titleName = new QLabel(tr(""));
    titleName->setPixmap(titleImage);
    titleName->setFixedSize(980,300);

    mainLayout->addSpacing(100);
    mainLayout->addWidget(titleName, 0, Qt::AlignHCenter);
    mainLayout->addLayout(bottomLayout);

    mainMenuWidget = new QWidget;
    mainMenuWidget->setLayout(mainLayout);
}