Changeset 960
- Timestamp:
- 10/31/08 10:31:07 (2 months ago)
- Location:
- mchelper/branches/v25
- Files:
-
- 2 modified
-
include/MainWindow.h (modified) (2 diffs)
-
src/MainWindow.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mchelper/branches/v25/include/MainWindow.h
r950 r960 77 77 About *about; 78 78 QListWidgetItem deviceListPlaceholder; 79 QTextCharFormat grayText, blackText; 79 80 bool no_ui; 80 81 bool hideOscMsgs; … … 87 88 bool winEvent( MSG* msg, long* result ); 88 89 #endif 90 void addMessage( QString time, QString msg, QString tofrom, QTextBlockFormat bkgnd ); 91 bool messagesEnabled( MsgType::Type type ); 89 92 90 93 private slots: -
mchelper/branches/v25/src/MainWindow.cpp
r950 r960 31 31 actionResetDevice->setEnabled(false); 32 32 actionSAMBA->setEnabled(false); 33 34 grayText.setForeground( Qt::gray ); 35 blackText.setForeground( Qt::black ); 33 36 34 37 // initializations … … 137 140 { 138 141 writeSettings( ); 142 qDebug( "closing" ); 139 143 qcloseevent->accept(); 144 qApp->quit(); // in case the inspector or anything else is still open 140 145 } 141 146 … … 348 353 void MainWindow::message(QStringList msgs, MsgType::Type type, QString from) 349 354 { 350 QStringList post; 355 if( !messagesEnabled( type ) ) 356 return; 351 357 QString currentTime = QTime::currentTime().toString(); 352 358 QTextBlockFormat format; 353 359 format.setBackground(msgColor(type)); 354 360 QString tofrom("from"); 355 if(type == MsgType::Command || type == MsgType::XMLMessage || type == MsgType::Response)356 {357 if( hideOscMsgs )358 return;359 }360 361 if(type == MsgType::Command) 361 362 tofrom = "to"; 362 363 364 outputConsole->setUpdatesEnabled(false); 365 QString tf = QString("%1 %2").arg(tofrom).arg(from); 363 366 foreach(QString msg, msgs) 364 post << QString("%1 %2 %3 %4").arg(currentTime).arg(msg).arg(tofrom).arg(from); 365 366 // because the format will be the same for all lines added via insertPlainText() 367 // we need to add a blank line to set our format, then insert the message 368 outputConsole->moveCursor(QTextCursor::End); 369 if(outputConsole->blockCount()) 370 outputConsole->insertPlainText("\n"); 371 outputConsole->textCursor().setBlockFormat(format); 372 outputConsole->insertPlainText(post.join("\n")); 373 outputConsole->ensureCursorVisible(); 367 addMessage( currentTime, msg, tf, format); 368 outputConsole->setUpdatesEnabled(true); 374 369 } 375 370 … … 383 378 else 384 379 { 380 if( !messagesEnabled( type ) ) 381 return; 385 382 QTextBlockFormat format; 386 383 format.setBackground(msgColor(type)); 387 384 QString tofrom = tr("from"); 388 if(type == MsgType::Command || type == MsgType::XMLMessage || type == MsgType::Response) 389 { 390 if( hideOscMsgs ) 391 return; 392 } 385 393 386 if(type == MsgType::Command) 394 387 tofrom = tr("to"); 395 388 396 msg.prepend(QTime::currentTime().toString() + " "); // todo - maybe make the time text gray 397 msg += QString(" %1 %2").arg(tofrom).arg(from); 398 outputConsole->appendPlainText(msg); // insert the message 399 outputConsole->moveCursor(QTextCursor::End); // move the cursor to the end 400 outputConsole->textCursor().setBlockFormat(format); // so that when we set the color, it colors the right block 401 outputConsole->ensureCursorVisible(); 402 } 389 outputConsole->setUpdatesEnabled(false); 390 addMessage( QTime::currentTime().toString(), msg, QString("%1 %2").arg(tofrom).arg(from), format); 391 outputConsole->setUpdatesEnabled(true); 392 } 393 } 394 395 void MainWindow::addMessage( QString time, QString msg, QString tofrom, QTextBlockFormat bkgnd ) 396 { 397 outputConsole->setCurrentCharFormat(grayText); 398 outputConsole->appendPlainText(time + " "); 399 outputConsole->setCurrentCharFormat(blackText); 400 outputConsole->insertPlainText(msg); 401 outputConsole->setCurrentCharFormat(grayText); 402 outputConsole->insertPlainText(" " + tofrom); 403 outputConsole->textCursor().setBlockFormat(bkgnd); 404 } 405 406 bool MainWindow::messagesEnabled( MsgType::Type type ) 407 { 408 bool retval = true; 409 if(type == MsgType::Command || type == MsgType::XMLMessage || type == MsgType::Response || type == MsgType::Warning) 410 { 411 if( hideOscMsgs ) 412 retval = false; 413 } 414 return retval; 403 415 } 404 416
