当前位置: 首页>>代码示例>>C++>>正文


C++ qCritical函数代码示例

本文整理汇总了C++中qCritical函数的典型用法代码示例。如果您正苦于以下问题:C++ qCritical函数的具体用法?C++ qCritical怎么用?C++ qCritical使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了qCritical函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: qCritical

void StagingDirDiff::stagingTreeDiffException(GitException e)
{
    qCritical() << __func__ << ":" << __LINE__<< " " << e.what();
}
开发者ID:andy-campbell,项目名称:libAcGit,代码行数:4,代码来源:Stagingdirdiff.cpp

示例2: main

int main(int argc, char** argv)
{
  QApplication myApp(argc, argv);
  myApp.setOrganizationName("CommonTK");
  myApp.setApplicationName("CommandLineModuleExplorer");

  ctkCommandLineParser cmdLineParser;
  cmdLineParser.setArgumentPrefix("--", "-");
  cmdLineParser.setStrictModeEnabled(true);

  cmdLineParser.addArgument("module", "", QVariant::String, "Path to a CLI module (executable)");
  //cmdLineParser.addArgument("module-xml", "", QVariant::String, "Path to a CLI XML description.");

  cmdLineParser.addArgument("validate-module", "", QVariant::String, "Path to a CLI module");
  cmdLineParser.addArgument("validate-xml", "", QVariant::String, "Path to a CLI XML description.");
  cmdLineParser.addArgument("verbose", "v", QVariant::Bool, "Be verbose.");
  cmdLineParser.addArgument("help", "h", QVariant::Bool, "Print this help text.");

  bool parseOkay = false;
  QHash<QString, QVariant> args = cmdLineParser.parseArguments(argc, argv, &parseOkay);

  QTextStream out(stdout, QIODevice::WriteOnly);

  if(!parseOkay)
  {
    out << "Error parsing command line arguments: " << cmdLineParser.errorString() << '\n';
    return EXIT_FAILURE;
  }

  if (args.contains("help"))
  {
    out << "Usage:\n" << cmdLineParser.helpText();
    out.flush();
    return EXIT_SUCCESS;
  }

  if (args.contains("validate-module"))
  {
    if (args.contains("validate-xml"))
    {
      out << "Ignoring \"validate-xml\" option.\n\n";
    }

    QString input = args["validate-module"].toString();
    if (!QFile::exists(input))
    {
      qCritical() << "Module does not exist:" << input;
      return EXIT_FAILURE;
    }

    QProcess process;
    process.setReadChannel(QProcess::StandardOutput);
    process.start(input, QStringList("--xml"));

    if (!process.waitForFinished() || process.exitStatus() == QProcess::CrashExit ||
        process.error() != QProcess::UnknownError)
    {
      qWarning() << "The executable at" << input << "could not be started:" << process.errorString();
      return EXIT_FAILURE;
    }

    process.waitForReadyRead();
    QByteArray xml = process.readAllStandardOutput();

    if (args.contains("verbose"))
    {
      qDebug() << xml;
    }

    // validate the outputted xml description
    QBuffer xmlInput(&xml);
    xmlInput.open(QIODevice::ReadOnly);

    ctkCmdLineModuleXmlValidator validator(&xmlInput);
    if (!validator.validateInput())
    {
      qCritical() << validator.errorString();
      return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
  }
  else if (args.contains("validate-xml"))
  {
    QFile input(args["validate-xml"].toString());
    if (!input.exists())
    {
      qCritical() << "XML description does not exist:" << input.fileName();
      return EXIT_FAILURE;
    }
    input.open(QIODevice::ReadOnly);

    ctkCmdLineModuleXmlValidator validator(&input);
    if (!validator.validateInput())
    {
      qCritical() << validator.errorString();
      return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
//.........这里部分代码省略.........
开发者ID:Koki-Shimizu,项目名称:CTK,代码行数:101,代码来源:ctkCommandLineModuleExplorerMain.cpp

示例3: main

//----------------------------------------------------------------------------
int main(int argv, char** argc)
{
  QApplication app(argv, argc);

  qApp->setOrganizationName("CTK");
  qApp->setOrganizationDomain("commontk.org");
  qApp->setApplicationName("ctkExampleHostedApp");

  ctkCommandLineParser parser;
  parser.setArgumentPrefix("--", "-"); // Use Unix-style argument names

  // Add command line argument names
  parser.addArgument("hostURL", "", QVariant::String, "Hosting system URL");
  parser.addArgument("applicationURL", "", QVariant::String, "Hosted Application URL");
  parser.addArgument("help", "h", QVariant::Bool, "Show this help text");

  bool ok = false;
  QHash<QString, QVariant> parsedArgs = parser.parseArguments(QCoreApplication::arguments(), &ok);
  if (!ok)
    {
    QTextStream(stderr, QIODevice::WriteOnly) << "Error parsing arguments: "
                                              << parser.errorString() << "\n";
    return EXIT_FAILURE;
    }

  // Show a help message
   if (parsedArgs.contains("help"))
     {
     print_usage();
     QTextStream(stdout, QIODevice::WriteOnly) << parser.helpText();
     return EXIT_SUCCESS;
     }

  if(parsedArgs.count() != 2)
    {
    qCritical() << "Wrong number of command line arguments.";
    print_usage();
    QTextStream(stdout, QIODevice::WriteOnly) << parser.helpText();
    return EXIT_FAILURE;
    }

  QString hostURL = parsedArgs.value("hostURL").toString();
  QString appURL = parsedArgs.value("applicationURL").toString();
  qDebug() << "appURL is: " << appURL << " . Extracted port is: " << QUrl(appURL).port();

  // setup the plugin framework
  ctkProperties fwProps;
  fwProps.insert("dah.hostURL", hostURL);
  fwProps.insert("dah.appURL", appURL);
  ctkPluginFrameworkFactory fwFactory(fwProps);
  QSharedPointer<ctkPluginFramework> framework = fwFactory.getFramework();

  try
    {
    framework->init();
    }
  catch (const ctkPluginException& exc)
    {
    qCritical() << "Failed to initialize the plug-in framework:" << exc;
    return EXIT_FAILURE;
    }

#ifdef CMAKE_INTDIR
  QString pluginPath = CTK_PLUGIN_DIR CMAKE_INTDIR "/";
#else
  QString pluginPath = CTK_PLUGIN_DIR;
#endif

  qApp->addLibraryPath(pluginPath);

  // Construct the name of the plugin with the business logic
  // (thus the actual logic of the hosted app)
  QString pluginName("org_commontk_dah_exampleapp");
  if(parser.unparsedArguments().count() > 0)
    {
    pluginName = parser.unparsedArguments().at(0);
    }

  // try to find the plugin and install all plugins available in
  // pluginPath containing the string "org_commontk_dah" (but do not start them)
  QSharedPointer<ctkPlugin> appPlugin;
  QStringList libFilter;
  libFilter << "*.dll" << "*.so" << "*.dylib";
  QDirIterator dirIter(pluginPath, libFilter, QDir::Files);
  while(dirIter.hasNext())
    {
    try
      {
      QString fileLocation = dirIter.next();
      if (fileLocation.contains("org_commontk_dah"))
        {
        QSharedPointer<ctkPlugin> plugin = framework->getPluginContext()->installPlugin(QUrl::fromLocalFile(fileLocation));
        if (fileLocation.contains(pluginName))
          {
          appPlugin = plugin;
          }
        //plugin->start(ctkPlugin::START_TRANSIENT);
        }
      }
//.........这里部分代码省略.........
开发者ID:Koki-Shimizu,项目名称:CTK,代码行数:101,代码来源:ctkExampleHostedAppMain.cpp

示例4: setHasResults

void SiteResponseModel::run()
{
    m_okToContinue = true;
    setHasResults(false);

    // Check the input -- FIMXE add more thorough checks
    if (m_siteProfile->rowCount() < 2) {
        qCritical() << "Need at least one soil layer!";
        m_okToContinue = false;
    }

    if (!m_motionLibrary->rowCount()) {
        qCritical() << "Need at least one input motion!";
        m_okToContinue = false;
    }

    if (!m_okToContinue)
        return;

    m_outputCatalog->clear();
    m_outputCatalog->log()->append(tr("<b>Starting Strata Calculation</b>"));

    // Determine the number of sites to be used in the computation
    const int siteCount = m_siteProfile->isVaried() ? m_siteProfile->profileCount() : 1;

    // Initialize the random number generator
    m_randNumGen->init();

    // Initialize the output
    m_outputCatalog->initialize(siteCount, m_motionLibrary);

    // Setup the progress bar with the number of steps
    const int motionCount = m_motionLibrary->motionCount();
    const int totalCount = motionCount * siteCount;
    emit progressRangeChanged(0, totalCount);
    emit progressChanged(0);

    m_outputCatalog->log()->append(tr("%1 Trial(s) (%2 Site(s) and %3 Motion(s) )")
                                   .arg(totalCount)
                                   .arg(siteCount)
                                   .arg(motionCount));

    int count = 0;
    for (int i = 0; i < siteCount; ++i) {
        // Break if not okay to continue
        if ( !m_okToContinue )
            break;

        m_outputCatalog->log()->append((
                                           QString(tr("[%1 of %2] Generating site and soil properties")).arg(i+1).arg(siteCount)));

        // Create the sublayers -- this randomizes the properties
        m_siteProfile->createSubLayers(m_outputCatalog->log());

        // FIXME -- check the site profile to ensure that the waves can be
        // computed for the intial coniditions
        int motionCountOffset = 0;
        for (int j = 0; j < m_motionLibrary->rowCount(); ++j ) {
            if (!m_motionLibrary->motionAt(j)->enabled()) {
                // Skip the disabled motion
                ++motionCountOffset;
                continue;
            }

            if (!m_okToContinue)
                // Break if not okay to continue
                break;

            // Output status
            m_outputCatalog->log()->append(QString(tr("\t[%1 of %2] Computing site response for motion: %3"))
                                           .arg(j - motionCountOffset + 1)
                                           .arg(motionCount)
                                           .arg(m_motionLibrary->motionAt(j)->name()));

            // Compute the site response
            if (!m_calculator->run(m_motionLibrary->motionAt(j), m_siteProfile) && m_okToContinue) {
                m_outputCatalog->log()->append(tr("\tWave propagation error -- removing site."));
                // Error in the calculation -- need to remove the site
                m_outputCatalog->removeLastSite();
                // Reset site count
                --i;
                break;
            }

            if (!m_okToContinue)
                // Break if not okay to continue
                break;

            // Generate the output
            m_outputCatalog->saveResults(j - motionCountOffset, m_calculator);

            // Increment the progress bar
            ++count;
            emit progressChanged(count);

            // Reset the sublayers
            m_siteProfile->resetSubLayers();
        }
    }

//.........这里部分代码省略.........
开发者ID:arkottke,项目名称:strata,代码行数:101,代码来源:SiteResponseModel.cpp

示例5: QString

void StatusSubscribe::socketError(int errorNum, const QString &errorMsg)
{
    const QString errorString = QString("Error %1: ").arg(errorNum) + errorMsg;
    qCritical() << errorString;
}
开发者ID:ftkalcevic,项目名称:QtQuickVcp,代码行数:5,代码来源:statussubscribe.cpp

示例6: LoaderVTK

bool Loader::loadVTK()
{
    QString fn = m_fileName.path();

    LoaderVTK* lv = new LoaderVTK( fn );

    if ( !lv->load() )
    {
        qCritical() << "Couldn't load vtk file";
        QStringList status = lv->getStatus();
        for ( int i = 0; i < status.size(); ++i )
        {
            qCritical() << status[i];
        }
        return false;
    }

    if ( lv->getPrimitiveType() == 1 )
    {
        std::vector<float>* points = lv->getPoints();
        std::vector<int> triangles = lv->getPolys();

        if ( triangles[0] != 3 )
        {
            qCritical() << "*ERROR* " << fn << " can only load triangle polygon data";
            return false;
        }

        unsigned int numPoints = lv->getNumPoints();
        unsigned int numTriangles = lv->getNumPolys();

        TriangleMesh2* mesh = new TriangleMesh2( numPoints, numTriangles );

        for ( unsigned int i = 0; i < numPoints; ++i )
        {
            mesh->addVertex( points->at( i * 3 ), points->at( i * 3 + 1 ), points->at( i * 3 + 2 ) );
        }

        for ( unsigned int i = 0; i < numTriangles; ++i )
        {
            mesh->addTriangle( triangles[i * 4 + 1], triangles[i * 4 + 2], triangles[i * 4 + 3] );
        }

        std::vector<std::vector<float> > values = lv->getPointData();

        float min = std::numeric_limits<float>().max();
        float max = -std::numeric_limits<float>().max();

        if ( values.size() > 0 )
        {
            std::vector<float> data = values[0];
            if ( data.size() == numPoints )
            {
                for ( unsigned int i = 0; i < numPoints; ++i )
                {
                    min = qMin( min, data[i] );
                    max = qMax( max, data[i] );
                    mesh->setVertexData( i, data[i] );
                }
            }
        }

        std::vector<unsigned char> colors = lv->getPointColors();
        if ( colors.size() == points->size() )
        {
            for ( unsigned int i = 0; i < numPoints; ++i )
            {
                mesh->setVertexColor( i, ( (float)colors[i * 3] ) /255.,
                                         ( (float)colors[i * 3 + 1] ) /255.,
                                         ( (float)colors[i * 3 + 2] ) /255., 1.0 );
            }
        }

        mesh->finalize();
        DatasetMesh* dataset = new DatasetMesh( mesh, fn );
        if ( min != max )
        {
            dataset->properties().set( Fn::Property::D_MIN, min );
            dataset->properties().set( Fn::Property::D_MAX, max );
        }
        m_dataset.push_back( dataset );
        delete lv;
        return true;
    }

    if ( lv->getPrimitiveType() == 2 )
    {

        DatasetFibers* dataset = new DatasetFibers( fn, lv );
        m_dataset.push_back( dataset );

        delete lv;
        return true;
    }

    return false;
}
开发者ID:dmastrovito,项目名称:braingl,代码行数:97,代码来源:loader.cpp

示例7: glyphsetfile

bool Loader::loadGlyphset()
{
    QString glyphsetname = m_fileName.path();
    QFile glyphsetfile( glyphsetname );
    if ( !glyphsetfile.open( QIODevice::ReadOnly ) )
    {
        qCritical( "glyphset file unreadable" );
    }
    QTextStream gts( &glyphsetfile );
    //TODO: Will windows have a problem with this?
    QString trunk = QFileInfo( glyphsetname ).path();

    //glyphsetfile has three lines: 1: nifti (skip), 2: surfaceset(s), 3: connectivity matrix

    //1: TODO: skip nifti for now
    QString gnl = gts.readLine();
    qDebug() << "skipping: " << gnl;

    //2: load surfaceset
    gnl = gts.readLine();
    QStringList datasetNames = gnl.split( " " );
    bool two = ( datasetNames.length() > 1 );
    QString datasetName = datasetNames.at( 0 );

    gnl = gts.readLine();
    QStringList sl2 = gnl.split( " " );

    QString connectivityName;
    if ( sl2.at( 0 ).startsWith( "http" ) )
    {
        connectivityName = sl2.at( 0 );
    }
    else
    {
        connectivityName = trunk + QDir::separator() + sl2.at( 0 );
    }
    float mt = 0.8;
    if ( sl2.length() > 1 )
    {
        mt = sl2.at( 1 ).toFloat();
        qDebug() << "minimum threshold: " << mt;
    }
    else
    {
        qDebug() << "no minimum threshold in glyphset file, default of " << mt << " used.";
    }
    float maxt = 1.0;
    if ( sl2.length() > 2 )
    {
        maxt = sl2.at( 2 ).toFloat();
    }

    DatasetGlyphset* dataset = new DatasetGlyphset( glyphsetname, mt, maxt );

    qDebug() << "loading glyph set: " << datasetName;
    if ( two )
    {
        qDebug() << "...and loading glyph set: " << datasetNames.at( 1 );
        if ( datasetNames.length() > 2 )
        {
            qCritical() << "only two hemispheres supported";
        }
    }

    QFile setfile( trunk + QDir::separator() + datasetName );
    if ( !setfile.open( QIODevice::ReadOnly ) )
    {
        qCritical( "set file unreadable" );
    }
    QTextStream ts( &setfile );
    QString nl;

    QString onl;
    QTextStream* ots;
    std::vector<QString> others;
    if ( two )
    {
        QFile othersetfile( trunk + QDir::separator() + datasetNames.at( 1 ) );
        if ( !othersetfile.open( QIODevice::ReadOnly ) )
        {
            qCritical( "second set file unreadable" );
        }
        ots = new QTextStream( &othersetfile );
        qDebug() << "ots initialized";
        while ( !ots->atEnd() )
        {
            onl = ots->readLine();
            others.push_back( onl );
        }

    }

    int k = 0;
    while ( !ts.atEnd() )
    {
        nl = ts.readLine();
        qDebug() << "!" << nl;
        if ( two )
        {
            onl = others.at( k );
//.........这里部分代码省略.........
开发者ID:dmastrovito,项目名称:braingl,代码行数:101,代码来源:loader.cpp

示例8: switch


//.........这里部分代码省略.........
    case QPortSettings::BAUDR_200:
        baud = B200;
        break;
    case QPortSettings::BAUDR_300:
        baud = B300;
        break;
    case QPortSettings::BAUDR_600:
        baud = B600;
        break;
    case QPortSettings::BAUDR_1200:
        baud = B1200;
        break;
    case QPortSettings::BAUDR_1800:
        baud = B1800;
        break;
    case QPortSettings::BAUDR_2400:
        baud = B2400;
        break;
    case QPortSettings::BAUDR_4800:
        baud = B4800;
        break;
    case QPortSettings::BAUDR_9600:
        baud = B9600;
        break;
    case QPortSettings::BAUDR_19200:
        baud = B19200;
        break;
    case QPortSettings::BAUDR_38400:
        baud = B38400;
        break;
    case QPortSettings::BAUDR_57600:
        baud = B57600;
        break;
        //case QPortSettings::BAUDR_76800:
        //  baud = B76800;
        //  break;
    case QPortSettings::BAUDR_115200:
        baud = B115200;
        break;
    case QPortSettings::BAUDR_230400:
#ifdef B230400
        baud = B230400;
#else
        baud = (speed_t)230400;
#endif
        break;
    case QPortSettings::BAUDR_460800:
#ifdef B460800
        baud = B460800;
#else
        baud = (speed_t)460800;
#endif
        break;
    case QPortSettings::BAUDR_500000:
#ifdef B500000
        baud = B500000;
#else
        baud = (speed_t)500000;
#endif
        break;
    case QPortSettings::BAUDR_576000:
#ifdef B576000
        baud = B576000;
#else
        baud = (speed_t)576000;
#endif
        break;
    case QPortSettings::BAUDR_921600:
#ifdef B921600
        baud = B921600;
#else
        baud = (speed_t)921600;
#endif
        break;
    default:
        qWarning() << "TermiosHelper::setBaudRate(" << baudRate << "): " \
                      "Unsupported baud rate";
    }

    //#ifdef Q_OS_MAC
    //  if ( ioctl( fileDescriptor_, IOSSIOSPEED, &baud ) == -1 )
    //          {
    //      qCritical() <<  QString("TermiosHelper::setBaudRate(file: %1) failed: %2(%3)")
    //                   .arg(fileDescriptor_)
    //                   .arg(strerror(errno))
    //                   .arg(errno);
    //              return false;
    //          }
    //#else

    qCritical() << "Baud rate is now: " << baud;

    if ( cfsetspeed(currentAttrs_, baud) == -1 ) {
        qCritical() <<  QString("TermiosHelper::setBaudRate(file: %1) failed: %2(%3)")
                        .arg(fileDescriptor_)
                        .arg(strerror(errno))
                        .arg(errno);
    }
    //#endif
}
开发者ID:Dormanfcbm,项目名称:batchelor-thesis,代码行数:101,代码来源:termioshelper.cpp

示例9: brush

void Plot2DHistogram::drawColumn (QPainter * painter, const QwtColumnRect & rect,
        const QwtIntervalSample & sample) const{
    QBrush brush( m_defaultColor );
    if ( !m_colored ){
        painter->setPen( m_defaultColor);
    }
    else {
        QColor sampleColor(m_defaultColor);
        if ( m_pipeline ){
            QwtInterval xRange = sample.interval;
            double midPt = (xRange.minValue() + xRange.maxValue()) / 2;
            std::array<double,3> normRGB;
            m_pipeline->convert( midPt, normRGB );
            if ( normRGB[0] >= 0 && normRGB[1] >= 0 && normRGB[2] >= 0 ){
                sampleColor.setRgbF(normRGB[0], normRGB[1], normRGB[2]);
            }
        }
        painter->setPen( sampleColor );
        brush.setColor( sampleColor );
    }
    painter->setBrush( brush );
    QRectF r = rect.toRect();
    if ( QwtPainter::roundingAlignment( painter ) ){
        r.setLeft( qRound( r.left() ) );
        r.setRight( qRound( r.right() ) );
        r.setTop( qRound( r.top() ) );
        r.setBottom( qRound( r.bottom() ) );
    }
    if ( m_drawStyle == Carta::Data::PlotStyles::PLOT_STYLE_FILL ){
        QwtPainter::fillRect( painter, r, brush );
    }
    else if ( m_drawStyle == Carta::Data::PlotStyles::PLOT_STYLE_LINE ){
        double middle = ( r.left() + r.right() ) / 2;
        QwtPainter::drawLine( painter, middle, r.bottom(), middle, r.top() );
    }
    else if ( m_drawStyle != Carta::Data::PlotStyles::PLOT_STYLE_OUTLINE ){
            qCritical() << "Unrecognized draw style="<< m_drawStyle;
    }


    if ( m_drawStyle == Carta::Data::PlotStyles::PLOT_STYLE_OUTLINE ||
            ( m_drawStyle == Carta::Data::PlotStyles::PLOT_STYLE_FILL && m_colored ) ){
        //Draw a black outline for colored fill style
        if ( m_drawStyle == Carta::Data::PlotStyles::PLOT_STYLE_FILL && m_colored ){
            QColor outlineC( "black" );
            painter->setPen( outlineC );
        }

        //Draw the top
        double top = r.top();
        double right = r.right();
        QwtPainter::drawLine( painter, r.left(), top, r.right(), top );
        //Draw the left vertical line
        QwtPainter::drawLine( painter, r.left(), m_lastY, r.left(), top );
        //Store the top for the next call.
        if ( top > 0 ){
            m_lastY = top;
        }
        if ( right > 0 ){
            m_lastX = right;
        }
    }
}
开发者ID:slovelan,项目名称:NRAODev,代码行数:63,代码来源:Plot2DHistogram.cpp

示例10: main


//.........这里部分代码省略.........
            {
                argsconc += QString("\"%1\" ").arg(allappargs.at(i));
                argsconcSingleQuote += QString("'%1' ").arg(allappargs.at(i));
            }
            argsconc += "\"rootcheck=no\"";
            argsconcSingleQuote += "'rootcheck=no'";
#ifdef Q_OS_LINUX
            QString gksulocation = checkforgraphicalsu("gksu");
            if (gksulocation != "REQCNOTFOUND")
            {
                QProcess::startDetached(QString("%1 %2 %3").arg(gksulocation).arg(app.applicationFilePath()).arg(argsconc));
                return 0;
            }
            QString kdesulocation = checkforgraphicalsu("kdesu");
            if (kdesulocation != "REQCNOTFOUND")
            {
                QProcess::startDetached(QString("%1 %2 %3").arg(kdesulocation).arg(app.applicationFilePath()).arg(argsconc));
                return 0;
            }
            QString gnomesulocation = checkforgraphicalsu("gnomesu");
            if (gnomesulocation != "REQCNOTFOUND")
            {
                QProcess::startDetached(QString("%1 %2 %3").arg(gnomesulocation).arg(app.applicationFilePath()).arg(argsconc));
                return 0;
            }
            QString kdesudolocation = checkforgraphicalsu("kdesudo");
            if (kdesudolocation != "REQCNOTFOUND")
            {
                QProcess::startDetached(QString("%1 %2 %3").arg(kdesudolocation).arg(app.applicationFilePath()).arg(argsconc));
                return 0;
            }
            QMessageBox rootmsgb;
            rootmsgb.setIcon(QMessageBox::Warning);
            rootmsgb.setWindowTitle(uninstaller::tr("Must run as root"));
            rootmsgb.setTextFormat(Qt::RichText);
            rootmsgb.setText(uninstaller::tr("%2 must be run as root. Close it, and re-run using either:<br/><b>sudo %1</b><br/>or:<br/><b>su - -c '%1'</b>").arg(app.applicationFilePath()).arg(UNETBOOTINB));
            rootmsgb.setStandardButtons(QMessageBox::Ok);
            switch (rootmsgb.exec())
            {
                case QMessageBox::Ok:
                    break;
                default:
                    break;
            }
#endif
#ifdef Q_OS_MAC
            /*
            QProcess osascriptProc;
            osascriptProc.start("osascript");
            osascriptProc.write(QString("do shell script \""+app.applicationFilePath()+"\" with administrator privileges\n").toAscii().data());
            osascriptProc.closeWriteChannel();
            osascriptProc.waitForFinished(-1);
            */
            //qDebug() << QString("osascript -e 'do shell script \"%1 %2\" with administrator privileges'").arg(app.applicationFilePath()).arg(argsconc);
            //QProcess::startDetached(QString("osascript -e 'do shell script \"%1 %2\" with administrator privileges'").arg(app.applicationFilePath()).arg(argsconc));
            QProcess::startDetached("osascript", QStringList() << "-e" << QString("do shell script \"'%1' %2\" with administrator privileges").arg(app.applicationFilePath()).arg(argsconcSingleQuote));
            return 0;
#endif
        }
    }
    #endif
    qmlRegisterType<BootMaker>("com.deepin.bootmaker", 1, 0, "BootMaker");
    qmlRegisterType<DOverrideWindow>("com.deepin.usbcreator", 1, 0, "DOverrideWindow");
    qmlRegisterType<DWindow>("com.deepin.usbcreator", 1, 0, "DWindow");
    qmlRegisterType<DIcon>("com.deepin.usbcreator", 1, 0, "DIcon");
    qmlRegisterType<DDropArea>("com.deepin.usbcreator", 1, 0, "DDropArea");

    QQmlApplicationEngine engine;
    engine.addImportPath("qrc:/qml/");


#ifdef Q_OS_WIN32
    if (CheckIsXP()){
        app.setFont(QFont("SimHei", 12));
        engine.load(QUrl("qrc:/qml/xp-fix-mainui.qml"));
    }
    else{
        engine.load(QUrl("qrc:/qml/mainui.qml"));
    }
#else
   engine.load(QUrl("qrc:/qml/mainui.qml"));
#endif

   app.setOverrideCursor( QCursor( Qt::ArrowCursor ) );

    QList<QObject *> roots = engine.rootObjects();
    QObject *topLevel = roots.value(0);
    QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);

    if (!window) {
        qCritical("load qrc:/qml/mainui.qml error!!");
    }

    QIcon icon;
    icon.addFile(":/image/deepin-boot-maker.png");
    window->setIcon(icon);
    window->show();
    window->setTitle(QApplication::tr("Deepin Boot Maker"));
    return app.exec();
}
开发者ID:electricface,项目名称:deepin-boot-maker,代码行数:101,代码来源:main.cpp

示例11: QMainWindow

Pony::Pony(const QString path, ConfigWindow *config, QWidget *parent) :
    QMainWindow(parent), sleeping(false), in_interaction(false), current_interaction_delay(0), gen(QDateTime::currentMSecsSinceEpoch()), label(this), config(config), dragging(false), mouseover(false)
{
    setAttribute(Qt::WA_TranslucentBackground, true);
    setAttribute(Qt::WA_ShowWithoutActivating);

#if defined QT_MAC_USE_COCOA && QT_VERSION >= 0x040800
    // Removes shadows that lag behind animation on OS X. QT 4.8+ needed.
    setAttribute(Qt::WA_MacNoShadow, true);
#endif

#ifdef QT_MAC_USE_COCOA
    // On OS X, tool windows are hidden when another program gains focus.
    Qt::WindowFlags windowflags = Qt::FramelessWindowHint;
#else
    Qt::WindowFlags windowflags = Qt::FramelessWindowHint | Qt::Tool;
#endif

    always_on_top = config->getSetting<bool>("general/always-on-top");
    if(always_on_top) {
        windowflags |= Qt::WindowStaysOnTopHint;
    }

#ifdef Q_WS_X11
    if(config->getSetting<bool>("general/bypass-wm")) {
        // Bypass the window manager
        windowflags |= Qt::X11BypassWindowManagerHint;
    }
#endif

    setWindowFlags( windowflags );

    // TODO: always on top toggle, we have to preserve the skip taskbar/pager flags, so we have to do
    //       it by using Xlib
#ifdef Q_WS_X11
    // Qt on X11 does not support the skip taskbar/pager window flags, we have to set them ourselves
    // We let Qt initialize the other window properties, which aren't deleted when we replace them with ours
    // (they probably are appended on show())
    Atom window_state = XInternAtom( QX11Info::display(), "_NET_WM_STATE", False );
    Atom window_props[] = {
        XInternAtom( QX11Info::display(), "_NET_WM_STATE_SKIP_TASKBAR", False ),
        XInternAtom( QX11Info::display(), "_NET_WM_STATE_SKIP_PAGER"  , False )
    };

    XChangeProperty( QX11Info::display(), window()->winId(), window_state, XA_ATOM, 32, PropModeReplace, (unsigned char*)&window_props, 2 );
#endif

    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(display_menu(const QPoint &)));

    // Setup speech label
    text_label.hide();
    text_label.setAttribute(Qt::WA_ShowWithoutActivating);
    text_label.setWindowFlags(windowflags);
    text_label.setAlignment(Qt::AlignHCenter);
    text_label.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
#ifdef Q_WS_X11
    // Same as above
    XChangeProperty( QX11Info::display(), text_label.window()->winId(), window_state, XA_ATOM, 32, PropModeReplace, (unsigned char*)&window_props, 2 );
#endif

    // Initially place the pony randomly on the screen, keeping a 50 pixel border
    x_pos = 50 + gen()%(QApplication::desktop()->availableGeometry(this).width()-100);
    y_pos = 50 + gen()%(QApplication::desktop()->availableGeometry(this).height()-100);

    move(x_pos, y_pos);

    directory = path;

    QFile ifile(QString("%1/%2/pony.ini").arg(ConfigWindow::getSetting<QString>("general/pony-directory"), path));
    if(!ifile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        qCritical() << "Cannot open pony.ini for pony:"<< path;
        qCritical() << ifile.errorString();
        throw std::exception();
    }

    name = path;

    if( ifile.isOpen() ) {
        QString line;
        QTextStream istr(&ifile);

        while (!istr.atEnd() ) {
            line = istr.readLine();

            if(line[0] != '\'' && !line.isEmpty()) {
                std::vector<QVariant> csv_data;
                CSVParser::ParseLine(csv_data, line, ',');

                if(csv_data[0] == "Name") {
                    name = csv_data[1].toString(); //Name,"name"
                }
                else if(csv_data[0] == "Behavior") {
                    Behavior b(this, path, csv_data);
                    behaviors.insert({b.name, std::move(b)});
                }
                else if(csv_data[0] == "Speak") {
                    std::shared_ptr<Speak> s = std::make_shared<Speak>(this, path, csv_data);
                    speak_lines.insert({s->name, std::move(s)});
                }
//.........这里部分代码省略.........
开发者ID:Schiwi,项目名称:qt-ponies,代码行数:101,代码来源:pony.cpp

示例12: QGuiApplication

    GreeterApp::GreeterApp(int &argc, char **argv) : QGuiApplication(argc, argv) {
        // point instance to this
        self = this;

        // Parse arguments
        bool testing = false;

        if (arguments().contains("--test-mode"))
            testing = true;

        // get socket name
        QString socket = parameter(arguments(), "--socket", "");

        // get theme path
        QString themePath = parameter(arguments(), "--theme", "");

        // create view
        m_view = new QQuickView();
        m_view->setResizeMode(QQuickView::SizeRootObjectToView);

        m_view->engine()->addImportPath(IMPORTS_INSTALL_DIR);

        // read theme metadata
        m_metadata = new ThemeMetadata(QString("%1/metadata.desktop").arg(themePath));

        // Translations
        // Components translation
        m_components_tranlator = new QTranslator();
        if (m_components_tranlator->load(QLocale::system(), "", "", COMPONENTS_TRANSLATION_DIR))
            installTranslator(m_components_tranlator);

        // Theme specific translation
        m_theme_translator = new QTranslator();
        if (m_theme_translator->load(QLocale::system(), "", "",
                           QString("%1/%2/").arg(themePath, m_metadata->translationsDirectory())))
            installTranslator(m_theme_translator);

        // get theme config file
        QString configFile = QString("%1/%2").arg(themePath).arg(m_metadata->configFile());

        // read theme config
        m_themeConfig = new ThemeConfig(configFile);

        // create models

        m_sessionModel = new SessionModel();
        m_screenModel = new ScreenModel();
        m_userModel = new UserModel();
        m_proxy = new GreeterProxy(socket);
        m_keyboard = new KeyboardModel();

        if(!testing && !m_proxy->isConnected()) {
            qCritical() << "Cannot connect to the daemon - is it running?";
            exit(EXIT_FAILURE);
        }

        // Set numlock upon start
        if (m_keyboard->enabled()) {
            if (mainConfig.Numlock.get() == MainConfig::NUM_SET_ON)
                m_keyboard->setNumLockState(true);
            else if (mainConfig.Numlock.get() == MainConfig::NUM_SET_OFF)
                m_keyboard->setNumLockState(false);
        }

        m_proxy->setSessionModel(m_sessionModel);

        // connect proxy signals
        QObject::connect(m_proxy, SIGNAL(loginSucceeded()), m_view, SLOT(close()));

        // set context properties
        m_view->rootContext()->setContextProperty("sessionModel", m_sessionModel);
        m_view->rootContext()->setContextProperty("screenModel", m_screenModel);
        m_view->rootContext()->setContextProperty("userModel", m_userModel);
        m_view->rootContext()->setContextProperty("config", *m_themeConfig);
        m_view->rootContext()->setContextProperty("sddm", m_proxy);
        m_view->rootContext()->setContextProperty("keyboard", m_keyboard);

        // get theme main script
        QString mainScript = QString("%1/%2").arg(themePath).arg(m_metadata->mainScript());

        // set main script as source
        m_view->setSource(QUrl::fromLocalFile(mainScript));

        // connect screen update signals
        connect(m_screenModel, SIGNAL(primaryChanged()), this, SLOT(show()));

        show();
    }
开发者ID:alien999999999,项目名称:sddm,代码行数:88,代码来源:GreeterApp.cpp

示例13: QLibrary

bool ADSI::loadLibrary(const QString &fileName)
{

    if(!adsiLibrary) {
        adsiLibrary = new QLibrary(this);
    }
    if(adsiLibrary->isLoaded()) {
        m_lastErrorString = "Library '" + fileName + "'already loaded!";
        qCritical() << m_lastErrorString;
        return false;
    }

//    adsiLibrary->unload();
    adsiLibrary->setFileName(fileName);
    adsiLibrary->load();
    if(!adsiLibrary->isLoaded()) {
        m_lastErrorString = "Failed to load library '" + fileName + "'!" + adsiLibrary->errorString();
        qCritical() << m_lastErrorString;
        return false;
    }

    m_AD_Open = (AD_OpenFunction) adsiLibrary->resolve("AD_Open");
    if(!m_AD_Open) {
        unloadLibrary();
        m_lastErrorString = "Failed to resolve function  'AD_Open' !" ;
        qCritical() << m_lastErrorString;
        return false;
    }

    m_AD_Close = (AD_CloseFunction) adsiLibrary->resolve("AD_Close");
    if(!m_AD_Close) {
        unloadLibrary();
        m_lastErrorString = "Failed to resolve function  'AD_Close' !" ;
        qCritical() << m_lastErrorString;
        return false;
    }

    m_AD_GetLastErrorCode = (AD_GetLastErrorCodeFunction) adsiLibrary->resolve("AD_GetLastErrorCode");
    if(!m_AD_GetLastErrorCode) {
        unloadLibrary();
        m_lastErrorString = "Failed to resolve function  'AD_GetLastErrorCode' !" ;
        qCritical() << m_lastErrorString;
        return false;
    }

    m_AD_GetLastErrorString = (AD_GetLastErrorStringFunction) adsiLibrary->resolve("AD_GetLastErrorString");
    if(!m_AD_GetLastErrorString) {
        unloadLibrary();
        m_lastErrorString = "Failed to resolve function  'AD_GetLastErrorString' !" ;
        qCritical() << m_lastErrorString;
        return false;
    }

    m_AD_DefaultNamingContext = (AD_DefaultNamingContextFunction) adsiLibrary->resolve("AD_DefaultNamingContext");
    if(!m_AD_DefaultNamingContext) {
        unloadLibrary();
        m_lastErrorString = "Failed to resolve function  'AD_DefaultNamingContext' !" ;
        qCritical() << m_lastErrorString;
        return false;
    }

    m_AD_ObjectExists = (AD_ObjectExistsFunction) adsiLibrary->resolve("AD_ObjectExists");
    if(!m_AD_ObjectExists) {
        unloadLibrary();
        m_lastErrorString = "Failed to resolve function  'AD_ObjectExists' !" ;
        qCritical() << m_lastErrorString;
        return false;
    }

    m_AD_RenameObject = (AD_RenameObjectFunction) adsiLibrary->resolve("AD_RenameObject");
    if(!m_AD_RenameObject) {
        unloadLibrary();
        m_lastErrorString = "Failed to resolve function  'AD_RenameObject' !" ;
        qCritical() << m_lastErrorString;
        return false;
    }

    m_AD_MoveObject = (AD_MoveObjectFunction) adsiLibrary->resolve("AD_MoveObject");
    if(!m_AD_MoveObject) {
        unloadLibrary();
        m_lastErrorString = "Failed to resolve function  'AD_MoveObject' !" ;
        qCritical() << m_lastErrorString;
        return false;
    }

    m_AD_DeleteObject = (AD_DeleteObjectFunction) adsiLibrary->resolve("AD_DeleteObject");
    if(!m_AD_DeleteObject) {
        unloadLibrary();
        m_lastErrorString = "Failed to resolve function  'AD_DeleteObject' !" ;
        qCritical() << m_lastErrorString;
        return false;
    }

    m_AD_UnlockObject = (AD_UnlockObjectFunction) adsiLibrary->resolve("AD_UnlockObject");
    if(!m_AD_UnlockObject) {
        unloadLibrary();
        m_lastErrorString = "Failed to resolve function  'AD_UnlockObject' !" ;
        qCritical() << m_lastErrorString;
        return false;
    }
//.........这里部分代码省略.........
开发者ID:ihehui,项目名称:HHSharedLibs,代码行数:101,代码来源:adsi.cpp

示例14: QObject


//.........这里部分代码省略.........
            break;

        case SymbolPinNames:
            mName = tr("Symbol Pin Names");
            mColor = QColor(64, 64, 64, 255);
            mColorHighlighted = Qt::gray;
            mIsVisible = true;
            break;

        case ComponentNames:
            mName = tr("Component Names");
            mColor = QColor(32, 32, 32, 255);
            mColorHighlighted = Qt::darkGray;
            mIsVisible = true;
            break;

        case ComponentValues:
            mName = tr("Component Values");
            mColor = QColor(80, 80, 80, 255);
            mColorHighlighted = Qt::gray;
            mIsVisible = true;
            break;

        case NetLabels:
            mName = tr("Net Labels");
            mColor = Qt::darkGreen;
            mColorHighlighted = Qt::green;
            mIsVisible = true;
            break;

        case Nets:
            mName = tr("Nets");
            mColor = Qt::darkGreen;
            mColorHighlighted = Qt::green;
            mIsVisible = true;
            break;

        case Busses:
            mName = tr("Busses");
            mColor = Qt::darkBlue;
            mColorHighlighted = Qt::blue;
            mIsVisible = true;
            break;

#ifdef QT_DEBUG
        case DEBUG_GraphicsItemsBoundingRect:
            mName = tr("DEBUG_GraphicsItemsBoundingRect");
            mColor = Qt::darkRed;
            mColorHighlighted = Qt::red;
            mIsVisible = false;
            break;

        case DEBUG_GraphicsItemsTextsBoundingRect:
            mName = tr("DEBUG_GraphicsItemsTextsBoundingRect");
            mColor = Qt::darkRed;
            mColorHighlighted = Qt::red;
            mIsVisible = false;
            break;

        case DEBUG_SymbolPinNetSignalNames:
            mName = tr("DEBUG_SymbolPinNetSignalNames");
            mColor = Qt::darkRed;
            mColorHighlighted = Qt::red;
            mIsVisible = false;
            break;

        case DEBUG_NetLinesNetSignalNames:
            mName = tr("DEBUG_NetLinesNetSignalNames");
            mColor = Qt::darkRed;
            mColorHighlighted = Qt::red;
            mIsVisible = false;
            break;

        case DEBUG_InvisibleNetPoints:
            mName = tr("DEBUG_InvisibleNetPoints");
            mColor = Qt::darkRed;
            mColorHighlighted = Qt::red;
            mIsVisible = false;
            break;

        case DEBUG_ComponentSymbolsCount:
            mName = tr("DEBUG_ComponentSymbolsCount");
            mColor = Qt::darkRed;
            mColorHighlighted = Qt::red;
            mIsVisible = false;
            break;
#endif

        default:
            if (mId >= UserDefinedBaseId)
            {
                // TODO: this is a user-defined layer...
            }
            else
            {
                qCritical() << "invalid schematic layer id:" << mId;
            }
            break;
    }
}
开发者ID:0xB767B,项目名称:LibrePCB,代码行数:101,代码来源:schematiclayer.cpp

示例15: qCritical

Profile* Profile::loadProfile(QString name, QString password)
{
    if (ProfileLocker::hasLock())
    {
        qCritical() << "Tried to load profile "<<name<<", but another profile is already locked!";
        return nullptr;
    }

    if (!ProfileLocker::lock(name))
    {
        qWarning() << "Failed to lock profile "<<name;
        return nullptr;
    }

    // Check password
    {
        QString path = Settings::getInstance().getSettingsDirPath() + name + ".tox";
        QFile saveFile(path);
        qDebug() << "Loading tox save "<<path;

        if (!saveFile.exists())
        {
            qWarning() << "The tox save file "<<path<<" was not found";
            ProfileLocker::unlock();
            return nullptr;
        }

        if (!saveFile.open(QIODevice::ReadOnly))
        {
            qCritical() << "The tox save file " << path << " couldn't' be opened";
            ProfileLocker::unlock();
            return nullptr;
        }

        qint64 fileSize = saveFile.size();
        if (fileSize <= 0)
        {
            qWarning() << "The tox save file"<<path<<" is empty!";
            ProfileLocker::unlock();
            return nullptr;
        }

        QByteArray data = saveFile.readAll();
        if (tox_is_data_encrypted((uint8_t*)data.data()))
        {
            if (password.isEmpty())
            {
                qCritical() << "The tox save file is encrypted, but we don't have a password!";
                ProfileLocker::unlock();
                return nullptr;
            }

            uint8_t salt[TOX_PASS_SALT_LENGTH];
            tox_get_salt(reinterpret_cast<uint8_t *>(data.data()), salt);
            auto tmpkey = *Core::createPasskey(password, salt);

            data = Core::decryptData(data, tmpkey);
            if (data.isEmpty())
            {
                qCritical() << "Failed to decrypt the tox save file";
                ProfileLocker::unlock();
                return nullptr;
            }
        }
        else
        {
            if (!password.isEmpty())
                qWarning() << "We have a password, but the tox save file is not encrypted";
        }
    }

    return new Profile(name, password, false);
}
开发者ID:kingctan,项目名称:qTox,代码行数:73,代码来源:profile.cpp


注:本文中的qCritical函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。