bool DecodeBitstreamCommand::execute( GitlCommandParameter& rcInputArg, GitlCommandParameter& rcOutputArg ) { ModelLocator* pModel = ModelLocator::getInstance(); /// *****STEP 0 : Request***** QVariant vValue; vValue = rcInputArg.getParameter("filename"); QString strFilename = vValue.toString(); vValue = rcInputArg.getParameter("version"); int iVersion = vValue.toInt(); vValue = rcInputArg.getParameter("skip_decode"); bool bSkipDecode = vValue.toBool(); QString strDecoderPath = "./decoders"; QString strDecoderOutputPath = pModel->getPreferences().getCacheFolder(); int iSequenceIndex = pModel->getSequenceManager().getAllSequences().size(); strDecoderOutputPath += QString("/%1").arg(iSequenceIndex); /// show busy dialog GitlUpdateUIEvt evt; evt.setParameter("busy_dialog_visible", true); evt.dispatch(); /// hide busy dialog when scope exit SCOPE_EXIT(GitlUpdateUIEvt evt; evt.setParameter("busy_dialog_visible", false); evt.dispatch(); );
static void xMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &strMsg) { QByteArray localMsg = strMsg.toLocal8Bit(); switch (type) { case QtDebugMsg: fprintf(stdout, "[Debug]: %s\n", localMsg.constData()); break; case QtWarningMsg: fprintf(stderr, "[Warn]: %s\n", localMsg.constData()); break; case QtCriticalMsg: fprintf(stderr, "[Crit]: %s\n", localMsg.constData()); break; case QtFatalMsg: fprintf(stderr, "[Fata]: %s\n", localMsg.constData()); } fflush(stdout); fflush(stderr); GitlUpdateUIEvt cEvt; cEvt.setParameter("msg_detail", strMsg); cEvt.setParameter("msg_level",(int)type); cEvt.dispatch(); if(type == QtFatalMsg) abort(); }
void BitstreamParser::displayDecoderOutput() { while( m_cDecoderProcess.canReadLine() ) { // write to file QString strLine = m_cDecoderProcess.readLine(); m_cStdOutputFile.write(strLine.toStdString().c_str()); // display progress text as event QRegExp cMatchTarget; cMatchTarget.setPattern("POC *(-?[0-9]+)"); if( cMatchTarget.indexIn(strLine) != -1 ) { GitlUpdateUIEvt evt; int iPoc = cMatchTarget.cap(1).toInt(); QString strText = QString("POC %1 Decoded").arg(iPoc); evt.setParameter("decoding_progress", strText); dispatchEvt(evt); } } }
void MainWindow::onPOCInfoChanged(GitlUpdateUIEvt& rcEvt) { static int iTotalFrameNum = -1; static int iCurrentFrameNum = -1; QVariant vValue; /// frame number if( rcEvt.hasParameter("total_frame_num") ) { vValue = rcEvt.getParameter("total_frame_num"); iTotalFrameNum = vValue.toInt(); ui->totalFrameNum->setText(QString("%1").arg(iTotalFrameNum)); } /// total frame number if( rcEvt.hasParameter("current_frame_poc") ) { vValue = rcEvt.getParameter("current_frame_poc"); iCurrentFrameNum = vValue.toInt() + 1; ui->currentFrameNum->setText(QString("%1").arg(iCurrentFrameNum)); } /// slide bar position int iMin = ui->progressBar->minimum(); int iMax = ui->progressBar->maximum(); int iPos = 0; if(iTotalFrameNum != 1) { iPos = (iCurrentFrameNum-1)*(iMax-iMin)/(iTotalFrameNum-1); } ui->progressBar->setValue(iPos); }
void PluginFilterList::onSequenceChanged(GitlUpdateUIEvt &rcEvt) { // rebuild the filter list int iVPos = verticalScrollBar()->value(); int iHPos = horizontalScrollBar()->value(); this->clear(); QStringList cFilterNames = rcEvt.getParameter("filter_names").toStringList(); QVector<bool> cFilterEnableStatus = rcEvt.getParameter("filter_status").value< QVector<bool> >(); for(int i = 0; i < cFilterNames.size(); i++) { QListWidgetItem* pcItem = new QListWidgetItem(); this->addItem(pcItem); PluginFilterItem *pItemWidget = new PluginFilterItem(cFilterNames[i], cFilterEnableStatus[i]); pcItem->setSizeHint(pItemWidget->sizeHint()); setItemWidget(pcItem, pItemWidget); } verticalScrollBar()->setValue(iVPos); horizontalScrollBar()->setValue(iHPos); }
void MainWindow::onStylesheetChanged(GitlUpdateUIEvt& rcEvt) { qApp->setStyleSheet(rcEvt.getParameter("theme_stylesheet").toString()); QString strThemeName = rcEvt.getParameter("theme_name").toString(); if(strThemeName == "default") ui->defaultThemeAction->setChecked(true); else if(strThemeName == "dark") ui->darkThemeAction->setChecked(true); }
void MessageViewer::onUIUpdate(GitlUpdateUIEvt &rcEvt) { /// <message level -- switch> table static MessageSwitchItem s_messageSwith[] = { {QtDebugMsg, ui->debugCheckBox }, {QtWarningMsg, ui->warningCheckBox }, {QtCriticalMsg, ui->critiCheckBox }, {QtFatalMsg, ui->fatalCheckBox }, {QtMsgType(-1), NULL} /// end mark }; if( rcEvt.hasParameter("msg_detail")) { QVariant vValue = rcEvt.getParameter("msg_detail"); QString strMsg = vValue.toString(); QtMsgType eMsgLevel = (QtMsgType)rcEvt.getParameter("msg_level").toInt(); /// different message, different color if(eMsgLevel != QtDebugMsg) ui->msgTextBrowser->setTextColor(QColor(Qt::red)); else ui->msgTextBrowser->setTextColor(m_cDefalutTextColor); /// check if the message type is allow MessageSwitchItem *pcItem = s_messageSwith; bool bIsAllowed = false; do { if(pcItem->eMsgType == eMsgLevel && pcItem->pcSwitch->isChecked()) { bIsAllowed = true; break; } pcItem++; }while(pcItem->pcSwitch != NULL); if(bIsAllowed) { /// display message ui->msgTextBrowser->append(strMsg); /// severe message should prompt dialog if( eMsgLevel >= QtCriticalMsg ) { m_cWarningBox.setText(strMsg); m_cWarningBox.show(); } } } }
void MainWindow::onSnapshot(GitlUpdateUIEvt& rcEvt) { /// TODO refactor QVariant vValue = rcEvt.getParameter("snapshot"); QPixmap* pcPixMap = (QPixmap*)(vValue.value<void *>()); xSaveSnapshot(pcPixMap); }
void GitlFrontController::onCommandRequestArrive(GitlIvkCmdEvt &rcEvt) { QMutexLocker cCmdExeMutexLocker(&m_cCmdExeMutex); GitlUpdateUIEvt cRefreshUIEvt; GitlCommandParameter& rcRequest = rcEvt.getParameters(); GitlCommandParameter& rcRespond = cRefreshUIEvt.getParameters(); // find command by name QString strCommandName = rcEvt.getCommandName(); rcRespond.setParameter("command_name", strCommandName); QHash<QString, QMetaObject*>::iterator i = m_cCommandTable.find(strCommandName); if( i != m_cCommandTable.end() ) { //command name matched //create command const QMetaObject* pMetaObj = i.value(); QObject* pObj = pMetaObj->newInstance(); //if fail to create command class if(pObj == NULL) { qCritical() << QString("Unable to create command class '%1'! Please ensure the constructor have Q_INVOKABLE macro.") .arg(pMetaObj->className()); return; } QSharedPointer<GitlAbstractCommand> pCmd(static_cast<GitlAbstractCommand *>(pObj)); //execute command if( pCmd->execute(rcRequest, rcRespond) == false ) { qDebug() << QString("%1 Execution Failed!").arg(pMetaObj->className()); } else { cRefreshUIEvt.dispatch(); qDebug() << QString("%1 Execution Success!").arg(pMetaObj->className()); } return; } qWarning() << QString("No matched command name found. %1").arg(strCommandName); return; }
void MainWindow::onFrameArrived(GitlUpdateUIEvt& rcEvt) { QVariant vValue = rcEvt.getParameter("picture"); QPixmap* pcPixMap = (QPixmap*)(vValue.value<void *>()); ui->imageView->setDisplayImage(pcPixMap); }
void multiParamListener(GitlUpdateUIEvt& rcEvt) { m_strMultiString = rcEvt.getParameter("fir_param").toString() + " " + rcEvt.getParameter("sec_param").toString(); }
void secParamListener(GitlUpdateUIEvt& rcEvt) { m_strSecString = rcEvt.getParameter("sec_param").toString(); }