void QgsDataDefinedButton::checkCheckedWidgets( bool check )
{
  // don't uncheck, only set to checked
  if ( !check )
  {
    return;
  }
  for ( int i = 0; i < mCheckedWidgets.size(); ++i )
  {
    QAbstractButton *btn = qobject_cast< QAbstractButton * >( mCheckedWidgets.at( i ) );
    if ( btn && btn->isCheckable() )
    {
      btn->setChecked( true );
      continue;
    }
    QGroupBox *grpbx = qobject_cast< QGroupBox * >( mCheckedWidgets.at( i ) );
    if ( grpbx && grpbx->isCheckable() )
    {
      grpbx->setChecked( true );
    }
  }
}
Exemple #2
0
void
QvisAnimationWindow::UpdateWindow(bool doAll)
{
    AnimationAttributes *atts = (AnimationAttributes *)subject;
    QAbstractButton *btn = 0;
    int index = 0;

    for(int i = 0; i < atts->NumAttributes(); ++i)
    {
        if(!atts->IsSelected(i) && !doAll)
            continue;

        switch(i)
        {
        case AnimationAttributes::ID_pipelineCachingMode:
            pipelineCachingToggle->blockSignals(true);
            pipelineCachingToggle->setChecked(atts->GetPipelineCachingMode());
            pipelineCachingToggle->blockSignals(false);
            break;
        case AnimationAttributes::ID_frameIncrement:
            animationIncrement->blockSignals(true);
            animationIncrement->setValue(atts->GetFrameIncrement());
            animationIncrement->blockSignals(false);
            break;
        case AnimationAttributes::ID_timeout:
            timeoutSlider->blockSignals(true);
            timeoutSlider->setValue(SLOWEST_TIMEOUT - atts->GetTimeout());
            timeoutSlider->blockSignals(false);
            break;
        case AnimationAttributes::ID_playbackMode:
            index = int(atts->GetPlaybackMode());
            btn = playbackModeButtonGroup->button(index);
            playbackModeButtonGroup->blockSignals(true);
            btn->setChecked(true);
            playbackModeButtonGroup->blockSignals(false);
            break;
        }
    }
}
Exemple #3
0
void SetupServer::readSettings()
{
    m_folderArchiveSettingPage->loadSettings();
    m_ui->accountName->setText(m_parentResource->name());
    m_oldResourceName = m_ui->accountName->text();

    KUser *currentUser = new KUser();
    KEMailSettings esetting;

    m_ui->imapServer->setText(
        !m_parentResource->settings()->imapServer().isEmpty() ? m_parentResource->settings()->imapServer() :
        esetting.getSetting(KEMailSettings::InServer));

    m_ui->portSpin->setValue(m_parentResource->settings()->imapPort());

    m_ui->userName->setText(
        !m_parentResource->settings()->userName().isEmpty() ? m_parentResource->settings()->userName() :
        currentUser->loginName());

    const QString safety = m_parentResource->settings()->safety();
    int i = 0;
    if (safety == QLatin1String("SSL")) {
        i = KIMAP::LoginJob::AnySslVersion;
    } else if (safety == QLatin1String("STARTTLS")) {
        i = KIMAP::LoginJob::TlsV1;
    } else {
        i = KIMAP::LoginJob::Unencrypted;
    }

    QAbstractButton *safetyButton = m_ui->safeImapGroup->button(i);
    if (safetyButton) {
        safetyButton->setChecked(true);
    }

    populateDefaultAuthenticationOptions();
    i = m_parentResource->settings()->authentication();
    qCDebug(IMAPRESOURCE_LOG) << "read IMAP auth mode: " << authenticationModeString((MailTransport::Transport::EnumAuthenticationType::type) i);
    setCurrentAuthMode(m_ui->authenticationCombo, (MailTransport::Transport::EnumAuthenticationType::type) i);

    i = m_parentResource->settings()->alternateAuthentication();
    setCurrentAuthMode(m_ui->authenticationAlternateCombo, (MailTransport::Transport::EnumAuthenticationType::type) i);

    bool rejected = false;
    const QString password = m_parentResource->settings()->password(&rejected);
    if (rejected) {
        m_ui->password->setEnabled(false);
        KMessageBox::information(Q_NULLPTR, i18n("Could not access KWallet. "
                                 "If you want to store the password permanently then you have to "
                                 "activate it. If you do not "
                                 "want to use KWallet, check the box below, but note that you will be "
                                 "prompted for your password when needed."),
                                 i18n("Do not use KWallet"), QStringLiteral("warning_kwallet_disabled"));
    } else {
        m_ui->password->insert(password);
    }

    m_ui->subscriptionEnabled->setChecked(m_parentResource->settings()->subscriptionEnabled());

    m_ui->checkInterval->setValue(m_parentResource->settings()->intervalCheckTime());
    m_ui->disconnectedModeEnabled->setChecked(m_parentResource->settings()->disconnectedModeEnabled());

    m_ui->managesieveCheck->setChecked(m_parentResource->settings()->sieveSupport());
    m_ui->sameConfigCheck->setChecked(m_parentResource->settings()->sieveReuseConfig());
    m_ui->sievePortSpin->setValue(m_parentResource->settings()->sievePort());
    m_ui->alternateURL->setText(m_parentResource->settings()->sieveAlternateUrl());
    m_vacationFileName = m_parentResource->settings()->sieveVacationFilename();

    Akonadi::Collection trashCollection(m_parentResource->settings()->trashCollection());
    if (trashCollection.isValid()) {
        Akonadi::CollectionFetchJob *fetchJob = new Akonadi::CollectionFetchJob(trashCollection, Akonadi::CollectionFetchJob::Base, this);
        connect(fetchJob, &Akonadi::CollectionFetchJob::collectionsReceived, this, &SetupServer::targetCollectionReceived);
    } else {
        Akonadi::SpecialMailCollectionsRequestJob *requestJob = new Akonadi::SpecialMailCollectionsRequestJob(this);
        connect(requestJob, &Akonadi::SpecialMailCollectionsRequestJob::result, this, &SetupServer::localFolderRequestJobFinished);
        requestJob->requestDefaultCollection(Akonadi::SpecialMailCollections::Trash);
        requestJob->start();
    }

    m_ui->useDefaultIdentityCheck->setChecked(m_parentResource->settings()->useDefaultIdentity());
    if (!m_ui->useDefaultIdentityCheck->isChecked()) {
        m_identityCombobox->setCurrentIdentity(m_parentResource->settings()->accountIdentity());
    }

    m_ui->enableMailCheckBox->setChecked(m_parentResource->settings()->intervalCheckEnabled());
    if (m_ui->enableMailCheckBox->isChecked()) {
        m_ui->checkInterval->setValue(m_parentResource->settings()->intervalCheckTime());
    } else {
        m_ui->checkInterval->setEnabled(false);
    }

    m_ui->autoExpungeCheck->setChecked(m_parentResource->settings()->automaticExpungeEnabled());

    if (m_vacationFileName.isEmpty()) {
        m_vacationFileName = QStringLiteral("kmail-vacation.siv");
    }

    m_ui->customUsername->setText(m_parentResource->settings()->sieveCustomUsername());

    rejected = false;
    const QString customPassword = m_parentResource->settings()->sieveCustomPassword(&rejected);
    if (rejected) {
        m_ui->customPassword->setEnabled(false);
        KMessageBox::information(Q_NULLPTR, i18n("Could not access KWallet. "
                                 "If you want to store the password permanently then you have to "
                                 "activate it. If you do not "
                                 "want to use KWallet, check the box below, but note that you will be "
                                 "prompted for your password when needed."),
                                 i18n("Do not use KWallet"), QStringLiteral("warning_kwallet_disabled"));
    } else {
        m_ui->customPassword->insert(customPassword);
    }

    const QString sieverCustomAuth(m_parentResource->settings()->sieveCustomAuthentification());
    if (sieverCustomAuth == QLatin1String("ImapUserPassword")) {
        m_ui->imapUserPassword->setChecked(true);
    } else if (sieverCustomAuth == QLatin1String("NoAuthentification")) {
        m_ui->noAuthentification->setChecked(true);
    } else if (sieverCustomAuth == QLatin1String("CustomUserPassword")) {
        m_ui->customUserPassword->setChecked(true);
    }

    delete currentUser;
}
Exemple #4
0
    virtual void setGuiValue(dyn_t val){
      {
        QAbstractButton *button = dynamic_cast<QAbstractButton*>(_widget);
        if (button!=NULL){
          if(val.type==BOOL_TYPE)
            button->setChecked(val.bool_number);
          else
            handleError("Button->setValue received %s, expected BOOL_TYPE", DYN_type_name(val.type));
          return;
        }
      }

      {
        QAbstractSlider *slider = dynamic_cast<QAbstractSlider*>(_widget);
        if (slider!=NULL){
          if(val.type==INT_TYPE)
            slider->setValue(val.bool_number);
          else
            handleError("Slider->setValue received %s, expected INT_TYPE", DYN_type_name(val.type));
          return;
        }
      }

      {
        QLabel *label = dynamic_cast<QLabel*>(_widget);
        if (label!=NULL){
          if(val.type==STRING_TYPE)
            label->setText(STRING_get_qstring(val.string));
          else
            handleError("Text->setValue received %s, expected STRING_TYPE", DYN_type_name(val.type));
          return;
        }
      }

      {
        QLineEdit *line_edit = dynamic_cast<QLineEdit*>(_widget);
        if (line_edit!=NULL){
          if(val.type==STRING_TYPE)
            line_edit->setText(STRING_get_qstring(val.string));
          else
            handleError("Line->setValue received %s, expected STRING_TYPE", DYN_type_name(val.type));
          return;
        }
      }

      {
        QTextEdit *text_edit = dynamic_cast<QTextEdit*>(_widget);
        if (text_edit!=NULL){ 
          if(val.type==STRING_TYPE)
            text_edit->setPlainText(STRING_get_chars(val.string));
          else
            handleError("Text->setValue received %s, expected STRING_TYPE", DYN_type_name(val.type));
          return;
        }
      }

      {
        QSpinBox *spinbox = dynamic_cast<QSpinBox*>(_widget);
        if (spinbox!=NULL){
          if (val.type==INT_TYPE)
            spinbox->setValue((int)val.int_number);
          else
            handleError("IntText->setValue received %s, expected INT_TYPE", DYN_type_name(val.type));
          return;
        }
      }

      {
        QDoubleSpinBox *doublespinbox = dynamic_cast<QDoubleSpinBox*>(_widget);
        if (doublespinbox!=NULL){
          if (val.type==FLOAT_TYPE)
            doublespinbox->setValue(val.float_number);
          else
            handleError("FloatText->setValue received %s, expected FLOAT_TYPE", DYN_type_name(val.type));
          return;
        }
      }
                  
      handleError("Gui #%d does not have a setValue method", _gui_num);
    }
