#include "mainwindow.h" #include #include #include #include #include #include #include // QString tempFileName; MainWindow::MainWindow( QWidget * parent, Qt::WFlags f) : QMainWindow(parent, f) { setupUi(this); connect(getButton, SIGNAL(clicked()), this, SLOT(getProverb())); //connect(getButton, SIGNAL(returnPressed()), this, SLOT(getProverb())); connect(aboutButton, SIGNAL(clicked()), this, SLOT(about())); QTemporaryFile tempFile; if (tempFile.open()) { tempFileName = tempFile.fileName(); qDebug()<<"Temp file name" <text().toUtf8().data(); if (command == "") command = "fortune fortune-ml"+command+" >"+tempFileName.toUtf8().data(); // തിരയാന്‍ ഒരു വാക്കും തന്നില്ലെങ്കില്‍ ഏതെങ്കിലും പഴഞ്ചൊല്ല് കാണിക്കാനുള്ള വിദ്യ else command = "fortune fortune-ml -m "+command+" >"+tempFileName.toUtf8().data(); //std::cout<setPlainText(in.readAll()); QApplication::restoreOverrideCursor(); QTextDocument *document = textEdit->document(); QTextCursor highlightCursor(document); QTextCursor cursor(document); QTextCursor startOfLine(document); QTextCursor deletePercentage(document); cursor.beginEditBlock(); QTextCharFormat plainFormat(highlightCursor.charFormat()); QTextCharFormat colorFormat = plainFormat; colorFormat.setFontItalic(true); colorFormat.setForeground(Qt::darkBlue); while (!deletePercentage.isNull() && !deletePercentage.atEnd()) // % ചിഹ്നം നീക്കാന്‍ { deletePercentage = document->find("%", deletePercentage, QTextDocument::FindWholeWords); if (!deletePercentage.isNull()) { deletePercentage.movePosition(QTextCursor::WordRight, QTextCursor::KeepAnchor); deletePercentage.removeSelectedText(); } } while (!startOfLine.isNull() && !startOfLine.atEnd()) // എല്ലാ വരിയുടെയും തുടക്കത്തില്‍ '* ' ചേര്‍ക്കാന്‍ { startOfLine.movePosition(QTextCursor::StartOfLine); startOfLine.insertText("* "); startOfLine.movePosition(QTextCursor::Down); } while (!highlightCursor.isNull() && !highlightCursor.atEnd()) // ആവശ്യപ്പെട്ട വാക്ക് നീലനിരത്തില്‍ ചരിച്ചെഴുതാന്‍ { highlightCursor = document->find(lineEdit->text(), highlightCursor); if (!highlightCursor.isNull()) { highlightCursor.movePosition(QTextCursor::WordRight, QTextCursor::KeepAnchor); highlightCursor.mergeCharFormat(colorFormat); } } cursor.endEditBlock(); } void MainWindow::about(void) { /* QMessageBox::about(this, tr("About Kuttans"), tr("

Proverb

GUI for fortune-ml

"));*/ About tabdialog("."); tabdialog.exec(); }