Ejemplo n.º 1
0
void ChatTextEdit::updateServer(const ServerProperties& srvprop)
{
    appendPlainText("");

    QString dt = getTimeStamp();
    
    QTextCharFormat format = textCursor().charFormat();
    QTextCharFormat original = format;
    QTextCursor cursor = textCursor();
    
    //show 'joined new channel' in bold
    QFont font = format.font();
    font.setBold(true);
    format.setFont(font);
    cursor.setCharFormat(format);
    QString line = dt + tr("Server Name: %1").arg(_Q(srvprop.szServerName));;
    setTextCursor(cursor);
    appendPlainText(line);

    line = dt + tr("Message of the Day: %1").arg(_Q(srvprop.szMOTD)) + "\r\n";
    format.setForeground(QBrush(Qt::darkCyan));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //revert bold
    font.setBold(false);
    format.setFont(font);

    //revert to original
    cursor.setCharFormat(original);
    setTextCursor(cursor);
    limitText();
}
Ejemplo n.º 2
0
void ShellEdit::onEditFinished()
{
    QString cmd = edit->text();
    // 如果输入为空则光标跳到下一行
    if (cmd.isEmpty()) {
        moveCursor(QTextCursor::End);
        edit->setStyleSheet("QLineEdit{background:black;font:bold;color:#87CEFA;border-width:0;border-style:outset}");
        edit->clear();

        appendPlainText(">>> ");
        updateEditPosition();

        edit->show();
        edit->setFocus();
        return;
    }
    // 解析输入的命令,并使光标跳到下一行
    moveCursor(QTextCursor::End);
    insertPlainText(cmd);
    edit->setStyleSheet("QLineEdit{background:black;font:bold;color:#87CEFA;border-width:0;border-style:outset}");
    edit->clear();

    appendPlainText(runCommand(cmd));
    appendPlainText(">>> ");
    updateEditPosition();

    edit->show();
    edit->setFocus();
}
Ejemplo n.º 3
0
void ResultDisplay::append(const QString& expression, Quantity& value)
{
    ++m_count;

    appendPlainText(expression);
    if (!value.isNan())
        appendPlainText(QLatin1String("= ") + NumberFormatter::format(value));
    appendPlainText(QLatin1String(""));
}
Ejemplo n.º 4
0
void ChatTextEdit::joinedChannel(int channelid)
{
    TTCHAR buff[TT_STRLEN];
    Channel chan;
    if(!TT_GetChannel(ttInst, channelid, &chan))
        return;
    if(!TT_GetChannelPath(ttInst, channelid, buff))
        return;

    appendPlainText("");

    QString dt = getTimeStamp();
    
    QTextCharFormat format = textCursor().charFormat();
    QTextCharFormat original = format;
    QTextCursor cursor = textCursor();
    
    //show 'joined new channel' in bold
    QFont font = format.font();
    font.setBold(true);
    format.setFont(font);
    cursor.setCharFormat(format);
    QString line = dt + tr("Joined new channel");
    setTextCursor(cursor);
    appendPlainText(line);
    //revert bold
    font.setBold(false);
    format.setFont(font);
    
    //show channel name in green
    line = tr("Channel: %1").arg(_Q(buff));
    format.setForeground(QBrush(Qt::darkGreen));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //show topic in blue
    line = tr("Topic: %1").arg(_Q(chan.szTopic));
    format.setForeground(QBrush(Qt::darkBlue));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //show disk quota in red
    line = tr("Disk quota: %1 KBytes").arg(chan.nDiskQuota/1024);
    format.setForeground(QBrush(Qt::darkRed));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //revert to original
    cursor.setCharFormat(original);
    setTextCursor(cursor);
    limitText();
}
Ejemplo n.º 5
0
/*!
 * \brief TextDoc::insertSkeleton adds a basic skeleton for type of text file
 */
