/**
* \author Jules Gorny - ALCoV team, ISIT, UMR 6284 UdA – CNRS
**/
AskSomething::AskSomething(QString windowsTitle, QString labelText, bool pwType, bool browseNeed, QIcon icon, QWidget *parent) : QDialog(parent)
{
	this->setWindowIcon(icon);
	this->setWindowTitle(windowsTitle);

    m_answer = new QLineEdit(this);
	if( pwType )
		m_answer->setEchoMode(QLineEdit::Password);
	m_answerLbl = new QLabel(this);
	m_answerLbl->setText(labelText);
	connect(m_answer, SIGNAL(textChanged(QString)), this, SLOT(slot_textChanged(QString)));
	
    validateButton = new QPushButton(tr("Validate"));
	validateButton->setDefault( true );
	validateButton->setEnabled( false );

	QSpacerItem *Spacer1 = new QSpacerItem(10, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
	QSpacerItem *Spacer2 = new QSpacerItem(10, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
		
	QPushButton *browseButton;
	if( browseNeed )
	{
		browseButton = new QPushButton();
		browseButton->setGeometry(browseButton->x(), browseButton->y(), 40, 28);
		QPixmap pixmap2(Config::IMAGES_FOLDER + "browse.png");
		QIcon ButtonIcon2(pixmap2);	
		browseButton->setIcon(ButtonIcon2);
		browseButton->setIconSize(QSize(28,28));
		browseButton->setFlat(true);
		connect(browseButton, SIGNAL(clicked()), this, SLOT(slot_browse()));
	}

    connect(validateButton, SIGNAL(clicked()), this, SLOT(accept()));
	
    QVBoxLayout *Vlt = new QVBoxLayout;
    QHBoxLayout *Hlt = new QHBoxLayout;
    QHBoxLayout *HltLbl = new QHBoxLayout;
    Vlt->addWidget(m_answerLbl);
    HltLbl->addWidget(m_answer);
	if( browseNeed )
		HltLbl->addWidget(browseButton);
	Hlt->addItem(Spacer1);
    Hlt->addWidget(validateButton);
    Hlt->addItem(Spacer2);
    Vlt->addLayout(HltLbl);
    Vlt->addLayout(Hlt);

    setLayout(Vlt);
}
示例#2
0
int TCommandLine::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QPlainTextEdit::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: textChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 1: slot_textChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 2: slot_sendCommand((*reinterpret_cast< const char*(*)>(_a[1]))); break;
        case 3: slot_popupMenu(); break;
        default: ;
        }
        _id -= 4;
    }
    return _id;
}