Пример #1
0
void Dialog::onMessageToGui(QString name, QString mes)
{
    QTextEdit *output = ui->te_outputMess;
    output->moveCursor(QTextCursor::End);
    output->setTextColor(Qt::blue);
    output->insertPlainText(QTime::currentTime().toString());
    output->setTextColor(Qt::red);
    output->insertPlainText("<"+name+">");
    output->setTextColor(Qt::black);
    output->insertPlainText(mes+"\n");
}
Пример #2
0
  /*!
     * \class TextCursorChangeFontColor
   * \author Anders Fernström
   * \date 2005-11-03
   * \date 2006-01-13 (update)
     *
     * \brief Command for changing font color
   *
   * 2005-11-07 AF, implemented the function
   * 2005-11-15 AF, added trick to get correct style on links
   * 2006-01-13 AF, remove trick to get correct style on links because
   * it made undo/redo work incorrectly
     */
  void TextCursorChangeFontColor::execute()
  {
    QTextEdit *editor = document()->getCursor()->currentCell()->textEdit();

    if( editor )
    {
      editor->setTextColor( color_ );


      // ugly trick to make the sure that the links haven't change
      // color
      /*
      if( !editor->toPlainText().isEmpty() )
      {
        int start = editor->textCursor().selectionStart();
        int end = editor->textCursor().selectionEnd();
        editor->setHtml( editor->toHtml() );

        QTextCursor cursor( editor->textCursor() );
        cursor.setPosition( start );
        cursor.setPosition( end, QTextCursor::KeepAnchor );
        editor->setTextCursor( cursor );
      }
      */
    }
  }
Пример #3
0
QWidget* AboutBox::createLicensePanel()
{
	// Create a label to display readme.txt
	QTextEdit* label = new QTextEdit();
	label->setReadOnly(true);
	QString fileName(QString::fromUtf8(m_gleInterface->getManualLocation().c_str()));
	fileName.resize(fileName.lastIndexOf(QDir::separator()));
	fileName += QDir::separator();
	fileName += tr("LICENSE.txt");
   GLEInterface* iface = GLEGetInterfacePointer();
   std::string licenseFileTxt;
   bool res = iface->readFileOrGZIPTxt(fileName.toUtf8().constData(), &licenseFileTxt);
   if (res) {
		QFont font;
		// Set the font to be fixed pitch
		font.setFixedPitch(true);
		font.setFamily("Courier");
      font.setStretch(QFont::Condensed);
		label->setLineWrapMode(QTextEdit::NoWrap);
		label->setFont(font);
		label->setTextColor(Qt::black);
		// Get the text and put it in the label
		label->setPlainText(licenseFileTxt.c_str());
		QFontMetrics fm(font);
		m_minWidth = fm.width("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
	} else {
		label->setPlainText(tr("File not found: '%1'").arg(fileName));
	}
	return label;
}
Пример #4
0
void Ventana_Principal::on_bt_buscar_3_clicked()
{
    Pestana *actual = (Pestana*)ui->tabWidget->currentWidget();

    if(actual != NULL){

        QTextEdit *editor = actual->textedit();

        int fw1 = editor->fontWeight();
        QColor gris1 = QColor("red");
        editor->setFontWeight(QFont::DemiBold);
        editor->setTextColor(QColor(gris1));
        editor->insertPlainText("hola");
        editor->setFontWeight(fw1);
        editor->setTextColor(gris1);
    }
    //this->AnalisisJSLT();

}
Пример #5
0
void ExplorerPane::updateErrors(const QString& errors)
{
    QTextEdit *errorWidget = dynamic_cast<QTextEdit *>(errorsPage);
    if (errorWidget)
    {
        // Get the current text
        QString text = errorWidget->toPlainText();
        if (!text.isEmpty())
        {
            // Set the text color to light grey
            errorWidget->setTextColor(QColor("grey"));
            // Restore the current text
            errorWidget->setPlainText(text);
        }
        // Set the text color to red
        errorWidget->setTextColor(QColor("red"));
        // Append the new error message
        errorWidget->append(errors);
        // Place cursor at end of text
        errorWidget->moveCursor(QTextCursor::End);
        // Raise the Error tab
        tabWidget->setCurrentWidget(errorsPage);
    }
}
Пример #6
0
bool EmulApp::eventFilter(QObject *watched, QEvent *event)
{
    int type = static_cast<int>(event->type());
    if (type == QEvent::KeyPress) {
    } 
    MainWindow *mw = dynamic_cast<MainWindow *>(watched);
    if (mw) {
        if (type == LogLineEventType) {
            LogLineEvent *evt = dynamic_cast<LogLineEvent *>(event);
            if (evt && mw->textEdit()) {
                QTextEdit *te = mw->textEdit();
                QColor origcolor = te->textColor();
                te->setTextColor(evt->color);
                te->append(evt->str);

                // make sure the log textedit doesn't grow forever
                // so prune old lines when a threshold is hit
                nLinesInLog += evt->str.split("\n").size();
                if (nLinesInLog > nLinesInLogMax) {
                    const int n2del = MAX(nLinesInLogMax/10, nLinesInLog-nLinesInLogMax);
                    QTextCursor cursor = te->textCursor();
                    cursor.movePosition(QTextCursor::Start);
                    for (int i = 0; i < n2del; ++i) {
                        cursor.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor);
                    }
                    cursor.removeSelectedText(); // deletes the lines, leaves a blank line
                    nLinesInLog -= n2del;
                }

                te->setTextColor(origcolor);
                te->moveCursor(QTextCursor::End);
                te->ensureCursorVisible();
                return true;
            } else {
                return false;
            }
        } else if (type == StatusMsgEventType) {
            StatusMsgEvent *evt = dynamic_cast<StatusMsgEvent *>(event);
            if (evt && mw->statusBar()) {
                mw->statusBar()->showMessage(evt->msg, evt->timeout);
                return true;
            } else {
                return false;
            }
        }
    }
    if (watched == this) {
        if (type == QuitEventType) {
            quit();
            return true;
        }
        if (type == SoundTrigEventType) {
            SoundTrigEvent *evt = dynamic_cast<SoundTrigEvent *>(event);
            if (evt) trigSound(evt->trig);
            if (evt->listener) evt->listener->triggered(evt->trig);
            return true;
        }
        if (type == SoundEventType) {
            SoundEvent *evt = dynamic_cast<SoundEvent *>(event);
            if (evt) gotSound(evt->id, evt->name, evt->loops);
            if (evt->listener) evt->listener->gotSound(evt->id);
            return true;
        }
    }
    // otherwise do default action for event which probably means
    // propagate it down
    return QApplication::eventFilter(watched, event);
}