OptionsWidget_identityAvatar::OptionsWidget_identityAvatar(QWidget * parent) : KviOptionsWidget(parent) { createLayout(); layout()->setMargin(10); m_pLocalAvatar = new KviPixmap(KVI_OPTION_PIXMAP(KviOption_pixmapMyAvatar)); bool bHaveAvatar = (!KVI_OPTION_STRING(KviOption_stringMyAvatar).isEmpty()) && m_pLocalAvatar->pixmap(); QString szTip = __tr2qs_ctx("Here you can choose your avatar image. It will be visible<br>" \ "by other people that request it. Choose a nice image of yourself,<br>" \ "possibly avoiding obscenity and offending images. It is a good idea<br>" \ "to choose a relatively small file (say 150 Kb max) because<br>" \ "most clients have a limit on the size of avatars being downloaded.<br>" \ "The image also should be smaller than 800x600 pixels since<br>" \ "it will have to be viewable in everyone's monitor.","options"); m_pUseAvatarCheck = new QCheckBox(__tr2qs_ctx("Use avatar","options"),this); addWidgetToLayout(m_pUseAvatarCheck,0,0,0,0); m_pUseAvatarCheck->setChecked(bHaveAvatar); mergeTip(m_pUseAvatarCheck,szTip); m_pAvatarPreview = new KviPixmapPreview(this); addWidgetToLayout(m_pAvatarPreview,0,1,0,1); m_pAvatarPreview->setPixmap(m_pLocalAvatar); m_pAvatarPreview->setEnabled(bHaveAvatar); connect(m_pUseAvatarCheck,SIGNAL(toggled(bool)),m_pAvatarPreview,SLOT(setEnabled(bool))); mergeTip(m_pAvatarPreview,szTip); KviTalHBox * hb = new KviTalHBox(this); hb->setSpacing(4); addWidgetToLayout(hb,0,2,0,2); m_pAvatarNameEdit = new QLineEdit(hb); m_pAvatarNameEdit->setReadOnly(true); m_pAvatarNameEdit->setEnabled(bHaveAvatar); m_pAvatarNameEdit->setText(KVI_OPTION_STRING(KviOption_stringMyAvatar)); connect(m_pUseAvatarCheck,SIGNAL(toggled(bool)),m_pAvatarNameEdit,SLOT(setEnabled(bool))); m_pChooseAvatarButton = new QPushButton(__tr2qs_ctx("Choose...","options"),hb); m_pChooseAvatarButton->setEnabled(bHaveAvatar); connect(m_pUseAvatarCheck,SIGNAL(toggled(bool)),m_pChooseAvatarButton,SLOT(setEnabled(bool))); connect(m_pChooseAvatarButton,SIGNAL(clicked()),this,SLOT(chooseAvatar())); layout()->setRowStretch(1,2); }
NewCyclistDialog::NewCyclistDialog(QDir home) : QDialog(NULL, Qt::Dialog), home(home) { setAttribute(Qt::WA_DeleteOnClose, false); // caller must delete me, once they've extracted the name useMetricUnits = (appsettings->value(this, GC_UNIT).toString() == "Metric"); QVBoxLayout *all = new QVBoxLayout(this); QGridLayout *grid = new QGridLayout; QLabel *namelabel = new QLabel(tr("Athlete Name")); QLabel *doblabel = new QLabel(tr("Date of Birth")); QLabel *sexlabel = new QLabel(tr("Sex")); QLabel *biolabel = new QLabel(tr("Bio")); QLabel *cplabel = new QLabel(tr("Critical Power (FTP)")); QLabel *resthrlabel = new QLabel(tr("Resting Heartrate")); QLabel *lthrlabel = new QLabel(tr("Lactate Heartrate")); QLabel *maxhrlabel = new QLabel(tr("Maximum Heartrate")); QString weighttext = QString(tr("Weight (%1)")).arg(useMetricUnits ? tr("kg") : tr("lb")); QLabel *weightlabel = new QLabel(weighttext); name = new QLineEdit(this); dob = new QDateEdit(this); sex = new QComboBox(this); sex->addItem(tr("Male")); sex->addItem(tr("Female")); weight = new QDoubleSpinBox(this); weight->setMaximum(999.9); weight->setMinimum(0.0); weight->setDecimals(1); weight->setValue(75); // default cp = new QSpinBox(this); cp->setMinimum(100); // juniors may average 100w for an hour, lower values might be seen for para-juniors (?) cp->setMaximum(500); // thats over 6w/kg for a 80kg rider, anything higher is physiologically unlikely cp->setSingleStep(5); // for those that insist on using the spinners, make it a bit quicker cp->setValue(250); // seems like a 'sensible' default for those that 'don't know' ? resthr = new QSpinBox(this); resthr->setMinimum(30); resthr->setMaximum(100); resthr->setSingleStep(1); resthr->setValue(60); lthr = new QSpinBox(this); lthr->setMinimum(80); lthr->setMaximum(220); lthr->setSingleStep(1); lthr->setValue(165); maxhr = new QSpinBox(this); maxhr->setMinimum(150); maxhr->setMaximum(250); maxhr->setSingleStep(1); maxhr->setValue(190); bio = new QTextEdit(this); avatar = QPixmap(":/images/noavatar.png"); avatarButton = new QPushButton(this); avatarButton->setContentsMargins(0,0,0,0); avatarButton->setFlat(true); avatarButton->setIcon(avatar.scaled(140,140)); avatarButton->setIconSize(QSize(140,140)); avatarButton->setFixedHeight(140); avatarButton->setFixedWidth(140); Qt::Alignment alignment = Qt::AlignLeft|Qt::AlignVCenter; grid->addWidget(namelabel, 0, 0, alignment); grid->addWidget(doblabel, 1, 0, alignment); grid->addWidget(sexlabel, 2, 0, alignment); grid->addWidget(weightlabel, 3, 0, alignment); grid->addWidget(cplabel, 4, 0, alignment); grid->addWidget(resthrlabel, 5, 0, alignment); grid->addWidget(lthrlabel, 6, 0, alignment); grid->addWidget(maxhrlabel, 7, 0, alignment); grid->addWidget(biolabel, 8, 0, alignment); grid->addWidget(name, 0, 1, alignment); grid->addWidget(dob, 1, 1, alignment); grid->addWidget(sex, 2, 1, alignment); grid->addWidget(weight, 3, 1, alignment); grid->addWidget(cp, 4, 1, alignment); grid->addWidget(resthr, 5, 1, alignment); grid->addWidget(lthr, 6, 1, alignment); grid->addWidget(maxhr, 7, 1, alignment); grid->addWidget(bio, 9, 0, 1, 4); grid->addWidget(avatarButton, 0, 2, 4, 2, Qt::AlignRight|Qt::AlignVCenter); all->addLayout(grid); all->addStretch(); // dialog buttons save = new QPushButton("Save", this); cancel = new QPushButton("Cancel", this); QHBoxLayout *h = new QHBoxLayout; h->addStretch(); h->addWidget(cancel); h->addWidget(save); all->addLayout(h); connect (avatarButton, SIGNAL(clicked()), this, SLOT(chooseAvatar())); connect (save, SIGNAL(clicked()), this, SLOT(saveClicked())); connect (cancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); }