35 #include <rosgraph_msgs/Log.h> 45 #include <QColorDialog> 47 #include <QApplication> 50 #include <QFileDialog> 70 QObject::connect(
ui.action_NewWindow, SIGNAL(triggered(
bool)),
73 QObject::connect(
ui.action_Copy, SIGNAL(triggered()),
76 QObject::connect(
ui.action_CopyExtended, SIGNAL(triggered()),
79 QObject::connect(
ui.action_SelectAll, SIGNAL(triggered()),
82 QObject::connect(
ui.action_ReadBagFile, SIGNAL(triggered(
bool)),
85 QObject::connect(
ui.action_ReadLogFile, SIGNAL(triggered(
bool)),
88 QObject::connect(
ui.action_ReadLogDirectory, SIGNAL(triggered(
bool)),
91 QObject::connect(
ui.action_SaveLogs, SIGNAL(triggered(
bool)),
94 QObject::connect(
ui.action_AbsoluteTimestamps, SIGNAL(toggled(
bool)),
97 QObject::connect(
ui.action_ShowTimestamps, SIGNAL(toggled(
bool)),
100 QObject::connect(
ui.action_RegularExpressions, SIGNAL(toggled(
bool)),
101 db_proxy_, SLOT(setUseRegularExpressions(
bool)));
103 QObject::connect(
ui.action_RegularExpressions, SIGNAL(toggled(
bool)),
106 QObject::connect(
ui.action_RegularExpressions, SIGNAL(toggled(
bool)),
109 QObject::connect(
ui.action_SelectFont, SIGNAL(triggered(
bool)),
112 QObject::connect(
ui.action_ColorizeLogs, SIGNAL(toggled(
bool)),
115 QObject::connect(
ui.debugColorWidget, SIGNAL(clicked(
bool)),
117 QObject::connect(
ui.infoColorWidget, SIGNAL(clicked(
bool)),
119 QObject::connect(
ui.warnColorWidget, SIGNAL(clicked(
bool)),
121 QObject::connect(
ui.errorColorWidget, SIGNAL(clicked(
bool)),
123 QObject::connect(
ui.fatalColorWidget, SIGNAL(clicked(
bool)),
128 ui.messageList->setUniformItemSizes(
true);
131 ui.nodeList->selectionModel(),
132 SIGNAL(selectionChanged(
const QItemSelection &,
133 const QItemSelection &)),
140 ui.checkDebug, SIGNAL(toggled(
bool)),
143 ui.checkInfo, SIGNAL(toggled(
bool)),
146 ui.checkWarn, SIGNAL(toggled(
bool)),
149 ui.checkError, SIGNAL(toggled(
bool)),
152 ui.checkFatal, SIGNAL(toggled(
bool)),
157 QObject::connect(
ui.checkFollowNewest, SIGNAL(toggled(
bool)),
161 QObject::connect(
ui.messageList, SIGNAL(customContextMenuRequested(
const QPoint&)),
164 QObject::connect(
ui.clearAllButton, SIGNAL(clicked()),
166 QObject::connect(
ui.clearMessagesButton, SIGNAL(clicked()),
170 ui.messageList->verticalScrollBar(), SIGNAL(valueChanged(
int)),
174 ui.includeText, SIGNAL(textChanged(
const QString &)),
178 ui.excludeText, SIGNAL(textChanged(
const QString &)),
183 ui.searchText, SIGNAL(textChanged(
const QString &)),
186 QObject::connect(
ui.pushPrev, SIGNAL(clicked()),
189 QObject::connect(
ui.pushNext, SIGNAL(clicked()),
196 ui.splitter->setSizes(sizes);
221 QString defaultname = QDateTime::currentDateTime().toString(Qt::ISODate) +
".bag";
222 QString filename = QFileDialog::getSaveFileName(
this,
224 QDir::homePath() + QDir::separator() + defaultname,
225 tr(
"Bag Files (*.bag);;Text Files (*.txt)"));
226 if (filename != NULL && !filename.isEmpty()) {
236 statusBar()->showMessage(
"Connected to ROS Master. URL: "+currentUrl);
238 statusBar()->showMessage(
"Disconnected from ROS Master.");
244 QMainWindow::closeEvent(event);
250 QModelIndexList selection =
ui.nodeList->selectionModel()->selectedIndexes();
251 std::set<std::string> nodes;
252 QStringList node_names;
254 for (
int i = 0; i < selection.size(); i++) {
257 node_names.append(name.c_str());
262 for (
int i = 0; i < node_names.size(); i++) {
263 node_names[i] = node_names[i].split(
"/", QString::SkipEmptyParts).last();
266 setWindowTitle(QString(
"SWRI Console (") + node_names.join(
", ") +
")");
273 if (
ui.checkDebug->isChecked()) {
274 mask |= rosgraph_msgs::Log::DEBUG;
276 if (
ui.checkInfo->isChecked()) {
277 mask |= rosgraph_msgs::Log::INFO;
279 if (
ui.checkWarn->isChecked()) {
280 mask |= rosgraph_msgs::Log::WARN;
282 if (
ui.checkError->isChecked()) {
283 mask |= rosgraph_msgs::Log::ERROR;
285 if (
ui.checkFatal->isChecked()) {
286 mask |= rosgraph_msgs::Log::FATAL;
302 if (
ui.checkFollowNewest->isChecked()) {
303 ui.messageList->scrollToBottom();
310 QMenu contextMenu(tr(
"Context menu"),
ui.messageList);
312 QAction select_all(tr(
"Select All"),
ui.messageList);
313 connect(&select_all, SIGNAL(triggered()),
this, SLOT(
selectAllLogs()));
315 QAction copy(tr(
"Copy"),
ui.messageList);
316 connect(©, SIGNAL(triggered()),
this, SLOT(
copyLogs()));
318 QAction copy_extended(tr(
"Copy Extended"),
ui.messageList);
319 connect(©_extended, SIGNAL(triggered()),
this, SLOT(
copyExtendedLogs()));
321 QAction alternate_row_colors(tr(
"Alternate Row Colors"),
ui.messageList);
322 alternate_row_colors.setCheckable(
true);
323 alternate_row_colors.setChecked(
ui.messageList->alternatingRowColors());
324 connect(&alternate_row_colors, SIGNAL(toggled(
bool)),
327 contextMenu.addAction(&select_all);
328 contextMenu.addAction(©);
329 contextMenu.addAction(©_extended);
330 contextMenu.addAction(&alternate_row_colors);
332 contextMenu.exec(
ui.messageList->mapToGlobal(point));
337 if (value !=
ui.messageList->verticalScrollBar()->maximum()) {
338 ui.checkFollowNewest->setChecked(
false);
340 ui.checkFollowNewest->setChecked(
true);
347 if (
ui.nodeList->hasFocus()) {
348 ui.nodeList->selectAll();
350 ui.messageList->selectAll();
357 foreach(
const QModelIndex &index,
ui.messageList->selectionModel()->selectedIndexes())
359 buffer <<
db_proxy_->
data(index, Qt::DisplayRole).toString();
361 QApplication::clipboard()->setText(buffer.join(tr(
"\n")));
367 foreach(
const QModelIndex &index,
ui.messageList->selectionModel()->selectedIndexes())
371 QApplication::clipboard()->setText(buffer.join(tr(
"\n\n")));
382 QStringList items = text.split(
";", QString::SkipEmptyParts);
383 QStringList filtered;
385 for (
int i = 0; i < items.size(); i++) {
386 QString x = items[i].trimmed();
400 QStringList items = text.split(
";", QString::SkipEmptyParts);
401 QStringList filtered;
403 for (
int i = 0; i < items.size(); i++) {
404 QString x = items[i].trimmed();
439 int rowSearchStart =
ui.messageList->currentIndex().row();
441 QString searchText =
ui.searchText->text();
442 searchText = searchText.toUpper().trimmed();
455 if (rowSearchStart==-1){
462 printf(
"Invalid string passed to ConsoleWindow::nextIndex");
467 ui.messageList->clearSelection();
468 if(newRowIndex == -1)
473 QModelIndex index =
ui.messageList->model()->index(newRowIndex,0);
474 ui.messageList->setCurrentIndex(index);
475 ui.checkFollowNewest->setChecked(
false);
484 ui.includeLabel->setText(
"Include");
486 ui.includeLabel->setText(
"<font color='red'>Include</font>");
493 ui.excludeLabel->setText(
"Exclude");
495 ui.excludeLabel->setText(
"<font color='red'>Exclude</font>");
501 ui.messageList->setFont(font);
502 ui.nodeList->setFont(font);
533 QColor color = QColorDialog::getColor(old_color,
this);
534 if (color.isValid()) {
541 QString ss = button->styleSheet();
542 QRegExp re(
"background: (#\\w*);");
544 if (re.indexIn(ss) >= 0) {
545 old_color = QColor(re.cap(1));
552 QString
s(
"background: #" 553 + QString(color.red() < 16?
"0" :
"") + QString::number(color.red(),16)
554 + QString(color.green() < 16?
"0" :
"") + QString::number(color.green(),16)
555 + QString(color.blue() < 16?
"0" :
"") + QString::number(color.blue(),16) +
";");
556 widget->setStyleSheet(s);
559 if (widget ==
ui.debugColorWidget) {
562 else if (widget ==
ui.infoColorWidget) {
565 else if (widget ==
ui.warnColorWidget) {
568 else if (widget ==
ui.errorColorWidget) {
571 else if (widget ==
ui.fatalColorWidget) {
575 qWarning(
"Unexpected widget passed to ConsoleWindow::updateButtonColor.");
585 if (button ==
ui.debugColorWidget) {
586 defaultColor = Qt::gray;
588 else if (button ==
ui.infoColorWidget) {
589 defaultColor = Qt::black;
591 else if (button ==
ui.warnColorWidget) {
592 defaultColor = QColor(255, 127, 0);
594 else if (button ==
ui.errorColorWidget) {
595 defaultColor = Qt::red;
597 else if (button ==
ui.fatalColorWidget) {
598 defaultColor = Qt::magenta;
600 QColor color = settings.value(key, defaultColor).value<QColor>();
606 ui.messageList->setAlternatingRowColors(checked);
630 ui.checkDebug->setChecked(showDebug);
631 ui.checkInfo->setChecked(showInfo);
632 ui.checkWarn->setChecked(showWarn);
633 ui.checkError->setChecked(showError);
634 ui.checkFatal->setChecked(showFatal);
646 ui.includeText->setText(includeFilter);
648 ui.excludeText->setText(excludeFilter);
651 ui.messageList->setAlternatingRowColors(alternate_row_colors);
static const QString INFO_COLOR
bool isExcludeValid() const
void showLogContextMenu(const QPoint &point)
static const QString DISPLAY_TIMESTAMPS
void nodeSelectionChanged()
ROSCPP_DECL const std::string & getURI()
void setFatalColor(const QColor &fatal_color)
static const QString FATAL_COLOR
void setIncludeFilters(const QStringList &list)
void toggleAlternateRowColors(bool)
static const QString USE_REGEXPS
NodeListModel * node_list_model_
static const QString SHOW_WARN
static const QString ALTERNATE_LOG_ROW_COLORS
virtual QVariant data(const QModelIndex &index, int role) const
static const QString WARN_COLOR
void closeEvent(QCloseEvent *event)
QColor getButtonColor(const QPushButton *button) const
LogDatabaseProxyModel * db_proxy_
bool isIncludeValid() const
void setInfoColor(const QColor &info_color)
void setSeverityFilter(uint8_t severity_mask)
void loadColorButtonSetting(const QString &key, QPushButton *button)
void setWarnColor(const QColor &warn_color)
std::string nodeName(const QModelIndex &index) const
static const QString FOLLOW_NEWEST
void setErrorColor(const QColor &error_color)
void setExcludeFilters(const QStringList &list)
void setFollowNewest(bool)
static const QString EXCLUDE_FILTER
static const QString DEBUG_COLOR
void updateExcludeLabel()
void saveToFile(const QString &filename) const
void loadBooleanSetting(const QString &key, T *element)
static const QString COLORIZE_LOGS
void setNodeFilter(const std::set< std::string > &names)
int getItemIndex(const QString searchText, int index, int increment)
void updateButtonColor(QPushButton *widget, const QColor &color)
static const QString ABSOLUTE_TIMESTAMPS
NodeClickHandler * node_click_handler_
void setFont(const QFont &font)
static const QString SHOW_INFO
void setDebugColor(const QColor &debug_color)
static const QString ERROR_COLOR
static const QString INCLUDE_FILTER
static const QString SHOW_DEBUG
void setExcludeRegexpPattern(const QString &pattern)
static const QString SHOW_ERROR
void excludeFilterUpdated(const QString &)
void updateIncludeLabel()
void includeFilterUpdated(const QString &)
void clearSearchFailure()
void updateCurrentIndex(function sF)
void chooseButtonColor(QPushButton *widget)
static const QString SHOW_FATAL
void setIncludeRegexpPattern(const QString &pattern)