void ParamWidget::AddDouble(const QString& name, double min, double max, double step, double initial_value, DisplayHint display_hint) { ExpectNameNotFound(name); if (display_hint == DisplayHint::kSpinBox) { QDoubleSpinBox* spinbox = new QDoubleSpinBox(this); spinbox->setRange(min, max); spinbox->setSingleStep(step); spinbox->setValue(initial_value); spinbox->setProperty("param_widget_type", kParamDouble); widgets_[name] = spinbox; AddLabeledRow(name, spinbox); connect(spinbox, static_cast<void(QDoubleSpinBox::*)(double)>( &QDoubleSpinBox::valueChanged), [this, name](double value) { emit ParamChanged(name); }); } else if (display_hint == DisplayHint::kSlider) { QWidget* row_widget = new QWidget(this); QHBoxLayout* row_hbox = new QHBoxLayout(row_widget); QSlider* slider = new QSlider(Qt::Horizontal, this); const int num_steps = static_cast<int>((max - min) / step); const int initial_value_int = static_cast<int>((initial_value - min) / step); slider->setRange(0, num_steps); slider->setSingleStep(1); slider->setValue(initial_value_int); slider->setProperty("min", min); slider->setProperty("max", max); slider->setProperty("step", step); slider->setProperty("param_widget_type", kParamDouble); QLabel* label = new QLabel(this); label->setText(QString::number((initial_value_int - min) * step)); row_hbox->addWidget(new QLabel(name, this)); row_hbox->addWidget(slider); row_hbox->addWidget(label); widgets_[name] = slider; layout_->addWidget(row_widget); slider->setProperty("param_widget_label", QVariant::fromValue(label)); label->setProperty("format_str", ""); connect(slider, &QSlider::valueChanged, [this, name, label, min, step](int position) { const double value = min + step * position; const QString format_str = label->property("format_str").toString(); if (format_str == "") { label->setText(QString::number(value)); label->setMinimumWidth(std::max(label->width(), label->minimumWidth())); } else { QString text; text.sprintf(format_str.toStdString().c_str(), value); label->setText(text); } emit ParamChanged(name); }); } else { throw std::invalid_argument("Invalid display hint"); } }
void KStatusBar::changeItem( const QString& text, int id ) { QLabel *label = d->items[id]; KSqueezedTextLabel *squeezed = qobject_cast<KSqueezedTextLabel*>( label ); if ( squeezed ) { squeezed->setText( text ); } else if ( label ) { label->setText( text ); if ( label->minimumWidth () != label->maximumWidth () ) { reformat(); } } else { kDebug() << "KStatusBar::changeItem: bad item id: " << id; } }
ClsQGroupStateManip::ClsQGroupStateManip ( const char * _name = 0,string _strGroupID = ""): QFrame( 0, _name, Qt::WDestructiveClose), strGroupID(_strGroupID) { bApplied = false; clsQStateArrayView = NULL; iInterval = 1; iLoops = 1; iStepSize = 1; string strGroupName = ClsFESystemManager::Instance()->getGroupName(strGroupID).c_str(); string strTitle = "State Manipulation Panel for \"" + strGroupName + "\""; this->setCaption(strTitle.c_str()); QBitmap qbmEraser( eraser_cursor_width, eraser_cursor_height, eraser_cursor_bits, TRUE ); QBitmap qbmEraserMask( eraser_cursor_mask_width, eraser_cursor_mask_height, eraser_cursor_mask_bits, TRUE ); qcursorEraser = new QCursor( qbmEraser, qbmEraserMask,0 ,0 ); QBitmap qbmPencil( pencil_cursor_width, pencil_cursor_height, pencil_cursor_bits, TRUE ); QBitmap qbmPencilMask( pencil_cursor_mask_width, pencil_cursor_mask_height, pencil_cursor_mask_bits, TRUE ); qcursorPencil = new QCursor( qbmPencil, qbmPencilMask, 0, 0 ); QSplitter *qsplitter = new QSplitter(this); QFrame *qfmLeftPane = new QFrame(qsplitter); QBoxLayout * layoutMain = new QHBoxLayout( this); layoutMain->setResizeMode (QLayout::Fixed); layoutMain->addWidget(qsplitter); QBoxLayout * layoutLeftPane = new QVBoxLayout( qfmLeftPane, 5, -1, "mainL"); qlblCaption = new QLabel(qfmLeftPane); qlblCaption->setText(strGroupName.c_str()); layoutLeftPane->addWidget(qlblCaption); qfmStateArray = new QFrame(qfmLeftPane);; QHBoxLayout *qlayoutQfm = new QHBoxLayout( qfmStateArray); qlayoutQfm->setAutoAdd ( true); createStateArray(strGroupID); layoutLeftPane->addWidget(qfmStateArray, 0, Qt::AlignHCenter); qfmStateArray->show(); clsQStateArrayView->show(); clsQStateArrayView->setValue(DEFAULTVALUE); QHBoxLayout *qlayoutGradient = new QHBoxLayout( layoutLeftPane); QString qstr; QLabel* qlblMin = new QLabel(qfmLeftPane); qstr.setNum(fMinVal()); qlblMin->setText(qstr); qlayoutGradient->addWidget(qlblMin, 0, Qt::AlignRight); qlblGradientPixmap = new QLabel(qfmLeftPane);; qlayoutGradient->addWidget(qlblGradientPixmap, 1, Qt::AlignHCenter); qstr.setNum(fMaxVal()); QLabel* qlblMax = new QLabel(qfmLeftPane); qlblMax->setText(qstr); qlayoutGradient->addWidget(qlblMax); int iImgWidth = clsQStateArrayView->width() - qlblMin->minimumWidth() - qlblMax->minimumWidth() - 30; int iImgHeight = 13; qlblGradientPixmap->setFixedSize(iImgWidth,iImgHeight); qlblGradientPixmap->setPixmap(clsQStateArrayView->getGradientPixmap(iImgWidth, iImgHeight)); /* -------------------------------- */ qgrpbxTools = new QGroupBox( ); QLabel *lblValue = new QLabel(); lblValue->setText("Value:"); qdblspnbx = new QDoubleSpinBox( qgrpbxTools ); qdblspnbx->setMinimum(fMinVal()); qdblspnbx->setMaximum(fMaxVal()); qdblspnbx->setDecimals(3); qdblspnbx->setSingleStep ( 0.01); qdblspnbx->setValue(DEFAULTVALUE); connect(qdblspnbx, SIGNAL(valueChanged(double)), this, SLOT(slotChangeValue(double))); QPushButton* qpbtnPen = new QPushButton (QIcon(QPixmap(pencil)), ""); qpbtnPen->setToggleButton ( true); qpbtnPen->setFlat(true); qpbtnPen->setChecked(true); slotSelectTool(TOOL_PENCIL); QPushButton* qpbtnEraser = new QPushButton (QIcon(QPixmap(eraser)), ""); qpbtnEraser->setToggleButton ( true); qpbtnEraser->setFlat(true); QHBoxLayout *qlayoutTools = new QHBoxLayout; qlayoutTools->addWidget(lblValue); qlayoutTools->addWidget(qdblspnbx); qlayoutTools->addWidget(qpbtnPen); qlayoutTools->addWidget(qpbtnEraser); qgrpbxTools->setLayout(qlayoutTools); qbtngrpTools = new QButtonGroup(); connect(qbtngrpTools, SIGNAL(buttonClicked(int)), this, SLOT(slotSelectTool(int))); qbtngrpTools->addButton(qpbtnPen, TOOL_PENCIL); qbtngrpTools->addButton(qpbtnEraser, TOOL_ERASER); layoutLeftPane->addWidget(qgrpbxTools); /* ------------------------------------ */ QHBoxLayout *layout2 = new QHBoxLayout( layoutLeftPane); QPushButton *qpbtnClear = new QPushButton ("Clear", qfmLeftPane); connect(qpbtnClear, SIGNAL(clicked()), this, SLOT(slotClear())); layout2->addWidget(qpbtnClear, Qt::AlignTop); QPushButton *qpbtnAdd = new QPushButton ("Add", qfmLeftPane); connect(qpbtnAdd, SIGNAL(clicked()), this, SLOT(slotAdd())); layout2->addWidget(qpbtnAdd, Qt::AlignTop); QPushButton *qpbtnReplace = new QPushButton ("Replace", qfmLeftPane); connect(qpbtnReplace, SIGNAL(clicked()), this, SLOT(slotReplace())); layout2->addWidget(qpbtnReplace, Qt::AlignTop); /* ------------------------------------ */ QGroupBox *qgrpbxMode = new QGroupBox("Mode", qfmLeftPane); QRadioButton *qrbClamp = new QRadioButton ("Clamp", qgrpbxMode ); qrbClamp->setChecked( TRUE ); slotSetMode(ClsGroupManipPattern::MODE_CLAMP); QRadioButton *qrbAddPattern = new QRadioButton ("Add", qgrpbxMode ); QRadioButton *qrbMultiplyPattern = new QRadioButton ("Multiply", qgrpbxMode ); QHBoxLayout *qlayoutMode = new QHBoxLayout; qlayoutMode->addWidget(qrbClamp, ClsGroupManipPattern::MODE_CLAMP); qlayoutMode->addWidget(qrbAddPattern, ClsGroupManipPattern::MODE_ADD); qlayoutMode->addWidget(qrbMultiplyPattern, ClsGroupManipPattern::MODE_MULTIPLY); qgrpbxMode->setLayout(qlayoutMode); QButtonGroup *qbtngrpMode = new QButtonGroup(); connect(qbtngrpMode, SIGNAL(buttonClicked(int)), SLOT(slotSetMode(int)) ); qbtngrpMode->addButton(qrbClamp, ClsGroupManipPattern::MODE_CLAMP); qbtngrpMode->addButton(qrbAddPattern, ClsGroupManipPattern::MODE_ADD); qbtngrpMode->addButton(qrbMultiplyPattern, ClsGroupManipPattern::MODE_MULTIPLY); layoutLeftPane->addWidget(qgrpbxMode); /* ------------------------------------ */ /* ------------------------------------ */ QGroupBox *qgrpbxPlayBack = new QGroupBox("Play Back", qfmLeftPane); QRadioButton *qrbPersist = new QRadioButton( "For ever" ); qrbPersist->setChecked( TRUE ); slotSetPlayback(ClsGroupManipPattern::PLAYBACK_LOOP); QRadioButton *qrbIterations = new QRadioButton( "Times"); QButtonGroup *qbtngrpPlayBack = new QButtonGroup(); connect(qbtngrpPlayBack, SIGNAL(buttonClicked(int)), SLOT(slotSetPlayback(int)) ); qbtngrpPlayBack->addButton(qrbPersist, ClsGroupManipPattern::PLAYBACK_LOOP); qbtngrpPlayBack->addButton(qrbIterations, ClsGroupManipPattern::PLAYBACK_ITERATIONS); qspnbxIterations = new QSpinBox( ); qspnbxIterations->setMinimum(1); qspnbxIterations->setMaximum(INT_MAX); qspnbxIterations->setMaximumWidth(50); connect(qspnbxIterations, SIGNAL(valueChanged(int)), this, SLOT(slotSetLoops(int))); QLabel *qlblInterval = new QLabel(); qlblInterval->setText("Interval"); qspnbxInterval = new QSpinBox( ); qspnbxInterval->setMinimum(1); qspnbxInterval->setMaximum(INT_MAX); qspnbxInterval->setMaximumWidth(50); connect(qspnbxInterval, SIGNAL(valueChanged(int)), this, SLOT(slotSetInterval(int))); QLabel *qlblStepSize = new QLabel(); qlblStepSize->setText("StepSize"); qspnbxStepSize = new QSpinBox(); qspnbxStepSize->setMinimum(1); qspnbxStepSize->setMaximum(INT_MAX); qspnbxStepSize->setMaximumWidth(50); connect(qspnbxStepSize, SIGNAL(valueChanged(int)), this, SLOT(slotSetInterval(int))); QGridLayout* qglayoutPlayBack = new QGridLayout (); qglayoutPlayBack->addWidget(qrbPersist, 1,1); qglayoutPlayBack->addWidget(qrbIterations, 1, 2); qglayoutPlayBack->addWidget(qspnbxIterations, 1, 3); qglayoutPlayBack->addWidget(qlblInterval, 2, 2); qglayoutPlayBack->addWidget(qspnbxInterval, 2, 3); qglayoutPlayBack->addWidget(qlblStepSize, 3,2); qglayoutPlayBack->addWidget(qspnbxStepSize, 3, 3); qgrpbxPlayBack->setLayout(qglayoutPlayBack); layoutLeftPane->addWidget(qgrpbxPlayBack); /* ------------------------------------ */ QHBoxLayout *qlayoutCmdButtons = new QHBoxLayout( layoutLeftPane, 5); QPushButton *qpbtnApply = new QPushButton ("Send", qfmLeftPane); connect(qpbtnApply, SIGNAL(clicked()), this, SLOT(slotApply())); qpbtnRevoke = new QPushButton ("Revoke", qfmLeftPane); qpbtnRevoke->setEnabled(false); connect(qpbtnRevoke, SIGNAL(clicked()), this, SLOT(slotRevoke())); QPushButton *qpbtnClose = new QPushButton ("Close", qfmLeftPane); connect(qpbtnClose, SIGNAL(clicked()), this, SLOT(close())); qlayoutCmdButtons->addWidget(qpbtnApply); qlayoutCmdButtons->addWidget(qpbtnRevoke); qlayoutCmdButtons->addWidget(qpbtnClose); QToolTip::add(qpbtnPen, "Pencil"); QToolTip::add(qpbtnEraser, "Eraser"); QToolTip::add(qpbtnClear, "Clear"); QToolTip::add(qpbtnAdd, "Add"); QToolTip::add(qrbClamp, "Repace Value"); QToolTip::add(qrbAddPattern, "Add Values"); QToolTip::add(qrbMultiplyPattern, "Mutliply with Values"); QToolTip::add(qrbPersist, "Apply for ever"); QToolTip::add(qspnbxIterations, "Apply for selected timesteps"); QToolTip::add(qspnbxInterval, "Apply every X timestep"); QToolTip::add(qspnbxStepSize, "Apply step by X"); clsQSAList = new ClsQSAList(qsplitter, this); connect(clsQSAList, SIGNAL(sigChangeMatrix(vector <vector<double> >)), this, SLOT(slotMatrixChanged(vector <vector<double> >))); clsQSAList->show(); qsplitter->setResizeMode(clsQSAList, QSplitter::FollowSizeHint); };
UserRegistrationDialogPrivate::UserRegistrationDialogPrivate(UserRegistrationDialog * dialog) : QObject(dialog), dialog(dialog), avatarChanged(false) { emailConfirmNoticeTemplate = QString( "You will shortly receive a confirmation email to the address you just " "registered (%1). Before you can log in to Utopia Documents for the first " "time, you must follow the instructions in that email to active your " "account." ); dialog->setFixedWidth(500); QVBoxLayout * dialogLayout = new QVBoxLayout(dialog); dialogLayout->setSpacing(0); dialogLayout->setContentsMargins(0, 0, 0, 0); gridLayout = new QGridLayout; gridLayout->setSpacing(8); gridLayout->setContentsMargins(12, 12, 12, 0); dialogLayout->addLayout(gridLayout); QLabel * stepLabel = verticalLabel("Step 1", dialog); gridLayout->addWidget(stepLabel, 0, 0, 9, 1, Qt::AlignLeft); QLabel * msgLabel = new QLabel; msgLabel->setText( "Please provide some personal information about yourself here. You can also " "choose a profile picture for your account. This information will be visible " "to other users." ); msgLabel->setWordWrap(true); gridLayout->addWidget(msgLabel, 1, 1, 1, 4); // Title QLabel * titleLabel = new QLabel("Title:"); gridLayout->addWidget(titleLabel, 2, 1, Qt::AlignRight); title = new QComboBox; title->setEditable(true); gridLayout->addWidget(title, 2, 2); // Forename QLabel * forenameLabel = new QLabel("Forename:"); gridLayout->addWidget(forenameLabel, 3, 1, Qt::AlignRight); forename = new QLineEdit; gridLayout->addWidget(forename, 3, 2); // Surname QLabel * surnameLabel = new QLabel("Surname:"); gridLayout->addWidget(surnameLabel, 4, 1, Qt::AlignRight); surname = new QLineEdit; gridLayout->addWidget(surname, 4, 2); // Institution QLabel * institutionLabel = new QLabel("Institution:"); gridLayout->addWidget(institutionLabel, 5, 1, Qt::AlignRight); institution = new QLineEdit; gridLayout->addWidget(institution, 5, 2); QFrame * avatarFrame = new QFrame; avatarFrame->setObjectName("avatarFrame"); avatarFrame->setFixedSize(128, 128); QVBoxLayout * avatarFrameLayout = new QVBoxLayout(avatarFrame); avatarFrameLayout->setContentsMargins(1, 1, 1, 1); avatar = new QLabel; avatar->setScaledContents(true); avatar->installEventFilter(this); avatar->setCursor(Qt::PointingHandCursor); avatar->setToolTip("Choose picture..."); avatarFrameLayout->addWidget(avatar); gridLayout->addWidget(avatarFrame, 2, 3, 5, 2, Qt::AlignTop | Qt::AlignHCenter); QPushButton * avatarButton = new QPushButton("Choose picture..."); connect(avatarButton, SIGNAL(clicked()), this, SLOT(pickAvatar())); gridLayout->addWidget(avatarButton, 7, 1, 1, 4, Qt::AlignTop | Qt::AlignRight); ///////////////////////////////////////////////////////////////////////////////// // Email address // Email stepLabel = verticalLabel("Step 2", dialog); gridLayout->addWidget(stepLabel, 9, 0, 4, 1, Qt::AlignLeft); emailDisclaimer = new QLabel( "You will use your email address to log in to Utopia. You will need to " "confirm your email address before you can use your account; instructions " "will be emailed to this address." ); emailDisclaimer->setWordWrap(true); gridLayout->addWidget(emailDisclaimer, 10, 1, 1, 4); QLabel * emailLabel = new QLabel("Email address:"); gridLayout->addWidget(emailLabel, 11, 1, Qt::AlignRight); email = new QLineEdit; gridLayout->addWidget(email, 11, 2, 1, 2); emailErrorIcon = new QLabel; emailErrorIcon->setFixedSize(20, 20); gridLayout->addWidget(emailErrorIcon, 11, 4, 1, 1, Qt::AlignCenter); emailErrorText = new QLabel; emailErrorText->setObjectName("errorLabel"); emailErrorText->setWordWrap(true); emailErrorText->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); connect(emailErrorText, SIGNAL(linkActivated(const QString &)), this, SLOT(onLinkActivated(const QString &))); emailErrorText->hide(); gridLayout->addWidget(emailErrorText, 12, 2, 1, 2); stepLabel = verticalLabel("Step 3", dialog); gridLayout->addWidget(stepLabel, 13, 0, 5, 1, Qt::AlignLeft); passwordDisclaimer = new QLabel( "Please choose (and confirm) a password for your new account. A combination " "of letters, numbers and other characters that is not easy to guess will be " "more secure." ); passwordDisclaimer->setWordWrap(true); gridLayout->addWidget(passwordDisclaimer, 14, 1, 1, 4); // Password 1 QLabel * newPassword1Label = new QLabel("Password:"******"Retype password:"******"errorLabel"); newPasswordErrorText->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); newPasswordErrorText->hide(); gridLayout->addWidget(newPasswordErrorText, 17, 2, 1, 2); ///////////////////////////////////////////////////////////////////////////////// // Control buttons QHBoxLayout * buttonLayout = new QHBoxLayout; buttonLayout->setContentsMargins(12, 12, 12, 12); buttonLayout->setSpacing(8); QPushButton * okButton = new QPushButton("Register"); okButton->setDefault(true); connect(okButton, SIGNAL(clicked()), this, SLOT(onOkButtonClicked())); QPushButton * cancelButton = new QPushButton("Cancel"); cancelButton->setDefault(false); connect(cancelButton, SIGNAL(clicked()), this, SLOT(onCancelButtonClicked())); spinner = new Utopia::Spinner; spinner->setFixedSize(18, 18); buttonLayout->addWidget(cancelButton, 0); buttonLayout->addStretch(1); buttonLayout->addWidget(spinner, 0); buttonLayout->addWidget(okButton, 0); dialogLayout->addStretch(1); dialogLayout->addLayout(buttonLayout, 0); // Layout gridLayout->setColumnStretch(0, 0); gridLayout->setColumnStretch(1, 0); gridLayout->setColumnStretch(2, 100); gridLayout->setColumnStretch(3, 1); gridLayout->setColumnStretch(4, 0); gridLayout->setColumnMinimumWidth(0, stepLabel->minimumWidth() + 10); gridLayout->setRowStretch(6, 1); dialog->setFixedHeight(dialog->heightForWidth(500)); dialog->setSizeGripEnabled(false); }