/** * Is called if the value of one of the version combo boxes has been changed. * @param value */ void CreateSceFile::versionSpinboxValueChangedSlot(int value) { QObject* obj = sender(); QSpinBox* box = static_cast<QSpinBox*>(obj); if(value < 10) { box->setPrefix("0"); } else { box->setPrefix(""); } }
TtipMelody::TtipMelody(TquestionPoint *point) : TtipChart(point) { setBgColor(point->color()); setPlainText(" "); m_w = new QWidget(); m_w->setObjectName("m_melodyView"); m_w->setStyleSheet("QWidget#m_melodyView { background: transparent }"); QString txt; if (point->nr()) txt = QString(TquestionAsWdg::questionTxt() + " <big><b>%1.</b></big>").arg(point->nr()); if (point->question()->questionAsNote() && point->question()->answerAsSound()) txt += (" <b>" + TexTrans::playMelodyTxt() + "</b>"); else if (point->question()->questionAsSound() && point->question()->answerAsNote()) txt += (" <b>" + TexTrans::writeMelodyTxt() + "</b>"); QLabel *headLab = new QLabel(txt, m_w); headLab->setAlignment(Qt::AlignCenter); m_score = new TmelodyView(qa()->question()->melody(), m_w); m_score->setFixedHeight(qApp->desktop()->availableGeometry().height() / 12); if (point->question()->exam()) { if (point->question()->exam()->level()->showStrNr) m_score->showStringNumbers(true); } QSpinBox *spinAtt = new QSpinBox(m_w); spinAtt->setRange(0, qa()->question()->attemptsCount()); spinAtt->setPrefix(TexTrans::attemptTxt() + " "); spinAtt->setSuffix(" " + tr("of", "It will give text: 'Attempt x of y'") + QString(" %1").arg(qa()->question()->attemptsCount())); m_attemptLabel = new QLabel(m_w); m_resultLabel = new QLabel(wasAnswerOKtext(point->question(), point->color()).replace("<br>", " "), m_w); m_resultLabel->setAlignment(Qt::AlignCenter); // txt = wasAnswerOKtext(point->question(), point->color()).replace("<br>", " ") + "<br>"; txt = tr("Melody was played <b>%n</b> times", "", qa()->question()->totalPlayBacks()) + "<br>"; txt += TexTrans::effectTxt() + QString(": <big><b>%1%</b></big>, ").arg(point->question()->effectiveness(), 0, 'f', 1, '0'); txt += TexTrans::reactTimeTxt() + QString("<big><b> %1</b></big>").arg(Texam::formatReactTime(point->question()->time, true)); QLabel *sumLab = new QLabel(txt, m_w); sumLab->setAlignment(Qt::AlignCenter); QVBoxLayout *lay = new QVBoxLayout; lay->addWidget(headLab); lay->addWidget(m_score, 0, Qt::AlignCenter); QHBoxLayout *attLay = new QHBoxLayout; attLay->addStretch(); attLay->addWidget(spinAtt); attLay->addStretch(); lay->addLayout(attLay); lay->addWidget(m_attemptLabel); lay->addWidget(m_resultLabel); lay->addWidget(sumLab); m_w->setLayout(lay); m_widget = point->scene()->addWidget(m_w); m_widget->setParentItem(this); connect(spinAtt, SIGNAL(valueChanged(int)), this, SLOT(attemptChanged(int))); }
//! [1] void Window::createSpinBoxes() { spinBoxesGroup = new QGroupBox(tr("Spinboxes")); QLabel *integerLabel = new QLabel(tr("Enter a value between " "%1 and %2:").arg(-20).arg(20)); QSpinBox *integerSpinBox = new QSpinBox; integerSpinBox->setRange(-20, 20); integerSpinBox->setSingleStep(1); integerSpinBox->setValue(0); //! [1] //! [2] QLabel *zoomLabel = new QLabel(tr("Enter a zoom value between " "%1 and %2:").arg(0).arg(1000)); //! [3] QSpinBox *zoomSpinBox = new QSpinBox; zoomSpinBox->setRange(0, 1000); zoomSpinBox->setSingleStep(10); zoomSpinBox->setSuffix("%"); zoomSpinBox->setSpecialValueText(tr("Automatic")); zoomSpinBox->setValue(100); //! [2] //! [3] //! [4] QLabel *priceLabel = new QLabel(tr("Enter a price between " "%1 and %2:").arg(0).arg(999)); QSpinBox *priceSpinBox = new QSpinBox; priceSpinBox->setRange(0, 999); priceSpinBox->setSingleStep(1); priceSpinBox->setPrefix("$"); priceSpinBox->setValue(99); //! [4] //! [5] QVBoxLayout *spinBoxLayout = new QVBoxLayout; spinBoxLayout->addWidget(integerLabel); spinBoxLayout->addWidget(integerSpinBox); spinBoxLayout->addWidget(zoomLabel); spinBoxLayout->addWidget(zoomSpinBox); spinBoxLayout->addWidget(priceLabel); spinBoxLayout->addWidget(priceSpinBox); spinBoxesGroup->setLayout(spinBoxLayout); }
QueryPage:: QueryPage(QWidget *parent) : QWidget(parent) { QGroupBox *packagesGroup = new QGroupBox("Look for packages"); QLabel *nameLabel = new QLabel("Name:"); QLineEdit *nameLineEdit = new QLineEdit; QLabel *dateLabel = new QLabel("Released after:"); QDateTimeEdit *dateEdit = new QDateTimeEdit(QDate::currentDate()); QCheckBox *releaseCheckBox = new QCheckBox("Releases"); QCheckBox *upgradesCheckBox = new QCheckBox("Upgrades"); QSpinBox *hitsSpinBox = new QSpinBox; hitsSpinBox->setPrefix("Return up to"); hitsSpinBox->setSuffix(" results"); hitsSpinBox->setSpecialValueText("Return only the first result"); hitsSpinBox->setMinimum(1); hitsSpinBox->setMaximum(100); hitsSpinBox->setSingleStep(10); QPushButton *startQueryButton = new QPushButton("Start query"); QGridLayout *packagesLayout = new QGridLayout; packagesLayout->addWidget(nameLabel, 0, 0); packagesLayout->addWidget(nameLineEdit, 0, 1); packagesLayout->addWidget(dateLabel, 1, 0); packagesLayout->addWidget(dateEdit, 1, 1); packagesLayout->addWidget(releaseCheckBox, 2, 0); packagesLayout->addWidget(upgradesCheckBox, 3, 0); packagesLayout->addWidget(hitsSpinBox, 4, 0, 1, 2); packagesGroup->setLayout(packagesLayout); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(packagesGroup); mainLayout->addSpacing(12); mainLayout->addWidget(startQueryButton); mainLayout->addStretch(1); setLayout(mainLayout); }
VPiano::VPiano() : QMainWindow() { QWidget *central = new QWidget(this); QVBoxLayout *vb = new QVBoxLayout; QHBoxLayout *octaves = new QHBoxLayout; QSignalMapper *octaveSignalMapper = new QSignalMapper(this); for(int i = 0; i < 9; i++) { QString title; title.setNum(i); QPushButton *o = new QPushButton(title, central); o->setFixedSize(fontMetrics().width(title)*4, o->height()); QString shortcut; shortcut.setNum(i+1); o->setShortcut(QKeySequence(QString("F") + shortcut)); octaves->addWidget(o); connect(o, SIGNAL(clicked()), octaveSignalMapper, SLOT(map())); octaveSignalMapper->setMapping(o, i); } OctaveRangeWidget *octRange = new OctaveRangeWidget(central); octaves->addWidget(octRange); QSlider *velocity = new QSlider(Qt::Horizontal, central); velocity->setMinimum(1); velocity->setMaximum(127); velocity->setValue(96); // TODO: read prev value from config velocity->setToolTip(tr("Velocity")); octaves->addWidget(velocity); QSpinBox *channel = new QSpinBox(central); channel->setPrefix(tr("Ch ", "Midi Channel number")); channel->setMinimum(0); channel->setMaximum(127); channel->setValue(0); // TODO: read prev value from config channel->setToolTip(tr("Select MIDI channel number to send messages to")); octaves->addWidget(channel); vb->addLayout(octaves); QHBoxLayout *keyarea = new QHBoxLayout; KeyboardWidget *kw = new KeyboardWidget(central); keyarea->addWidget(kw); QVBoxLayout *rightside = new QVBoxLayout; QSlider *pitchWheel = new QSlider(Qt::Vertical, central); pitchWheel->setMinimum(-64); pitchWheel->setMaximum(63); pitchWheel->setValue(0); // TODO: read prev value from config pitchWheel->setToolTip(tr("Pitch wheel")); rightside->addWidget(pitchWheel); QCheckBox *porta = new QCheckBox(central); porta->setToolTip(tr("Enable portamento")); rightside->addWidget(porta); keyarea->addLayout(rightside); vb->addLayout(keyarea); central->setLayout(vb); setCentralWidget(central); setWindowTitle(tr("Virtual MIDI keyboard")); // TODO: connect pitchWheel connect(octaveSignalMapper, SIGNAL(mapped(int)), kw, SLOT(octaveSelected(int))); connect(channel, SIGNAL(valueChanged(int)), kw, SLOT(midiChannelSelected(int))); connect(kw, SIGNAL(highlightOctaves(int,int)), octRange, SLOT(highlightOctaves(int,int))); kw->octaveSelected(0); // TODO: use value read from config }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { centralWidget = new QWidget(this); this->setCentralWidget(centralWidget); QHBoxLayout *mainLayout = new QHBoxLayout; QTableWidget* table = new QTableWidget(this); mainLayout->addWidget(table); table->setColumnCount(2); //table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); table->resize(20, table->height()); table->setBaseSize(20,20); canvas = new Canvas(this); // Main MenuBar menuBar = new QMenuBar(canvas); // File Menus QMenu* fileMenu = new QMenu("File"); QPixmap openPix("img/folder_picture.png"); QAction* open = new QAction(openPix, "&Open", this); fileMenu->addAction(open); fileMenu->addSeparator(); QPixmap savePix("img/disk.png"); QAction* save = new QAction(savePix, "&Save", this); fileMenu->addAction(save); QPixmap saveAsPix("img/disk_multiple.png"); QAction* saveAs = new QAction(saveAsPix, "&Save As", this); fileMenu->addAction(saveAs); fileMenu->addSeparator(); QPixmap quitPix("img/door_out.png"); QAction* quit = new QAction(quitPix, "&Quit", this); fileMenu->addAction(quit); // Edit Menu QMenu* editMenu = new QMenu("Edit"); QPixmap cutPix("img/cut.png"); QAction* cut = new QAction(cutPix, "&Cut", this); editMenu->addAction(cut); QPixmap copyPix("img/copy.png"); QAction* copy = new QAction(copyPix, "&Copy", this); editMenu->addAction(copy); QPixmap pastePix("img/paste.png"); QAction* paste = new QAction(pastePix, "&Paste", this); editMenu->addAction(paste); editMenu->addSeparator(); editMenu->addAction("Sprite"); editMenu->addAction("Animation"); // View Menus QMenu* viewMenu = new QMenu("View"); QPixmap gridPix("img/grid.png"); QAction* viewGrid = new QAction(gridPix, "&Grid", this); viewMenu->addAction(viewGrid); viewGrid->setCheckable(true); viewGrid->setChecked(true); QAction *viewSprite = viewMenu->addAction("Sprite"); viewSprite->setCheckable(true); viewSprite->setChecked(true); QAction *viewSymmetry = viewMenu->addAction("Symmetry Hints"); viewSymmetry->setCheckable(true); viewSymmetry->setChecked(true); viewMenu->addSeparator(); QPixmap zoomInPix("img/zoom_in.png"); QAction* zoomIn = new QAction(zoomInPix, "&Zoom In", this); viewMenu->addAction(zoomIn); QPixmap zoomOutPix("img/zoom_out.png"); QAction* zoomOut = new QAction(zoomOutPix, "&Zoom Out", this); viewMenu->addAction(zoomOut); QPixmap zoom100Pix("img/zoom.png"); QAction* zoom100 = new QAction(zoom100Pix, "&Actual Size", this); viewMenu->addAction(zoom100); // Help Menus QMenu* helpMenu = new QMenu("Help"); QPixmap aboutPix("img/star.png"); QAction* about = new QAction(aboutPix, "&About", this); helpMenu->addAction(about); menuBar->addMenu(fileMenu); menuBar->addMenu(editMenu); menuBar->addMenu(viewMenu); menuBar->addMenu(helpMenu); // ToolBar QToolBar* toolBar = new QToolBar(canvas); toolBar->addAction(open); toolBar->addSeparator(); toolBar->addAction(save); toolBar->addAction(saveAs); toolBar->addSeparator(); toolBar->addAction(cut); toolBar->addAction(copy); toolBar->addAction(paste); toolBar->addSeparator(); toolBar->addAction(viewGrid); toolBar->addSeparator(); QSpinBox* gridX = new QSpinBox(this); gridX->setPrefix("X: "); toolBar->addWidget(gridX); toolBar->addSeparator(); QSpinBox* gridY = new QSpinBox(this); gridY->setPrefix("Y: "); toolBar->addWidget(gridY); toolBar->addSeparator(); toolBar->addAction(zoomIn); toolBar->addAction(zoomOut); toolBar->addAction(zoom100); toolBar->addSeparator(); QDoubleSpinBox* speed = new QDoubleSpinBox(this); speed->setPrefix("Speed: "); speed->setDecimals(3); speed->setSingleStep(0.001); speed->setAccelerated(true); toolBar->addWidget(speed); mainLayout->addWidget(canvas); setMenuBar(menuBar); addToolBar(toolBar); toolBar->addSeparator(); QPixmap playPix("img/play.png"); QAction* play = new QAction(playPix, "&Play", this); toolBar->addAction(play); QPixmap pausePix("img/pause.png"); QAction* pause = new QAction(pausePix, "&Pause", this); toolBar->addAction(pause); QPixmap stopPix("img/stop.png"); QAction* stop = new QAction(stopPix, "&Stop", this); toolBar->addAction(stop); toolBar->addSeparator(); QSpinBox* frame = new QSpinBox(this); frame->setPrefix("Frame: "); toolBar->addWidget(frame); mainLayout->setMargin(0); centralWidget->setLayout(mainLayout); }
void CSVAtlasWindow::sMapChanged( int ) { CSVMap map; if(!_selectedMap.isEmpty()) { map = _atlas->map(_selectedMap); if(tr("Insert") == _action->currentText()) map.setAction(CSVMap::Insert); else if(tr("Update") == _action->currentText()) map.setAction(CSVMap::Update); else if(tr("Append") == _action->currentText()) map.setAction(CSVMap::Append); map.setDescription(_description->toPlainText()); map.setSqlPre(_preSql->toPlainText().trimmed()); map.setSqlPreContinueOnError(_sqlPreContinueOnError->isChecked()); map.setSqlPost(_postSql->toPlainText().trimmed()); for(int r = 0; r < _fields->rowCount(); r++) { CSVMapField field = map.field(_fields->item(r, 1)->data(Qt::EditRole).toString()); field.setName(_fields->item(r, 1)->data(Qt::EditRole).toString()); if (qobject_cast<QCheckBox*>(_fields->cellWidget(r, 0))) field.setIsKey(qobject_cast<QCheckBox*>(_fields->cellWidget(r,0))->isChecked()); else field.setIsKey(FALSE); field.setType(QVariant::nameToType(_fields->item(r, 2)->data(Qt::EditRole).toString().toAscii().data())); if (qobject_cast<QComboBox*>(_fields->cellWidget(r, 4))) field.setAction(CSVMapField::nameToAction(qobject_cast<QComboBox*>(_fields->cellWidget(r, 4))->currentText())); else field.setAction(CSVMapField::Action_Default); if (qobject_cast<QSpinBox*>(_fields->cellWidget(r, 5))) field.setColumn(qobject_cast<QSpinBox*>(_fields->cellWidget(r,5))->value()); else field.setColumn(0); if (qobject_cast<QComboBox*>(_fields->cellWidget(r, 6))) field.setIfNullAction(CSVMapField::nameToIfNull(qobject_cast<QComboBox*>(_fields->cellWidget(r, 6))->currentText())); else field.setIfNullAction(CSVMapField::Nothing); if (qobject_cast<QSpinBox*>(_fields->cellWidget(r, 7))) field.setColumnAlt(qobject_cast<QSpinBox*>(_fields->cellWidget(r, 7))->value()); else field.setColumnAlt(1); if (qobject_cast<QComboBox*>(_fields->cellWidget(r, 8))) field.setIfNullActionAlt(CSVMapField::nameToIfNull(qobject_cast<QComboBox*>(_fields->cellWidget(r, 8))->currentText())); else field.setIfNullActionAlt(CSVMapField::Nothing); field.setValueAlt(_fields->item(r, 9)->data(Qt::EditRole).toString()); map.setField(field); } map.simplify(); _atlas->setMap(map); } QSqlDatabase db = QSqlDatabase::database(); if (db.isValid()) { _fields->setRowCount(0); if(_map->count() && ! _map->currentText().isEmpty()) { // CODE TO SELECT MAP _selectedMap = _map->currentText(); map = _atlas->map(_selectedMap); _table->setTitle(tr("Table: ") + map.table()); _table->setEnabled(TRUE); _action->setCurrentIndex(map.action()); _description->setText(map.description()); _preSql->setText(map.sqlPre()); _sqlPreContinueOnError->setChecked(map.sqlPreContinueOnError()); _postSql->setText(map.sqlPost()); QSqlRecord record = db.record(map.table()); QStringList fieldnames; if (record.isEmpty()) { _msghandler->message(QtWarningMsg, tr("No Existing Table"), tr("<p>The table %1 does not exist in this " "database. You may continue to use and edit " "this map but only those fields that are known " "will be shown.").arg(map.table()), QUrl(), QSourceLocation()); fieldnames = map.fieldList(); } else { QStringList fList = map.fieldList(); for(int i = 0; i < fList.size(); ++i) { CSVMapField f = map.field(fList.at(i)); if(!record.contains(fList.at(i))) { map.removeField(fList.at(i)); MissingField diag(this, f.name(), record); if(diag.exec() == QDialog::Accepted) { f.setName(diag._fields->currentText()); map.setField(f); } _atlas->setMap(map); } } for (int i = 0; i < record.count(); i++) fieldnames.append(record.fieldName(i)); } _fields->setRowCount(fieldnames.size()); for(int row = 0; row < fieldnames.size(); ++row) { CSVMapField mf = map.field(fieldnames.at(row)); QCheckBox *check = new QCheckBox(_fields); if(!mf.isEmpty()) check->setChecked(mf.isKey()); _fields->setCellWidget(row, 0, check); _fields->setItem(row, 1, new QTableWidgetItem(fieldnames.at(row))); if (record.isEmpty()) { _fields->setItem(row, 2, new QTableWidgetItem(QVariant::typeToName(mf.type()))); _fields->setItem(row, 3, new QTableWidgetItem(tr("Unknown"))); } else { _fields->setItem(row, 2, new QTableWidgetItem(QVariant::typeToName(record.field(row).type()))); _fields->setItem(row, 3, new QTableWidgetItem( (record.field(row).requiredStatus() == QSqlField::Required) ? tr("Yes") : (record.field(row).requiredStatus() == QSqlField::Optional) ? tr("No") : tr("Unknown"))); } QComboBox *actcombo = new QComboBox(_fields); actcombo->addItems(CSVMapField::actionList()); if (! mf.isEmpty()) actcombo->setCurrentIndex(mf.action()); _fields->setCellWidget(row, 4, actcombo); QSpinBox *colspinner = new QSpinBox(_fields); colspinner->setRange(1, 999); colspinner->setPrefix(tr("Column ")); if(!mf.isEmpty()) colspinner->setValue(mf.column()); _fields->setCellWidget(row, 5, colspinner); QComboBox *nullcombo = new QComboBox(_fields); nullcombo->addItems(CSVMapField::ifNullList()); if (! mf.isEmpty()) nullcombo->setCurrentIndex(mf.ifNullAction()); _fields->setCellWidget(row, 6, nullcombo); QSpinBox *altspinner = new QSpinBox(_fields); altspinner->setRange(1, 999); altspinner->setPrefix(tr("Column ")); if (! mf.isEmpty()) altspinner->setValue(mf.columnAlt()); _fields->setCellWidget(row, 7, altspinner); QComboBox *altnullcombo = new QComboBox(_fields); altnullcombo->addItems(CSVMapField::ifNullList(TRUE)); if (! mf.isEmpty()) altnullcombo->setCurrentIndex(mf.ifNullActionAlt()); _fields->setCellWidget(row, 8, altnullcombo); _fields->setItem(row, 9, new QTableWidgetItem(mf.valueAlt())); RowController *control = new RowController(_fields, row, colspinner); control->setAction(actcombo); control->setColumn(colspinner); control->setIfNull(nullcombo); control->setAltColumn(altspinner); control->setAltIfNull(altnullcombo); control->setAltValue(_fields->item(row, 9)); control->finishSetup(); } } else { _selectedMap = QString::null; _table->setTitle(tr("Table: ")); _table->setEnabled(FALSE); } } else _msghandler->message(QtCriticalMsg, tr("No Database"), tr("Could not get the database connection.")); }
void Window::createSpinBoxes() { /// \brief spinBoxesGroup /// /// spinBoxesGroup is used to contains spinBox. /// spinBoxesGroup = new QGroupBox(tr("Spinboxes")); QLabel *integerLabel = new QLabel(tr("Enter a value between %1 and %2:").arg(0).arg(1000)); QSpinBox *integerSpinBox = new QSpinBox; integerSpinBox->setRange(-20, 20); integerSpinBox->setSingleStep(1); integerSpinBox->setValue(0); QLabel *zoomLabel = new QLabel(tr("Enter a zoom value between %1 and %2:").arg(0).arg(1000)); QSpinBox *zoomSpinBox = new QSpinBox; zoomSpinBox->setRange(0, 1000); zoomSpinBox->setSingleStep(10); zoomSpinBox->setSuffix("%"); ///< a suffix zoomSpinBox->setSpecialValueText(tr("Automatic")); zoomSpinBox->setValue(100); QLabel *priceLabel = new QLabel(tr("Enter a price between %1 and %2:").arg(0).arg(999)); QSpinBox *priceSpinBox = new QSpinBox; priceSpinBox->setRange(0, 999); priceSpinBox->setPrefix("$"); priceSpinBox->setValue(99); QLabel *hexLabel = new QLabel(tr("Enter a value between %1 and %2:") .arg('-' + QString::number(31, 16)) .arg(QString::number(31, 16))); QSpinBox *hexSpinBox = new QSpinBox; hexSpinBox->setRange(-31, 31); hexSpinBox->setSingleStep(1); hexSpinBox->setDisplayIntegerBase(16); groupSeparatorSpinBox = new QSpinBox; groupSeparatorSpinBox->setRange(-9999999, 9999999); groupSeparatorSpinBox->setValue(1000); groupSeparatorSpinBox->setGroupSeparatorShown(true); QCheckBox *groupSeparatorChkBox = new QCheckBox; groupSeparatorChkBox->setText(tr("Show group separator")); groupSeparatorChkBox->setChecked(true); connect(groupSeparatorChkBox, &QCheckBox::toggled, groupSeparatorSpinBox, &QSpinBox::setGroupSeparatorShown); QVBoxLayout *spinBoxLayout = new QVBoxLayout; spinBoxLayout->addWidget(integerLabel); spinBoxLayout->addWidget(integerSpinBox); spinBoxLayout->addWidget(zoomLabel); spinBoxLayout->addWidget(zoomSpinBox); spinBoxLayout->addWidget(priceLabel); spinBoxLayout->addWidget(priceSpinBox); spinBoxLayout->addWidget(hexLabel); spinBoxLayout->addWidget(hexSpinBox); spinBoxLayout->addWidget(groupSeparatorChkBox); spinBoxLayout->addWidget(groupSeparatorSpinBox); spinBoxesGroup->setLayout(spinBoxLayout); }