QTfrontend/ui/widget/seedprompt.cpp
changeset 8434 4821897a0f10
parent 8386 2aaa2995a32e
child 8622 2045bdf1b11b
equal deleted inserted replaced
8432:f2d57e987ba9 8434:4821897a0f10
    26 
    26 
    27 #include "seedprompt.h"
    27 #include "seedprompt.h"
    28 
    28 
    29 SeedPrompt::SeedPrompt(QWidget* parent, const QString & seed, bool editable) : QDialog(parent)
    29 SeedPrompt::SeedPrompt(QWidget* parent, const QString & seed, bool editable) : QDialog(parent)
    30 {
    30 {
    31 	setModal(true);
    31     setModal(true);
    32 	setWindowFlags(Qt::Sheet);
    32     setWindowFlags(Qt::Sheet);
    33 	setWindowModality(Qt::WindowModal);
    33     setWindowModality(Qt::WindowModal);
    34 	setMinimumSize(360, 160);
    34     setMinimumSize(360, 160);
    35 	resize(360, 160);
    35     resize(360, 160);
    36 	setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    36     setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    37 
    37 
    38 	// Layout
    38     // Layout
    39 	QVBoxLayout * dialogLayout = new QVBoxLayout(this);
    39     QVBoxLayout * dialogLayout = new QVBoxLayout(this);
    40 
    40 
    41 	// Label
    41     // Label
    42 	QLabel * label = new QLabel(tr("The map seed is the basis for all random values generated by the game."));
    42     QLabel * label = new QLabel(tr("The map seed is the basis for all random values generated by the game."));
    43 	label->setWordWrap(true);
    43     label->setWordWrap(true);
    44 	dialogLayout->addWidget(label, 0);
    44     dialogLayout->addWidget(label, 0);
    45 
    45 
    46 	// Input box
    46     // Input box
    47 	editBox = new QLineEdit();
    47     editBox = new QLineEdit();
    48 	editBox->setText(seed);
    48     editBox->setText(seed);
    49 	editBox->setReadOnly(!editable);
    49     editBox->setReadOnly(!editable);
    50 	editBox->setStyleSheet("QLineEdit { padding: 3px; }");
    50     editBox->setStyleSheet("QLineEdit { padding: 3px; }");
    51 	dialogLayout->addWidget(editBox, 1);
    51     dialogLayout->addWidget(editBox, 1);
    52 
    52 
    53 	dialogLayout->addStretch(1);
    53     dialogLayout->addStretch(1);
    54 
    54 
    55 	// Buttons
    55     // Buttons
    56 	QHBoxLayout * buttonLayout = new QHBoxLayout();
    56     QHBoxLayout * buttonLayout = new QHBoxLayout();
    57 	buttonLayout->addStretch(1);
    57     buttonLayout->addStretch(1);
    58 	dialogLayout->addLayout(buttonLayout);
    58     dialogLayout->addLayout(buttonLayout);
    59 	if (editable)
    59     if (editable)
    60 	{
    60     {
    61 		QPushButton * btnCancel = new QPushButton(tr("Cancel"));
    61         QPushButton * btnCancel = new QPushButton(tr("Cancel"));
    62 		QPushButton * btnOkay = new QPushButton(tr("Set seed"));
    62         QPushButton * btnOkay = new QPushButton(tr("Set seed"));
    63 		connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
    63         connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
    64 		connect(btnOkay, SIGNAL(clicked()), this, SLOT(accept()));
    64         connect(btnOkay, SIGNAL(clicked()), this, SLOT(accept()));
    65 		buttonLayout->addWidget(btnCancel);
    65         buttonLayout->addWidget(btnCancel);
    66 		buttonLayout->addWidget(btnOkay);
    66         buttonLayout->addWidget(btnOkay);
    67 		btnOkay->setDefault(true);
    67         btnOkay->setDefault(true);
    68 	}
    68     }
    69 	else
    69     else
    70 	{
    70     {
    71 		QPushButton * btnClose = new QPushButton(tr("Close"));
    71         QPushButton * btnClose = new QPushButton(tr("Close"));
    72 		connect(btnClose, SIGNAL(clicked()), this, SLOT(reject()));
    72         connect(btnClose, SIGNAL(clicked()), this, SLOT(reject()));
    73 		buttonLayout->addWidget(btnClose);
    73         buttonLayout->addWidget(btnClose);
    74 		btnClose->setDefault(true);
    74         btnClose->setDefault(true);
    75 	}
    75     }
    76 
    76 
    77 	setStyleSheet("QPushButton { padding: 5px; }");
    77     setStyleSheet("QPushButton { padding: 5px; }");
    78 
    78 
    79 	connect(this, SIGNAL(accepted()), this, SLOT(setSeed()));
    79     connect(this, SIGNAL(accepted()), this, SLOT(setSeed()));
    80 }
    80 }
    81 
    81 
    82 void SeedPrompt::setSeed()
    82 void SeedPrompt::setSeed()
    83 {
    83 {
    84 	emit seedSelected(editBox->text());
    84     emit seedSelected(editBox->text());
    85 }
    85 }