18 #include "milxQtConsole.h" 26 dockArea = Qt::BottomDockWidgetArea;
28 dock =
new QDockWidget(tr(
"Console"));
29 dock->setFeatures(QDockWidget::AllDockWidgetFeatures);
30 dock->setWidget(
this);
31 dock->setObjectName(
"Console");
37 logWindow->setTextInteractionFlags(Qt::TextBrowserInteraction);
53 void milxQtConsole::setTab(QWidget *newWidget)
55 QTextEdit *editor = qobject_cast<QTextEdit *>(newWidget);
59 connect(
this, SIGNAL(currentChanged(
int)),
this, SLOT(
consoleSwitched(
int)));
62 addTab(newWidget, newWidget->windowTitle());
79 QDateTime currentTime = QDateTime::currentDateTime();
80 QString timeStr =
"[" + currentTime.toString(
"ddd-d hh:mm:ss") +
"] ";
85 cerr << timeStr.toStdString() << msg.toStdString() << endl;
87 msg.prepend(
"Error: ");
89 msg.prepend(
"<font color='red'>");
90 msg.append(
"</font>");
96 QDateTime currentTime = QDateTime::currentDateTime();
97 QString timeStr =
"[" + currentTime.toString(
"ddd-d hh:mm:ss") +
"] ";
102 cerr << timeStr.toStdString() << msg.toStdString() << endl;
103 msg.prepend(
"Warning: ");
104 msg.prepend(timeStr);
105 msg.prepend(
"<font color='blue'>");
106 msg.append(
"</font>");
112 QDateTime currentTime = QDateTime::currentDateTime();
113 QString timeStr =
"[" + currentTime.toString(
"ddd-d hh:mm:ss") +
"] ";
118 cerr << timeStr.toStdString() << msg.toStdString() << endl;
119 msg.prepend(
"Debug: ");
120 msg.prepend(timeStr);
121 msg.prepend(
"<font color='orange'>");
122 msg.append(
"</font>");
128 QDateTime currentTime = QDateTime::currentDateTime();
129 QString timeStr =
"[" + currentTime.toString(
"ddd-d hh:mm:ss") +
"] ";
134 cout << timeStr.toStdString() << msg.toStdString() << endl;
135 msg.prepend(timeStr);
136 msg.prepend(
"<font color='black'>");
137 msg.append(
"</font>");
143 for(
int j = 0; j < count(); j ++)
145 QTextEdit *editor = qobject_cast<QTextEdit *>(widget(j));
146 if(editor && j != currentIndex())
149 if(editor->document()->isModified())
150 setTabText(j, editor->windowTitle() +
"*");
157 QTextEdit *editor = qobject_cast<QTextEdit *>(widget(index));
161 editor->document()->setModified(
false);
162 setTabText(index, editor->windowTitle());
169 copyAct->setIcon(QIcon(
":/resources/toolbar/copy.png"));
170 copyAct->setText(tr(
"Console",
"Copy", 0));
171 copyAct->setShortcut(tr(
"Ctrl+c"));
182 clearAct->setText(tr(
"Console",
"Clear", 0));
183 clearAct->setShortcut(tr(
"Crtl+z"));
void consoleWasModified()
Change the window title to show that the tab has been modified.
void printDebug(QString msg)
Debug message wrapper for console.
QPointer< QTextEdit > logWindow
Log messages window.
void consoleHTMLMessage(const QString &message)
output message as HTML
void printError(QString msg)
Error message wrapper for console.
void createActions()
Create all the actions for the console.
QAction * copyAct
Copy action for text.
milxQtConsole(QWidget *theParent=0)
void consoleSwitched(int index)
Update member for when the tab changes.
void consoleMessage(const QString &message)
output message
void printWarning(QString msg)
Warning message wrapper for console.
QAction * clearAct
clear action for text
bool timestamps
Timestamp messages?
void printInfo(QString msg)
Info message wrapper for console.
void createConnections()
Create connections for the console.
QPointer< QDockWidget > dock
Dock widget.