// // QtkMainWindow implementation. // QtkMainWindow::QtkMainWindow(QWidget * parent, QUrl url): QMainWindow(parent) { this->resize(800, 600); this->setWindowTitle(tr("AppRTC Desk")); _stackedLayout = new QStackedWidget(); _vbox = new ConnectWindow(0, url); _localLabel = new QLabel(); _localLabel->setAccessibleName(QString("local")); QLabel *nameLocalLabel = new QLabel("Local Webcam"); nameLocalLabel->setAlignment(Qt::AlignCenter); _remoteLabel = new QLabel(); _remoteLabel->setAccessibleName(QString("remote")); QLabel *nameRemoteLabel = new QLabel("Remote Webcam"); nameRemoteLabel->setAlignment(Qt::AlignCenter); QGridLayout *streamingLayout = new QGridLayout; streamingLayout->addWidget(_localLabel, 0, 0); streamingLayout->addWidget(_remoteLabel, 0,1); streamingLayout->addWidget(nameLocalLabel, 1, 0); streamingLayout->addWidget(nameRemoteLabel, 1, 1); QWidget *streamingWidget = new QWidget; streamingWidget->setLayout(streamingLayout); _stackedLayout -> addWidget(_vbox); _stackedLayout -> addWidget(streamingWidget); this->setCentralWidget(_stackedLayout); QObject::connect(_vbox,SIGNAL(toConnect(QUrl, QByteArray)),this,SLOT(toConnect(QUrl, QByteArray))); }
// this is constructor. Menu::Menu(Configuration & newConfig) : config(newConfig), gui(config.window) { /* initialize the menu state */ state = STATE::getUserName; gui.setFont(tgui::Font(config.fontMan.get("Carlito-Bold.ttf"))); //set the default font of gui titlePic = std::make_shared<tgui::Picture>(); titlePic->setTexture(config.texMan.get("title.png")); titlePic->setPosition(100, 50); titlePic->setSize(600, 150); /* initialize the background */ backgrd.setSize(sf::Vector2f(config.window.getSize())); backgrd.setTexture(&config.texMan.get("Tower1.png")); /* initialize the getUserName gui */ state_getUserName.initialize(config); state_getUserName.confirm->connect("mousereleased", [&]() { config.soundMan.get("Decision2.ogg").play(); //config.player_name->connect("mousereleased", [&]() {state_getUserName.textBox->setText("")}); config.player_name = state_getUserName.textBox->getText(); toMainMenu(); }); /* initialize the mainMenu gui */ state_mainMenu.initialize(config); state_mainMenu.startButton->connect("mousereleased", [&]() { config.soundMan.get("Decision2.ogg").play(); tomodeChoice(); }); state_mainMenu.settingButton->connect("mousereleased", [&]() { config.soundMan.get("Decision2.ogg").play(); toSetting(); }); state_mainMenu.exitButton->connect("mousereleased", [&]() {config.window.close(); }); /* initialize the setting gui */ state_settings.initialize(config); state_settings.backButton->connect("mousereleased", [&]() { config.soundMan.get("Decision2.ogg").play(); toMainMenu(); }); state_settings.MusVol->connect("valuechanged", [&]() { float value = state_settings.MusVol->getValue() * 10.f; config.musMan.setVolume(value); }); state_settings.sonVol->connect("valuechanged", [&]() { float value = state_settings.sonVol->getValue() * 10.f; config.soundMan.setVolume(value); }); /* initialize modeChoice gui */ state_modeChoice.initialize(config); state_modeChoice.client->connect("mousereleased", [&]() { config.soundMan.get("Decision2.ogg").play(); toConnect(); }); state_modeChoice.server->connect("mousereleased", [&]() { config.soundMan.get("Decision2.ogg").play(); toLobby(); }); state_modeChoice.back->connect("mousereleased", [&]() { config.soundMan.get("Decision2.ogg").play(); toMainMenu(); }); /* initialize connect gui */ state_connect.initialize(config); state_connect.backButton->connect("mousereleased", [&]() { config.soundMan.get("Decision2.ogg").play(); tomodeChoice(); }); state_connect.connectButton->connect("mousereleased", [&]() { config.soundMan.get("Decision2.ogg").play(); toConnecting(); config.window.clear(); draw(); config.window.display(); tryConnect(); if (lobbyPtr) { toLobby(); } else { state_connecting.text->setText("Failed to connect the server."); state_connecting.backButton->show(); } }); /* initialize connecting gui */ state_connecting.initialize(config); state_connecting.backButton->connect("mousereleased", [&](){ config.soundMan.get("Decision2.ogg").play(); toConnect(); state_connecting.text->setText("Connecting..."); /// hide vs show ??? state_connecting.backButton->hide(); }); done = false; }