RKReadLineDialog::RKReadLineDialog (QWidget *parent, const QString &caption, const QString &prompt, RCommand *command) : KDialogBase (parent, 0, true, caption, KDialogBase::Ok | KDialogBase::Cancel) {
	RK_TRACE (DIALOGS);
	RK_ASSERT (command);

	QVBox *page = makeVBoxMainWidget ();
	new QLabel (caption, page);

	int screen_width = qApp->desktop ()->width () - 2*marginHint() - 2*spacingHint ();		// TODO is this correct on xinerama?

	QString context = command->fullOutput ();
	if (!context.isEmpty ()) {
		new QLabel (i18n ("Context:"), page);

		QTextEdit *output = new QTextEdit (page);
		output->setUndoRedoEnabled (false);
		output->setTextFormat (QTextEdit::PlainText);
		output->setCurrentFont (QFont ("Courier"));
		output->setWordWrap (QTextEdit::NoWrap);
		output->setText (context);
		output->setReadOnly (true);
		int cwidth = output->contentsWidth ();
		output->setMinimumWidth (screen_width < cwidth ? screen_width : cwidth);
		output->scrollToBottom ();
		output->setFocusPolicy (QWidget::NoFocus);
	}

	QLabel *promptl = new QLabel (prompt, page);
	promptl->setAlignment (Qt::WordBreak | promptl->alignment ());

	input = new QLineEdit (QString (), page);
	input->setMinimumWidth (fontMetrics ().maxWidth ()*20);
	input->setFocus ();
}
void UBMessagesDialog::setMessages(const QList<QString> messages)
{
    mMessages = messages;

    if (mMessages.count())
    {        
        QVBoxLayout *messagesLayout = new QVBoxLayout(this);
        foreach (QString message, mMessages)
        {
            QTextEdit *messageBox = new QTextEdit(this);
            messageBox->setMinimumHeight(55);
            messageBox->setReadOnly(true);
            messageBox->setFocusPolicy(Qt::NoFocus);
            messageBox->setText(message);
            messagesLayout->addWidget(messageBox);
        }
Beispiel #3
0
void MathTest::initDisplay()
{
    int index;

    // Set the starting coordinates in pixels for the objects that will be
    // laid out.
    //
    const int tests_x = 20;     // x coord of left side of groups
    const int tests_y = 50;     // y coord of top of groups
    const int text_w = 80;      // Width of all text
    const int text_h = 14;      // Height of all text
    const int box_w = 60;       // Width of Edit Boxes and Labels
    const int box_h = 30;       // Height of all controls
    const int vs = 36;          // Vertical Span
    const int hs = 36;          // Horizontal span

    // Instantiate the Layout parameters.
    // See layout.h
    //
    LAYOUT_INIT()

    // Layout the Tests Checkboxes
    //
    LAYOUT(tests_x, tests_y, 0, vs)
    Twidget *tw = new Twidget;
    tw->objName = "Tests";
    tw->objText << "Add" << "Subtract" << "Multiply" << "Divide";
    tw->sizes   << QSize(text_w+10, box_h);
    tw->layout  << CELL(0,0) << CELL(0,1) << CELL(0,2) << CELL(0,3);
    tw->connect = false;
    //
    // Layout the Labels for number of Problems, time in Seconds, and Grade
    // Level.
    // These labels will "belong" to the pTests control group.
    //
    int label_x  = tests_x + text_w + hs;
    int label_y  = 14;
    int label_hs = box_w + hs;
    LAYOUT(label_x, label_y, label_hs, text_h)
    tw->labelText   << "Number of" << "Problems"
                    << "Time in" << "Seconds"
                    << "Grade" << "Level";
    tw->labelSizes  << QSize(text_w, text_h);
    tw->labelLayout << CELL(0,0) << CELL(0,1)
                    << CELL(1,0) << CELL(1,1)
                    << CELL(2,0) << CELL(2,1);
    pTests = new TButtonGroup <QCheckBox>(tw, this);

    // Layout the "Problems" QLineEdit boxes
    //
    tw = new Twidget;
    int prob_x = label_x;
    int prob_y = tests_y;
    LAYOUT(prob_x, prob_y, 0, vs)
    tw->objName = "Problems";
    tw->objText << "5" << "5" << "5" << "5";
    tw->sizes   << QSize(box_w, box_h);
    tw->layout  << CELL(0,0) << CELL(0,1) << CELL(0,2) << CELL (0,3);
    tw->connect = true;
    pProblems   = new TEditGroup <QLineEdit>(tw, this);
    for(index = 0; index < pProblems->widgetList.size(); index++)
        pProblems->widgetList[index]->setInputMask("00");

    // Layout the "Seconds" QLineEdit boxes
    //
    tw = new Twidget;
    int time_x = label_x + box_w + hs;
    int time_y = prob_y;
    LAYOUT(time_x, time_y, 0, vs);
    tw->layout  << CELL(0,0) << CELL(0,1) << CELL(0,2) << CELL(0,3);
    tw->objName = "Seconds";
    tw->objText << "10" << "10" << "25" << "30";
    tw->sizes   << QSize(box_w, box_h);
    tw->connect = false;
    pTimes      = new TEditGroup <QLineEdit>(tw, this);
    for(index = 0; index < pTimes->widgetList.size(); index++)
        pTimes->widgetList[index]->setInputMask("00");

    // Layout the Grade Level radiobuttons.
    //
    tw = new Twidget;
    int gl_x = time_x + box_w + hs - 10;
    int gl_y = time_y;
    LAYOUT(gl_x, gl_y, 0, vs);
    tw->layout << CELL(0,0) << CELL(0,1) << CELL(0,2) << CELL(0,3);
    tw->sizes << QSize(box_w - 10, box_h);
    tw->objText << "1" << "2" << "3" <<"4";
    tw->connect = true;
    tw->grouped = true;
    pGradeLevel = new TButtonGroup <QRadioButton>(tw, this);
    pGradeLevel->widgetList[gl_3]->setChecked(true);
    connect(pGradeLevel->buttonGroup, SIGNAL(buttonClicked(int)),
            this, SLOT(onGradeLevel(int)));

    // Layout the UserName box and its label
    //
    int userName_x = tests_x;
    int userName_y = tests_y + text_h + (4 * vs);
    int userNameEd_x = userName_x + text_w;
    int userNameEd_w = 250;
    userNameLabel = new QLabel(this);
    userNameLabel->setGeometry(userName_x, userName_y, text_w, text_h);
    userNameLabel->setText("Your Name:");
    userNameEdit = new QLineEdit(this);
    userNameEdit->setGeometry(userNameEd_x, userName_y, userNameEd_w, box_h);
    userNameEdit->setText("");
    userNameEdit->setCursorPosition(0);
    connect(userNameEdit, SIGNAL(returnPressed()), this, SLOT(onUserName()));

    // Create and connect the Start button.
    // Because this pushbutton's parent is QDialog, it will have its
    // autoDefault property set when instantiated. This can cause some very
    // confusing behavior if you don't know this. See "autoDefault" in the
    // QPushButton class reference. We will explicitly set this property
    // to FALSE for this button, and also set its "default" property to
    // FALSE.
    //
    const int pbw = 100;
    const int pbhs = 110;
    int goButton_x = tests_x+10;
    int goButton_y = userName_y + vs + 6;
    goButton = new QPushButton("Start", this);
    goButton->setGeometry(goButton_x, goButton_y, pbw, box_h);
    goButton->setAutoDefault(false);
    goButton->setDefault(false);
    connect(goButton, SIGNAL(clicked()), this, SLOT(onGo()));

    // Create and connect the stop button.
    //
    int stopButton_x = goButton_x + pbhs;
    int stopButton_y = goButton_y;
    stopButton = new QPushButton("Stop", this);
    stopButton->setGeometry(stopButton_x, stopButton_y, pbw, box_h);
    stopButton->setAutoDefault(false);
    stopButton->setDefault(false);
    connect(stopButton, SIGNAL(clicked()), this, SLOT(onStop()));

    // Create and connect the Default button.
    //
    int defaultButton_x = stopButton_x + pbhs;
    int defaultButton_y = goButton_y;
    defaultButton = new QPushButton("Defaults", this);
    defaultButton->setGeometry(defaultButton_x, defaultButton_y, pbw, box_h);
    defaultButton->setAutoDefault(false);
    defaultButton->setDefault(false);
    connect(defaultButton, SIGNAL(clicked()), this, SLOT(onDefault()));

    // Layout the Quiz and Answer Boxes and their labels
    //
    tw = new Twidget;
    int quiz_x = tests_x + 20;
    int quiz_y = goButton_y + vs;
    LAYOUT(quiz_x, quiz_y, hs + box_w+10, text_h)
    tw->labelLayout << CELL(0,0) << CELL(1,0) << CELL(2,0)
                    << CELL(0,1) << CELL(1,1) << CELL(2,1);
    tw->labelText   << "Problem" << "The" << "Your"
                    << "Number" << "Problem" << "Answer";
    tw->labelSizes  << QSize(text_w, text_h);
    LAYOUT(quiz_x, quiz_y+(2*text_h)+2, hs + box_w+10, 0)
    tw->objName = "Quiz";
    tw->objText << "";
    tw->sizes   << QSize(box_w, box_h)
                << QSize(box_w+30, box_h)
                << QSize(box_w+10, box_h);
    tw->hOffset << 20 << -5 << 0 << 20 << -5 << 0;
    tw->layout  << CELL(0,0) << CELL(1,0) << CELL(2,0);
    pQuiz = new TEditGroup <QLineEdit>(tw, this);
    //
    // Set the Quiz Box to ReadOnly and connect the returnPressed
    // signal from the Answer Box.
    //
    pQuiz->widgetList[qz_number]->setReadOnly(true);
    pQuiz->widgetList[qz_number]->setAlignment(Qt::AlignRight);
    pQuiz->widgetList[qz_quiz]->setReadOnly(true);
    pQuiz->widgetList[qz_answer]->setEnabled(true);
    pQuiz->widgetList[qz_answer]->setInputMask("0000");
    pQuiz->widgetList[qz_answer]->setCursor(Qt::IBeamCursor);
    pQuiz->widgetList[qz_answer]->setCursorPosition(0);
    QLineEdit *tempLineEdit = pQuiz->widgetList[qz_answer];
    connect (tempLineEdit, SIGNAL(returnPressed()),
        this, SLOT(onAnswer()));

    // Create the Message Box
    //
    int msg_x = tests_x;
    int msg_y = quiz_y + vs + (3 * text_h);
    int msg_w = 340;
    int msg_h = 180;
    QTextEdit* messages = new QTextEdit(this);
    messages->setGeometry(msg_x, msg_y, msg_w, msg_h);
    messages->setReadOnly(true);
    messages->setFocusPolicy(Qt::ClickFocus);
    messages->setUpdatesEnabled(true);
    pMsg = new Msg(messages);
}