About::About(QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f) { // stuff setWindowTitle("About LibreLibreCell"); QLabel *versionLabel = new QLabel(QString("Git revision: %1").arg(LIBRELIBRECELL_VERSION)); QPlainTextEdit *aboutBox = new QPlainTextEdit; QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); QVBoxLayout *vLayout = new QVBoxLayout; vLayout->addWidget(versionLabel); vLayout->addWidget(aboutBox, 1); vLayout->addSpacing(10); vLayout->addWidget(buttonBox); setLayout(vLayout); aboutBox->setReadOnly(true); aboutBox->setTabChangesFocus(true); aboutBox->setWordWrapMode(QTextOption::NoWrap); aboutBox->setLineWrapMode(QPlainTextEdit::NoWrap); aboutBox->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); aboutBox->setFont(QFont("Monospace", 10)); QFile readme(":/README.txt"); if (readme.open(QIODevice::ReadOnly)) { QTextStream stream(&readme); aboutBox->setPlainText(stream.readAll()); readme.close(); } else { aboutBox->setPlainText("Could not open README.txt."); } QFontMetrics fm(aboutBox->font()); aboutBox->setMinimumSize(fm.width(QLatin1Char('m')) * 76, 450); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); }
void SettingWidget::createValueWidget() { rsArgument* argument = task->getArgument(option->name); switch(option->type) { case G_OPTION_ARG_FILENAME: case G_OPTION_ARG_STRING: case G_OPTION_ARG_STRING_ARRAY: case G_OPTION_ARG_CALLBACK: case G_OPTION_ARG_INT: case G_OPTION_ARG_INT64: case G_OPTION_ARG_DOUBLE: { // Display text box if number of values is not restricted if ( option->allowedValues == NULL ) { if ( option->nLines < 2 ) { QLineEdit *w = new QLineEdit(); valueWidget = w; w->setPlaceholderText(option->cli_arg_description); connect(w, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); if ( argument != NULL ) { w->setText(argument->value); } else if ( option->defaultValue != NULL ) { w->setText(option->defaultValue); } } else { // create a QTextEdit field instead QPlainTextEdit *w = new QPlainTextEdit(); valueWidget = w; connect(w, SIGNAL(textChanged()), this, SLOT(textChanged())); if ( argument != NULL ) { w->setPlainText(argument->value); } else if ( option->defaultValue != NULL ) { w->setPlainText(option->defaultValue); } QFontMetrics m(w->font()) ; int rowHeight = m.lineSpacing() ; w->setFixedHeight(option->nLines * rowHeight) ; w->setLineWrapMode(QPlainTextEdit::NoWrap); } } else { // if the allowed values are restricted display radio buttons instead QWidget *w = new QWidget(); QBoxLayout *wLayout = new QBoxLayout(QBoxLayout::TopToBottom); QButtonGroup *buttonGroup = new QButtonGroup(); buttonGroup->setExclusive(true); valueWidget = w; connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(buttonClicked(int))); // go through all options and add a radio button for them rsUIOptionValue** values = option->allowedValues; for (size_t i=0; values[i] != NULL; i++ ) { // add radio button QRadioButton *b = new QRadioButton(QString("'")+QString(values[i]->name)+QString("'")); QFont f("Arial", 12, QFont::Bold); b->setFont(f); buttonGroup->addButton(b, (int)i); wLayout->addWidget(b); // set it to checked if it is the default or set value b->setChecked(false); if ( argument != NULL ) { if ( ! strcmp(argument->value,values[i]->name) ) { b->setChecked(true); } } else if ( ! strcmp(option->defaultValue,values[i]->name) ) { b->setChecked(true); } // add its description QLabel *label = new QLabel(values[i]->description); label->setIndent(22); label->setWordWrap(true); label->setContentsMargins(0, 0, 0, 4); QFont f2("Arial", 11, QFont::Normal); label->setFont(f2); wLayout->addWidget(label); } w->setLayout(wLayout); } } break; /* case G_OPTION_ARG_INT: case G_OPTION_ARG_INT64: valueWidget = new QSpinBox(); break; case G_OPTION_ARG_DOUBLE: valueWidget = new QDoubleSpinBox(); break; */ case G_OPTION_ARG_NONE: { QCheckBox *w = new QCheckBox("Enabled"); // new SwitchWidget(); valueWidget = w; connect(w, SIGNAL(stateChanged(int)), this, SLOT(stateChanged(int))); if ( argument != NULL ) { w->setCheckState(Qt::Checked); } else { w->setCheckState(Qt::Unchecked); } } break; default: throw std::invalid_argument("UI argument type unknown"); } }
dlgStdPad::dlgStdPad(_cfg_port *cfg_port, QWidget *parent = 0) : QDialog(parent) { QFont f9, f8; f9.setPointSize(9); f9.setWeight(QFont::Light); f8.setPointSize(8); f8.setWeight(QFont::Light); memset(&data, 0x00, sizeof(data)); memcpy(&data.cfg, cfg_port, sizeof(_cfg_port)); setupUi(this); setFont(parent->font()); groupBox_controller->setTitle(tr("Controller %1 : Standard Pad").arg(cfg_port->id)); tabWidget->setCurrentIndex(JOYSTICK); combo_id_init(); for (int a = KEYBOARD; a <= JOYSTICK; a++) { QPlainTextEdit *txt; QPushButton *bt; txt = findChild<QPlainTextEdit *>("plainTextEdit_" + SPT(a) + "_info"); if (txt->font().pointSize() > 9) { txt->setFont(f9); } bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Sequence"); bt->setProperty("myType", QVariant(a)); connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_in_sequence_clicked(bool))); bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Unset_all"); bt->setProperty("myType", QVariant(a)); connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_unset_all_clicked(bool))); bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Defaults"); bt->setProperty("myType", QVariant(a)); connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_defaults_clicked(bool))); for (int b = BUT_A; b < MAX_STD_PAD_BUTTONS; b++) { int vbutton = b + (a * MAX_STD_PAD_BUTTONS); QPushButton *unset; bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_" + SPB(b)); unset = findChild<QPushButton *>("pushButton_" + SPT(a) + "_unset_" + SPB(b)); if (bt->font().pointSize() > 9) { bt->setFont(f9); } if (unset->font().pointSize() > 8) { unset->setFont(f8); } if (a == KEYBOARD) { bt->setText(inpObject::kbd_keyval_to_name(data.cfg.port.input[a][b])); } else { bt->setText(uQString(jsv_to_name(data.cfg.port.input[a][b]))); } bt->installEventFilter(this); bt->setProperty("myVbutton", QVariant(vbutton)); unset->setProperty("myVbutton", QVariant(vbutton)); connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_input_clicked(bool))); connect(unset, SIGNAL(clicked(bool)), this, SLOT(s_unset_clicked(bool))); } } { comboBox_Controller_type->addItem(tr("Auto")); comboBox_Controller_type->addItem(tr("Original")); comboBox_Controller_type->addItem(tr("3rd-party")); comboBox_Controller_type->setCurrentIndex(data.cfg.port.type_pad); connect(comboBox_Controller_type, SIGNAL(activated(int)), this, SLOT(s_combobox_controller_type_activated(int))); } for (int i = TURBOA; i <= TURBOB; i++) { QSlider *tb = findChild<QSlider *>("horizontalSlider_" + SPB(i + TRB_A)); QLabel *label = findChild<QLabel *>("label_value_slider_" + SPB(i + TRB_A)); tb->setRange(1, TURBO_BUTTON_DELAY_MAX); tb->setProperty("myTurbo", QVariant(i)); tb->setValue(data.cfg.port.turbo[i].frequency); connect(tb, SIGNAL(valueChanged(int)), this, SLOT(s_slider_td_value_changed(int))); label->setFixedWidth(label->sizeHint().width()); td_update_label(i, data.cfg.port.turbo[i].frequency); } pushButton_Apply->setProperty("myPointer", QVariant::fromValue(((void *)cfg_port))); connect(pushButton_Apply, SIGNAL(clicked(bool)), this, SLOT(s_apply_clicked(bool))); connect(pushButton_Discard, SIGNAL(clicked(bool)), this, SLOT(s_discard_clicked(bool))); setAttribute(Qt::WA_DeleteOnClose); setFixedSize(width(), height()); setFocusPolicy(Qt::StrongFocus); groupBox_controller->setFocus(Qt::ActiveWindowFocusReason); data.joy.timer = new QTimer(this); connect(data.joy.timer, SIGNAL(timeout()), this, SLOT(s_pad_joy_read_timer())); data.seq.timer = new QTimer(this); connect(data.seq.timer, SIGNAL(timeout()), this, SLOT(s_pad_in_sequence_timer())); installEventFilter(this); }