void Profile::setLabel() { QLabel *item; QProgressBar *bar; bar = this->findChild<QProgressBar *>("LifeBar"); bar->setValue(_hero->getLife()); bar->setMaximum(_hero->getLifeMax()); bar = this->findChild<QProgressBar *>("ManaBar"); bar->setValue(_hero->getMana()); bar->setMaximum(_hero->getManaMax()); item = this->findChild<QLabel *>("Name"); item->setText(QString::fromStdString(_hero->getName())); item = this->findChild<QLabel *>("RaceClass"); item->setText(QString::fromStdString(SRace[static_cast<uint>(_hero->getRace())]) + " " + QString::fromStdString(SClass[static_cast<uint>(_hero->getClass())])); item = this->findChild<QLabel *>("Lvl"); item->setText("Lvl " + QString::number(_hero->getLvl())); item = this->findChild<QLabel *>("Agility"); item->setText("Agility : " + QString::number(_hero->getAgility())); item = this->findChild<QLabel *>("Intellect"); item->setText("Intellect : " + QString::number(_hero->getIntellect())); item = this->findChild<QLabel *>("Stamina"); item->setText("Stamina : " + QString::number(_hero->getStamina())); item = this->findChild<QLabel *>("Strength"); item->setText("Strength : " + QString::number(_hero->getStrength())); /* int fd = open("/Users/Arnaud/totoHero.txt", O_RDWR); int d = write(fd, reinterpret_cast<void *>(_hero), sizeof(KiwiHero)); int size = sizeof(KiwiHero); KiwiHero *test = new KiwiHero(); int n = read(fd, test, size); qDebug() << "Race is : " << QString::fromStdString(test->getName()) << d << n; delete test; ::close(fd); */ /* QFile file; QDir::setCurrent("/Users/Arnaud"); file.setFileName("totoHero.txt"); if (!(file.open(QIODevice::ReadWrite | QIODevice::Truncate))) qDebug() << "open failed"; else qDebug() << "open success"; QDataStream out(&file); out.writeBytes(reinterpret_cast<const char *>(_hero), sizeof(KiwiHero)); KiwiHero *test = new KiwiHero(); QByteArray line = file.readLine(); qDebug() << line; //qDebug() << "Race is : " << QString::toStdString(SRace[static_cast<uint>(test->getRace())]); delete test; */ }
void TelechargerFichier::finTelechargement() { QNetworkReply *reponse; reponse = qobject_cast<QNetworkReply *>(sender()); QPushButton *bouton = qobject_cast<QPushButton *>(listeTelechargements->cellWidget(reponses.indexOf(reponse), 0)); bouton->setDisabled(true); QProgressBar *progression = progressionsTelechargements.value(reponses.indexOf(reponse)); progression->setMaximum(100); progression->setValue(100); listeTelechargements->item(reponses.indexOf(reponse), 3)->setText("Transfert terminé"); QString nomFichier = nomsFichiers.value(reponses.indexOf(reponse)); QSettings emplacementDossier(Multiuso::appDirPath() + "/ini/config.ini", QSettings::IniFormat); QDir dir; dir.mkpath(emplacementDossier.value("telechargements/dossier").toString() + "/Multiuso - Téléchargements"); QFile fichier(emplacementDossier.value("telechargements/dossier").toString() + "/Multiuso - Téléchargements/" + nomFichier); fichier.open(QIODevice::WriteOnly | QIODevice::Truncate); fichier.write(reponse->readAll()); fichier.close(); }
void ProfileWizard::createProfile(int result) { if (_profile_edit->isComplete() ) { bts::profile_config conf; conf.firstname = _profile_edit->ui.first_name->text().toUtf8().constData(); conf.firstname = fc::trim( conf.firstname ); conf.middlename = _profile_edit->ui.middle_name->text().toUtf8().constData(); conf.middlename = fc::trim( conf.middlename ); conf.lastname = _profile_edit->ui.last_name->text().toUtf8().constData(); conf.lastname = fc::trim( conf.lastname ); conf.brainkey = _profile_edit->ui.brainkey->text().toUtf8().constData(); conf.brainkey = fc::trim( conf.brainkey ); std::string password = _profile_edit->ui.local_password1->text().toUtf8().constData(); std::string profile_name = conf.firstname + " " + conf.lastname; auto app = bts::application::instance(); fc::thread* main_thread = &fc::thread::current(); QProgressBar* progress = new QProgressBar(); progress->setWindowTitle( "Creating Profile" ); progress->setMaximum(1000); progress->resize( 640, 20 ); progress->show(); auto profile = app->create_profile(profile_name, conf, password, [=]( double p ) { main_thread->async( [=](){ progress->setValue( 1000*p ); qApp->sendPostedEvents(); qApp->processEvents(); if( p >= 1.0 ) progress->deleteLater(); } ).wait(); } ); assert(profile != nullptr); //store myself as contact /* std::string dac_id_string = _nym_page->_profile_nym_ui.keyhotee_id->text().toStdString(); bts::addressbook::wallet_contact myself; myself.wallet_index = 0; myself.first_name = conf.firstname; myself.last_name = conf.lastname; myself.set_dac_id(dac_id_string); auto priv_key = profile->get_keychain().get_identity_key(myself.dac_id_string); myself.public_key = priv_key.get_public_key(); profile->get_addressbook()->store_contact(myself); //store myself as identity bts::addressbook::wallet_identity new_identity; static_cast<bts::addressbook::contact&>(new_identity) = myself; profile->store_identity(new_identity); bts::application::instance()->add_receive_key(priv_key); */ _mainApp.displayMainWindow(); } }
KRPleaseWait::KRPleaseWait(QString msg, QWidget *parent, int count, bool cancel): QProgressDialog(cancel ? 0 : parent) , inc(true) { setModal(!cancel); timer = new QTimer(this); setWindowTitle(i18n("Krusader::Wait")); setMinimumDuration(500); setAutoClose(false); setAutoReset(false); connect(timer, SIGNAL(timeout()), this, SLOT(cycleProgress())); QProgressBar* progress = new QProgressBar(this); progress->setMaximum(count); progress->setMinimum(0); setBar(progress); QLabel* label = new QLabel(this); setLabel(label); QPushButton* btn = new QPushButton(i18n("&Cancel"), this); setCancelButton(btn); btn->setEnabled(canClose = cancel); setLabelText(msg); show(); }
QProgressBar* USNavigation::CreateRangeMeter(int i) { mitk::DataNode::Pointer zone = m_Zones.at(i); float zoneColor[3]; bool success = m_Zones.at(i)->GetColor(zoneColor); QString zoneColorString = "#555555"; if (success) { QString zoneColorString = QString("#%1%2%3").arg(static_cast<unsigned int>(zoneColor[0]*255), 2, 16, QChar('0')) .arg(static_cast<unsigned int>(zoneColor[1]*255), 2, 16, QChar('0')).arg(static_cast<unsigned int>(zoneColor[2]*255), 2, 16, QChar('0')); } QProgressBar* meter = new QProgressBar(); meter->setMinimum(0); meter->setMaximum(100); meter->setValue(0); QString zoneName = zone->GetName().c_str(); meter->setFormat(zoneName + ": No Data"); QString style = m_RangeMeterStyle; style = style.replace("#StartColor#", zoneColorString); style = style.replace("#StopColor#", zoneColorString); meter->setStyleSheet(style); meter->setVisible(true); return meter; }
void ArchiveList::fillPartialArchiveItem(PartialArchive *a, QTreeWidgetItem *item) { QTreeWidgetItem *subItem = new QTreeWidgetItem(item); QPushButton *pauseButton = new QPushButton(); pauseButton->setText(a->isDownloading() ? tr("Pause") : tr("Continue")); connect(pauseButton, SIGNAL(clicked()), a, SLOT(togglePauseDownload())); downloadPausedMapper->setMapping(a, pauseButton); downloadStartedMapper->setMapping(a, pauseButton); connect(a, SIGNAL(downloadStarted()), downloadStartedMapper, SLOT(map())); connect(a, SIGNAL(downloadPaused()), downloadPausedMapper, SLOT(map())); int pbarColumn; if (compactLayout) { pbarColumn = 1; subItem->setSizeHint(1, pauseButton->sizeHint()); setItemWidget(subItem, 1, pauseButton); QPushButton *detailsButton = new QPushButton(tr("Details")); showDetailsMapper->setMapping(detailsButton, a); connect(detailsButton, SIGNAL(clicked()), showDetailsMapper, SLOT(map())); subItem->setSizeHint(0, detailsButton->sizeHint()); setItemWidget(subItem, 0, detailsButton); } else { pbarColumn = 2; item->setSizeHint(3, pauseButton->sizeHint()); setItemWidget(item, 3, pauseButton); item->setText(1, a->getSizeMB()); QLabel *peerInfo = new QLabel(); subItem->setSizeHint(1, peerInfo->sizeHint()); setItemWidget(subItem, 1, peerInfo); connect(a, SIGNAL(peerInfoUpdated(QString)), peerInfo, SLOT(setText(QString))); QLabel *speedText = new QLabel(); subItem->setSizeHint(2, speedText->sizeHint()); setItemWidget(subItem, 2, speedText); connect(a, SIGNAL(speedTextUpdated(QString)), speedText, SLOT(setText(QString))); QLabel *statusText = new QLabel(); subItem->setSizeHint(3, statusText->sizeHint()); setItemWidget(subItem, 3, statusText); connect(a, SIGNAL(statusTextUpdated(QString)), statusText, SLOT(setText(QString))); } QProgressBar *pbar = new QProgressBar(); pbar->setMinimum(0); pbar->setMaximum(100); item->setSizeHint(pbarColumn, pbar->sizeHint()); setItemWidget(item, pbarColumn, pbar); connect(a, SIGNAL(progressUpdated(int)), pbar, SLOT(setValue(int))); a->emitStatusEvents(); }
bool downloadTracksFromOSM(QWidget* Main, const QString& aWeb, const QString& aUser, const QString& aPassword, const CoordBox& aBox , Document* theDocument) { Downloader theDownloader(aUser, aPassword); QList<TrackLayer*> theTracklayers; //TrackMapLayer* trackLayer = new TrackMapLayer(QApplication::translate("Downloader","Downloaded tracks")); //theDocument->add(trackLayer); IProgressWindow* aProgressWindow = dynamic_cast<IProgressWindow*>(Main); if (!aProgressWindow) return false; QProgressDialog* dlg = aProgressWindow->getProgressDialog(); dlg->setWindowTitle(QApplication::translate("Downloader","Parsing...")); QProgressBar* Bar = aProgressWindow->getProgressBar(); Bar->setTextVisible(false); Bar->setMaximum(11); QLabel* Lbl = aProgressWindow->getProgressLabel(); Lbl->setText(QApplication::translate("Downloader","Parsing XML")); if (dlg) dlg->show(); theDownloader.setAnimator(dlg,Lbl,Bar,true); for (int Page=0; ;++Page) { Lbl->setText(QApplication::translate("Downloader","Downloading trackpoints %1-%2").arg(Page*5000+1).arg(Page*5000+5000)); QString URL = theDownloader.getURLToTrackPoints(); URL = URL.arg(aBox.bottomLeft().x()). arg(aBox.bottomLeft().y()). arg(aBox.topRight().x()). arg(aBox.topRight().y()). arg(Page); QUrl theUrl(aWeb+URL); if (!theDownloader.go(theUrl)) return false; if (theDownloader.resultCode() != 200) return false; int Before = theTracklayers.size(); QByteArray Ar(theDownloader.content()); bool OK = importGPX(Main, Ar, theDocument, theTracklayers, true); if (!OK) return false; if (Before == theTracklayers.size()) break; theTracklayers[theTracklayers.size()-1]->setName(QApplication::translate("Downloader", "Downloaded track - nodes %1-%2").arg(Page*5000+1).arg(Page*5000+5000)); } return true; }
void Progression::addCopy(QString src, QString){ QLabel * label = new QLabel(src, this); label->setObjectName(src); label->setMaximumSize(780, 30); label->setGeometry(label->x(), label->y(), 780, label->height()); QProgressBar * prog = new QProgressBar(this); prog->setObjectName(src); prog->setMaximum(QFile(src).size()); vbl->addWidget(label); vbl->addWidget(prog); ProgressBars[label->text()] = prog; qDebug() << label->text(); this->adjustSize(); }
void ProgressBarDuo::setMax(int max, int n) { QProgressBar *p = 0; switch(n) { case 0: p = ui->Bar0; break; case 1: p = ui->Bar1; break; default: break; } if(p) p->setMaximum(max); }
QProgressBar* medDoubleParameterPresenter::buildProgressBar() { QProgressBar *progressBar = new QProgressBar; progressBar->setValue(_percentFromValue(d->parameter->value())); connect(this, &medDoubleParameterPresenter::valueChanged,progressBar, &QProgressBar::setValue); progressBar->setToolTip(d->parameter->description()); this->_connectWidget(progressBar); progressBar->setMinimum(0); progressBar->setMaximum(100); return progressBar; }
void ImageViewer::progressDialog() { QDialog *dialog = new QDialog(this); dialog->setModal(false); dialog->setFixedSize(QSize(700, 400)); QGridLayout *dialogLayout = new QGridLayout(dialog); dialogLayout->setAlignment(Qt::AlignCenter); dialogLayout->addWidget(new QLabel("Generating Thumbnail", dialog)); QProgressBar *progress = new QProgressBar(dialog); progress->setMaximum(100); progress->setValue(0); connect(this, SIGNAL(setProgress(int)), progress, SLOT(setValue(int))); dialogLayout->addWidget(progress); dialog->setLayout(dialogLayout); dialog->show(); }
void TelechargerFichier::telechargementContinue(qint64 recu, qint64 total) { QNetworkReply *reponse; reponse = qobject_cast<QNetworkReply *>(sender()); QProgressBar *progression = progressionsTelechargements.value(reponses.indexOf(reponse)); listeTelechargements->item(reponses.indexOf(reponse), 3)->setText("Transfert en cours..."); if (total != -1) { progression->setMaximum(total); progression->setValue(recu); } }
void UUpdateWidget::slot_showUpdatesTable(UUpdatesModel *model) { if (model->rowCount() == 0) { qDebug() << "there is no updates"; QMessageBox::information(this, tr("Nanomite updater"), tr("There is no updates")); m_stackedWidget->setCurrentIndex(0); m_toolBarActions.at(eINSTALL_UPDATES_ACTION)->setEnabled(false); m_toolBarActions.at(eCHECK_UPDATES_ACTION)->setEnabled(true); return; } // create folder for updates QDir currDir(QDir::currentPath()); QString createdFolder = currDir.currentPath() + "/updates"; currDir.mkdir(createdFolder); currDir.setCurrent(createdFolder); // end of creating folder for updates m_updatesTableView->setModel(model); m_progressBarList.clear(); QProgressBar *progressBar; for (int i = 0; i < model->rowCount(); i++) { progressBar = new QProgressBar(m_updatesTableView); progressBar->setTextVisible(false); progressBar->setMinimum(0); progressBar->setMaximum(0); m_progressBarList.append(progressBar); m_updatesTableView->setIndexWidget(model->index(i, UUpdatesModel::eSTATUS), m_progressBarList.last()); } m_updatesTableView->resizeColumnsToContents(); m_stackedWidget->setCurrentIndex(2); m_toolBarActions.at(eINSTALL_UPDATES_ACTION)->setEnabled(true); m_toolBarActions.at(eCHECK_UPDATES_ACTION)->setEnabled(false); }
void ProgressTree2::fillItem(QTreeWidgetItem* item, Job* job) { item->setText(0, job->getTitle().isEmpty() ? "-" : job->getTitle()); QProgressBar* pb = new QProgressBar(this); pb->setMaximum(10000); setItemWidget(item, 3, pb); CancelPushButton* cancel = new CancelPushButton(this); cancel->setText(QObject::tr("Cancel")); cancel->item = item; connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); setItemWidget(item, 4, cancel); item->setData(0, Qt::UserRole, qVariantFromValue((void*) job)); }
QgsBusyIndicatorDialog::QgsBusyIndicatorDialog( const QString &message, QWidget *parent, Qt::WindowFlags fl ) : QDialog( parent, fl ) , mMessage( QString( message ) ) { setWindowTitle( tr( "QGIS" ) ); setLayout( new QVBoxLayout() ); setWindowModality( Qt::WindowModal ); setMinimumWidth( 250 ); mMsgLabel = new QLabel( mMessage ); layout()->addWidget( mMsgLabel ); QProgressBar *pb = new QProgressBar(); pb->setMaximum( 0 ); // show as busy indicator layout()->addWidget( pb ); if ( mMessage.isEmpty() ) { mMsgLabel->hide(); } }
void Joysticks::setupIndicators (int row) { /* Remove all joystick indicators in the widget */ foreach (QSpinBox * b, findChildren<QSpinBox*>()) delete b; foreach (QPushButton * c, findChildren<QPushButton*>()) delete c; foreach (QProgressBar * p, findChildren<QProgressBar*>()) delete p; /* Clear joystick data */ m_axes.clear(); m_povs.clear(); m_buttons.clear(); /* Avoid crashing the application when there are no joysticks */ if (row < 0) return; /* Get joystick information */ int povCount = JOYSTICK_MANAGER()->getInputDevice (row).numPOVs; int axisCount = JOYSTICK_MANAGER()->getInputDevice (row).numAxes; int buttonCount = JOYSTICK_MANAGER()->getInputDevice (row).numButtons; /* Make the indicator containers visible */ m_POVIndicators->setVisible (povCount > 0); m_axisIndicators->setVisible (axisCount > 0); m_buttonIndicators->setVisible (buttonCount > 0); /* Create a progress bar for each axis */ for (int i = 0; i < axisCount; ++i) { QProgressBar* bar = new QProgressBar (this); bar->setFixedHeight (DPI_SCALE (19)); bar->setValue (0); bar->setMaximum (100); bar->setMinimum (-100); bar->setFormat (tr ("Axis %1").arg (i)); m_axes.append (bar); m_axesBox->addWidget (bar); } /* Create a button for each joystick button */ for (int i = 0; i < buttonCount; ++i) { QPushButton* button = new QPushButton (this); button->setEnabled (false); button->setCheckable (true); button->setFixedSize (DPI_SCALE (18), DPI_SCALE (12)); button->setToolTip (tr ("Button %1").arg (i)); /* Distribute the button items in a nice layout */ int row = (i <= 7) ? i : i - 8; int column = (i <= 7) ? 0 : (i / 8); m_buttons.append (button); m_buttonsBox->addWidget (button, row, column); } /* Create a spinbox for each joystick hat */ for (int i = 0; i < povCount; ++i) { QSpinBox* box = new QSpinBox (this); box->setRange (0, 360); box->setEnabled (false); m_povs.append (box); m_povsBox->addWidget (box); } }
void HistoryProgressBar::setTotalSteps(unsigned n) { m_bar->setMaximum(n); }
AppBarExamples::AppBarExamples(QWidget *parent) : QWidget(parent) { Progress *p = new Progress; p->setProgressType(Material::IndeterminateProgress); p->setMinimum(0); p->setMaximum(99); p->setValue(22); QVBoxLayout *l = new QVBoxLayout; setLayout(l); l->addStretch(1); l->addWidget(p); CircularProgress *cp = new CircularProgress; cp->setProgressType(Material::IndeterminateProgress); cp->setMinimum(0); cp->setMaximum(99); cp->setValue(90); l->addWidget(cp); QProgressBar *pb = new QProgressBar; pb->setMinimum(0); pb->setMaximum(99); pb->setValue(50); QPushButton *b = new QPushButton; l->addWidget(b); l->addWidget(pb); /* QLayout *mainLayout = widget()->layout(); { QWidget *widget = new QWidget; QVBoxLayout *layout = new QVBoxLayout; widget->setLayout(layout); AppBar *appBar = new AppBar; layout->addWidget(appBar); layout->addStretch(); layout->setContentsMargins(0, 0, 0, 0); QScrollArea *area = new QScrollArea; area->setWidget(widget); area->setWidgetResizable(true); area->setBackgroundRole(QPalette::Base); Frame *frame = new Frame; frame->setCodeSnippet( "QVBoxLayout *layout = new QVBoxLayout;\n" "AppBar *appBar = new AppBar;\n" "layout->addWidget(appBar);\n" "layout->addStretch();\n" "layout->setContentsMargins(0, 0, 0, 0);" ); frame->setWidget(area); mainLayout->addWidget(frame); } { QWidget *widget = new QWidget; QVBoxLayout *layout = new QVBoxLayout; widget->setLayout(layout); Progress *p = new Progress; Frame *frame = new Frame; frame->setCodeSnippet( "" ); frame->setWidget(p); mainLayout->addWidget(frame); } */ }
QTextDocument * Exporter::buildFinalDoc() { //search for checked items : QDomDocument domDoc = hub->project()->mainTreeDomDoc(); QDomElement root = domDoc.documentElement(); QList<QDomElement> itemList = searchForCheckedItems(root); if(itemList.size() == 0) return new QTextDocument(); // set up the progress bar : QWidget *progressWidget = new QWidget(this, Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); QHBoxLayout *progressLayout = new QHBoxLayout(progressWidget); QProgressBar *progressBar = new QProgressBar(progressWidget); int progressValue = 0; progressLayout->addWidget(progressBar); progressWidget->setLayout(progressLayout); progressBar->setMaximum(itemList.size()); progressBar->setValue(progressValue); progressWidget->show(); // QString debug; // qDebug() << "itemList" << debug.setNum(itemList->size()); QTextDocument *textDocument = new QTextDocument(this); QTextEdit *edit = new QTextEdit(this); textDocument->setDefaultStyleSheet("p, li { white-space: pre-wrap; } p{line-height: 2em; font-family:'Liberation Serif'; font-size:12pt;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:72px;}"); for(int i = 0; i < itemList.size(); ++i){ QDomElement element = itemList.at(i); QTextCursor *tCursor = new QTextCursor(textDocument); QTextBlockFormat blockFormatLeft; blockFormatLeft.setBottomMargin(0); blockFormatLeft.setTopMargin(0); blockFormatLeft.setTextIndent(72); blockFormatLeft.setLineHeight(200, QTextBlockFormat::ProportionalHeight); blockFormatLeft.setAlignment(Qt::AlignJustify); QTextCharFormat charFormatLeft; charFormatLeft.setFontPointSize(12); charFormatLeft.setFontFamily("Courrier"); QTextBlockFormat blockFormatCenter; blockFormatCenter.setAlignment(Qt::AlignCenter); if(element.tagName() != "separator"){ qDebug() << "element name : "+ element.attribute("name"); MainTextDocument *textDoc = hub->project()->findChild<MainTextDocument *>("textDoc_" + element.attribute("number")); MainTextDocument *synDoc = hub->project()->findChild<MainTextDocument *>("synDoc_" + element.attribute("number")); MainTextDocument *noteDoc = hub->project()->findChild<MainTextDocument *>("noteDoc_" + element.attribute("number")); QTextDocumentFragment textFrag(prepareTextDoc(textDoc)); QTextDocumentFragment synFrag(prepareSynDoc(synDoc)); QTextDocumentFragment noteFrag(prepareNoteDoc(noteDoc)); edit->setDocument(textDocument); if(element.tagName() == "book"){ textDocument->setMetaInformation(QTextDocument::DocumentTitle,element.attribute("name", "")); edit->append("<h1>" + element.attribute("name", "") + "</h1>"); tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->mergeBlockFormat(blockFormatCenter); edit->append("<h4>" + QDateTime::currentDateTime().toString() + "</h4>"); tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->mergeBlockFormat(blockFormatCenter); edit->append("<br>"); edit->append("<br>"); } if(element.tagName() == "act"){ edit->append("<br>"); edit->append("<br>"); edit->append("<h2>" + element.attribute("name", "") + "</h2>"); tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->mergeBlockFormat(blockFormatCenter); edit->append("<br>"); } if(element.tagName() == "chapter"){ edit->append("<br>"); edit->append("<br>"); edit->append("<h2>" + element.attribute("name", "") + "</h2>"); tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->mergeBlockFormat(blockFormatCenter); edit->append("<br>"); } if(element.tagName() == "scene" && ui->setSceneTitlesComboBox->currentIndex() != 0){ QString sceneTitle; switch (ui->setSceneTitlesComboBox->currentIndex()){ case 1: sceneTitle = element.attribute("name", ""); break; case 2: sceneTitle = "###"; break; case 3: sceneTitle = "***"; break; default: sceneTitle = element.attribute("name", ""); break; } edit->append("<br>"); edit->append("<h3>" + sceneTitle + "</h3>"); tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->mergeBlockFormat(blockFormatCenter); edit->append("<br>"); } if(ui->synopsisCheckBox->isChecked() && !synFrag.isEmpty()){ edit->append("<br>"); edit->append("<h4>" + tr("Synopsis") + "</h4>"); tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->mergeBlockFormat(blockFormatCenter); edit->append("<br>"); tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->insertBlock(blockFormatLeft, charFormatLeft); tCursor->insertFragment(synFrag); } if(ui->notesCheckBox->isChecked() && !noteFrag.isEmpty()){ edit->append("<br>"); edit->append("<h4>" + tr("Note") + "</h4>"); tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->mergeBlockFormat(blockFormatCenter); edit->append("<br>"); tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->insertBlock(blockFormatLeft, charFormatLeft); tCursor->insertFragment(noteFrag); } if(ui->storyCheckBox->isChecked()){ if((ui->synopsisCheckBox->isChecked() || ui->notesCheckBox->isChecked()) && !textFrag.isEmpty()){ tCursor->insertBlock(); tCursor->insertHtml("<h4>" + tr("Story") + "</h4>"); tCursor->mergeBlockFormat(blockFormatCenter); tCursor->insertBlock(); } tCursor->insertHtml("<br>"); // tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->insertBlock(blockFormatLeft, charFormatLeft); tCursor->insertFragment(textFrag); // edit->append(textFrag->toHtml()); } } else if(element.tagName() == "separator"){ edit->append("<br>"); edit->append("<h3>#</h3>"); tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->mergeBlockFormat(blockFormatCenter); edit->append("<br>"); tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1); tCursor->mergeBlockFormat(blockFormatLeft); } progressValue += 1; progressBar->setValue(progressValue); } QRegExp reg("-qt-paragraph-type:.*;|margin-top:.*;|margin-bottom:.*;|margin-left:.*;|margin-right:.*;|-qt-block-indent:.*;|text-indent:.*;|font-family:.*;|font-size:.*;"); reg.setMinimal(true); textDocument->setHtml(textDocument->toHtml().remove(reg)); //find and change final page css style : //textDocument->setDefaultStyleSheet("p, li { white-space: pre-wrap; } p{line-height: 2em; font-family:'Liberation Serif'; font-size:14pt;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:72px;}"); // <style type="text/css"> // p, li { white-space: pre-wrap; } // </style> // tCursor // qDebug() << textDocument->toHtml(); progressWidget->close(); return textDocument; }
void RenderCommand::rasterRender(bool isPreview) { ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); if (isPreview) { //Let the PreviewFxManager own the rest. Just pass him the current output node. PreviewFxManager::instance()->showNewPreview((TFx *)scene->getXsheet()->getFxDag()->getCurrentOutputFx()); return; } string ext = m_fp.getType(); #ifdef WIN32 if (ext == "avi" && !isPreview) { TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext); string codecName = props->getProperty(0)->getValueAsString(); TDimension res = scene->getCurrentCamera()->getRes(); if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) { QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format.")); MsgBox(WARNING, msg); return; } } #endif; //Extract output properties TOutputProperties *prop = isPreview ? scene->getProperties()->getPreviewProperties() : scene->getProperties()->getOutputProperties(); //Build thread count /*-- Dedicated CPUs のコンボボックス (Single, Half, All) --*/ int index = prop->getThreadIndex(); const int procCount = TSystem::getProcessorCount(); const int threadCounts[3] = {1, procCount / 2, procCount}; int threadCount = threadCounts[index]; /*-- MovieRendererを作る。Previewの場合はファイルパスは空 --*/ MovieRenderer movieRenderer(scene, isPreview ? TFilePath() : m_fp, threadCount, isPreview); TRenderSettings rs = prop->getRenderSettings(); //Build raster granularity size index = prop->getMaxTileSizeIndex(); const int maxTileSizes[4] = { (std::numeric_limits<int>::max)(), TOutputProperties::LargeVal, TOutputProperties::MediumVal, TOutputProperties::SmallVal}; rs.m_maxTileSize = maxTileSizes[index]; //Build #ifdef BRAVODEMO rs.m_mark = loadBravo(scene->getCurrentCamera()->getRes()); #endif /*-- RenderSettingsをセット --*/ movieRenderer.setRenderSettings(rs); /*-- カメラDPIの取得、セット --*/ TPointD cameraDpi = isPreview ? scene->getCurrentPreviewCamera()->getDpi() : scene->getCurrentCamera()->getDpi(); movieRenderer.setDpi(cameraDpi.x, cameraDpi.y); movieRenderer.enablePrecomputing(true); /*-- プログレス ダイアログの作成 --*/ RenderListener *listener = new RenderListener(movieRenderer.getTRenderer(), m_fp, ((m_numFrames - 1) / m_step) + 1, isPreview); QObject::connect(listener, SIGNAL(canceled()), &movieRenderer, SLOT(onCanceled())); movieRenderer.addListener(listener); bool fieldRendering = rs.m_fieldPrevalence != TRenderSettings::NoField; /*-- buildSceneFxの進行状況を表示するプログレスバー --*/ QProgressBar *buildSceneProgressBar = new QProgressBar(TApp::instance()->getMainWindow()); buildSceneProgressBar->setAttribute(Qt::WA_DeleteOnClose); buildSceneProgressBar->setWindowFlags(Qt::SubWindow | Qt::Dialog | Qt::WindowStaysOnTopHint); buildSceneProgressBar->setMinimum(0); buildSceneProgressBar->setMaximum(m_numFrames - 1); buildSceneProgressBar->setValue(0); buildSceneProgressBar->move(600, 500); buildSceneProgressBar->setWindowTitle("Building Schematic..."); buildSceneProgressBar->show(); for (int i = 0; i < m_numFrames; ++i, m_r += m_stepd) { buildSceneProgressBar->setValue(i); if (rs.m_stereoscopic) scene->shiftCameraX(-rs.m_stereoscopicShift / 2); TFxPair fx; fx.m_frameA = buildSceneFx(scene, m_r, rs.m_shrinkX, isPreview); if (fieldRendering && !isPreview) fx.m_frameB = buildSceneFx(scene, m_r + 0.5 / m_timeStretchFactor, rs.m_shrinkX, isPreview); else if (rs.m_stereoscopic) { scene->shiftCameraX(rs.m_stereoscopicShift); fx.m_frameB = buildSceneFx(scene, m_r + 0.5 / m_timeStretchFactor, rs.m_shrinkX, isPreview); scene->shiftCameraX(-rs.m_stereoscopicShift / 2); } else fx.m_frameB = TRasterFxP(); /*-- movieRendererにフレーム毎のFxを登録 --*/ movieRenderer.addFrame(m_r, fx); } /*-- プログレスバーを閉じる --*/ buildSceneProgressBar->close(); //resetViewer(); //TODO cancella le immagini dell'eventuale render precedente //FileViewerPopupPool::instance()->getCurrent()->onClose(); movieRenderer.start(); }
void WifiWidget::setupDisplay() { const int numRowsPerInterface = 6; const int numDigits = 4; QGridLayout *globalLayout = new QGridLayout(this); globalLayout->setColumnStretch(0,0); globalLayout->setColumnStretch(1,1); globalLayout->setColumnStretch(2,1); for (unsigned int i=0; i<numInterfaces_; i++) { QLabel *interfaceLabel = new QLabel; interfaceLabel->setFont(QFont("Helvetica", 12, QFont::Bold)); globalLayout->addWidget(interfaceLabel,numRowsPerInterface*i,0); interfaceLabels_.push_back( interfaceLabel ); QLabel *accessPointLabel = new QLabel; accessPointLabel->setFont(QFont("Helvetica", 12, QFont::Bold)); globalLayout->addWidget(accessPointLabel,numRowsPerInterface*i,1); accessPointLabels_.push_back( accessPointLabel ); QLCDNumber *lcdSignalLevel = new QLCDNumber(numDigits, this); lcdSignalLevel->setSegmentStyle(QLCDNumber::Filled); lcdsSignal_.push_back(lcdSignalLevel); QLCDNumber *lcdMaxSignalLevel = new QLCDNumber(numDigits, this); lcdMaxSignalLevel->setSegmentStyle(QLCDNumber::Filled); lcdsMaxSignal_.push_back(lcdMaxSignalLevel); QLabel *signalLabel = new QLabel("Signal: "); globalLayout->addWidget( signalLabel,numRowsPerInterface*i+1,0); globalLayout->addWidget( lcdSignalLevel,numRowsPerInterface*i+1,1); globalLayout->addWidget( lcdMaxSignalLevel,numRowsPerInterface*i+1,2); QLCDNumber *lcdNoiseLevel = new QLCDNumber(numDigits, this); lcdNoiseLevel->setSegmentStyle(QLCDNumber::Filled); lcdsNoise_.push_back(lcdNoiseLevel); QLCDNumber *lcdMaxNoiseLevel = new QLCDNumber(numDigits, this); lcdMaxNoiseLevel->setSegmentStyle(QLCDNumber::Filled); lcdsMaxNoise_.push_back(lcdMaxNoiseLevel); QLabel *noiseLabel = new QLabel("Noise: "); globalLayout->addWidget( noiseLabel,numRowsPerInterface*i+2,0); globalLayout->addWidget( lcdNoiseLevel,numRowsPerInterface*i+2,1); globalLayout->addWidget( lcdMaxNoiseLevel,numRowsPerInterface*i+2,2); QLCDNumber *lcdLinkLevel = new QLCDNumber(numDigits, this); lcdLinkLevel->setSegmentStyle(QLCDNumber::Filled); lcdsLink_.push_back(lcdLinkLevel); QLCDNumber *lcdMaxLinkLevel = new QLCDNumber(numDigits, this); lcdMaxLinkLevel->setSegmentStyle(QLCDNumber::Filled); lcdsMaxLink_.push_back(lcdMaxLinkLevel); QLabel *linkLabel = new QLabel("Link quality: "); globalLayout->addWidget( linkLabel,numRowsPerInterface*i+3,0); globalLayout->addWidget( lcdLinkLevel,numRowsPerInterface*i+3,1); globalLayout->addWidget( lcdMaxLinkLevel,numRowsPerInterface*i+3,2); QLCDNumber *lcdBitrate = new QLCDNumber(numDigits, this); lcdBitrate->setSegmentStyle(QLCDNumber::Filled); lcdsBitrate_.push_back(lcdBitrate); QLabel *bitRateLabel = new QLabel("Bit rate (Mb/s): "); globalLayout->addWidget( bitRateLabel,numRowsPerInterface*i+4,0); globalLayout->addWidget( lcdBitrate,numRowsPerInterface*i+4,1); QProgressBar *overall = new QProgressBar; overall->setMinimum(0); overall->setMaximum(MAXIMUM_SNR); progressBars_.push_back(overall); QLabel *progressLabel = new QLabel("Overall signal level: "); QLabel *overallSigLabel = new QLabel; overallSigLabel->setFont(QFont("Helvetica", 12, QFont::Bold)); overallSigLabels_.push_back( overallSigLabel ); globalLayout->addWidget( progressLabel,numRowsPerInterface*i+5,0); globalLayout->addWidget( overall,numRowsPerInterface*i+5,1); globalLayout->addWidget( overallSigLabel,numRowsPerInterface*i+5,2); } setLayout(globalLayout); }
void MainWindow::fillMainWindow() { ui->listUV->clear(); ui->m_tree->clear(); for(int rows = 0; rows != ui->m_gridcursus->rowCount();rows++){ ui->m_gridcursus->removeItem(ui->m_gridcursus->itemAtPosition(rows,0)); ui->m_gridcursus->removeItem(ui->m_gridcursus->itemAtPosition(rows,1)); ui->m_gridcursus->removeItem(ui->m_gridcursus->itemAtPosition(rows,2)); } /* ONGLET DOSSIER */ ui->m_tree->setColumnCount(5); QTreeWidgetItem* headerItem = new QTreeWidgetItem(); headerItem->setText(0,QString("Nom")); headerItem->setText(1,QString("Titre")); headerItem->setText(2,QString("Crédits")); headerItem->setText(3,QString("Catégories")); headerItem->setText(4,QString("Résultat")); ui->m_tree->setHeaderItem(headerItem); ui->m_tree->header()->resizeSection(0, 150); ui->m_tree->header()->resizeSection(1, 300); ui->m_tree->header()->resizeSection(2, 70); ui->m_tree->header()->resizeSection(3, 70); ui->m_tree->header()->resizeSection(4, 40); ui->m_tree->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->m_tree->setSelectionBehavior(QAbstractItemView::SelectRows); ui->m_tree->setSelectionMode(QAbstractItemView::SingleSelection); QList <Dossier *> myDossiers = fac->getDossierDAO()->findAllByEtudiant(currentEtudiant->ID()); QMap<QString, Cursus*> cursusToCompute; for (QList<Dossier *>::const_iterator d = myDossiers.begin(); d != myDossiers.end(); ++d) { QTreeWidgetItem *folderWidget = new QTreeWidgetItem(ui->m_tree,QStringList( (*d)->getTitre() )); QList<Semestre *> mySemestres = fac->getInscriptionDAO()->findSemestresByDossier( (*d)->ID() ); for(QList<Semestre *>::const_iterator s = mySemestres.begin(); s != mySemestres.end(); ++s){ QStringList columns; columns << (*s)->getTitre() << (*s)->getComputedCode() << QString::number( fac->getSemestreDAO()->calculEcts( (*s)->ID() ) ); if((*s)->getCursus()){ columns << (*s)->getCursus()->getFull(); } if((*d)->isCurrent()){ cursusToCompute.insert( (*s)->getCursus()->getCode(), (*s)->getCursus() ); } QTreeWidgetItem *semWidget = new QTreeWidgetItem(folderWidget, columns ); QList<UV *> myUVs = fac->getInscriptionDAO()->findUvsBySemestre( (*s)->ID() ); qDebug()<<myUVs; for(QList<UV *>::const_iterator u = myUVs.begin(); u != myUVs.end(); ++u){ QStringList columns; columns << (*u)->getCode() << (*u)->getTitre() << (*u)->getCreditsString() << (*u)->getCursusString() << fac->getInscriptionDAO()->getResultat((*d)->ID(),(*s)->ID(),(*u)->ID()); QTreeWidgetItem *uvWidget = new QTreeWidgetItem(semWidget, columns); } } } /* ONGLET CURSUS */ int row = 0; for(QMap<QString, Cursus*>::const_iterator i = cursusToCompute.begin(); i != cursusToCompute.end(); ++i){ QProgressBar* pb = new QProgressBar(); QLabel *lab = new QLabel(i.value()->getCode()); pb->setMaximum(i.value()->getEcts()); ui->m_gridcursus->addWidget(lab,row,0); ui->m_gridcursus->addWidget(pb,row,1,1,2); row++; int somme =0; QMap<QString, int> detail = fac->getCursusDAO()->computePercent(i.value()->ID()); for(QMap<QString, int>::const_iterator j = detail.begin(); j != detail.end(); ++j){ QProgressBar* pb = new QProgressBar(); int max = i.value()->getCredits().find(j.key()).value(); int val = j.value(); somme += val; pb->setMaximum( max ); pb->setValue(val); ui->m_gridcursus->addWidget(new QLabel(j.key() + "("+QString::number( val )+"/"+QString::number( max )+")"),row,1 ); ui->m_gridcursus->addWidget(pb,row,2); row++; } pb->setValue(somme); lab->setText( i.value()->getCode() + "("+QString::number( somme )+"/"+QString::number( i.value()->getEcts() )+")" ); } }
void FtpSessionDialog::updateProgress(int id, qint64 done, qint64 total) { QProgressBar *progress = progressBars->value(id); progress->setMaximum(total); progress->setValue(done); }
bool downloadOSM(QWidget* aParent, const QUrl& theUrl, const QString& aUser, const QString& aPassword, Document* theDocument, Layer* theLayer) { Downloader Rcv(aUser, aPassword); IProgressWindow* aProgressWindow = dynamic_cast<IProgressWindow*>(aParent); if (aProgressWindow) { QProgressDialog* dlg = aProgressWindow->getProgressDialog(); if (dlg) { dlg->setWindowTitle(QApplication::translate("Downloader","Downloading...")); dlg->setWindowFlags(dlg->windowFlags() & ~Qt::WindowContextHelpButtonHint); dlg->setWindowFlags(dlg->windowFlags() | Qt::MSWindowsFixedSizeDialogHint); } QProgressBar* Bar = aProgressWindow->getProgressBar(); Bar->setTextVisible(false); Bar->setMaximum(11); QLabel* Lbl = aProgressWindow->getProgressLabel(); Lbl->setText(QApplication::translate("Downloader","Downloading from OSM (connecting)")); if (dlg) dlg->show(); Rcv.setAnimator(dlg, Lbl, Bar, true); } if (!Rcv.go(theUrl)) { #ifndef _MOBILE aParent->setCursor(QCursor(Qt::ArrowCursor)); #endif return false; } int x = Rcv.resultCode(); switch (x) { case 200: break; case 301: case 302: case 307: { QString aWeb = Rcv.locationText(); if (!aWeb.isEmpty()) { QUrl aURL(aWeb); return downloadOSM(aParent, aURL, aUser, aPassword, theDocument, theLayer); } else { QString msg = QApplication::translate("Downloader","Unexpected http status code (%1)\nServer message is '%2'").arg(x).arg(Rcv.resultText()); if (!Rcv.errorText().isEmpty()) msg += QApplication::translate("Downloader", "\nAPI message is '%1'").arg(Rcv.errorText()); QMessageBox::warning(aParent,QApplication::translate("Downloader","Download failed"), msg); return false; } break; } case 401: QMessageBox::warning(aParent,QApplication::translate("Downloader","Download failed"),QApplication::translate("Downloader","Username/password invalid")); return false; default: QString msg = QApplication::translate("Downloader","Unexpected http status code (%1)\nServer message is '%2'").arg(x).arg(Rcv.resultText()); if (!Rcv.errorText().isEmpty()) msg += QApplication::translate("Downloader", "\nAPI message is '%1'").arg(Rcv.errorText()); QMessageBox::warning(aParent,QApplication::translate("Downloader","Download failed"), msg); return false; } Downloader Down(aUser, aPassword); bool OK = importOSM(aParent, Rcv.content(), theDocument, theLayer, &Down); return OK; }
bool downloadMapdust(MainWindow* Main, const CoordBox& aBox, Document* theDocument, SpecialLayer* theLayer) { QUrl url; url.setUrl(M_PREFS->getMapdustUrl()); if (Main) Main->view()->setUpdatesEnabled(false); Downloader theDownloader("", ""); SpecialLayer* trackLayer = theLayer; if (!trackLayer) { trackLayer = new SpecialLayer(QApplication::translate("Downloader","MapDust"), Layer::MapDustLayer); trackLayer->setUploadable(false); theDocument->add(trackLayer); } IProgressWindow* aProgressWindow = dynamic_cast<IProgressWindow*>(Main); if (!aProgressWindow) return false; QProgressDialog* dlg = aProgressWindow->getProgressDialog(); dlg->setWindowTitle(QApplication::translate("Downloader","Parsing...")); QProgressBar* Bar = aProgressWindow->getProgressBar(); Bar->setTextVisible(false); Bar->setMaximum(11); QLabel* Lbl = aProgressWindow->getProgressLabel(); Lbl->setText(QApplication::translate("Downloader","Parsing XML")); if (dlg) dlg->show(); theDownloader.setAnimator(dlg,Lbl,Bar,true); Lbl->setText(QApplication::translate("Downloader","Downloading points")); #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QUrlQuery theQuery(url); #define theQuery theQuery #else #define theQuery url #endif theQuery.addQueryItem("t", COORD2STRING(aBox.topRight().y())); theQuery.addQueryItem("l", COORD2STRING(aBox.bottomLeft().x())); theQuery.addQueryItem("b", COORD2STRING(aBox.bottomLeft().y())); theQuery.addQueryItem("r", COORD2STRING(aBox.topRight().x())); #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) url.setQuery(theQuery); #endif #undef theQuery if (!theDownloader.go(url)) return false; if (theDownloader.resultCode() != 200) return false; QByteArray Ar(theDownloader.content()); ImportExportGdal gdal(theDocument); bool OK = gdal.import(trackLayer, Ar, false); if (Main) Main->view()->setUpdatesEnabled(true); if (OK) { if (Main) Main->invalidateView(); } return OK; }
bool downloadOpenstreetbugs(MainWindow* Main, const CoordBox& aBox, Document* theDocument, SpecialLayer* theLayer) { QUrl osbUrl; osbUrl.setUrl(M_PREFS->getOpenStreetBugsUrl()); osbUrl.setPath(osbUrl.path() + "getGPX"); if (Main) Main->view()->setUpdatesEnabled(false); Downloader theDownloader("", ""); QList<TrackLayer*> theTracklayers; SpecialLayer* trackLayer = theLayer; if (!trackLayer) { SpecialLayer* trackLayer = new SpecialLayer(QApplication::translate("Downloader","OpenStreetBugs"),Layer::OsmBugsLayer); trackLayer->setUploadable(false); theDocument->add(trackLayer); } theTracklayers << trackLayer; IProgressWindow* aProgressWindow = dynamic_cast<IProgressWindow*>(Main); if (!aProgressWindow) return false; QProgressDialog* dlg = aProgressWindow->getProgressDialog(); dlg->setWindowTitle(QApplication::translate("Downloader","Parsing...")); QProgressBar* Bar = aProgressWindow->getProgressBar(); Bar->setTextVisible(false); Bar->setMaximum(11); QLabel* Lbl = aProgressWindow->getProgressLabel(); Lbl->setText(QApplication::translate("Downloader","Parsing XML")); if (dlg) dlg->show(); theDownloader.setAnimator(dlg,Lbl,Bar,true); Lbl->setText(QApplication::translate("Downloader","Downloading points")); #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QUrlQuery theQuery(osbUrl); #define theQuery theQuery #else #define theQuery osbUrl #endif theQuery.addQueryItem("t", COORD2STRING(aBox.topRight().y())); theQuery.addQueryItem("l", COORD2STRING(aBox.bottomLeft().x())); theQuery.addQueryItem("b", COORD2STRING(aBox.bottomLeft().y())); theQuery.addQueryItem("r", COORD2STRING(aBox.topRight().x())); theQuery.addQueryItem("open", "yes"); #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) osbUrl.setQuery(theQuery); #endif #undef theQuery if (!theDownloader.go(osbUrl)) return false; if (theDownloader.resultCode() != 200) return false; QByteArray Ar(theDownloader.content()); bool OK = importGPX(Main, Ar, theDocument, theTracklayers, true); if (Main) Main->view()->setUpdatesEnabled(true); if (OK) { if (Main) Main->invalidateView(); } return OK; }
Spectrum::Spectrum(QMap<QString, unsigned int> answerCount, QWidget *parent) : QWidget(parent) { QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); QLabel *title = new QLabel(tr("Spectre")); title->setAlignment(Qt::AlignCenter); mainLayout->addWidget(title); QHBoxLayout *extraversionIntroversionLayout = new QHBoxLayout; mainLayout->addLayout(extraversionIntroversionLayout); QLabel *extraversion = new QLabel(tr("Extraversion")); extraversion->setMinimumWidth(100); extraversion->setAlignment(Qt::AlignRight); extraversionIntroversionLayout->addWidget(extraversion); QProgressBar *extraversionProgressBar = new QProgressBar; extraversionProgressBar->setInvertedAppearance(true); extraversionProgressBar->setMaximum(10); extraversionIntroversionLayout->addWidget(extraversionProgressBar); QProgressBar *introversionProgressBar = new QProgressBar; introversionProgressBar->setMaximum(10); extraversionIntroversionLayout->addWidget(introversionProgressBar); QLabel *introversion = new QLabel(tr("Introversion")); introversion->setMinimumWidth(100); extraversionIntroversionLayout->addWidget(introversion); QHBoxLayout *sensingIntuitionLayout = new QHBoxLayout; mainLayout->addLayout(sensingIntuitionLayout); QLabel *sensing = new QLabel(tr("Sensation")); sensing->setMinimumWidth(100); sensing->setAlignment(Qt::AlignRight); sensingIntuitionLayout->addWidget(sensing); QProgressBar *sensingProgressBar = new QProgressBar; sensingProgressBar->setInvertedAppearance(true); sensingProgressBar->setMaximum(20); sensingIntuitionLayout->addWidget(sensingProgressBar); QProgressBar *intuitionProgressBar = new QProgressBar; intuitionProgressBar->setMaximum(20); sensingIntuitionLayout->addWidget(intuitionProgressBar); QLabel *intuition = new QLabel(tr("Intuition")); intuition->setMinimumWidth(100); sensingIntuitionLayout->addWidget(intuition); QHBoxLayout *thinkingFeelingLayout = new QHBoxLayout; mainLayout->addLayout(thinkingFeelingLayout); QLabel *thinking = new QLabel(tr("Pensée")); thinking->setAlignment(Qt::AlignRight); thinking->setMinimumWidth(100); thinkingFeelingLayout->addWidget(thinking); QProgressBar *thinkingProgressBar = new QProgressBar; thinkingProgressBar->setInvertedAppearance(true); thinkingProgressBar->setMaximum(20); thinkingFeelingLayout->addWidget(thinkingProgressBar); QProgressBar *feelingProgressBar = new QProgressBar; feelingProgressBar->setMaximum(20); thinkingFeelingLayout->addWidget(feelingProgressBar); QLabel *feeling = new QLabel(tr("Sentiment")); feeling->setMinimumWidth(100); thinkingFeelingLayout->addWidget(feeling); QHBoxLayout *judgingPerceptionLayout = new QHBoxLayout; mainLayout->addLayout(judgingPerceptionLayout); QLabel *judging = new QLabel(tr("Jugement")); judging->setAlignment(Qt::AlignRight); judging->setMinimumWidth(100); judgingPerceptionLayout->addWidget(judging); QProgressBar *judgingProgressBar = new QProgressBar; judgingProgressBar->setInvertedAppearance(true); judgingProgressBar->setMaximum(20); judgingPerceptionLayout->addWidget(judgingProgressBar); QProgressBar *perceptionProgressBar = new QProgressBar; perceptionProgressBar->setMaximum(20); judgingPerceptionLayout->addWidget(perceptionProgressBar); QLabel *perception = new QLabel(tr("Perception")); perception->setMinimumWidth(100); judgingPerceptionLayout->addWidget(perception); QLabel *result = new QLabel(tr("Resultat")); result->setAlignment(Qt::AlignCenter); mainLayout->addWidget(result); QHBoxLayout *resultLayout = new QHBoxLayout; mainLayout->addLayout(resultLayout); //search result, if there is equal result, we have to //set several button. QList<QString> firstLetters; if (answerCount["extraversion"] < answerCount["introversion"]) { firstLetters.append("I"); } else if (answerCount["extraversion"] > answerCount["introversion"]) { firstLetters.append("E"); } else { firstLetters.append("I"); firstLetters.append("E"); } QList<QString> secondLetters; if (answerCount["sensing"] < answerCount["intuition"]) { secondLetters.append("N"); } else if (answerCount["sensing"] > answerCount["intuition"]) { secondLetters.append("S"); } else { secondLetters.append("N"); secondLetters.append("S"); } QList<QString> thirdLetters; if (answerCount["thinking"] < answerCount["feeling"]) { thirdLetters.append("F"); } else if (answerCount["thinking"] > answerCount["feeling"]) { thirdLetters.append("T"); } else { thirdLetters.append("F"); thirdLetters.append("T"); } QList<QString> fourthLetters; if (answerCount["judging"] < answerCount["perception"]) { fourthLetters.append("P"); } else if (answerCount["judging"] > answerCount["perception"]) { fourthLetters.append("J"); } else { fourthLetters.append("P"); fourthLetters.append("J"); } signalMapper = new QSignalMapper(this); //release the cartesian product of letters, and create a button //for each case for (int i = 0; i < firstLetters.size(); i++) { for (int j = 0; j < secondLetters.size(); j++) { for (int k = 0; k < thirdLetters.size(); k++) { for (int l = 0; l < fourthLetters.size(); l++) { QString type = firstLetters[i] + secondLetters[j] + thirdLetters[k] + fourthLetters[l]; QPushButton *resultButton = new QPushButton(type); resultLayout->addWidget(resultButton); connect(resultButton, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(resultButton, type); } } } } connect(signalMapper, SIGNAL(mapped(QString)), this, SLOT(openTypeDescription(QString))); extraversionProgressBar->setValue(answerCount["extraversion"]); introversionProgressBar->setValue(answerCount["introversion"]); sensingProgressBar->setValue(answerCount["sensing"]); intuitionProgressBar->setValue(answerCount["intuition"]); thinkingProgressBar->setValue(answerCount["thinking"]); feelingProgressBar->setValue(answerCount["feeling"]); judgingProgressBar->setValue(answerCount["judging"]); perceptionProgressBar->setValue(answerCount["perception"]); QPushButton *openTypeDescriptionsButton = new QPushButton(tr("Tableau des types")); mainLayout->addWidget(openTypeDescriptionsButton); connect(openTypeDescriptionsButton, SIGNAL(clicked()), this, SLOT(openTypeDescriptions())); }