SelectProfileWidget::SelectProfileWidget(IRoster *ARoster, IGateways *AGateways, IOptionsManager *AOptionsManager, const IGateServiceDescriptor &ADescriptor, QWidget *AParent) : QWidget(AParent)
{
	ui.setupUi(this);

	FVisible = true;
	FAutoSelect = true;
	FRoster = ARoster;
	FGateways = AGateways;
	FOptionsManager = AOptionsManager;
	FDescriptor = ADescriptor;

	ui.wdtProfiles->setLayout(new QVBoxLayout);
	ui.wdtProfiles->layout()->setMargin(0);

	connect(FRoster->instance(),SIGNAL(opened()),SLOT(onRosterOpened()));
	connect(FRoster->instance(),SIGNAL(closed()),SLOT(onRosterClosed()));

	connect(FGateways->instance(),SIGNAL(loginReceived(const QString &, const QString &)),
		SLOT(onServiceLoginReceived(const QString &, const QString &)));
	connect(FGateways->instance(),SIGNAL(errorReceived(const QString &, const QString &)),
		SLOT(onGatewayErrorReceived(const QString &, const QString &)));
	connect(FGateways->instance(),SIGNAL(streamServicesChanged(const Jid &)),
		SLOT(onStreamServicesChanged(const Jid &)));
	connect(FGateways->instance(),SIGNAL(serviceEnableChanged(const Jid &, const Jid &, bool)),
		SLOT(onServiceEnableChanged(const Jid &, const Jid &, bool)));
	connect(FGateways->instance(),SIGNAL(servicePresenceChanged(const Jid &, const Jid &, const IPresenceItem &)),
		SLOT(onServicePresenceChanged(const Jid &, const Jid &, const IPresenceItem &)));

	updateProfiles();
}
Exemplo n.º 2
0
void OptionsDetailed::init()
{
    updateProfiles();

    cFormat->setCurrentIndex( 0 );
    formatChanged( cFormat->currentText() );
}
void SelectProfileWidget::setAutoSelectProfile(bool AAuto)
{
	if (FAutoSelect != AAuto)
	{
		FAutoSelect = AAuto;
		updateProfiles();
	}
}
Exemplo n.º 4
0
AddAction::AddAction(QWidget *parent, const char *name, const Mode &mode): AddActionBase(parent, name), theMode(mode)
{
	connect(this, SIGNAL( selected(const QString &) ), SLOT( updateForPageChange() ));
	connect(this, SIGNAL( selected(const QString &) ), SLOT( slotCorrectPage() ));
	curPage = 0;
	updateProfiles();
	updateButtons();
	updateObjects();
	updateProfileFunctions();
}
Exemplo n.º 5
0
void OptionsSimple::profileRemove()
{
    const QString profileName = cProfile->currentText();

    const int ret = KMessageBox::questionYesNo( this, i18n("Do you really want to remove the profile: %1").arg(profileName), i18n("Remove profile?") );
    if( ret == KMessageBox::Yes )
    {
        QDomDocument list("soundkonverter_profilelist");

        QFile listFile( KStandardDirs::locateLocal("data","soundkonverter/profiles.xml") );
        if( listFile.open( QIODevice::ReadOnly ) )
        {
            if( list.setContent( &listFile ) )
            {
                QDomElement root = list.documentElement();
                if( root.nodeName() == "soundkonverter" && root.attribute("type") == "profilelist" )
                {
                    QDomElement profileElement;
                    QDomNodeList conversionOptionsElements = root.elementsByTagName("conversionOptions");
                    for( int i=0; i<conversionOptionsElements.count(); i++ )
                    {
                        if( conversionOptionsElements.at(i).toElement().attribute("profileName") == profileName )
                        {
                            delete config->data.profiles[profileName];
                            config->data.profiles.remove(profileName);
                            root.removeChild(conversionOptionsElements.at(i));
                            break;
                        }
                    }
                }
            }
            listFile.close();
        }

        if( listFile.open( QIODevice::WriteOnly ) )
        {
            updateProfiles();
            emit customProfilesEdited();

            QTextStream stream(&listFile);
            stream << list.toString();
            listFile.close();
        }
    }
}
Exemplo n.º 6
0
void MyoDevice::runDeviceLoop()
{
    WearableDevice::setDeviceStatus(deviceStatus::RUNNING);

    GestureFilter gestureFilter(state, 0, mainGui);
    posePipeline.registerFilter(&gestureFilter);
    posePipeline.registerFilter(WearableDevice::sharedData);

    AveragingFilter averagingFilter(5);
    MyoTranslationFilter translationFilter(state);
    orientationPipeline.registerFilter(&averagingFilter);
    orientationPipeline.registerFilter(&translationFilter);
    orientationPipeline.registerFilter(WearableDevice::sharedData);

    mainGui->connectSignallerToProfileWidgets(&profileSignaller);
	
    AveragingFilter rssiAveragingFilter(5);
    rssiPipeline.registerFilter(&rssiAveragingFilter);
    rssiPipeline.registerFilter(WearableDevice::sharedData);

    connectPipeline.registerFilter(WearableDevice::sharedData);

    std::chrono::milliseconds rssi_start =
        std::chrono::duration_cast<std::chrono::milliseconds>(
            std::chrono::steady_clock::now().time_since_epoch()); /* Used to control when to request rssi */
    std::chrono::milliseconds rssi_finish;

    try
    {
        Hub hub(appIdentifier);
        hub.setLockingPolicy(hub.lockingPolicyNone);
        Myo* myo = hub.waitForMyo(myoFindTimeout);

        if (!myo)
        {
            std::cout << "Could not find a Myo." << std::endl;
            WearableDevice::setDeviceStatus(deviceStatus::ERR);
            return;
        }

        MyoCallbacks myoCallbacks(*this);
        hub.addListener(&myoCallbacks);

        while (true)
        {
            if (WearableDevice::stopDeviceRequested()) 
            {
                break;
            }

            filterDataMap extraData = gestureFilter.getExtraDataForSCD();
            if (extraData.size() > 0)
            {
                WearableDevice::sharedData->setInput(extraData);
                WearableDevice::sharedData->process();
            }

            if (profileSignaller.getProfileName() != prevProfileName)
            {
                prevProfileName = profileSignaller.getProfileName();
                updateProfiles();
            }

            rssi_finish = std::chrono::duration_cast<std::chrono::milliseconds>(
                std::chrono::steady_clock::now().time_since_epoch());
            if ((rssi_finish - rssi_start).count() > MIN_RSSI_DELAY)
            {
                myo->requestRssi();
                rssi_start = std::chrono::duration_cast<std::chrono::milliseconds>(
                    std::chrono::steady_clock::now().time_since_epoch());
            }

            hub.run(durationInMilliseconds);
            
        }
    }
    catch (const std::exception& e)
    {
        std::cout << "Exception: " << e.what() << std::endl;
        WearableDevice::setDeviceStatus(deviceStatus::ERR);
        return;
    }

    WearableDevice::setDeviceStatus(deviceStatus::DONE);
}
Exemplo n.º 7
0
void UmlPackage::importHeader(FileIn & in)
{
    Token & tk = in.read();

    if (tk.what() != "xml")
        in.error("xml version expected");

    if (tk.valueOf("version") != "1.0") {
        UmlCom::trace("Only import xml 1.0");
        return;
    }

    in.setEncoding(tk.valueOf("encoding"));

    (void) in.read();	// update tk

    if (tk.what() == "xmi:xmi") {
        WrapperStr ver = tk.valueOf("xmi:version");

        if (ver.isEmpty())
            UmlCom::trace("warning : unknown xmi version<br><br>");
        else if (ver != "2.1")
            UmlCom::trace("warning : imported file is not xmi 2.1<br><br>");

        FromEclipse =
            // for instance RSA Eclipse xmi export
            !tk.valueOf("xmlns:ecore").isEmpty();

        if (FromEclipse)
            UmlCom::trace("xmi file produced under <b>Eclipse</b><br><br>");

        // read all before stereotype use
        WrapperStr prof_st;
        Q3ValueList<WrapperStr> base_v;

        while ((void) in.read(), !tk.close("xmi:xmi")) {
            if (UmlClass::isAppliedStereotype(tk, prof_st, base_v))
                break;

            UmlCom::targetItem()->import(in, tk);
        }

        solveRefs();

        if (NumberOfProfile != 0)
            // to take into account inheritances
            updateProfiles();

        // read stereotype use
        while (!tk.close("xmi:xmi")) {
            applyStereotype(in, tk);
            (void) in.read();
        }
    }
    else if ((tk.what() == "uml:model") || (tk.what() == "uml:profile")) {
        // Borland Together 2006 for Eclipse
        // Visual Paradigm for UML 6.1
        // RSA Eclipse (profile)
        WrapperStr ver = tk.valueOf("xmi:version");

        if (ver.isEmpty())
            UmlCom::trace("warning : unknown xmi version<br><br>");
        else if (ver != "2.1")
            UmlCom::trace("warning : imported file is not xmi 2.1<br><br>");

        FromEclipse =
            // .uml
            !tk.valueOf("xmlns:ecore").isEmpty();

        if (FromEclipse)
            UmlCom::trace("xmi file produced under <b>Eclipse</b><br><br>");

        UmlCom::targetItem()->import(in, tk);

        solveRefs();

        if (NumberOfProfile != 0)
            updateProfiles();
    }
    else
        in.error("uml:model or uml:profile or xmi:xmi expected, nothing imported");
}
Exemplo n.º 8
0
void UmlPackage::importIt(FileIn & in, Token & token, UmlItem * where)
{
    while (where->kind() != aPackage)
        where = where->parent();

    WrapperStr s = token.valueOf("name");

    if (s.isEmpty()) {
        static unsigned n = 0;

        s.sprintf("anonymous %u", ++n);
    }

    UmlPackage * pack = create((UmlPackage *) where, s);

    if (pack == 0)
        in.error("cannot create package '" + s + "' in '" + where->name() + "'");

    bool profile =
        (token.what() == "uml:profile") || (token.xmiType() == "uml:Profile");

    if (profile) {
        pack->set_Stereotype("profile");
        pack->set_PropertyValue("xmiId", token.xmiId());
        NumberOf -= 1;
        NumberOfProfile += 1;

        if (!(s = token.valueOf("metamodelreference")).isEmpty())
            pack->set_PropertyValue("metamodelReference", s);

        if (!(s = token.valueOf("metaclassreference")).isEmpty())
            pack->set_PropertyValue("metaclassReference", s);
    }

    s = token.xmiId();

    if (!s.isEmpty()) {
        pack->addItem(s, in);

        if (! token.closed()) {
            WrapperStr k = token.what();
            const char * kstr = k;

            if (profile) {
                while (in.read(), !token.close(kstr)) {
                    if ((token.what() == "packagedelement") &&
                        (token.xmiType() == "uml:Extension")) {
                        if (! token.closed())
                            in.finish(token.what());
                    }
                    else if (token.what() == "packageimport")
                        pack->packageImport(in, token);
                    else
                        pack->UmlItem::import(in, token);
                }

                updateProfiles();
            }
            else
                while (in.read(), !token.close(kstr))
                    pack->UmlItem::import(in, token);
        }
    }
    else if (! token.valueOf("href", s))
        in.error("xmi:id is missing"); // doesn't return
    else {
        in.warning("bypass external package " + s);

        if (! token.closed())
            in.finish(token.what());
    }

    pack->unload(TRUE, FALSE);
}
QgsRasterFormatSaveOptionsWidget::QgsRasterFormatSaveOptionsWidget( QWidget* parent, const QString& format,
    QgsRasterFormatSaveOptionsWidget::Type type, const QString& provider )
    : QWidget( parent )
    , mFormat( format )
    , mProvider( provider )
    , mRasterLayer( nullptr )
    , mRasterFileName( QString() )
    , mPyramids( false )
    , mPyramidsFormat( QgsRaster::PyramidsGTiff )

