void CellWidget::setLayoutItems(int num) { QVBoxLayout* layout = (QVBoxLayout*) this->layout(); if(m_numLayoutItems < num) { m_checkers.resize(num); m_editors.resize(num); for(int i = m_numLayoutItems; i < num; i++) { QCheckBox* checker = new QCheckBox(); QTextEdit* editor = new QTextEdit(); editor->setReadOnly(true); editor->setFixedHeight(20); editor->setFixedWidth(120); QHBoxLayout* child_layout = new QHBoxLayout(); child_layout->addWidget(checker); child_layout->addWidget(editor); layout->addLayout(child_layout); m_checkers[i] = checker; m_editors[i] = editor; } } else if(m_numLayoutItems > num) { for(int i = num ; i < m_numLayoutItems; i++) { m_checkers[i]->setHidden(true); //m_checkers[i]->setChecked(false); m_editors[i]->setHidden(true); } } m_numLayoutItems = num; }
InfoPanel::InfoPanel(QWidget *parent) :QWidget(parent) { #ifdef K_DEBUG #ifdef Q_OS_WIN qDebug() << "[InfoPanel()]"; #else TINIT; #endif #endif QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom); QLabel *label = new QLabel(tr("Tips")); label->setAlignment(Qt::AlignHCenter); layout->addWidget(label); mainLayout->addLayout(layout); QTextEdit *textArea = new QTextEdit; textArea->setFixedHeight(250); textArea->setHtml("<p><b>" + tr("X Key or Right Mouse Button") + ":</b> " + tr("Close line") + "</p>"); mainLayout->addWidget(textArea); mainLayout->addStretch(2); }
ZoomConfigurator::ZoomConfigurator(QWidget *parent) :QWidget(parent) { #ifdef K_DEBUG #ifdef Q_OS_WIN32 qDebug() << "[ZoomConfigurator()]"; #else TINIT; #endif #endif QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom); scale = new QLabel(tr("Scale Factor")); scale->setFont(QFont("Arial", 8, QFont::Normal, false)); scale->setAlignment(Qt::AlignHCenter); layout->addWidget(scale); factor = new QDoubleSpinBox(); factor->setDecimals(1); factor->setSingleStep(0.1); factor->setMinimum(0.1); factor->setMaximum(0.9); layout->addWidget(factor); QLabel *label = new QLabel(tr("Tips")); label->setAlignment(Qt::AlignHCenter); label->setFont(QFont("Arial", 8, QFont::Normal, false)); QTextEdit *textArea = new QTextEdit; textArea->setFont(QFont("Arial", 8, QFont::Normal, false)); textArea->setHtml("<p><b>" + tr("Zoom Square mode") + ":</b> " + tr("Press Ctrl key + Mouse left button") + "</p>"); QString text = textArea->document()->toPlainText(); int height = (text.length()*270)/207; textArea->setFixedHeight(height); mainLayout->addLayout(layout); mainLayout->addWidget(label); mainLayout->addWidget(textArea); mainLayout->addStretch(2); TCONFIG->beginGroup("ZoomTool"); double value = TCONFIG->value("zoomFactor", -1).toDouble(); if (value > 0) factor->setValue(value); else factor->setValue(0.5); }
void TextZone::createThumbnail() { QWidget *w = QApplication::focusWidget(); if(w){ // pixmap.fill( Qt::white ); // QPainter painter( &pixmap ); // painter.setPen( Qt::black ); //// rect.translate( 0, rect.height()+10 ); //// rect.setHeight( 160 ); // doc.setTextWidth( rect.width() ); // painter.save(); // painter.translate( rect.topLeft() ); // doc.drawContents( &painter, rect.translated( -rect.topLeft() ) ); // painter.restore(); // rect.setHeight( textDocument.size().height()-160 ); // painter.setBrush( Qt::gray ); // painter.drawRect( rect ); // pixmap.save( "text.png" ); QTextEdit tempEdit; tempEdit.setDocument(textDocument); tempEdit.setFixedHeight(textDocument->size().height()); tempEdit.setFixedWidth(textDocument->textWidth()); #if QT_VERSION < 0x050000 QPixmap thumbnail = QPixmap::grabWidget(&tempEdit); #endif #if QT_VERSION >= 0x050000 QPixmap thumbnail = tempEdit.grab(); #endif emit textThumbnailSignal(thumbnail); } }
void DialogEditor::addItem() { int itemCount = ui->treeWidget->topLevelItemCount(); QTreeWidgetItem* item = new QTreeWidgetItem(QTreeWidgetItem::Type); item->setText(0, "Dialog_"+QString::number(itemCount)); ui->treeWidget->addTopLevelItem(item); QTextEdit* dialog = new QTextEdit(); dialog->setFixedHeight(60); ui->treeWidget->setItemWidget(item, 2, dialog); QComboBox* cb = new QComboBox(); cb->addItem("Message"); cb->addItem("Start Quest"); cb->addItem("Sell Item"); cb->addItem("End"); ui->treeWidget->setItemWidget(item, 1, cb); }
void myTextEdit::textAreaChanged() { QTextDocument *document = qobject_cast<QTextDocument*>(sender()); if (document) { QTextEdit *editor = qobject_cast<QTextEdit*>(document->parent()->parent()); if (editor) { int newheight = document->size().rheight(); if (newheight != editor->height()) { editor->setFixedHeight(newheight+5); this->setFixedHeight(newheight); } } } }
GenericStep::GenericStep( bool isInput_in, QString ID_in, vector<StepGenericElement*> elements_in, QWidget *parent) : QWidget(parent) { ui.setupUi(this); inputStep = isInput_in; ID = ID_in; QVBoxLayout * mainLayout = new QVBoxLayout(); StepGenericElement * currentElement; //Loop through the elements for(int i = 0; i<elements_in.size(); i++){ currentElement = elements_in.at(i); if(currentElement != 0){ //Check the type of element switch(currentElement->getElementName()){ case TEXT: Text * textElement = dynamic_cast<Text*>(currentElement); //Generating area where to insert the text QScrollArea * scrollArea = new QScrollArea(); scrollArea->setWidgetResizable(true); //if(textElement->getWidth() != 0) //scrollArea->setFixedWidth(textElement->getWidth()); //if(textElement->getRows() != 0) //scrollArea->setFixedHeight(textElement->getRows()); QLabel *description = new QLabel(textElement->getContent(), this); description->setWordWrap(true); description->setAlignment(Qt::AlignJustify); scrollArea->setWidget(description); mainLayout->addWidget(scrollArea); break; case INPUTFIELD: Input * inputElement = dynamic_cast<Input*>(currentElement); //Generating a gridlayout where to put both the label and the field QGridLayout * inputContainerLayout = new QGridLayout(this); QWidget * inputContainer = new QWidget(this); QLabel * inputLabel = new QLabel(inputElement->getLabel(),this); QTextEdit * inputText = new QTextEdit(inputElement->getContent(),this); inputText->setObjectName(inputElement->getId()); inputElements.push_back(inputText); if(inputElement->getWidth() != 0) inputText->setFixedHeight(inputElement->getWidth()); if(inputElement->getRows() != 0) inputText->setFixedHeight(inputElement->getRows()*20); switch(inputElement->getPos()){ case UP: inputContainerLayout->addWidget(inputLabel,0,0); inputContainerLayout->addWidget(inputText,1,0); break; case DOWN: inputContainerLayout->addWidget(inputLabel,1,0); inputContainerLayout->addWidget(inputText,0,0); break; case LEFT: inputContainerLayout->addWidget(inputLabel,0,0); inputContainerLayout->addWidget(inputText,0,1); break; case RIGHT: inputContainerLayout->addWidget(inputLabel,0,1); inputContainerLayout->addWidget(inputText,0,0); break; default : break; } inputContainer->setLayout(inputContainerLayout); inputContainerLayout->setVerticalSpacing(1); mainLayout->addWidget(inputContainer); break; case IMAGE: /* TODO: Given an Image element, this part of the code should * renderize a box (as big as width and height attributes say) * containing the image. The base64 encoding of the image is given * by the content of the element. Probably the most part of the times * this functionality won't be required. The important thing to do * is to renderize a button to snap the photo. */ break; case RECORDING: /* TODO: * The stuff to do is exactly the same then the one of the image. The only * differenze is that you have to renderize a "record","play","pause" button * to interact with the mobile recorder. */ break; case SELECT: Select * selectElement = dynamic_cast<Select*>(currentElement); QButtonGroup * radioGroup = new QButtonGroup(); radioGroup->setExclusive(selectElement->isMutex()); for(int j = 0; j < selectElement->getOptions().size(); j++){ Select::Option optionElement = selectElement->getOption(j); QRadioButton * option = new QRadioButton(optionElement.getContent(), this); option->setChecked(optionElement.isSelected()); //The object name is eventually used to retrive the object reference //(During the saving process). //So the ID in the configuration file MUST be unique. option->setObjectName(optionElement.getId()); inputElements.push_back(option); radioGroup->addButton(option); mainLayout->addWidget(option); } break; default: //TODO: handle exception break; } } } this->setLayout(mainLayout); this->resize(400,600); }
Configurator::Configurator(QWidget *parent) :QWidget(parent) { #ifdef K_DEBUG TINIT; #endif QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); QTextEdit *textArea = new QTextEdit; textArea->setFixedHeight(170); textArea->setHtml("<p>" + tr("This tool is just a <b>proof-of-concept</b> of the basic algorithm for the Tupi's free-tracing vectorial brushes") + "</p>"); mainLayout->addWidget(textArea); QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom); QLabel *label = new QLabel(tr("Parameters")); label->setAlignment(Qt::AlignHCenter); layout->addWidget(label); mainLayout->addLayout(layout); QBoxLayout *structureLayout = new QBoxLayout(QBoxLayout::TopToBottom); QLabel *structureLabel = new QLabel(tr("Structure")); structureLabel->setAlignment(Qt::AlignHCenter); structureLayout->addWidget(structureLabel); structureCombo = new QComboBox(); structureCombo->addItem(tr("Basic")); structureCombo->addItem(tr("Axial")); structureCombo->addItem(tr("Organic")); structureCombo->setCurrentIndex(2); structureLayout->addWidget(structureCombo); mainLayout->addLayout(structureLayout); QBoxLayout *spaceLayout = new QBoxLayout(QBoxLayout::TopToBottom); QLabel *spaceLabel = new QLabel(tr("Dot Spacing")); spaceLabel->setAlignment(Qt::AlignHCenter); spaceLayout->addWidget(spaceLabel); spacingBox = new QSpinBox(); spacingBox->setSingleStep(1); spacingBox->setMinimum(1); spacingBox->setMaximum(10); spacingBox->setValue(2); spaceLayout->addWidget(spacingBox); connect(spacingBox, SIGNAL(valueChanged(int)), this, SIGNAL(updateSpacing(int))); mainLayout->addLayout(spaceLayout); QBoxLayout *sizeLayout = new QBoxLayout(QBoxLayout::TopToBottom); QLabel *sizeLabel = new QLabel(tr("Size Tolerance")); sizeLabel->setAlignment(Qt::AlignHCenter); sizeLayout->addWidget(sizeLabel); sizeBox = new QSpinBox(); sizeBox->setSingleStep(10); sizeBox->setMinimum(0); sizeBox->setMaximum(200); sizeBox->setValue(0); sizeLayout->addWidget(sizeBox); connect(sizeBox, SIGNAL(valueChanged(int)), this, SIGNAL(updateSizeTolerance(int))); mainLayout->addLayout(sizeLayout); QBoxLayout *checkLayout = new QBoxLayout(QBoxLayout::TopToBottom); checkBox = new QCheckBox(tr("Run simulation")); checkLayout->addWidget(checkBox); connect(checkBox, SIGNAL(stateChanged(int)), this, SLOT(updateInterface(int))); mainLayout->addLayout(checkLayout); QBoxLayout *smoothLayout = new QBoxLayout(QBoxLayout::TopToBottom); QLabel *smoothLabel = new QLabel(tr("Smoothness")); smoothLabel->setAlignment(Qt::AlignHCenter); smoothLayout->addWidget(smoothLabel); smoothBox = new QDoubleSpinBox(); smoothBox->setValue(2.0); smoothBox->setDecimals(2); smoothBox->setSingleStep(0.1); smoothBox->setMaximum(100); smoothLayout->addWidget(smoothBox); mainLayout->addLayout(smoothLayout); smoothBox->setDisabled(true); mainLayout->addStretch(2); }