void TextDoc::insertSkeleton ()
{
  if (language == LANG_VHDL)
    appendPlainText("entity  is\n  port ( : in bit);\nend;\n"
	    "architecture  of  is\n  signal : bit;\nbegin\n\nend;\n\n");
  else if (language == LANG_VERILOG)
    appendPlainText ("module  ( );\ninput ;\noutput ;\nbegin\n\nend\n"
	    "endmodule\n\n");
  else if (language == LANG_OCTAVE)
    appendPlainText ("function  =  ( )\n"
	    "endfunction\n\n");
}
Ejemplo n.º 6
0
QString ChatTextEdit::addTextMessage(const TextMessage& msg)
{
    User user;
    if(!TT_GetUser(ttInst, msg.nFromUserID, &user))
        return QString();

    QString dt = getTimeStamp();
    QString line = dt;

    switch(msg.nMsgType)
    {
    case MSGTYPE_USER :
        line += QString("<%1> %2").arg(getDisplayName(user)).arg(_Q(msg.szMessage));
        break;
    case MSGTYPE_CHANNEL :
        if(msg.nChannelID != TT_GetMyChannelID(ttInst))
        {
            TTCHAR chpath[TT_STRLEN] = {};
            TT_GetChannelPath(ttInst, msg.nChannelID, chpath);
            line += QString("<%1->%2> %3").arg(getDisplayName(user))
                           .arg(_Q(chpath)).arg(_Q(msg.szMessage));
        }
        else
            line += QString("<%1> %2").arg(getDisplayName(user))
                           .arg(_Q(msg.szMessage));
        break;
    case MSGTYPE_BROADCAST :
        line += QString("<%1->BROADCAST> %2").arg(getDisplayName(user))
                       .arg(_Q(msg.szMessage));
        break;
    case MSGTYPE_CUSTOM : break;
    }

    if(TT_GetMyUserID(ttInst) == msg.nFromUserID)
    {
        QTextCharFormat format = textCursor().charFormat();
        QTextCharFormat original = format;
        format.setForeground(QBrush(Qt::darkGray));
        QTextCursor cursor = textCursor();
        cursor.setCharFormat(format);
        setTextCursor(cursor);
        appendPlainText(line);
        cursor.setCharFormat(original);
        setTextCursor(cursor);
    }
    else
        appendPlainText(line);
    limitText();

    return line;
}
Ejemplo n.º 7
0
bool EBTextEdit::readFile()
{
    qDebug()<<  "EBTextEdit::readFile" << qPrintable(m_FullFileName);
    QFile file(m_FullFileName);
    if (!file.open(QFile::ReadOnly | QFile::Text))
        return false;
    if (m_ViewType == EditorView::XmlSource) {
        qDebug() << "file.read(SOURCE): "<< m_FullFileName;
        setPlainText(file.readAll());
    } else if (m_ViewType == EditorView::Text || m_ViewType == EditorView::OnlyPlainData ) {
        qDebug() << "file.read(DOM): "<< m_FullFileName;
        QDomDocument doc( m_FullFileName );
        QString errotMsg("");
        int iErrorLine(0), iErrorCol(0);
        if ( !doc.setContent( &file,false, &errotMsg, &iErrorLine, &iErrorCol))
        {
            file.close();
            qCritical()<< "QDomDocument::setContent: " <<  errotMsg << " Line " << iErrorLine << " column: " << iErrorCol;
            return false;
        }
        file.close();

        QString tagName("");
        QDomElement docElem = doc.documentElement();
        QDomNode n = docElem.firstChild();

        //we take only data
        if(m_ViewType == EditorView::OnlyPlainData) {
            QString sData = docElem.elementsByTagName(DataOwnerSingl::XmlKeywords::KEYWORD_DATA).at(0).toElement().text();
            if(sData.startsWith("\n"))
                sData = sData.mid(1);
            appendPlainText(sData);
        }
        else {
            while(!n.isNull()) {
                QDomElement e = n.toElement();
                if (!e.isNull()) {
                    //qDebug()<< qPrintable(e.tagName())  << " : " << qPrintable(e.text());
                    tagName =  DataOwnerSingl::XmlKeywords::convertKeywordXml2Txt(e.tagName());
                    appendPlainText(tagName + qPrintable(e.text()));
                }
                n = n.nextSibling();
            }
        }
    }
    else
        qCritical("More views are not implemented yet.");
    setDocumentTitle(m_FullFileName);
    return true;
}
Ejemplo n.º 8
0
void ResultDisplay::refresh()
{
    clear();
    QList<HistoryEntry> history = Evaluator::instance()->session()->historyToList();
    m_count = history.count();

    for(int i=0; i<m_count; ++i) {
        QString expression = history[i].expr();
        Quantity value = history[i].result();
        appendPlainText(expression);
        if (!value.isNan())
            appendPlainText(QLatin1String("= ") + NumberFormatter::format(value));
        appendPlainText(QLatin1String(""));
    }

}
Ejemplo n.º 9
0
void tekOutput::printDate()
{
	QDateTime tmdt = QDateTime::currentDateTime();
	appendPlainText(tr("Date:") + getDate(tmdt) + tr("\n") +
					tr("Time: ")+ getTime(tmdt) + tr("\n"));
	ensureCursorVisible();
}
Ejemplo n.º 10
0
void PgxConsole::keyPressEvent(QKeyEvent *event)
{
    switch(event->key()) {
    case Qt::Key_Up:
        emit historyUp();
        break;
    case Qt::Key_Down:
        emit historyDown();
        break;
    case Qt::Key_Left:
        if(!textCursor().atBlockStart())
            QPlainTextEdit::keyPressEvent(event);
        break;
    case Qt::Key_Backspace:
        if(!textCursor().atBlockStart())
            QPlainTextEdit::keyPressEvent(event);
        break;
    case Qt::Key_Return:
    case Qt::Key_Enter:
        emit commandSignal(QString());
        break;
    case Qt::Key_Backslash:
        QPlainTextEdit::keyPressEvent(event);
        appendPlainText("");
        break;
    default:
        QPlainTextEdit::keyPressEvent(event);
    }
}
GraphicInterface::GraphicInterface(int numRAM, int numHD, int numPRI, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::GraphicInterface)
{
    ui->setupUi(this);

    //Look for available IP's to connect
    QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
    // add to the IP combo box all IPv4 address, including localhost(127.0.0.1)
    for (int i = 0; i < ipAddressesList.size(); i++) {
        if (ipAddressesList.at(i).toIPv4Address())
        {
            ui->ipCombo->addItem(ipAddressesList.at(i).toString());
            ipv4AddressesList.push_back(ipAddressesList.at(i));
        }
    }

    // Set Different Resources names and values
    QString resourcesNames[]      = {"RAM Memory: ","Hard Drive:     ", "Printers:          "};
    int numInstancesOfResource[]  = {numRAM,numHD,numPRI};
    numberOfResources = 3;

    //Create server
    server = new Server(numInstancesOfResource,this);
    connect(server,SIGNAL(sendMessageToLog(QString)),ui->logTextBox,SLOT(appendPlainText(QString)));
    connect(server,SIGNAL(updateAddResourceInGUI(int,int)),this,SLOT(addInstanceOfResource(int,int)));

    QVBoxLayout *resourcesLayout = new QVBoxLayout;
    for (int i = 0 ; i < numberOfResources ; i++)
    {
        resourcesMeters[i] = new ResourceMeter(resourcesNames[i],0,numInstancesOfResource[i],numInstancesOfResource[i]);
        resourcesLayout->addWidget(resourcesMeters[i]);
    }
    ui->resourcesFrame->setLayout(resourcesLayout);
}
void TrackEditor::connectDevice() {
	//        QDialog *devdlg = new QDialog(this);
	//        Ui::DeviceDialog dlg;
	//        dlg.setupUi(devdlg);

	CDeviceDialog *devdlg = new CDeviceDialog(this);
	devdlg->setModal(true);
	int retval = devdlg->exec();

	if(retval == QDialog::Accepted) {
		qDebug("OK pressed.");
		CSerialPortSettings settings = devdlg->getPortSettings();
		m_serial_port = new QextSerialPort(settings.getName(), settings);
		bool res = m_serial_port->open( QIODevice::ReadWrite );
		connect(m_serial_port, SIGNAL(readyRead()), this, SLOT(readDevice()));

		// openTTY("/dev/rfcomm0", 115200);
		m_device_io = new CWintec("WBT201");
		connect(this, SIGNAL(emitData(QByteArray)), m_device_io, SLOT(addData(QByteArray)));
		connect(m_device_io, SIGNAL(sendData(QByteArray)), this, SLOT(sendData(QByteArray)));
		connect(m_device_io, SIGNAL(nemaString(QString)), ui.nemaText, SLOT(appendPlainText(QString)));

		connect(m_device_io, SIGNAL(progress(int)), this, SLOT(progress(int)));

		connect(m_device_io, SIGNAL(readLogFinished()), this, SLOT(readLogFinished()));

		connect(m_device_io, SIGNAL(newTrack(Track*)), this, SLOT(newTrack(Track*)));
		connect(m_device_io, SIGNAL(newWayPoint(TrackPoint*)), this, SLOT(newWayPoint(TrackPoint*)));
		connect(m_device_io, SIGNAL(newLogPoint(TrackPoint*)), this, SLOT(newLogPoint(TrackPoint*)));

		// readDevice();

		ui.action_Read_Log->setDisabled(false);
	}
Ejemplo n.º 13
0
void ResultDisplay::append(const QString& expression, const HNumber& value)
{
    ++m_count;

    appendPlainText(expression);
    if (!value.isNan())
        appendPlainText(QLatin1String("= ") + NumberFormatter::format(value));
    appendPlainText(QLatin1String(""));

    // TODO: Refactor, this only serves to save a session.
    m_expressions.append(expression);
    if (value.isNan()) {
        m_results.append("");
    } else {
        const char format = value.format() != 0 ? value.format() : 'e';
        char* str = HMath::format(value, format, DECPRECISION);
        m_results.append(str);
        free(str);
    }
}
Ejemplo n.º 14
0
void pConsole::executeCommand( const QString& command, bool writeCommand, bool showPrompt )
{
	const QStringList clearCommands = QStringList( "clear" ) << "cls";
	
	if ( clearCommands.contains( command, Qt::CaseInsensitive ) )
	{
		clear();
		
		if ( showPrompt )
		{
			displayPrompt();
		}
		
		return;
	}
	
	// write command to execute
	if ( writeCommand )
	{
		if ( !currentCommand().isEmpty() )
		{
			displayPrompt();
		}
		
		insertPlainText( command );
	}
	
	// execute command
	int res;
	QString strRes = interpretCommand( command, &res );
	
	// write output in different colors if needed
	if ( res == 0 )
	{
		useColor( ctOutput );
	}
	else
	{
		useColor( ctError );
	}
	
	if ( !strRes.isEmpty() )
	{
		appendPlainText( strRes );
	}
	
	useColor( ctCommand );
	
	// display the prompt again if needed
	if ( showPrompt )
	{
		displayPrompt();
	}
}
Ejemplo n.º 15
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    ui.setupUi(this);
    ui.graphicsView->setScene(&scene);


    cameraHandler = new CameraHandler(this);
   // connect(cameraHandler, SIGNAL(displayImage(QImage)), SLOT(displayImage(QImage)));
    connect(cameraHandler, SIGNAL(updateLog(QString)), ui.plainTextEdit, SLOT(appendPlainText(QString)));
    connect(this, SIGNAL(updateLog(QString)), ui.plainTextEdit, SLOT(appendPlainText(QString)));
    cameraHandler->init();
    picItem = new ClickablePixmapItem;
    picItem->setScale(0.5);
    scene.addItem(picItem);
    connect(picItem, SIGNAL(clickedPt(QPoint)), this, SLOT(clickedPicture(QPoint)));
    fd = new FiducialDetector(this);
    connect(fd, SIGNAL(updateLog(QString)), ui.plainTextEdit, SLOT(appendPlainText(QString)));
    fd->saveIntermediatePictures(true);

}
Ejemplo n.º 16
0
Console::Console(QWidget *parent)
    : QPlainTextEdit(parent)
{
    setWindowTitle("Console");
    resize(800, 600);

    setUndoRedoEnabled(false);
    appendPlainText(QString(""));

    QFont courier("Courier");
    setFont(courier);
}
Ejemplo n.º 17
0
void Qt5DebugOutput::appendText(const char* line)
{
    if (line[0] == 0)
        return;

    //printf("Called with line  %s\n", line);
    //printf("Called with chars %x %x %x %x\n", line[0], line[1], line[2], line[3]);

    QString t = QString::fromLocal8Bit(line);
    t.replace(QString("\n"), QString(""));
    t.replace(QString("\r"), QString(""));

    appendPlainText(t);
}
Ejemplo n.º 18
0
void ChatTextEdit::addLogMessage(const QString& msg)
{
    QString line = QString("%1 * %2").arg(getTimeStamp()).arg(msg);
    QTextCharFormat format = textCursor().charFormat();
    QTextCharFormat original = format;
    format.setForeground(QBrush(Qt::gray));
    QTextCursor cursor = textCursor();
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);
    cursor.setCharFormat(original);
    setTextCursor(cursor);
    limitText();
}
Ejemplo n.º 19
0
LogWindow::LogWindow(QWidget *parent) : QPlainTextEdit(parent) {
    setCenterOnScroll(true);
    setReadOnly(true);
    setLineWrapMode(NoWrap);
    setTextInteractionFlags(Qt::TextSelectableByMouse);

    #ifdef WIN32
    setFont(QFont("Consolas", 8));
    #endif
    new Highlighter(document());
   
    g_logWindow = this;
    appendPlainText(g_logBuffer.trimmed());
    g_logBuffer.clear();    
}
Ejemplo n.º 20
0
ShellEdit::ShellEdit(QWidget *parent) : QPlainTextEdit(parent)
{
    // 设置只读模式
    setReadOnly(true);
    // 加入>>>提示句
    appendPlainText(">>> ");
    // 设置QPlainTextEdit属性
    setStyleSheet("QPlainTextEdit{background:black;font:bold;color:#87CEFA}");

    edit = new QLineEdit(this->viewport());
    // 设置edit属性
    edit->setStyleSheet("QLineEdit{background:black;font:bold;color:#87CEFA;border-width:0;border-style:outset}");
    // 触发enter信号
    connect(edit, SIGNAL(returnPressed()), SLOT(onEditFinished()));
}
Ejemplo n.º 21
0
void PgxConsole::historyUpCommand()
{
    if(!history.isEmpty() && hit > 0) {
        QTextCursor cursor = textCursor();
        cursor.movePosition(QTextCursor::End);
        setTextCursor(cursor);
        cursor.select(QTextCursor::BlockUnderCursor);
        if(cursor.hasSelection()) {
            cursor.removeSelectedText();
            appendPlainText(history.at(--hit));
        }
        else
            insertPlainText(history.at(--hit));
    }
}
Ejemplo n.º 22
0
void ClientGui::on_connect_clicked(bool checked)
{
    mSocket.connectToServer("qtRemoteSignalsTest");
    if(mSocket.waitForConnected(1))
    {
        connect(&mClient, SIGNAL(echoAnswer(QString)), ui->echoOutput, SLOT(appendPlainText(QString)));
        mClient.initialize();
        ui->inputWidget->setEnabled(true);
        ui->connect->setEnabled(false);
    }
    else
    {
        QMessageBox::warning(this, "Could not connect", "Could not connect to server");
        ui->connect->setChecked(false);
    }
}
Ejemplo n.º 23
0
void PgxConsole::historyDownCommand()
{
    if(!history.isEmpty() && hit < history.size()-1) {
        QTextCursor cursor = textCursor();
        cursor.movePosition(QTextCursor::End);
        setTextCursor(cursor);
        cursor.select(QTextCursor::BlockUnderCursor);
        if(cursor.hasSelection()) {
            cursor.removeSelectedText();
            appendPlainText(history.value(++hit));
        }
        else
            insertPlainText(history.value(++hit));
    }
    ensureCursorVisible();
}
Ejemplo n.º 24
0
void LogWidget::appendLog(const QString& text)
{
	QString t=text.trimmed()+"\n";
	if(mScrollDirDown) {
		appendPlainText(t);
		QScrollBar *vsb=verticalScrollBar();
		if(nullptr!=vsb) {
			vsb->setValue(vsb->maximum());
		}
	} else {
		moveCursor(QTextCursor::Start);
		insertPlainText(t);
		QScrollBar *vsb=verticalScrollBar();
		if(nullptr!=vsb) {
			vsb->setValue(vsb->minimum());
		}
	}
}
Ejemplo n.º 25
0
void PgxConsole::pasteAsSingleFromClipboard()
{
    if(!textCursor().atEnd()) {
        if(textCursor().block().next().isValid()) {
            QTextCursor cursor = textCursor();
            cursor.movePosition(QTextCursor::End);
            setTextCursor(cursor);
        }
    }
    QClipboard *clipboard = QApplication::clipboard();
    QString clipboard_text = clipboard->text();
    QStringList clipboard_text_list = clipboard_text.trimmed().split("\n", QString::SkipEmptyParts);
    int clipboard_text_list_size = clipboard_text_list.size();
    for(int i = 0; i < clipboard_text_list_size; i++) {
        appendPlainText(clipboard_text_list.at(i));
        if(i != clipboard_text_list_size-1)
            insertPlainText(" \\");
    }
    //showView(clipboard_text_list.join(" "));
}
Ejemplo n.º 26
0
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	ui->setupUi(this);
	storage = new PicStorage;
	mProgress = new QProgressDialog(this);
	mProgress->setWindowModality(Qt::WindowModal);
	mProgress->setMinimumDuration(1000);

	connect(storage, SIGNAL(message(QString)), ui->plainTextEdit, SLOT(appendPlainText(QString)));
	connect(ui->actionImport, SIGNAL(triggered(bool)), this, SLOT(onImport()));
	connect(ui->actionLoad, SIGNAL(triggered(bool)), this, SLOT(onLoad()));
	connect(ui->actionSetStorage, SIGNAL(triggered(bool)), this, SLOT(onSetRoot()));
