NewGame::NewGame(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::NewGame),
        _isNetworkGame(false),
        _createOrJoin(0)
{
    ui->setupUi(this);
    _game = NULL;
    _winner = -1;
    ui->ComputOrHuman->setChecked(true);
    ui->VsHuman->setChecked(true);
    ui->WhiteColor->setChecked(true);

    QObject::connect(ui->ComputOrHuman, SIGNAL(clicked(bool)), this, SLOT(CompVSComp(bool)));
    QObject::connect(ui->cbNetwork, SIGNAL(clicked(bool)), this, SLOT(NetworkGame(bool)));
    QObject::connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(CreateNewGame()));
    QObject::connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(CancelNewGame()));
    QObject::connect(ui->cbNetwork, SIGNAL(clicked(bool)),this, SLOT(isNetwork(bool)));
    QObject::connect(ui->btnCreate, SIGNAL(clicked()), this, SLOT(Create()));
    QObject::connect(ui->btnJoin, SIGNAL(clicked()), this, SLOT(Join()));
    QObject::connect(ui->listRefresh, SIGNAL(clicked()), this, SLOT(refreshGames()));
}
Beispiel #2
0
/** Library constructor
 * Initialize the library UI and generate an initial list of all the games available.
 * \param p Inherited palette configuration for setting StyleSheets.
 * \param parent Pointer to parent widget.
*/
Library::Library(QSettings* p, QWidget* parent)
    : QWidget(parent)
{
    this->setObjectName("libraryUI");
    this->setStyleSheet("QPushButton {"
                        "color: " + p->value("Primary/LightText").toString() + "; "
                        "background-color: " + p->value("Primary/DarkElement").toString() + "; "
                        "border: none; margin: 0px; padding: 0px;} "
                        "QPushButton:hover {"
                        "background-color: " + p->value("Primary/InactiveSelection").toString() + ";} "
                        "QListWidget {"
                        "background-color: " + p->value("Primary/TertiaryBase").toString() + "; "
                        "color: " + p->value("Primary/LightText").toString() + ";}"
                        "QLabel {"
                        "color: " + p->value("Primary/LightText").toString() + ";"
                        "font-family: SourceSansPro;"
                        "}");

    init(p);

    if (!db.init())
    {
        QMessageBox error;
        error.critical(0, tr("Error!"), tr("An error occurred while trying to load the database."));
        exit(EXIT_FAILURE);
    }

    QList<Game> games = db.getGames();
    for (auto game : games)
    {
        qDebug() << game.id << game.gameName << game.gameDirectory << game.executablePath;
    }

    QFileSystemWatcher* watcher = new QFileSystemWatcher;
    watcher->addPath(QDir(CONFIG_FOLDER).filePath("horizon.db"));
    connect(watcher, &QFileSystemWatcher::fileChanged, this, &Library::refreshGames);

    refreshGames();
}