void DesktopSwitch::onCurrentDesktopChanged(int current)
{
    QAbstractButton *button = m_buttons->button(current - 1);
    if (button)
        button->setChecked(true);
}
void AMControlMoveButtonContextMenu::onStepSizeIndexChanged(int newIndex)
{
	QAbstractButton* currentButton = stepSizeButtons_.button(newIndex);
	if(currentButton)
		currentButton->setChecked(true);
}
Exemple #7
0
void wxRadioBox::SetSelection(int n)
{
    QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, n );
    wxCHECK_RET( qtButton != NULL, INVALID_INDEX_MESSAGE );
    qtButton->setChecked( true );
}
void QgsPropertyOverrideButton::updateSiblingWidgets( bool state )
{

  Q_FOREACH ( const SiblingWidget &sw, mSiblingWidgets )
  {
    switch ( sw.mSiblingType )
    {

      case SiblingCheckState:
      {
        // don't uncheck, only set to checked
        if ( state )
        {
          QAbstractButton *btn = qobject_cast< QAbstractButton * >( sw.mWidgetPointer.data() );
          if ( btn && btn->isCheckable() )
          {
            btn->setChecked( sw.mNatural ? state : !state );
          }
          else
          {
            QGroupBox *grpbx = qobject_cast< QGroupBox * >( sw.mWidgetPointer.data() );
            if ( grpbx && grpbx->isCheckable() )
            {
              grpbx->setChecked( sw.mNatural ? state : !state );
            }
          }
        }
        break;
      }

      case SiblingEnableState:
      {
        QLineEdit *le = qobject_cast< QLineEdit * >( sw.mWidgetPointer.data() );
        if ( le )
          le->setReadOnly( sw.mNatural ? !state : state );
        else
          sw.mWidgetPointer.data()->setEnabled( sw.mNatural ? state : !state );
        break;
      }

      case SiblingVisibility:
      {
        sw.mWidgetPointer.data()->setVisible( sw.mNatural ? state : !state );
        break;
      }

      case SiblingExpressionText:
      {
        QLineEdit *le = qobject_cast<QLineEdit *>( sw.mWidgetPointer.data() );
        if ( le )
        {
          le->setText( mProperty.asExpression() );
        }
        else
        {
          QTextEdit *te = qobject_cast<QTextEdit *>( sw.mWidgetPointer.data() );
          if ( te )
          {
            te->setText( mProperty.asExpression() );
          }
        }
        break;
      }

      default:
        break;
    }


  }
}
Exemple #9
0
ReniceDlg::ReniceDlg(QWidget* parent, const QStringList& processes, int currentCpuPrio, int currentCpuSched, int currentIoPrio, int currentIoSched )
	: KDialog( parent )
{
	setObjectName( "Renice Dialog" );
	setModal( true );
	setCaption( i18n("Set Priority") );
	setButtons( Ok | Cancel );
	previous_cpuscheduler = 0;

	connect( this, SIGNAL(okClicked()), SLOT(slotOk()) );

	if(currentIoSched == KSysGuard::Process::None) {
		// CurrentIoSched == 0 means that the priority is set automatically.
		// Using the formula given by the linux kernel Documentation/block/ioprio
		currentIoPrio = (currentCpuPrio+20)/5;
	}
	if(currentIoSched == (int)KSysGuard::Process::BestEffort && currentIoPrio == (currentCpuPrio+20)/5) {
		// Unfortunately, in linux you can't ever set a process back to being None.  So we fake it :)
		currentIoSched = KSysGuard::Process::None;
	}
	ioniceSupported = (currentIoPrio != -2);


	QWidget *widget = new QWidget(this);
	setMainWidget(widget);
	ui = new Ui_ReniceDlgUi();
	ui->setupUi(widget);
	ui->listWidget->insertItems(0, processes);

	cpuScheduler = new QButtonGroup(this);
	cpuScheduler->addButton(ui->radioNormal, (int)KSysGuard::Process::Other);
#ifndef Q_OS_SOLARIS
	cpuScheduler->addButton(ui->radioBatch, (int)KSysGuard::Process::Batch);
#else
	cpuScheduler->addButton(ui->radioBatch, (int)KSysGuard::Process::Interactive);
    ui->radioBatch->setText( i18nc("Scheduler", "Interactive") );
#endif
	cpuScheduler->addButton(ui->radioFIFO, (int)KSysGuard::Process::Fifo);
	cpuScheduler->addButton(ui->radioRR, (int)KSysGuard::Process::RoundRobin);
	if(currentCpuSched >= 0) { //negative means none of these
		QAbstractButton *sched = cpuScheduler->button(currentCpuSched);
		if(sched) {
			sched->setChecked(true); //Check the current scheduler
			previous_cpuscheduler = currentCpuSched;
		}
	}
	cpuScheduler->setExclusive(true);

	ioScheduler = new QButtonGroup(this);
	ioScheduler->addButton(ui->radioIONormal, (int)KSysGuard::Process::None);
	ioScheduler->addButton(ui->radioIdle, (int)KSysGuard::Process::Idle);
	ioScheduler->addButton(ui->radioRealTime, (int)KSysGuard::Process::RealTime);
	ioScheduler->addButton(ui->radioBestEffort, (int)KSysGuard::Process::BestEffort);
	if(currentIoSched >= 0) { //negative means none of these
		QAbstractButton *iosched = ioScheduler->button(currentIoSched);
		if(iosched)
		       	iosched->setChecked(true); //Check the current io scheduler
	}

	ioScheduler->setExclusive(true);

	setSliderRange(); //Update the slider ranges before trying to set their current values
	if(ioniceSupported)
		ui->sliderIO->setValue(currentIoPrio);
	ui->sliderCPU->setValue(currentCpuPrio);

	ui->imgCPU->setPixmap( KIcon("cpu").pixmap(128, 128) );
	ui->imgIO->setPixmap( KIcon("drive-harddisk").pixmap(128, 128) );

	newCPUPriority = 40;

	connect(cpuScheduler, SIGNAL(buttonClicked(int)), this, SLOT(cpuSchedulerChanged(int)));
	connect(ioScheduler, SIGNAL(buttonClicked(int)), this, SLOT(updateUi()));
	connect(ui->sliderCPU, SIGNAL(valueChanged(int)), this, SLOT(cpuSliderChanged(int)));
	connect(ui->sliderIO, SIGNAL(valueChanged(int)), this, SLOT(ioSliderChanged(int)));

	updateUi();
}
Exemple #10
0
FittingDialog::FittingDialog(MyApp *app, QWidget *parent) :QDialog(parent)
{
  mApp = app;
  float nDim=mApp->getDim()-1;
  float x1Idx1=mApp->getX1RangeLow()/nDim;
  float x1Idx2=mApp->getX1RangeHigh()/nDim;
  float x2Idx1=mApp->getX2RangeLow()/nDim;
  float x2Idx2=mApp->getX2RangeHigh()/nDim;
  char tmpStr[20];
  int which = mApp->getZeroFitMethod();

  setWindowTitle(tr("Fitting Range & Method"));

  // Set up the zero-fitting method radio group
  QGroupBox *zeroGrpBox = new QGroupBox(tr("Zero-finding method"), this);
  QButtonGroup *zeroButGroup = new QButtonGroup(this);
  QVBoxLayout *vbox=new QVBoxLayout;
  vbox->setSpacing(0);
  vbox->setContentsMargins(5, 2, 5, 5);
  QRadioButton *radio = new QRadioButton(tr("Fit to CTF-like curve"));
  zeroButGroup->addButton(radio, 0);
  vbox->addWidget(radio);
  radio->setToolTip("Fit to a function based on a CTF curve over the selected range");
  radio = new QRadioButton(tr("Fit polynomial to dip"));
  zeroButGroup->addButton(radio, 1);
  vbox->addWidget(radio);
  radio->setToolTip("Fit a polynomial over the selected range and take the minimum as "
                    "the zero");
  radio = new QRadioButton(tr("Find intersection of 2 curves"));
  zeroButGroup->addButton(radio, 2);
  vbox->addWidget(radio);
  radio->setToolTip("Fit curves or lines over two frequency ranges and take the zero as "
                    "their intersection");
  zeroGrpBox->setLayout(vbox);
  QAbstractButton *button = zeroButGroup->button(which);
  button->setChecked(true);

  // Checkbox for finding power and polynomial order spin button
  mPowerCheckBox = new QCheckBox(tr("Vary exponent of CTF function"), this);
  mPowerCheckBox->setChecked(mApp->getVaryCtfPowerInFit());
  mPowerCheckBox->setToolTip("Add a fifth parameter to the fit to vary the exponent of "
                             "the function being fit");

  QHBoxLayout *orderHbox = new QHBoxLayout;
  mOrderLabel = new QLabel(tr("Order of polynomial:"), this);
  orderHbox->addWidget(mOrderLabel);
  mOrderSpinBox = new QSpinBox(this);
  mOrderSpinBox->setRange(2, 6);
  mOrderSpinBox->setSingleStep(1);
  mOrderSpinBox->setValue(mApp->getPolynomialOrder());
  orderHbox->addWidget(mOrderSpinBox);
  mOrderSpinBox->setToolTip("Set the order for the polynomial fit, e.g., 3 for cubic");

  // FREQUENCY SCALE CHANGE: FOUR " / 2." AND %4.2f -> %4.3f

  // X1 start and end fields
  mX1_label_1=new QLabel(tr("X1 &Starts:"), this);
  sprintf(tmpStr, "%4.3f", x1Idx1 / 2.);
  mX1_edit_1=new QLineEdit(tmpStr, this);
  mX1_label_1->setBuddy(mX1_edit_1);
  mX1_edit_1->setToolTip("Starting frequency (in 1/pixel) of range for CTF-like, "
                         "polynomial, or first curve fit");

  //printf("??????????%f \n", x1Idx1);
  mX1_label_2=new QLabel(tr("X1 &Ends:"), this);
  sprintf(tmpStr, "%4.3f", x1Idx2 / 2.);
  mX1_edit_2=new QLineEdit(tmpStr, this);
  mX1_label_2->setBuddy(mX1_edit_1);
  mX1_edit_2->setToolTip("Ending frequency (in 1/pixel) of range for "
                         "first curve fit");

  // Set up the X1 fitting radio group
  mX1Group=new QGroupBox(tr("X1 fitting method"), this);
  QButtonGroup *x1ButGroup = new QButtonGroup(this);
  mX1LinearRadio=new QRadioButton(tr("Line"));
  mX1SimplexRadio=new QRadioButton(tr("Gaussian"));
  x1ButGroup->addButton(mX1LinearRadio, 0);
  x1ButGroup->addButton(mX1SimplexRadio, 1);
  mX1SimplexRadio->setChecked(true);

  vbox=new QVBoxLayout;
  vbox->addWidget(mX1LinearRadio);
  vbox->addWidget(mX1SimplexRadio);
  mX1Group->setLayout(vbox);
  vbox->setSpacing(0);
  vbox->setContentsMargins(5, 2, 5, 5);

  mX2_label_1=new QLabel(tr("X2 S&tarts:"), this);
  sprintf(tmpStr, "%4.3f", x2Idx1 / 2.);
  mX2_edit_1=new  QLineEdit(tmpStr, this);
  mX2_label_1->setBuddy(mX2_edit_1);
  mX2_edit_1->setToolTip("Starting frequency (in 1/pixel) of range for "
                         "second curve fit");

  mX2_label_2=new QLabel(tr("X2 E&nds:"), this);
  sprintf(tmpStr, "%4.3f", x2Idx2 / 2.);
  mX2_edit_2=new QLineEdit(tmpStr, this);
  mX2_label_2->setBuddy(mX2_edit_2);
  mX2_edit_2->setToolTip("Ending frequency (in 1/pixel) of range for CTF-like, "
                         "polynomial, or second curve fit");

  mX2Group=new QGroupBox(tr("X2 fitting method"), this);
  mX2LinearRadio=new QRadioButton(tr("Line"));
  mX2SimplexRadio=new QRadioButton(tr("Gaussian"));
  QButtonGroup *x2ButGroup = new QButtonGroup(this);
  x2ButGroup->addButton(mX2LinearRadio, 0);
  x2ButGroup->addButton(mX2SimplexRadio, 1);
  mX2SimplexRadio->setChecked(true);

  QVBoxLayout *vbox2=new QVBoxLayout;
  vbox2->addWidget(mX2LinearRadio);
  vbox2->addWidget(mX2SimplexRadio);
  mX2Group->setLayout(vbox2);
  vbox2->setSpacing(0);
  vbox2->setContentsMargins(5, 2, 5, 5);

  QHBoxLayout *baseOrderHbox = new QHBoxLayout;
  mBaselineLabel = new QLabel(tr("Baseline fitting order:"), this);
  baseOrderHbox->addWidget(mBaselineLabel);
  mBaselineSpinBox = new QSpinBox(this);
  mBaselineSpinBox->setRange(0, 4);
  mBaselineSpinBox->setSingleStep(1);
  mBaselineSpinBox->setValue(mApp->getBaselineOrder());
  baseOrderHbox->addWidget(mBaselineSpinBox);
  mBaselineSpinBox->setToolTip("Set the order for a polynomial fit to make baseline "
                               "flat, or 0 for none (hot keys 0 to 4 in plotter window)");

  mApplyButton= new QPushButton( tr("&Apply"), this);
  mApplyButton->setDefault(true);
  mApplyButton->setEnabled(false);

  mCloseButton=new QPushButton( tr("&Close"), this);

  connect(mX1_edit_1, SIGNAL(textChanged(const QString &)), this,
      SLOT(enableApplyButton(const QString &)) );
  connect(mX1_edit_2, SIGNAL(textChanged(const QString &)), this,
      SLOT(enableApplyButton(const QString &)) );
  connect(mX2_edit_1, SIGNAL(textChanged(const QString &)), this,
      SLOT(enableApplyButton(const QString &)) );
  connect(mX2_edit_2, SIGNAL(textChanged(const QString &)), this,
      SLOT(enableApplyButton(const QString &)) );

  connect(mApplyButton, SIGNAL(clicked()), this, SLOT(rangeSetted()) );
  connect(mCloseButton, SIGNAL(clicked()), this, SLOT(close()) );
  connect(mX1LinearRadio, SIGNAL(clicked()), this, SLOT(x1LinearChecked()) );
  connect(mX1SimplexRadio, SIGNAL(clicked()), this, SLOT(x1SimplexChecked()) );
  connect(mX2LinearRadio, SIGNAL(clicked()), this, SLOT(x2LinearChecked()) );
  connect(mX2SimplexRadio, SIGNAL(clicked()), this, SLOT(x2SimplexChecked()) );
  connect(zeroButGroup, SIGNAL(buttonClicked(int)), this, SLOT(zeroMethodClicked(int)));
  connect(mPowerCheckBox, SIGNAL(clicked(bool)), this, SLOT(fitPowerClicked(bool)));
  connect(mOrderSpinBox, SIGNAL(valueChanged(int)), this, SLOT(orderChanged(int)));
  connect(mBaselineSpinBox, SIGNAL(valueChanged(int)), this, SLOT(baseOrderChanged(int)));

  QHBoxLayout *x1HLayout_1=new QHBoxLayout;
  x1HLayout_1->addWidget(mX1_label_1);
  x1HLayout_1->addWidget(mX1_edit_1);

  QHBoxLayout *x1HLayout_2=new QHBoxLayout;
  x1HLayout_2->addWidget(mX1_label_2);
  x1HLayout_2->addWidget(mX1_edit_2);

  QVBoxLayout *x1VLayout=new QVBoxLayout;
  x1VLayout->addLayout(x1HLayout_1);
  x1VLayout->addLayout(x1HLayout_2);

  QHBoxLayout *x1HLayout_3= new QHBoxLayout;
  x1HLayout_3->addLayout(x1VLayout);
  x1HLayout_3->addWidget(mX1Group);

  QHBoxLayout *x2HLayout_1=new QHBoxLayout;
  x2HLayout_1->addWidget(mX2_label_1);
  x2HLayout_1->addWidget(mX2_edit_1);

  QHBoxLayout *x2HLayout_2=new QHBoxLayout;
  x2HLayout_2->addWidget(mX2_label_2);
  x2HLayout_2->addWidget(mX2_edit_2);

  QVBoxLayout *x2VLayout=new QVBoxLayout;
  x2VLayout->addLayout(x2HLayout_1);
  x2VLayout->addLayout(x2HLayout_2);

  QHBoxLayout *x2HLayout_3= new QHBoxLayout;
  x2HLayout_3->addLayout(x2VLayout);
  x2HLayout_3->addWidget(mX2Group);


  QHBoxLayout *lowHLayout=new QHBoxLayout;
  lowHLayout->addWidget(mApplyButton);
  lowHLayout->addWidget(mCloseButton);

  QVBoxLayout *mainLayout=new QVBoxLayout(this);
  mainLayout->setMargin(11);
  mainLayout->setSpacing(6);
  mainLayout->addWidget(zeroGrpBox);
  mainLayout->addWidget(mPowerCheckBox);
  mainLayout->addLayout(orderHbox);
  mainLayout->addLayout(x1HLayout_3);
  mainLayout->addLayout(x2HLayout_3);
  mainLayout->addLayout(baseOrderHbox);
  mainLayout->addLayout(lowHLayout);
  manageWidgets(which);
}
Exemple #11
0
// Update associated QWidget / QObject based on treeGuiWidget_ data
void QtWidgetObject::updateQt()
{
	// Check treeGuiWidget_ pointer first
	if (treeGuiWidget_ == NULL)
	{
		printf("Critical Error: treeGuiWidget_ pointer has not been set in QtWidgetObject.\n");
		return;
	}

	// Do generic properties here
	if (qWidget_ != NULL)
	{
		qWidget_->setEnabled(treeGuiWidget_->enabled());
		qWidget_->setVisible(treeGuiWidget_->visible());
		// And corresponding label
		if (labelWidget_ != NULL)
		{
			labelWidget_->setEnabled(treeGuiWidget_->enabled());
			labelWidget_->setVisible(treeGuiWidget_->visible());
		}
	}

	// Now, check widget type to see what we do
	if (treeGuiWidget_->type() == TreeGuiWidget::ButtonWidget)
	{
		QPushButton *button = static_cast<QPushButton*>(qWidget_);
		if (!button) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QPushButton.\n");
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::CheckWidget)
	{
		QCheckBox *check = static_cast<QCheckBox*>(qWidget_);
		if (!check) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QCheckBox.\n");
		else
		{
			check->setChecked(treeGuiWidget_->valueI() == 1);
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::ComboWidget)
	{
		QComboBox* combo = static_cast<QComboBox*>(qWidget_);
		if (!combo) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QComboBox.\n");
		else
		{
			// Has items list been modified since last update
			if (treeGuiWidget_->propertyChanged(TreeGuiWidgetEvent::ItemsProperty))
			{
				combo->clear();
				for (int n=0; n<treeGuiWidget_->comboItems().count(); ++n) combo->addItem(treeGuiWidget_->comboItems().at(n));
				treeGuiWidget_->resetChanged(TreeGuiWidgetEvent::ItemsProperty);
			}
			// Set current index
			combo->setCurrentIndex(treeGuiWidget_->valueI()-1);
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::DoubleSpinWidget)
	{
		QDoubleSpinBox* spin = static_cast<QDoubleSpinBox*>(qWidget_);
		if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QDoubleSpinBox.\n");
		else
		{
			spin->setRange(treeGuiWidget_->minimumD(), treeGuiWidget_->maximumD());
			spin->setValue(treeGuiWidget_->valueD());
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::EditWidget)
	{
		QLineEdit *edit = static_cast<QLineEdit*>(qWidget_);
		if (!edit) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTextEdit.\n");
		else
		{
			edit->setText(treeGuiWidget_->text());
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::IntegerSpinWidget)
	{
		QSpinBox *spin = static_cast<QSpinBox*>(qWidget_);
		if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QSpinBox.\n");
		else
		{
			spin->setRange(treeGuiWidget_->minimumI(), treeGuiWidget_->maximumI());
			spin->setValue(treeGuiWidget_->valueI());
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::LabelWidget)
	{
		QLabel *label = static_cast<QLabel*>(qWidget_);
		if (!label) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QLabel.\n");
		else
		{
			label->setText(treeGuiWidget_->text());
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::RadioButtonWidget)
	{
		QRadioButton *button = static_cast<QRadioButton*>(qWidget_);
		if (!button) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QRadioButton.\n");
		else
		{
			button->setChecked(treeGuiWidget_->valueI() == 1);
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::RadioGroupWidget)
	{
		QButtonGroup *butgroup = static_cast<QButtonGroup*>(qObject_);
		if (!butgroup) printf("Critical Error: Couldn't cast stored qObject_ pointer into QButtonGroup.\n");
		else
		{
			QAbstractButton *button = butgroup->button(treeGuiWidget_->valueI());
			if (!button) printf("Critical Error: Couldn't find button with id %i in button group.\n", treeGuiWidget_->valueI());
			else button->setChecked(true);
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::TabWidget)
	{
		QTabWidget *tabs = static_cast<QTabWidget*>(qWidget_);
		if (!tabs) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTabWidget.\n");
		else
		{
			tabs->setCurrentIndex(treeGuiWidget_->valueI()-1);
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::StackWidget)
	{
		QStackedWidget *stack = static_cast<QStackedWidget*>(qWidget_);
		if (!stack) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QStackedWidget.\n");
		else
		{
			stack->setCurrentIndex(treeGuiWidget_->valueI()-1);
		}
	}
}
DriverWidget::DriverWidget(const Device &device, QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Form)
    , m_radioGroup(new QButtonGroup(this))
{
    ui->setupUi(this);
    ui->label->setText(xi18nc("@info %1 is hardware vendor, %2 is hardware model",
                              "<title>%1 %2</title>",
                              device.vendor,
                              device.model));

    // We want to sort drivers so they have consistent order across starts.
    QList<Driver> driverList = device.drivers;
    qSort(driverList);

    foreach (const Driver &driver, driverList) {
        // This driver is not manual, but also has no package, hence we cannot
        // do anything with it and should not display anything.
        if (driver.package == nullptr && !driver.manualInstall){
            qDebug() << "encountered invalid driver" << driver.package << driver.manualInstall << "for" << device.model;
            continue;
        }

        QAbstractButton *button;
        if (driverList.count() <= 1) {
            button = new QCheckBox(this);
            m_radioGroup->setExclusive(false);
        } else {
            button = new QRadioButton(this);
        }
        button->setProperty("package", driver.packageName);
        button->setProperty("builtin", driver.builtin);
        ui->verticalLayout->addWidget(button);
        m_radioGroup->addButton(button);

        if (driver.fuzzyActive) {
            button->setChecked(true);
        }

        if (driver.manualInstall) {
            button->setText(i18nc("Manually installed 3rd party driver",
                                  "This device is using a manually-installed driver : (%1)",
                                  driver.packageName));
            break; // Manually installed drivers have no additional information available.
        }

        if (driver.recommended) {
            button->setText(i18nc("%1 is description and %2 is package name; when driver is recommended for use",
                                  "Using %1 from %2 (Recommended Driver)",
                                  driver.package->shortDescription(),
                                  driver.package->name()));
        } else { // !recommended
            button->setText(i18nc("%1 is description and %2 is package name",
                                  "Using %1 from %2",
                                  driver.package->shortDescription(),
                                  driver.package->name()));
        }

        if (driver.free) {
            button->setToolTip(i18nc("The driver is under a open source license",
                                     "Open Source Driver"));
        } else { // !free
            button->setToolTip(i18nc("The driver is under a proprietary license",
                                     "Proprietary Driver"));
        }
    }

    m_indexSelected = m_radioGroup->checkedId();
    m_defaultSelection = m_indexSelected;
    connect(m_radioGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(selectionChanged()));
}
void QgsPropertyOverrideButton::updateSiblingWidgets( bool state )
{
  Q_FOREACH ( const SiblingWidget &sw, mSiblingWidgets )
  {
    switch ( sw.mSiblingType )
    {

      case SiblingCheckState:
      {
        // don't uncheck, only set to checked
        if ( state )
        {
          QAbstractButton *btn = qobject_cast< QAbstractButton * >( sw.mWidgetPointer.data() );
          if ( btn && btn->isCheckable() )
          {
            btn->setChecked( sw.mNatural ? state : !state );
          }
          else
          {
            QGroupBox *grpbx = qobject_cast< QGroupBox * >( sw.mWidgetPointer.data() );
            if ( grpbx && grpbx->isCheckable() )
            {
              grpbx->setChecked( sw.mNatural ? state : !state );
            }
          }
        }
        break;
      }

      case SiblingEnableState:
      {
        QLineEdit *le = qobject_cast< QLineEdit * >( sw.mWidgetPointer.data() );
        if ( le )
          le->setReadOnly( sw.mNatural ? !state : state );
        else
          sw.mWidgetPointer.data()->setEnabled( sw.mNatural ? state : !state );
        break;
      }

      case SiblingVisibility:
      {
        sw.mWidgetPointer.data()->setVisible( sw.mNatural ? state : !state );
        break;
      }

      case SiblingExpressionText:
      {
        QLineEdit *le = qobject_cast<QLineEdit *>( sw.mWidgetPointer.data() );
        if ( le )
        {
          le->setText( mProperty.asExpression() );
        }
        else
        {
          QTextEdit *te = qobject_cast<QTextEdit *>( sw.mWidgetPointer.data() );
          if ( te )
          {
            te->setText( mProperty.asExpression() );
          }
        }
        break;
      }

      case SiblingLinkedWidget:
      {
        if ( QgsColorButton *cb = qobject_cast< QgsColorButton * >( sw.mWidgetPointer.data() ) )
        {
          if ( state && mProperty.isProjectColor() )
          {
            QRegularExpression rx( QStringLiteral( "^project_color\\('(.*)'\\)$" ) );
            QRegularExpressionMatch match = rx.match( mExpressionString );
            if ( match.hasMatch() )
            {
              cb->linkToProjectColor( match.captured( 1 ) );
            }
          }
          else
          {
            cb->linkToProjectColor( QString() );
          }
        }
        break;
      }
    }
  }
}