void EntityEditorWindow::create_connections() { connect( m_entity_editor.get(), SIGNAL(signal_applied(foundation::Dictionary)), SIGNAL(signal_applied(foundation::Dictionary))); connect(m_ui->buttonbox, SIGNAL(accepted()), SLOT(slot_accept())); connect(m_ui->buttonbox, SIGNAL(rejected()), SLOT(slot_cancel())); connect( create_window_local_shortcut(this, Qt::Key_Escape), SIGNAL(activated()), SLOT(slot_cancel())); }
PropertiesBuilding::PropertiesBuilding( QList<GenericPlayer *> * players, QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { setWindowTitle( tr( "building properties" ) ); _building = 0; QLabel * ownerLabel = new QLabel( this ); ownerLabel->setText( tr( "Owner:" ) ); _name = new QLabel( this ); _resBuil = new AskCost( tr( "Res Buil: " ), this ); _ownerList = new QComboBox( this ); refresh( players ); _listBuilding = new QListWidget( this ); QPushButton * pb = new QPushButton( this ); pb->setText( tr( "Ok" ) ); FIXEDSIZE( pb ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setSpacing( 5 ); layH1->addWidget( ownerLabel ); layH1->addWidget( _ownerList, 1 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->setSpacing( 5 ); layH2->addWidget( _listBuilding, 1 ); QHBoxLayout * layH = new QHBoxLayout(); layH->setMargin( 5 ); layH->addStretch( 1 ); layH->addWidget( pb ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layH1 ); layout->addStretch( 1 ); layout->addWidget( _name ); layout->addWidget( _resBuil ); layout->addWidget( _listBuilding ); layout->addLayout( layH ); layout->activate(); connect( pb, SIGNAL( clicked() ), SLOT( slot_accept() ) ); connect( _ownerList, SIGNAL( activated( int ) ), SLOT( slot_owner( int ) ) ); }
ConfigDialog::ConfigDialog(QString path, QWidget* parent) : QDialog(parent), _ui(new Ui::ConfigDialog) { _ui->setupUi(this); if(QFile::exists(path)) this->loadConfig("/home/chris/workspace/optris_intrinsic_calibration_tool/config/pattern.ini"); else qDebug() << __PRETTY_FUNCTION__ << "]: config file not found."; this->slot_patternChanged(0); connect(_ui->_buttonBox, SIGNAL(accepted()), this, SLOT(slot_accept())); connect(_ui->_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(_ui->_patternBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_patternChanged(int))); }
MatchInviteDialog::MatchInviteDialog(QString name, QString rank, bool canRefuseFuture) { int horiz_pos = 0; seconds = 20; //does it? /* FIXME, we need to center this text, make the font larger, or * bold, etc.. */ namelabel = new QLabel(tr("%1 %2").arg(name).arg(rank)); dialoglabel = new QLabel(tr("wants to play a match...")); timelabel = new QLabel(tr("%1 seconds").arg(seconds)); acceptButton = new QPushButton(tr("&Accept")); acceptButton->setDefault(true); declineButton = new QPushButton(tr("&Decline")); if(canRefuseFuture) refuseFutureCB = new QCheckBox(tr("Refuse Invites from %1").arg(name)); else refuseFutureCB = 0; buttonBox = new QDialogButtonBox(Qt::Horizontal); buttonBox->addButton(acceptButton, QDialogButtonBox::ActionRole); buttonBox->addButton(declineButton, QDialogButtonBox::ActionRole); connect(acceptButton, SIGNAL(clicked()), this, SLOT(slot_accept())); connect(declineButton, SIGNAL(clicked()), this, SLOT(slot_decline())); if(refuseFutureCB) connect(refuseFutureCB, SIGNAL(clicked(bool)), this, SLOT(slot_refuseFutureCB(bool))); QGridLayout * mainLayout = new QGridLayout; mainLayout->setSizeConstraint(QLayout::SetFixedSize); mainLayout->addWidget(namelabel, horiz_pos++, 0); mainLayout->addWidget(dialoglabel, horiz_pos++, 0); mainLayout->addWidget(timelabel, horiz_pos++, 0); if(refuseFutureCB) mainLayout->addWidget(refuseFutureCB, horiz_pos++, 0); mainLayout->addWidget(buttonBox, horiz_pos++, 0); setLayout(mainLayout); setWindowTitle(tr("Match Invite!")); startTimer(1000); }
PropertiesEvent::PropertiesEvent( GenericEvent * event, QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { _event = event; createContentView(); QPushButton * pbCondition = new QPushButton( this ); pbCondition->setText( tr( "Condition" ) ); FIXEDSIZE( pbCondition ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbCondition ); layH1->addStretch( 1 ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addStretch( 1 ); layH2->addWidget( pbCan ); layH2->addStretch( 1 ); layH2->addWidget( pbOk ); layH2->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addWidget( _content, 1 ); layout->addLayout( layH1 ); layout->addLayout( layH2 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( slot_accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); }
ExpressionEditorWindow::ExpressionEditorWindow( const Project& project, ParamArray& settings, const QString& widget_name, const string& expression, QWidget* parent) : WindowBase(parent, "expression_editor_window") , m_ui(new Ui::ExpressionEditorWindow()) , m_project(project) , m_settings(settings) , m_widget_name(widget_name) , m_show_examples(false) { m_ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); setWindowFlags(Qt::Tool); QHBoxLayout* root_layout = new QHBoxLayout(m_ui->scrollarea); QVBoxLayout* left_layout = new QVBoxLayout(); QVBoxLayout* right_layout = new QVBoxLayout(); root_layout->addLayout(left_layout); root_layout->addLayout(right_layout); // Expression controls. SeExprEdControlCollection* controls = new SeExprEdControlCollection(); QScrollArea* controls_scrollarea = new QScrollArea(this); controls_scrollarea->setObjectName("expression_controls"); controls_scrollarea->setMinimumHeight(200); controls_scrollarea->setWidgetResizable(true); controls_scrollarea->setWidget(controls); left_layout->addWidget(controls_scrollarea); // Clear button. QShortcut* clear_shortcut = new QShortcut(QKeySequence("Ctrl+N"), this); connect(clear_shortcut, SIGNAL(activated()), SLOT(slot_clear_expression())); QPushButton* clear_button = new QPushButton("Clear"); clear_button->setToolTip(clear_shortcut->key().toString(QKeySequence::NativeText)); connect(clear_button, SIGNAL(clicked()), SLOT(slot_clear_expression())); // Save button. QShortcut* save_shortcut = new QShortcut(QKeySequence("Ctrl+S"), this); connect(save_shortcut, SIGNAL(activated()), SLOT(slot_save_script())); QPushButton* save_button = new QPushButton("Save"); save_button->setToolTip(save_shortcut->key().toString(QKeySequence::NativeText)); connect(save_button, SIGNAL(clicked()), SLOT(slot_save_script())); // Load button. QShortcut* load_shortcut = new QShortcut(QKeySequence("Ctrl+O"), this); connect(load_shortcut, SIGNAL(activated()), SLOT(slot_load_script())); QPushButton* load_button = new QPushButton("Load"); load_button->setToolTip(load_shortcut->key().toString(QKeySequence::NativeText)); connect(load_button, SIGNAL(clicked()), SLOT(slot_load_script())); // Help button. QPushButton* help_button = new QPushButton("Help"); connect(help_button, SIGNAL(clicked()), SLOT(slot_show_help())); // Examples button. QPushButton* examples_button = new QPushButton("Examples"); connect(examples_button, SIGNAL(clicked()), SLOT(slot_show_examples())); QHBoxLayout* file_buttonbox = new QHBoxLayout(); file_buttonbox->addWidget(clear_button); file_buttonbox->addWidget(load_button); file_buttonbox->addWidget(save_button); file_buttonbox->addWidget(help_button); file_buttonbox->addWidget(examples_button); left_layout->addLayout(file_buttonbox); m_editor = new SeExprEditor(this, controls); QTextEdit* text_edit = m_editor->findChild<QTextEdit*>(""); text_edit->setObjectName("expression_editor"); m_editor->setExpr(expression, true); left_layout->addWidget(m_editor); m_error = new QLabel("Expression has errors. Check log for details."); m_error->setObjectName("error"); m_error->hide(); left_layout->addWidget(m_error); // Expression browser. m_browser = new SeExprEdBrowser(nullptr, m_editor); const bf::path root_path(Application::get_root_path()); const string scripts_path = (root_path / "seexpr").string(); m_browser->addPath("Examples", scripts_path); m_browser->update(); m_browser->hide(); right_layout->addWidget(m_browser); m_ui->buttonbox_layout->addStretch(1); m_ui->buttonbox_layout->setStretch(0, 1); m_ui->buttonbox_layout->setStretch(1, 0); connect(m_ui->buttonbox, SIGNAL(accepted()), SLOT(slot_accept())); connect(m_ui->buttonbox, SIGNAL(rejected()), SLOT(slot_cancel())); connect( m_ui->buttonbox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SLOT(slot_apply())); connect( create_window_local_shortcut(this, Qt::Key_Escape), SIGNAL(activated()), SLOT(close())); WindowBase::load_settings(); }
UndoPrompt::UndoPrompt(const QString * _name, bool multiple, int _moves) : name(_name), moves(_moves) { movesSpin = 0; if(name) { if(!multiple) mainlabel = new QLabel(tr("%1 wants to undo the last move").arg(*name)); else mainlabel = new QLabel(tr("%1 wants to undo to move %2").arg(*name).arg(moves)); } else { if(!multiple) mainlabel = new QLabel(tr("Undo the last move?").arg(*name)); else { mainlabel = new QLabel(tr("Undo to what move?")); movesSpin = new QSpinBox(); movesSpin->setValue(moves); // really shouldn't this be moves -1? movesSpin->setRange(0, moves); } } if(!movesSpin) { acceptButton = new QPushButton(tr("&Accept")); acceptButton->setDefault(true); declineButton = new QPushButton(tr("&Decline")); } else { acceptButton = new QPushButton(tr("&Request")); acceptButton->setDefault(true); declineButton = new QPushButton(tr("&Cancel")); } buttonBox = new QDialogButtonBox(Qt::Horizontal); buttonBox->addButton(acceptButton, QDialogButtonBox::ActionRole); buttonBox->addButton(declineButton, QDialogButtonBox::ActionRole); connect(acceptButton, SIGNAL(clicked()), this, SLOT(slot_accept())); connect(declineButton, SIGNAL(clicked()), this, SLOT(slot_decline())); QGridLayout * mainLayout = new QGridLayout; mainLayout->setSizeConstraint(QLayout::SetFixedSize); mainLayout->addWidget(mainlabel, 0, 0); if(movesSpin) mainLayout->addWidget(movesSpin, 1, 0); mainLayout->addWidget(buttonBox, (movesSpin ? 2 : 1), 0); setLayout(mainLayout); if(name) setWindowTitle(tr("Undo requested")); else setWindowTitle(tr("Request undo?")); // we might want to set modality here //startTimer(1000); }
PropertiesCreature::PropertiesCreature (QWidget * parent, const char * name) :QDialog (parent, Qt::Dialog) { setWindowTitle( QString ( name)); _creaturePix = new QLabel( this ); _resCrea= new AskCost( tr( "Res Crea: " ), this ); _creatureBehaviour = new AskCombo( tr( "Behaviour of creatures: " ), this ); _creatureBehaviour->insertItem( GenericMapCreature::getBehaviourString( GenericMapCreature::Obedient ) ); _creatureBehaviour->insertItem( GenericMapCreature::getBehaviourString( GenericMapCreature::Friendly ) ); _creatureBehaviour->insertItem( GenericMapCreature::getBehaviourString( GenericMapCreature::Neutral ) ); _creatureBehaviour->insertItem( GenericMapCreature::getBehaviourString( GenericMapCreature::Aggressive ) ); _creatureBehaviour->insertItem( GenericMapCreature::getBehaviourString( GenericMapCreature::Hostile ) ); _creatureFlee = new AskBool( tr( "Never flee: " ), this ); _lookingRight = new AskBool( tr( "Looking at right side: " ), this ); _creatureGrowth = new AskCombo( tr( "Growth of creatures: " ), this ); _creatureGrowth->insertItem( GenericMapCreature::getGrowthString( GenericMapCreature::Stable ) ); _creatureGrowth->insertItem( GenericMapCreature::getGrowthString( GenericMapCreature::FixedPercentage ) ); _creatureGrowth->insertItem( GenericMapCreature::getGrowthString( GenericMapCreature::VariablePercentage ) ); _growthParam0 = new AskInt( tr( "Growth param 0: " ), this ); _growthParam0->setMinValue( 0 ); _growthParam0->setMaxValue( 1000 ); _growthParam0->setEnabled( false ); _growthParam1 = new AskInt( tr( "Growth param 1: " ), this ); _growthParam1->setMinValue( 0 ); _growthParam1->setMaxValue( 1000 ); _growthParam0->setEnabled( false ); QVBoxLayout * layV1 = new QVBoxLayout(); layV1->setMargin( 5 ); layV1->addWidget( _creaturePix, 1 ); layV1->addSpacing( 10 ); layV1->addWidget( _creatureBehaviour, 1 ); layV1->addWidget( _creatureFlee, 1 ); layV1->addWidget( _lookingRight, 1 ); layV1->addWidget( _creatureGrowth, 1 ); layV1->addWidget( _growthParam0, 1 ); layV1->addWidget( _growthParam1, 1 ); QVBoxLayout * layV2 = new QVBoxLayout(); layV2->setMargin( 5 ); layV2->setSpacing( 5 ); layV2->addStretch( 1 ); AskInt * stack; QString label; _creatureStacks.resize( MAX_UNIT ); for( uint i = 0; i < MAX_UNIT; i++ ) { label = QString (tr( "Number of creatures in stack %1: " ).arg(i)); stack = new AskInt( label, this ); stack->setMinValue( 0 ); stack->setMaxValue( 10000 ); layV2->addWidget( stack ); layV2->addStretch( 1 ); if( _creatureStacks[ i] ) { delete _creatureStacks[ i]; } _creatureStacks[ i] = stack ; } QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setSpacing( 5 ); layH1->setMargin( 5 ); layH1->addLayout( layV1, 1 ); layH1->addLayout( layV2, 1 ); QPushButton * butOk = new QPushButton( this ); butOk->setText( tr( "Ok" ) ); FIXEDSIZE( butOk ); QPushButton * butCan = new QPushButton( this ); butCan->setText( tr( "Cancel" ) ); FIXEDSIZE( butCan ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->setMargin( 5 ); layH2->setSpacing( 5 ); layH2->addStretch( 1 ); layH2->addWidget( butOk ); layH2->addStretch( 1 ); layH2->addWidget( butCan ); layH2->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layH1, 1 ); layout->addWidget( _resCrea ); layout->addLayout( layH2 ); layout->activate(); connect( butOk, SIGNAL( clicked() ), this, SLOT( slot_accept() ) ); connect( butCan, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( _creatureGrowth, SIGNAL( sig_activated( int ) ), SLOT( slot_growthMode( int ) ) ); }