ProgressFormWidget::ProgressFormWidget(QWidget *parent) : AbstractFormWidget(parent), m_maxValue(100) { m_fieldNameLabel = new QLabel("Invalid Name", this); m_mainLayout = new QVBoxLayout(this); m_progressBar = new QProgressBar(this); m_spinBox = new QSpinBox(this); //static styling m_fieldNameLabel->setStyleSheet("QLabel {color: gray;}"); m_progressLayout = new QHBoxLayout; m_progressLayout->addWidget(m_spinBox); m_progressLayout->addWidget(m_progressBar); m_mainLayout->addWidget(m_fieldNameLabel); m_mainLayout->addLayout(m_progressLayout); m_mainLayout->addStretch(); m_spinBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_progressBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); this->heightUnits = 1; this->widthUnits = 2; //connections connect(m_spinBox, SIGNAL(editingFinished()), this, SLOT(validateData())); setupFocusPolicy(); }
DateFormWidget::DateFormWidget(QWidget *parent) : AbstractFormWidget(parent) { m_fieldNameLabel = new QLabel("Invalid Name", this); m_dateTimeEdit = new QDateTimeEdit(this); m_dateTimeEdit->setMinimumDate(QDate(100, 1, 1)); m_mainLayout = new QVBoxLayout(this); m_lastValidDateTime = new QDateTime(); //static styling m_fieldNameLabel->setStyleSheet("QLabel {color: gray;}"); QColor c = PlatformColorService::getHighlightColor(); QString style; //generate style style.append( "QDateTimeEdit {" "border-radius: 7px;" "padding: 5px;" "border: 2px solid lightgray;" "}" ); style.append(QString( "QDateTimeEdit:focus { " "border: 2px solid rgb(%1, %2, %3);}") .arg(c.red()).arg(c.green()).arg(c.blue())); m_dateTimeEdit->setStyleSheet(style); //on mac disable focus rect around rounded borders m_dateTimeEdit->setAttribute(Qt::WA_MacShowFocusRect, 0); m_mainLayout->addWidget(m_fieldNameLabel); m_mainLayout->addWidget(m_dateTimeEdit); m_mainLayout->addStretch(); this->heightUnits = 1; this->widthUnits = 1; //connections connect(m_dateTimeEdit, SIGNAL(editingFinished()), this, SLOT(editingFinishedSlot())); setupFocusPolicy(); }
CheckboxFormWidget::CheckboxFormWidget(QWidget *parent) : AbstractFormWidget(parent) { m_mainLayout = new QVBoxLayout(this); m_checkbox = new QCheckBox(this); m_mainLayout->addStretch(); m_mainLayout->addWidget(m_checkbox); m_mainLayout->addStretch(); this->heightUnits = 1; this->widthUnits = 1; //connections connect(m_checkbox, SIGNAL(clicked()), this, SLOT(validateData())); setupFocusPolicy(); }
ComboboxFormWidget::ComboboxFormWidget(QWidget *parent) : AbstractFormWidget(parent), m_default(-1), m_markEmpty(false) { m_fieldNameLabel = new QLabel("Invalid Name", this); m_mainLayout = new QVBoxLayout(this); m_comboBox = new QComboBox(this); m_comboBox->setCurrentIndex(-1); m_mainLayout->addWidget(m_fieldNameLabel); m_mainLayout->addWidget(m_comboBox); m_mainLayout->addStretch(); this->heightUnits = 1; this->widthUnits = 1; //connections connect(m_comboBox, SIGNAL(activated(int)), this, SLOT(validateData())); setupFocusPolicy(); }