void DkPreferenceWidget::createLayout() {

	// create tab entries
	QWidget* tabs = new QWidget(this);
	tabs->setObjectName("DkPreferenceTabs");

	QPixmap pm = DkImage::colorizePixmap(QIcon(":/nomacs/img/power.svg").pixmap(QSize(32, 32)), QColor(255, 255, 255));
	QPushButton* restartButton = new QPushButton(pm, "", this);
	restartButton->setObjectName("DkPlayerButton");
	restartButton->setFlat(true);
	restartButton->setIconSize(QSize(32, 32));
	restartButton->setObjectName("DkRestartButton");
	restartButton->setStatusTip(tr("Restart nomacs"));
	connect(restartButton, SIGNAL(clicked()), this, SIGNAL(restartSignal()));

	mTabLayout = new QVBoxLayout(tabs);
	mTabLayout->setContentsMargins(0, 60, 0, 0);
	mTabLayout->setSpacing(0);
	mTabLayout->setAlignment(Qt::AlignTop);
	mTabLayout->addStretch();
	mTabLayout->addWidget(restartButton);

	// create central widget
	QWidget* centralWidget = new QWidget(this);
	mCentralLayout = new QStackedLayout(centralWidget);
	mCentralLayout->setContentsMargins(0, 0, 0, 0);

	QWidget* dummy = new QWidget(this);
	QHBoxLayout* layout = new QHBoxLayout(dummy);
	layout->setContentsMargins(0, 0, 0, 0);
	layout->setSpacing(0);
	layout->setAlignment(Qt::AlignLeft);
	layout->addWidget(tabs);
	layout->addWidget(centralWidget);

	// add a scroll area
	DkResizableScrollArea* scrollArea = new DkResizableScrollArea(this);
	scrollArea->setObjectName("DkScrollAreaPlots");
	scrollArea->setWidgetResizable(true);
	scrollArea->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
	scrollArea->setWidget(dummy);

	QVBoxLayout* sL = new QVBoxLayout(this);
	sL->setContentsMargins(1, 1, 1, 1);	// 1 to get the border
	sL->addWidget(scrollArea);
}
/*
 * Protocol
 *
 * From clients:
 * Direction: "O2Up", 2 - id, Up - orientation (Up, Down, Left, Right)
 *
 * From server:
 * Timer: "T"
 * Id: "I5", 5 - id number
 * Dimensions: "D 15 20", 15 - width, 20 - height
 * Snakes: "S1 2 4 2 5 2 6; S2 3 10 3 11 3 12", 1 - client id, 2 4 - points x y in snake
 * GameStatus: "G1" - game over, 1 - loser
 * Food: "F 2 4 5 6"
 * Scores: "C1 5 C2 10", 1 - id
 *
 */
void Parser::process(const QString &t_message) const
{
    if (t_message.isEmpty())
        return;

    auto ch = t_message[0];
    auto rightStr = t_message.right(t_message.size() - 1);
    if (ch == 'I')
        processId(rightStr);
    else if (ch == 'O')
        processDirection(rightStr);
    else if (ch == 'D')
        processDimensions(rightStr);
    else if (ch == 'F')
        processFood(rightStr);
    else if (ch == 'S')
        processSnakes(t_message);
    else if (ch == 'G')
        processGameOver(rightStr);
    else if (ch == 'C')
        processScores(t_message);
    else if (ch == 'R')
        emit restartSignal();
}
Exemple #3
0
void OptionsView::restartSlot()
{
    emit restartSignal();
}