//	connect(ui->actionImport, SIGNAL(triggered(bool)), this, SLOT(onImport()));
//	connect(ui->actionImport, SIGNAL(triggered(bool)), this, SLOT(onImport()));

	connect(storage, SIGNAL(progressStart(int,QString)), this, SLOT(showProgress(int,QString)));
	connect(storage, SIGNAL(progress(int)), this, SLOT(progress(int)));
	connect(storage, SIGNAL(progressEnd()), mProgress, SLOT(reset()));
}
Ejemplo n.º 27
0
void LogWidget::appendText(const QString &message)
{
    appendPlainText(message);
    ensureCursorVisible();
}
Ejemplo n.º 28
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //about window
    this->aboutWindow = new AboutWindow();
    this->aboutWindow->hide();
    this->aboutWindow->move(this->geometry().center()-this->aboutWindow->geometry().center());
    //calibrate Dialog
    this->calibrateDialog = new CalibrateDialog();
    this->calibrateDialog->hide();
    this->calibrateDialog->move(this->geometry().center()-this->calibrateDialog->geometry().center());
    //option Dialog
    this->optionDialog = new OptionDialog();
    this->optionDialog->hide();
    this->optionDialog->move(this->geometry().center()-this->optionDialog->geometry().center());
    //slice dialog
    this->sliceDialog = new SliceDialog(ui->glWidget, this);
    this->sliceDialog->hide();
    this->sliceDialog->move(this->geometry().center()-this->sliceDialog->geometry().center());
    //macros window
    this->macrosWindow = new MacrosWindow();
    this->macrosWindow->hide();
    this->macrosWindow->move(this->geometry().center()-this->macrosWindow->geometry().center());
    connect(this->macrosWindow, SIGNAL(buttonAdded(MacroButton*)), this, SLOT(addMacroBtn(MacroButton*)));
    connect(this->macrosWindow, SIGNAL(buttonRemoved(MacroButton*)), this, SLOT(removeMacroBtn(MacroButton*)));
    //sd card window
    this->sdCardWindow = new SDCardWindow();
    this->sdCardWindow->hide();
    this->sdCardWindow->move(this->geometry().center()-this->sdCardWindow->geometry().center());
    connect(this->sdCardWindow, SIGNAL(sdFile_selected(QString)), this, SLOT(sdFile_selected(QString)));
    connect(this->optionDialog, SIGNAL(slicerPathChanged(QString)), this->sliceDialog, SLOT(updateSlicerPath(QString)));
    connect(this->optionDialog, SIGNAL(outputPathChanged(QString)), this->sliceDialog, SLOT(updateOutputPath(QString)));
    connect(this->optionDialog, SIGNAL(newSize(QVector3D)), this, SLOT(updatadeSize(QVector3D)));
    connect(this->optionDialog, SIGNAL(newList(QList<Material*>*)), this->sliceDialog, SLOT(setMaterialList(QList<Material*>*)));
    connect(this->sliceDialog, SIGNAL(fileSliced(QString)), this, SLOT(loadFile(QString)));
    //set version number
    this->setWindowTitle("YARRH v"+QString::number(VERSION_MAJOR)+"."+QString::number(VERSION_MINOR)+"."+QString::number(VERSION_REVISION));
    this->aboutWindow->setVersion(VERSION_MAJOR,VERSION_MINOR,VERSION_REVISION);
    //setting up printer and its thread
    this->printerObj = new Printer();
    QThread *qthread = new QThread();

    //connecting ui to printer
    connect(printerObj, SIGNAL(write_to_console(QString)), ui->inConsole, SLOT(appendPlainText(QString)), Qt::QueuedConnection);
    connect(this->macrosWindow, SIGNAL(writeToPrinter(QString)), printerObj, SLOT(send_now(QString)),Qt::QueuedConnection);
    connect(ui->fanSpinBox, SIGNAL(valueChanged(int)), printerObj, SLOT(setFan(int)), Qt::QueuedConnection);
    ui->fanSpinBox->blockSignals(true);
    connect(this->printerObj, SIGNAL(SDFileList(QStringList)), this->sdCardWindow, SLOT(updateFileList(QStringList)));
    connect(this->printerObj, SIGNAL(uploadProgress(int,int)), this->sdCardWindow, SLOT(updateProgress(int,int)));
    this->sdCardWindow->setPrinter(this->printerObj);
    //connecting move btns
    connect(ui->homeX, SIGNAL(clicked()), printerObj, SLOT(homeX()), Qt::QueuedConnection);
    connect(ui->homeY, SIGNAL(clicked()), printerObj, SLOT(homeY()), Qt::QueuedConnection);
    connect(ui->homeAll, SIGNAL(clicked()), printerObj, SLOT(homeAll()), Qt::QueuedConnection);
    //connect monit temp checkbox
    connect(ui->graphGroupBox, SIGNAL(toggled(bool)), printerObj, SLOT(setMonitorTemperature(bool)),Qt::QueuedConnection);
    //connect printer to temp widget
    connect(printerObj, SIGNAL(currentTemp(double,double,double)), this, SLOT(drawTemp(double,double,double)));
    connect(printerObj, SIGNAL(progress(int,int)), this, SLOT(updateProgress(int,int)));
    connect(printerObj, SIGNAL(connected(bool)), this, SLOT(printerConnected(bool)));
    //setting ui temp from gcode
    connect(printerObj, SIGNAL(settingTemp1(double)), this, SLOT(setTemp1FromGcode(double)));
    connect(printerObj, SIGNAL(settingTemp3(double)), this, SLOT(setTemp3FromGcode(double)));
    //updating head position in ui
    connect(printerObj, SIGNAL(currentPosition(QVector3D)), this, SLOT(updateHeadPosition(QVector3D)));
    //print finished signal
    connect(printerObj, SIGNAL(printFinished(bool)), this, SLOT(printFinished(bool)));
    //connect calibration dialog to printer
    connect(calibrateDialog, SIGNAL(writeToPrinter(QString)), printerObj, SLOT(send_now(QString)),Qt::QueuedConnection);
    //connect z slider
    connect(ui->zSlider, SIGNAL(valueChanged(int)), this, SLOT(moveZ(int)));
    connect(ui->zSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateZ(int)));
    //connect action load
    connect(ui->actionLoad, SIGNAL(triggered()), this, SLOT(loadFile()));

    printerObj->moveToThread(qthread);
    qthread->start(QThread::HighestPriority);


    this->portEnum = new QextSerialEnumerator(this);
    this->portEnum->setUpNotifications();
    QList<QextPortInfo> ports = this->portEnum->getPorts();
    //finding avalible ports
    foreach (QextPortInfo info, ports) {
        ui->portCombo->addItem(info.portName);
    }