{
  setupUi( this );

  setType( type );

  if ( mBuiltinProfiles.isEmpty() )
  {
    // key=profileKey values=format,profileName,options
    mBuiltinProfiles[ "z_adefault" ] = ( QStringList() << "" << tr( "Default" ) << "" );

    // these GTiff profiles are based on Tim's benchmarks at
    // http://linfiniti.com/2011/05/gdal-efficiency-of-various-compression-algorithms/
    // big: no compression | medium: reasonable size/speed tradeoff | small: smallest size
    mBuiltinProfiles[ "z_gtiff_1big" ] =
      ( QStringList() << "GTiff" << tr( "No compression" )
        << "COMPRESS=NONE BIGTIFF=IF_NEEDED" );
    mBuiltinProfiles[ "z_gtiff_2medium" ] =
      ( QStringList() << "GTiff" << tr( "Low compression" )
        << "COMPRESS=PACKBITS" );
    mBuiltinProfiles[ "z_gtiff_3small" ] =
      ( QStringList() << "GTiff" << tr( "High compression" )
        << "COMPRESS=DEFLATE PREDICTOR=2 ZLEVEL=9" );
    mBuiltinProfiles[ "z_gtiff_4jpeg" ] =
      ( QStringList() << "GTiff" << tr( "JPEG compression" )
        << "COMPRESS=JPEG JPEG_QUALITY=75" );

    // overview compression schemes for GTiff format, see
    // http://www.gdal.org/gdaladdo.html and http://www.gdal.org/frmt_gtiff.html
    // TODO - should we offer GDAL_TIFF_OVR_BLOCKSIZE option here or in QgsRasterPyramidsOptionsWidget ?
    mBuiltinProfiles[ "z__pyramids_gtiff_1big" ] =
      ( QStringList() << "_pyramids" << tr( "No compression" )
        << "COMPRESS_OVERVIEW=NONE BIGTIFF_OVERVIEW=IF_NEEDED" );
    mBuiltinProfiles[ "z__pyramids_gtiff_2medium" ] =
      ( QStringList() << "_pyramids" << tr( "Low compression" )
        << "COMPRESS_OVERVIEW=PACKBITS" );
    mBuiltinProfiles[ "z__pyramids_gtiff_3small" ] =
      ( QStringList() << "_pyramids" << tr( "High compression" )
        << "COMPRESS_OVERVIEW=DEFLATE PREDICTOR_OVERVIEW=2 ZLEVEL=9" ); // how to set zlevel?
    mBuiltinProfiles[ "z__pyramids_gtiff_4jpeg" ] =
      ( QStringList() << "_pyramids" << tr( "JPEG compression" )
        << "JPEG_QUALITY_OVERVIEW=75 COMPRESS_OVERVIEW=JPEG PHOTOMETRIC_OVERVIEW=YCBCR INTERLEAVE_OVERVIEW=PIXEL" );
  }

  connect( mProfileComboBox, SIGNAL( currentIndexChanged( const QString & ) ),
           this, SLOT( updateOptions() ) );
  connect( mOptionsTable, SIGNAL( cellChanged( int, int ) ), this, SLOT( optionsTableChanged() ) );
  connect( mOptionsHelpButton, SIGNAL( clicked() ), this, SLOT( helpOptions() ) );
  connect( mOptionsValidateButton, SIGNAL( clicked() ), this, SLOT( validateOptions() ) );

  // create eventFilter to map right click to swapOptionsUI()
  // mOptionsLabel->installEventFilter( this );
  mOptionsLineEdit->installEventFilter( this );
  mOptionsStackedWidget->installEventFilter( this );

  updateControls();
  updateProfiles();

  QgsDebugMsg( "done" );
}
void QgsRasterFormatSaveOptionsWidget::setFormat( const QString& format )
{
  mFormat = format;
  updateControls();
  updateProfiles();
}
Exemplo n.º 11
0
void OptionsSimple::init()
{
    updateProfiles();
}
Exemplo n.º 12
0
bool OptionsDetailed::saveCustomProfile( bool lastUsed )
{
    if( wPlugin && currentPlugin )
    {
        QString profileName;
        if( lastUsed )
        {
            profileName = "soundkonverter_last_used";
        }
        else
        {
            bool ok;
            profileName = KInputDialog::getText( i18n("New profile"), i18n("Enter a name for the new profile:"), "", &ok );
            if( !ok )
                return false;
        }

        if( profileName.isEmpty() )
        {
            KMessageBox::information( this, i18n("You cannot save a profile without a name."), i18n("Profile name is empty") );
            return false;
        }

        QStringList profiles;
        profiles += i18n("Very low");
        profiles += i18n("Low");
        profiles += i18n("Medium");
        profiles += i18n("High");
        profiles += i18n("Very high");
        profiles += i18n("Lossless");
        profiles += i18n("Hybrid");
        profiles += i18n("Last used");
        profiles += "Last used";
        profiles += i18n("User defined");
        if( !lastUsed )
            profiles += "soundkonverter_last_used";

        if( profiles.contains(profileName) )
        {
            KMessageBox::information( this, i18n("You cannot overwrite the built-in profiles."), i18n("Profile already exists") );
            return false;
        }

        QDomDocument list("soundkonverter_profilelist");
        QDomElement root;
        bool profileFound = false;

        QFile listFile( KStandardDirs::locateLocal("data","soundkonverter/profiles.xml") );
        if( listFile.open( QIODevice::ReadOnly ) )
        {
            if( list.setContent( &listFile ) )
            {
                root = list.documentElement();
                if( root.nodeName() == "soundkonverter" && root.attribute("type") == "profilelist" )
                {
                    QDomNodeList conversionOptionsElements = root.elementsByTagName("conversionOptions");
                    for( int i=0; i<conversionOptionsElements.count(); i++ )
                    {
                        if( conversionOptionsElements.at(i).toElement().attribute("profileName") == profileName )
                        {
                            int ret;
                            if( lastUsed )
                                ret = KMessageBox::Yes;
                            else
                                ret = KMessageBox::questionYesNo( this, i18n("A profile with this name already exists.\n\nDo you want to overwrite the existing one?"), i18n("Profile already exists") );

                            if( ret == KMessageBox::Yes )
                            {
                                ConversionOptions *conversionOptions = currentConversionOptions( false );
                                delete config->data.profiles[profileName];
                                config->data.profiles[profileName] = conversionOptions;
                                root.removeChild(conversionOptionsElements.at(i));
                                QDomElement profileElement = conversionOptions->toXml(list);
                                profileElement.setAttribute("profileName",profileName);
                                root.appendChild(profileElement);
                                profileFound = true;
                                break;
                            }
                            else
                            {
                                return false;
                            }
                        }
                    }
                }
            }
            listFile.close();
        }

        if( listFile.open( QIODevice::WriteOnly ) )
        {
            if( list.childNodes().isEmpty() )
            {
                root = list.createElement("soundkonverter");
                root.setAttribute("type","profilelist");
                list.appendChild(root);
            }

            if( !profileFound )
            {
                ConversionOptions *conversionOptions = currentConversionOptions( false );
                config->data.profiles[profileName] = conversionOptions;
                QDomElement profileElement = conversionOptions->toXml(list);
                profileElement.setAttribute("profileName",profileName);
                root.appendChild(profileElement);
            }

            updateProfiles();
            emit customProfilesEdited();

            QTextStream stream(&listFile);
            stream << list.toString();
            listFile.close();

            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}