Example #1
0
/****************************************************************************
  Return selected colors (for highlighting chat).
****************************************************************************/
struct ft_color option_dialog::get_color(struct option *poption) {

  QPalette pal;
  QColor col1, col2;
  QWidget *w;
  QPushButton* but;

  w = reinterpret_cast<QPushButton *>(option_get_gui_data(poption));
  but = w->findChild<QPushButton *>("text_color");
  pal = but->palette();
  col1 =  pal.color(QPalette::Button);
  but = w->findChild<QPushButton *>("text_background");
  pal = but->palette();
  col2 =  pal.color(QPalette::Button);

  return ft_color(col1.name().toUtf8().data(), col2.name().toUtf8().data());
}
AdvancedPanel::AdvancedPanel(QWidget *parent)
	: QWidget(parent, Qt::Tool)
{
	setWindowTitle( tr("Advanced Options") );

	QGridLayout *layout = new QGridLayout(this);

	int row = 0;
	m_EncoderDegreesPerTick = new QLineEdit(this);
	layout->addWidget(new QLabel(tr("Encoder degrees per tick"),this), row, 0);
	layout->addWidget(m_EncoderDegreesPerTick, row, 1);

	++row;
	m_FeedbackDelay = new QLineEdit(this);
	layout->addWidget(new QLabel(tr("Fader Feedback Delay (ms)"),this), row, 0);
	layout->addWidget(m_FeedbackDelay, row, 1);

	++row;
	m_CmdSendAllDelay = new QLineEdit(this);
	layout->addWidget(new QLabel(tr("Command Send All Delay (ms)"),this), row, 0);
	layout->addWidget(m_CmdSendAllDelay, row, 1);

	++row;
	m_MetroRefreshRate = new QLineEdit(this);
	layout->addWidget(new QLabel(tr("Metronome Refresh Rate (ms)"),this), row, 0);
	layout->addWidget(m_MetroRefreshRate, row, 1);

	++row;
	m_SineRefreshRate = new QLineEdit(this);
	layout->addWidget(new QLabel(tr("Sine Wave Refresh Rate (ms)"),this), row, 0);
	layout->addWidget(m_SineRefreshRate, row, 1);

	++row;
	m_PedalRefreshRate = new QLineEdit(this);
	layout->addWidget(new QLabel(tr("Pedal Refresh Rate (ms)"),this), row, 0);
	layout->addWidget(m_PedalRefreshRate, row, 1);
	
	++row;
	m_FlickerRefreshRate = new QLineEdit(this);
	layout->addWidget(new QLabel(tr("Flicker Refresh Rate (ms)"),this), row, 0);
	layout->addWidget(m_FlickerRefreshRate, row, 1);

	++row;
	QPushButton *button = new QPushButton(tr("Restore Defaults"), this);
	QPalette pal( button->palette() );
	pal.setColor(QPalette::Button, ERROR_COLOR);
	button->setPalette(pal);
	connect(button, SIGNAL(clicked(bool)), this, SLOT(onRestoreDefaultsClicked(bool)));
	layout->addWidget(button, row, 0);

	button = new QPushButton(tr("Apply"), this);
	connect(button, SIGNAL(clicked(bool)), this, SLOT(onApplyClicked(bool)));
	layout->addWidget(button, row, 1);

	Load();
}
Example #3
0
void Preferences::pbBrowse_clicked()
{
	QPushButton *pb = qobject_cast<QPushButton*>(sender());
	cd.setCurrentColor(pb->palette().background().color());

	if (cd.exec() == QDialog::Accepted)
	{
		pb->setPalette(QPalette(cd.currentColor()));
	}
}
void RazorSensorsConfiguration::detectedChipSelected(int index)
{
    mSettings.beginGroup("chips");
    QStringList chipNames = mSettings.childGroups();
    QStringList chipFeatureLabels;
    QPushButton* colorButton = NULL;
    QCheckBox* enabledCheckbox = NULL;
    QTableWidgetItem *chipFeatureLabel = NULL;

    if (index < chipNames.size())
    {
        qDebug() << "Selected chip: " << ui->detectedChipsCB->currentText();

        // In case of reloading settings we have to clear GUI elements
        ui->chipFeaturesT->setRowCount(0);

        // Add detected chips and features
        QStringList chipFeaturesLabels;
        chipFeaturesLabels << tr("Enabled") << tr("Label") << tr("Color");
        ui->chipFeaturesT->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
        ui->chipFeaturesT->setHorizontalHeaderLabels(chipFeaturesLabels);

        mSettings.beginGroup(chipNames[index]);
        chipFeatureLabels = mSettings.childGroups();
        for (int j = 0; j < chipFeatureLabels.size(); ++j)
        {
            mSettings.beginGroup(chipFeatureLabels[j]);

            ui->chipFeaturesT->insertRow(j);

            enabledCheckbox = new QCheckBox(ui->chipFeaturesT);
            enabledCheckbox->setChecked(mSettings.value("enabled").toBool());
            // Connect here after the setChecked call because we don't want to send signal
            connect(enabledCheckbox, SIGNAL(stateChanged(int)), this, SLOT(saveSettings()));
            ui->chipFeaturesT->setCellWidget(j, 0, enabledCheckbox);

            chipFeatureLabel = new QTableWidgetItem(chipFeatureLabels[j]);
            chipFeatureLabel->setFlags(Qt::ItemIsEnabled);
            ui->chipFeaturesT->setItem(j, 1, chipFeatureLabel);

            colorButton = new QPushButton(ui->chipFeaturesT);
            connect(colorButton, SIGNAL(clicked()), this, SLOT(changeProgressBarColor()));
            QPalette pal = colorButton->palette();
            pal.setColor(QPalette::Normal, QPalette::Button,
                         QColor(mSettings.value("color").toString()));
            colorButton->setPalette(pal);
            ui->chipFeaturesT->setCellWidget(j, 2, colorButton);

            mSettings.endGroup();
        }
        mSettings.endGroup();
    }
void RazorSensorsConfiguration::saveSettings()
{
    mSettings.setValue("updateInterval", ui->updateIntervalSB->value());
    mSettings.setValue("tempBarWidth", ui->tempBarWidthSB->value());

    if (ui->fahrenheitTempScaleRB->isChecked())
    {
        mSettings.setValue("useFahrenheitScale", true);
    }
    else
    {
        mSettings.setValue("useFahrenheitScale", false);
    }

    mSettings.beginGroup("chips");
    QStringList chipNames = mSettings.childGroups();

    if (chipNames.size())
    {
        QStringList chipFeatureLabels;
        QPushButton* colorButton = NULL;
        QCheckBox* enabledCheckbox = NULL;

        mSettings.beginGroup(chipNames[ui->detectedChipsCB->currentIndex()]);

        chipFeatureLabels = mSettings.childGroups();
        for (int j = 0; j < chipFeatureLabels.size(); ++j)
        {
            mSettings.beginGroup(chipFeatureLabels[j]);

            enabledCheckbox = qobject_cast<QCheckBox*>(ui->chipFeaturesT->cellWidget(j, 0));
            // We know what we are doing so we don't have to check if enabledCheckbox == 0
            mSettings.setValue("enabled", enabledCheckbox->isChecked());

            colorButton = qobject_cast<QPushButton*>(ui->chipFeaturesT->cellWidget(j, 2));
            // We know what we are doing so we don't have to check if colorButton == 0
            mSettings.setValue(
                    "color",
                    colorButton->palette().color(QPalette::Normal, QPalette::Button).name());

            mSettings.endGroup();
        }
        mSettings.endGroup();

    }
    mSettings.endGroup();
}
Example #6
0
QWidget* QmitkPropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option
  , const QModelIndex &index) const
{
  QVariant data = index.data(Qt::EditRole);
  QVariant displayData = index.data(Qt::DisplayRole);
  QString name = index.model()->data(index.model()->index(index.row(), index.column()-1)).value<QString>();

  if(data.isValid())
  {

    QWidget* editorWidget = NULL;

    if(data.type() == QVariant::Color)
    {
      QPushButton* colorBtn = new QPushButton(parent);
      QColor color = data.value<QColor>();

      QColor result = QColorDialog::getColor(color);
      if(result.isValid())
      {
        QPalette palette = colorBtn->palette();
        palette.setColor(QPalette::Button, result);
        colorBtn->setPalette(palette);
        colorBtn->setStyleSheet(QString("background-color: %1;foreground-color: %1; border-style: none;").arg(result.name()));
      }
      // QColorDialog closed by 'Cancel' button, use the old property color
      else
      {
        QPalette palette = colorBtn->palette();
        palette.setColor(QPalette::Button, color);
        colorBtn->setPalette(palette);
        colorBtn->setStyleSheet(QString("background-color: %1;foreground-color: %1; border-style: none;").arg(color.name()));

      }

      connect(colorBtn, SIGNAL(pressed()), this, SLOT(commitAndCloseEditor()));

      editorWidget = colorBtn;
    }

    else if(data.type() == QVariant::Int)
    {
      QSpinBox* spinBox = new QSpinBox(parent);
      spinBox->setSingleStep(1);
      spinBox->setMinimum(std::numeric_limits<int>::min());
      spinBox->setMaximum(std::numeric_limits<int>::max());
      editorWidget = spinBox;
    }
    // see qt documentation. cast is correct, it would be obsolete if we
    // store doubles
    else if(static_cast<QMetaType::Type>(data.type()) == QMetaType::Float)
    {
      QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent);
      spinBox->setDecimals(2);
      spinBox->setSingleStep(0.1);
      if(name == "opacity")
      {
        spinBox->setMinimum(0.0);
        spinBox->setMaximum(1.0);
      }
      else
      {
        spinBox->setMinimum(std::numeric_limits<float>::min());
        spinBox->setMaximum(std::numeric_limits<float>::max());
      }

      editorWidget = spinBox;
    }

    else if(data.type() == QVariant::StringList)
    {
      QStringList entries = data.value<QStringList>();
      QComboBox* comboBox = new QComboBox(parent);
      comboBox->setEditable(false);
      comboBox->addItems(entries);

      editorWidget = comboBox;
    }


    else
    {
      editorWidget = QStyledItemDelegate::createEditor(parent, option, index);
    }

    if ( editorWidget )
    {
      // install event filter
      editorWidget->installEventFilter( const_cast<QmitkPropertyDelegate*>(this) );
    }

    return editorWidget;

  }
  else
    return new QLabel(displayData.toString(), parent);

}