Ejemplo n.º 29
0
void PgxConsole::showView(QString cmd)
{
    if(cmd.isEmpty()) {
        if(!textCursor().atEnd()) {
            QTextCursor cursor = textCursor();
            cursor.movePosition(QTextCursor::End);
            setTextCursor(cursor);
        }
        QTextBlock block = document()->end();
        if(!block.isValid())
            block = block.previous();
        cmd = block.text().trimmed();
        for (block = block.previous(); block.text().endsWith("\\"); block = block.previous())
            cmd.insert(0, block.text().trimmed().replace(QLatin1String("\\"), QLatin1String(" ")));
        // Do nothing on whitespace input.
        if(cmd.trimmed().isEmpty()) {
            appendPlainText("");
            return;
        }
    }
    // Save the command into the command history and
    // reassign the history iterator.
    history << cmd;
    hit = history.size();

    // 'clear' command to clear the console keeping the
    // history intact.
    if(cmd.compare("clear", Qt::CaseInsensitive) == 0)
        clear();
    // 'clearh' command to clear the history alone. Console
    // is not cleared.
    else if(cmd.compare("clearh", Qt::CaseInsensitive) == 0) {
        history.clear();
        hit = 0;
        appendPlainText("");
    }
    // 'clearall' command to clear console and history
    else if(cmd.compare("clearall", Qt::CaseInsensitive) == 0) {
        history.clear();
        hit = 0;
        clear();
    }
    // 'quit' command to clear console and history
    else if(cmd.compare("quit", Qt::CaseInsensitive) == 0) {
        history.clear();
        hit = 0;
        clear();
        pgxconsole_mainwin->close();
        return;
    }
    // 'exit' command to clear console and history
    else if(cmd.compare("exit", Qt::CaseInsensitive) == 0) {
        history.clear();
        hit = 0;
        clear();
        pgxconsole_mainwin->close();
    }
    else {
        // Reduce all groups of whitespace characters
        // to a single space between words.
        cmd = cmd.simplified();
        // Start a timer to count the seconds taken to display the
        // required output (used for queries and tables only).
        QTime t;
        t.start();
        emit showQueryView(database, cmd);
        appendPlainText("");
    }
}
Ejemplo n.º 30
0
void Log::receiveLog(const QString & log)
{
	QTime time = QTime::currentTime();
	QString timestamp = "[" + time.toString("hh:mm:ss") + "] ";
	appendPlainText(timestamp + log);
}