예제 #1
0
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 QDebugMessageClient::messageReceived(const QByteArray &data)
{
    QDataStream ds(data);
    QByteArray command;
    ds >> command;

    if (command == "MESSAGE") {
        int type;
        int line;
        QByteArray debugMessage;
        QByteArray file;
        QByteArray function;
        ds >> type >> debugMessage >> file >> line >> function;
        QDebugContextInfo info;
        info.line = line;
        info.file = QString::fromUtf8(file);
        info.function = QString::fromUtf8(function);
        emit message(QtMsgType(type), QString::fromUtf8(debugMessage), info);
    }
예제 #3
0
/**
 * Parse command line arguments
 *
 * @param argc Number of arguments in array argv
 * @param argv Arguments array
 *
 * @return true to continue with application launch; otherwise false
 */
bool parseArgs()
{
    QStringListIterator it(QCoreApplication::arguments());
    while (it.hasNext() == true)
    {
        QString arg(it.next());

        if ((arg == "-c" || arg == "--closebutton") && it.hasNext() == true)
        {
            QString str(it.next());
            QStringList parts = str.split(",");
            if (parts.size() == 4)
            {
                QRect rect(parts[0].toInt(), parts[1].toInt(),
                           parts[2].toInt(), parts[3].toInt());
                if (rect.isValid() == true)
                    QLCArgs::closeButtonRect = rect;
            }
        }
        else if (arg == "-d" || arg == "--debug")
        {
            if (it.hasNext() == true)
                QLCArgs::debugLevel = QtMsgType(it.peekNext().toInt());
            else
                QLCArgs::debugLevel = QtMsgType(0);
        }
        else if (arg == "-g" || arg == "--log")
        {
            QLCArgs::logToFile = true;
            QString logFilename = QDir::homePath() + QDir::separator() + "QLC+.log";
            QLCArgs::logFile.setFileName(logFilename);
            QLCArgs::logFile.open(QIODevice::Append);
        }
        else if (arg == "-f" || arg == "--fullscreen")
        {
            QLCArgs::fullScreen = true;
            if (it.hasNext() == true && it.peekNext() == "resize")
                QLCArgs::fullScreenResize = true;
        }
        else if (arg == "-h" || arg == "--help")
        {
            printUsage();
            return false;
        }
        else if (arg == "-k" || arg == "--kiosk")
        {
            QLCArgs::kioskMode = true;
        }
        else if (arg == "-l" || arg == "--locale")
        {
            if (it.hasNext() == true)
                QLCi18n::setDefaultLocale(it.next());
        }
        else if (arg == "-o" || arg == "--open")
        {
            if (it.hasNext() == true)
                QLCArgs::workspace = it.next();
        }
        else if (arg == "-p" || arg == "--operate")
        {
            QLCArgs::operate = true;
        }
        else if (arg == "-w" || arg == "--web")
        {
            QLCArgs::enableWebAccess = true;
        }
        else if (arg == "-v" || arg == "--version")
        {
            /* Don't print anything, since version is always
               printed before anything else. Just make the app
               exit by returning false. */
            return false;
        }
    }

    return true;
}