47 #include "loggerWidget.hh" 53 LoggerWidget::LoggerWidget( QWidget *parent)
60 setAttribute(Qt::WA_DeleteOnClose,
false);
62 QVBoxLayout* vlayout =
new QVBoxLayout();
63 QHBoxLayout* hlayout =
new QHBoxLayout();
65 list_ =
new QListWidget();
67 list_->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
68 list_->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
69 list_->setFocusPolicy(Qt::NoFocus);
70 list_->setSelectionMode(QAbstractItemView::ExtendedSelection);
71 list_->setUniformItemSizes(
true);
73 QString path = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
78 context_ =
new QMenu(tr(
"Log Viewer"));
80 QAction* copyAction =
new QAction(QIcon(path +
"edit-copy.png"), tr(
"Copy"),0);
81 copyAction->setShortcut( QKeySequence(
"Ctrl+C") );
82 QAction* selectAction =
new QAction(tr(
"Select All"),0);
83 selectAction->setShortcut( QKeySequence(
"Ctrl+A") );
85 connect (copyAction, SIGNAL(triggered()),
this, SLOT(copySelected()));
86 connect (selectAction, SIGNAL(triggered()), list_, SLOT(selectAll()));
88 context_->addAction(copyAction);
89 context_->addSeparator();
90 context_->addAction(selectAction);
96 filterMenu_ =
new QMenu(tr(
"Log Viewer"));
98 openMeshFilterAction_ =
new QAction(QIcon(path +
"edit-copy.png"), tr(
"Enable OpenMesh error messages"),0);
99 openMeshFilterAction_->setCheckable(
true);
103 openMeshFilterAction_->setChecked(
true );
106 openMeshFilterAction_->setChecked(
false );
110 filterMenu_->addAction(openMeshFilterAction_);
117 connect (&loggerUpdateTimer_, SIGNAL(timeout ()),
this, SLOT(slotScrollUpdate()));
120 loggerUpdateTimer_.setSingleShot(
true);
121 loggerUpdateTimer_.setInterval(500);
123 allButton_ =
new QPushButton(QIcon(path +
"status_all.png"),tr(
"All Messages"));
124 allButton_->setCheckable(
true);
125 allButton_->setAutoExclusive(
true);
126 infoButton_ =
new QPushButton(QIcon(path +
"status_green.png"),tr(
"Information"));
127 infoButton_->setCheckable(
true);
128 infoButton_->setAutoExclusive(
true);
129 warnButton_ =
new QPushButton(QIcon(path +
"status_yellow.png"),tr(
"Warnings"));
130 warnButton_->setCheckable(
true);
131 warnButton_->setAutoExclusive(
true);
132 errorButton_ =
new QPushButton(QIcon(path +
"status_red.png"),tr(
"Errors"));
133 errorButton_->setCheckable(
true);
134 errorButton_->setAutoExclusive(
true);
136 filterButton_ =
new QPushButton(QIcon(path +
"status_filter.png"),tr(
"Set Filters"));
137 filterButton_->setCheckable(
false);
139 allButton_->setChecked(
true);
141 connect(allButton_, SIGNAL(clicked()),
this, SLOT(updateList()));
142 connect(infoButton_, SIGNAL(clicked()),
this, SLOT(updateList()));
143 connect(warnButton_, SIGNAL(clicked()),
this, SLOT(updateList()));
144 connect(errorButton_, SIGNAL(clicked()),
this, SLOT(updateList()));
145 connect(filterButton_,SIGNAL(clicked()),
this, SLOT(slotFilterMenu()));
147 clearButton_ =
new QPushButton(QIcon(path +
"edit-clear.png"),tr(
"Clear Messages"));
148 connect(clearButton_, SIGNAL(clicked()), list_, SLOT(clear()));
150 hlayout->addWidget( allButton_ );
151 hlayout->addWidget( infoButton_ );
152 hlayout->addWidget( warnButton_ );
153 hlayout->addWidget( errorButton_ );
154 hlayout->addStretch();
155 hlayout->addWidget( filterButton_ );
156 hlayout->addStretch();
157 hlayout->addWidget( clearButton_ );
159 hlayout->setSpacing(0);
160 hlayout->setContentsMargins (0,0,0,0);
161 vlayout->setSpacing(0);
162 vlayout->setContentsMargins (0,0,0,0);
164 vlayout->addWidget(list_);
165 vlayout->addLayout( hlayout );
167 setLayout( vlayout );
170 LoggerWidget::~LoggerWidget()
187 list_->addItem(_text);
189 QListWidgetItem* item = list_->item( list_->count()-1 );
191 if ( allButton_->isChecked() )
192 item->setHidden(
false);
194 item->setHidden(
true);
198 item->setForeground( QBrush(QColor(Qt::darkGreen)) );
199 item->setBackground( QBrush(QColor(225,255,225), Qt::SolidPattern) );
201 if ( infoButton_->isChecked() )
202 item->setHidden(
false);
205 item->setForeground( QPalette{}.windowText() );
208 item->setForeground( QBrush(QColor(160,160,0)) );
209 item->setBackground( QBrush(QColor(255,240,200),Qt::SolidPattern) );
211 if ( warnButton_->isChecked() )
212 item->setHidden(
false);
215 item->setForeground( QBrush(QColor(Qt::red)) );
216 item->setBackground( QBrush(QColor(255,225,225),Qt::SolidPattern) );
218 if ( errorButton_->isChecked() )
219 item->setHidden(
false);
222 item->setForeground( QBrush(QColor(Qt::blue)) );
223 item->setBackground( QBrush(QColor(255,225,225),Qt::SolidPattern) );
225 if ( errorButton_->isChecked() )
226 item->setHidden(
false);
241 if ( ! loggerUpdateTimer_.isActive() ) {
243 list_->scrollToBottom();
250 loggerUpdateTimer_.start();
261 list_->scrollToBottom();
274 if ( infoButton_->isChecked() )
275 color = QColor(Qt::darkGreen);
276 else if ( warnButton_->isChecked() )
277 color = QColor(160,160,0);
278 else if ( errorButton_->isChecked() )
279 color = QColor(Qt::red);
281 color = QColor(Qt::black);
283 if (color == QColor(Qt::black)){
285 for (
int i=0; i < list_->count(); i++)
286 list_->item( i )->setHidden(
false);
290 for (
int i=0; i < list_->count(); i++)
291 if ( list_->item(i)->foreground().color() == color )
292 list_->item( i )->setHidden(
false);
294 list_->item( i )->setHidden(
true);
297 list_->scrollToBottom();
302 list_->scrollToBottom();
310 if ( (_event->modifiers() & Qt::ControlModifier ) && ( _event->key() == Qt::Key_C ) )
313 else if ( (_event->modifiers() & Qt::ControlModifier ) && ( _event->key() == Qt::Key_A ) )
325 QPoint p = list_->mapToGlobal( event->pos() );
327 context_->popup( p );
338 for (
int i=0; i < list_->selectedItems().count(); i++)
339 str += (list_->selectedItems()[i])->text() +
"\n";
341 QClipboard *clipboard = QApplication::clipboard();
343 clipboard->setText(str);
349 filterMenu_->popup( list_->mapToGlobal(filterButton_->pos()) );
Logtype
Log types for Message Window.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.