void MainWindow::configureKaffeine() { QDialog *dialog = new ConfigurationDialog(this); dialog->setAttribute(Qt::WA_DeleteOnClose, true); dialog->setModal(true); dialog->show(); }
void addView() { // the new View we want to add: osgViewer::View* view = new osgViewer::View(); // a widget to hold our view: QWidget* viewWidget = new osgEarth::QtGui::ViewWidget(view); // a dialog to hold the view widget: QDialog* win = new QDialog(this); win->setModal( false ); win->setLayout( new QHBoxLayout() ); win->layout()->addWidget( viewWidget ); int x = osgEarth::Random().next( 1024 ); int y = osgEarth::Random().next( 768 ); win->setGeometry( x, y, 640, 480 ); win->show(); // set up the view view->setCameraManipulator( new osgEarth::Util::EarthManipulator ); view->setSceneData( _scene.get() ); view->getDatabasePager()->setUnrefImageDataAfterApplyPolicy(true,false); // add it to the composite viewer. _viewer.addView( view ); }
void Fenetre::modifSommetForme(Sommet *sommet) { //Création d'une boîte de dialogue QDialog fenDiag; //Boutons OK et Annuler QHBoxLayout *layoutButton=new QHBoxLayout; QPushButton *okFenDiag=new QPushButton("&OK"); QPushButton *cancFenDiag=new QPushButton("&Annuler"); layoutButton->addWidget(okFenDiag); layoutButton->addWidget(cancFenDiag); connect(okFenDiag, SIGNAL(clicked()), &fenDiag, SLOT(accept())); connect(cancFenDiag, SIGNAL(clicked()), &fenDiag, SLOT(reject())); //Champ pour choisir la forme QComboBox *boxFormes=new QComboBox; boxFormes->addItems(graphe.getListeForme()); //Ajout de tout ça à la fenêtre de dialogue QVBoxLayout *layoutFenetre=new QVBoxLayout; layoutFenetre->addWidget(boxFormes); layoutFenetre->addLayout(layoutButton); fenDiag.setLayout(layoutFenetre); //On affiche la fenêtre fenDiag.setVisible(true); fenDiag.setModal(true); //On traîte la demande if(fenDiag.exec()){ //Si on a cliqué sur ok ! QString currentText=boxFormes->currentText(); sommet->setForme(currentText); } }
int Busqueda_on_mui_buscar_clicked ( BlSearchWidget *busq ) { if ( busq->tableName() == "cliente" ) { QDialog *diag = new QDialog ( 0 ); diag->setModal ( true ); diag->setGeometry ( QRect ( 0, 0, 750, 550 ) ); blCenterOnScreen ( diag ); ClientsList *clients = new ClientsList ( ( BfCompany * ) busq->mainCompany(), diag, 0, BL_SELECT_MODE ); busq->connect ( clients, SIGNAL ( selected ( QString ) ), diag, SLOT ( accept() ) ); /// Creamos un layout donde estara el contenido de la ventana y la ajustamos al QDialog /// para que sea redimensionable y aparezca el titulo de la ventana. QHBoxLayout *layout = new QHBoxLayout; layout->addWidget ( clients ); layout->setMargin ( 0 ); layout->setSpacing ( 0 ); diag->setLayout ( layout ); diag->setWindowTitle ( clients->windowTitle() ); diag->exec(); if ( clients->idclient() != "" ) { busq->setId ( clients->idclient() ); } // end if delete diag; return 1; } // end if return 0; }
void RbUtilQt::about() { QDialog *window = new QDialog(this); Ui::aboutBox about; about.setupUi(window); window->setLayoutDirection(Qt::LeftToRight); window->setModal(true); QFile licence(":/docs/gpl-2.0.html"); licence.open(QIODevice::ReadOnly); QTextStream c(&licence); QString cline = c.readAll(); about.browserLicense->insertHtml(cline); about.browserLicense->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor); QFile credits(":/docs/CREDITS"); credits.open(QIODevice::ReadOnly); QTextStream r(&credits); r.setCodec(QTextCodec::codecForName("UTF-8")); QString rline = r.readAll(); about.browserCredits->insertPlainText(rline); about.browserCredits->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor); QString title = QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION); about.labelTitle->setText(title); window->show(); }
void getReferencedSelection(const App::DocumentObject* thisObj, const Gui::SelectionChanges& msg, App::DocumentObject*& selObj, std::vector<std::string>& selSub) { if (!thisObj) return; if (strcmp(thisObj->getDocument()->getName(), msg.pDocName) != 0) return; selObj = thisObj->getDocument()->getObject(msg.pObjectName); if (selObj == thisObj) return; std::string subname = msg.pSubName; //check if the selection is an external reference and ask the user what to do //of course only if thisObj is in a body, as otherwise the old workflow would not //be supportet PartDesign::Body* body = PartDesignGui::getBodyFor(thisObj, false); bool originfeature = selObj->isDerivedFrom(App::OriginFeature::getClassTypeId()); if(!originfeature && body) { PartDesign::Body* selBody = PartDesignGui::getBodyFor(selObj, false); if(!selBody || body != selBody) { auto* pcActivePart = PartDesignGui::getPartFor(body, false); QDialog* dia = new QDialog; Ui_Dialog dlg; dlg.setupUi(dia); dia->setModal(true); int result = dia->exec(); if(result == QDialog::DialogCode::Rejected) { selObj = NULL; return; } else if(!dlg.radioXRef->isChecked()) { auto copy = PartDesignGui::TaskFeaturePick::makeCopy(selObj, subname, dlg.radioIndependent->isChecked()); if(selBody) body->addObject(copy); else pcActivePart->addObject(copy); selObj = copy; subname.erase(std::remove_if(subname.begin(), subname.end(), &isdigit), subname.end()); subname.append("1"); } } } // Remove subname for planes and datum features if (PartDesign::Feature::isDatum(selObj)) { subname = ""; } selSub = std::vector<std::string>(1,subname); }
void MainWindow::doFileLocations() { QDialog *dialog = new FileLocationsWidget(0); dialog->setModal(true); dialog->show(); // if (!fileLocationsSubWindow) // fileLocationsSubWindow = new FileLocationsSubWindow(_mdiArea); // fileLocationsSubWindow->adjustSize(); // fileLocationsSubWindow->show(); }
bool Settings::layout(QWidget* w) { if(!w || w->objectName().isEmpty()) { return false; } beginGroup("Geometry"); QList<int> values; bool valid = list(w->objectName(), values, 5); if(valid) // Enough values { int x = values[0]; x &= ~0xC0000000; if (values[0] & 0x80000000) w->setWindowState(Qt::WindowMaximized); else if (values[0] & 0x40000000) w->setWindowState(Qt::WindowFullScreen); else { w->resize(values[2], values[3]); w->move(x, values[1]); } QSplitter* s = qobject_cast<QSplitter*>(w); if (s) { QByteArray splits = value("Splitter", QByteArray()).toByteArray(); if (splits.size()) { s->restoreState(splits); } } else { QMainWindow* m = qobject_cast<QMainWindow*>(w); if(m) { QByteArray docks = value("Docks", QByteArray()).toByteArray(); if(docks.count()) { m->restoreState(docks, 0); } } else { if(values[4]) { QDialog* d = qobject_cast<QDialog*>(w); if (d) d->setModal(true); w->show(); } } } } endGroup(); return valid; }
void MainWindow::doToolsTreeView() { QDialog *dialog; try { dialog = new TreeViewWidget(0); dialog->setModal(true); dialog->show(); } catch (UniSim::Exception &ex) { showErrorMessage(ex); } }
int drv_dialog(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9) { handle_head* head = (handle_head*)a0; QDialog *self = (QDialog*)head->native; switch (drvid) { case DIALOG_INIT: { drvNewObj(a0,new QDialog); break; } case DIALOG_SETMODAL: { self->setModal(drvGetBool(a1)); break; } case DIALOG_ISMODAL: { drvSetBool(a1,self->isModal()); break; } case DIALOG_SETRESULT: { self->setResult(drvGetInt(a1)); break; } case DIALOG_RESULT: { drvSetInt(a1,self->result()); break; } case DIALOG_EXEC: { drvSetInt(a1,self->exec()); break; } case DIALOG_DONE: { self->done(drvGetInt(a1)); break; } case DIALOG_ACCEPT: { self->accept(); break; } case DIALOG_REJECT: { self->reject(); break; } case DIALOG_ONACCEPTED: { QObject::connect(self,SIGNAL(acceped()),drvNewSignal(self,a1,a2),SLOT(call())); break; } case DIALOG_ONREJECTED: { QObject::connect(self,SIGNAL(rejected()),drvNewSignal(self,a1,a2),SLOT(call())); break; } default: return 0; } return 1; }
QMathMLFileViewer::QMathMLFileViewer( QWidget *parent ) : QDockWidget( tr("MathML Documents Explorer"), parent ) { m_iconSize = QSize(16, 16); m_isRecursiveSearch = true; m_currentDir.setPath( QDir::currentPath() ); directoryComboBox = createComboBox( m_currentDir.absolutePath() ); directoryComboBox->setMinimumWidth(150); QDirModel *dirModelCompleter = new QDirModel(this); dirModelCompleter->setFilter( QDir::AllDirs/*QDir::Dirs*/ ); QCompleter *completer = new QCompleter( this ); completer->setModel( dirModelCompleter ); directoryComboBox->setCompleter( completer ); connect(directoryComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(changeDir(const QString&))); QToolButton *btnBrowse = new QToolButton(); btnBrowse->setIcon(QIcon(":/images/folderopen.png")); //btnBrowse->setIconSize( m_iconSize ); btnBrowse->setToolTip(tr("Select a new folder")); connect(btnBrowse, SIGNAL(clicked()), this, SLOT(browse())); QToolButton *btnBrowseUp = new QToolButton(); btnBrowseUp->setIcon(QIcon(":/images/up.png")); //btnBrowseUp->setIconSize( m_iconSize ); btnBrowseUp->setToolTip(tr("Navagate one level up")); connect(btnBrowseUp, SIGNAL(clicked()), this, SLOT(browseUp())); QHBoxLayout *dirLayout = new QHBoxLayout(); dirLayout->addWidget(directoryComboBox); dirLayout->addWidget(btnBrowseUp); dirLayout->addWidget(btnBrowse); dirLayout->addStretch(1); createFilesTree(); createFilesTable(); foundMessage = new QLabel(tr("No search results")); QHBoxLayout *toolLayout = setupToolLayout(); QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->addLayout(toolLayout); mainLayout->addLayout(dirLayout); mainLayout->addWidget(m_dirTree); mainLayout->addWidget(filesTable); mainLayout->addWidget(foundMessage); QDialog *centralDlg = new QDialog(); centralDlg->setModal( false ); centralDlg->setLayout( mainLayout ); setWidget( centralDlg ); }
int64_t video_output_qt::wait_for_subtitle_renderer() { if (_subtitle_renderer.is_initialized()) { return 0; } int64_t wait_start = timer::get_microseconds(timer::monotonic); exc init_exception; QDialog *mbox = NULL; // Show a dialog only in GUI mode if (_container_is_external && !dispatch::parameters().fullscreen()) { mbox = new QDialog(_container_widget); mbox->setModal(true); mbox->setWindowTitle(_("Please wait")); QGridLayout *mbox_layout = new QGridLayout; QLabel *mbox_label = new QLabel(_("Waiting for subtitle renderer initialization...")); mbox_layout->addWidget(mbox_label, 0, 0); mbox->setLayout(mbox_layout); mbox->show(); } else { msg::wrn(_("Waiting for subtitle renderer initialization...")); } QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); try { while (!_subtitle_renderer.is_initialized()) { process_events(); usleep(10000); } } catch (std::exception &e) { init_exception = e; } QApplication::restoreOverrideCursor(); if (mbox) { mbox->hide(); delete mbox; } if (!init_exception.empty()) { throw init_exception; } int64_t wait_stop = timer::get_microseconds(timer::monotonic); return (wait_stop - wait_start); }
void InstallDialog::SlotOkButtonClicked() { Action installAction("org.kde.kcontrol.kcmgrub2.install"); installAction.setHelperId("org.kde.kcontrol.kcmgrub2"); for (int i = 0; i < ui->treeWidget_recover->topLevelItemCount(); i++) { QRadioButton *radio = qobject_cast<QRadioButton *>(ui->treeWidget_recover->itemWidget(ui->treeWidget_recover->topLevelItem(i), 0)); if (radio && radio->isChecked()) { installAction.addArgument("partition", ui->treeWidget_recover->topLevelItem(i)->text(1)); installAction.addArgument("mountPoint", ui->treeWidget_recover->topLevelItem(i)->text(2)); installAction.addArgument("mbrInstall", !ui->checkBox_partition->isChecked()); break; } } if (installAction.arguments().value("partition").toString().isEmpty()) { KMessageBox::sorry(this, i18nc("@info", "Sorry, you have to select a partition with a proper name!")); return; } QProgressDialog progressDlg(this, Qt::Dialog); progressDlg.setWindowTitle(i18nc("@title:window", "Installing")); progressDlg.setLabelText(i18nc("@info:progress", "Installing GRUB...")); progressDlg.setCancelButton(0); progressDlg.setModal(true); progressDlg.setRange(0,0); progressDlg.show(); ExecuteJob* reply = installAction.execute(); reply->exec(); if (reply->action().status() != Action::AuthorizedStatus ) { progressDlg.hide(); return; } //connect(reply, SIGNAL(result()), &progressDlg, SLOT(hide())); progressDlg.hide(); if (reply->error()) { KMessageBox::detailedError(this, i18nc("@info", "Failed to install GRUB."), reply->data().value("errorDescription").toString()); this->reject(); } else { progressDlg.hide(); QDialog *dialog = new QDialog(this, Qt::Dialog); dialog->setWindowTitle(i18nc("@title:window", "Information")); dialog->setModal(true); QDialogButtonBox *btnbox = new QDialogButtonBox(QDialogButtonBox::Ok); KMessageBox::createKMessageBox(dialog, btnbox, QMessageBox::Information, i18nc("@info", "Successfully installed GRUB."), QStringList(), QString(), 0, KMessageBox::Notify, reply->data().value("output").toString()); // krazy:exclude=qclasses this->accept(); } //this->accept(); }
void MenuButton::mousePressEvent ( QGraphicsSceneMouseEvent * event ) { QGraphicsItem::mousePressEvent(event); if(event->button() != Qt::LeftButton) return; if(currentMenu) { currentMenu->setFocus(); //BUG: doesnt seem to work return; } QDialog *menu = new QDialog(panelWindow); menu->move(event->screenPos().x(), event->screenPos().y()); QVBoxLayout *layout = new QVBoxLayout(); QCheckBox *editModeCheck = new QCheckBox("Edit Panel", menu); editModeCheck->setChecked(editMode); connect(editModeCheck, SIGNAL(clicked(bool)), panelWindow, SLOT(setEditMode(bool))); connect(editModeCheck, SIGNAL(clicked(bool)), this, SLOT(setEditMode(bool))); layout->addWidget(editModeCheck); QPushButton *addButton = new QPushButton("Add Item", menu); connect(addButton, SIGNAL(clicked()), panelWindow, SLOT(addItem())); layout->addWidget(addButton); QPushButton *saveButton = new QPushButton("Save panel", menu); connect(saveButton, SIGNAL(clicked()), panelWindow, SLOT(savePanel())); layout->addWidget(saveButton); QPushButton *loadButton = new QPushButton("Load panel", menu); connect(loadButton, SIGNAL(clicked()), panelWindow, SLOT(loadPanel())); layout->addWidget(loadButton); QPushButton *settingsButton = new QPushButton("App Settings", menu); connect(settingsButton, SIGNAL(clicked()), panelWindow, SLOT(showSettings())); connect(settingsButton, SIGNAL(clicked()), this, SLOT(closeCurrentMenu())); layout->addWidget(settingsButton); QPushButton *closeButton = new QPushButton("Close", menu); connect(closeButton, SIGNAL(clicked()), this, SLOT(closeCurrentMenu())); layout->addWidget(closeButton); QPushButton *quitButton = new QPushButton("Quit", menu); connect(quitButton, SIGNAL(clicked()), panelWindow, SLOT(quit())); layout->addWidget(quitButton); currentMenu = menu; connect(currentMenu, SIGNAL(finished(int)), this, SLOT(closeCurrentMenu())); menu->setLayout(layout); menu->setModal(false); menu->show(); }
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(); }
QDialog * Replacer::replaceNextDialog() { if(!m_replace) return 0; QDialog *replaceNextDialog = m_replace->replaceNextDialog(false); if(!replaceNextDialog && m_replace->options() & KReplaceDialog::PromptOnReplace) { replaceNextDialog = m_replace->replaceNextDialog(true); replaceNextDialog->setModal(true); } return replaceNextDialog; }
void CDInfoDialog::slotChangeEncoding() { QDialog* dialog = new QDialog(this); dialog->setWindowTitle(i18n("Change Encoding")); dialog->setModal( true ); QStringList songTitles; for (int t = 0; t < m_trackModel->rowCount(); ++t) { QString title = m_trackModel->index(t, Private::TRACK_ARTIST).data().toString().trimmed(); if (!title.isEmpty()) title.append(Private::SEPARATOR); title.append(m_trackModel->index(t, Private::TRACK_TITLE).data().toString().trimmed()); songTitles << title; } KCDDB::CDInfoEncodingWidget* encWidget = new KCDDB::CDInfoEncodingWidget( dialog, d->ui->m_artist->text(),d->ui->m_title->text(), songTitles); QVBoxLayout* layout = new QVBoxLayout(dialog); layout->addWidget(encWidget); if (dialog->exec()) { KCharsets* charsets = KCharsets::charsets(); QTextCodec* codec = charsets->codecForName(charsets->encodingForName(encWidget->selectedEncoding())); d->ui->m_artist->setText(codec->toUnicode(d->ui->m_artist->text().toLatin1())); d->ui->m_title->setText(codec->toUnicode(d->ui->m_title->text().toLatin1())); d->ui->m_genre->setItemText(d->ui->m_genre->currentIndex(), codec->toUnicode(d->ui->m_genre->currentText().toLatin1())); d->ui->m_comment->setText(codec->toUnicode(d->ui->m_comment->text().toLatin1())); QModelIndex trackIndex = m_trackModel->index(0, 0, QModelIndex()); int trackRows = m_trackModel->rowCount(trackIndex); for (int t = 0; t < trackRows; ++t) { QString artist = m_trackModel->index(t, Private::TRACK_ARTIST, trackIndex).data().toString(); m_trackModel->setData(m_trackModel->index(t, Private::TRACK_ARTIST, trackIndex), codec->toUnicode(artist.toLatin1())); QString title = m_trackModel->index(t, Private::TRACK_TITLE, trackIndex).data().toString(); m_trackModel->setData(m_trackModel->index(t, Private::TRACK_TITLE, trackIndex), codec->toUnicode(title.toLatin1())); QString comment = m_trackModel->index(t, Private::TRACK_COMMENT, trackIndex).data().toString(); m_trackModel->setData(m_trackModel->index(t, Private::TRACK_COMMENT, trackIndex), codec->toUnicode(comment.toLatin1())); } } }
bool GmailPyInterface::login() { bool goon=true; while(m_user == "" || m_pass == "") { QDialog d; d.setModal(true); QLineEdit* user(new QLineEdit); QLineEdit* pass(new QLineEdit); pass->setEchoMode(QLineEdit::Password); QVBoxLayout* layout(new QVBoxLayout); d.setLayout(layout); layout->addWidget(new QLabel("Enter you gmail account:")); QGridLayout* glayout(new QGridLayout()); glayout->addWidget(new QLabel("Username:"******"Password:"******"Ok")); QPushButton* cancelbutton(new QPushButton("Cancel")); QObject::connect(okbutton, SIGNAL(clicked()), &d, SLOT(accept())); QObject::connect(cancelbutton, SIGNAL(clicked()), &d, SLOT(reject())); buttons->addWidget(okbutton); buttons->addWidget(cancelbutton); layout->addLayout(buttons); d.exec(); if (d.result() == QDialog::Accepted) { if (user->text().isEmpty() || pass->text().isEmpty()) continue; m_user = user->text(); m_pass = pass->text(); break; } else return false; } delete m_sender; m_sender = 0; m_sender = new MailSender("smtp.gmail.com", m_user + "@gmail.com", QStringList(m_user + "@gmail.com"), "@SAK", "Enjoy!"); m_sender->setSsl(true); m_sender->setPort(587); m_sender->setLogin(m_user, m_pass); return true; }
void TSController::startExam() { readerThread->setReadingType(ReadAll); recordingStarted = true; readerThread->startRead(); tempInScaleRate = 1.0/5000; tempOutScaleRate = 1.0/5000; volumeScaleRate = 1.0/5000; horizontalStep = 1.0; initPaintDevices(); plotingTimer.start(100); QDialog *mvlDialog = new QDialog(this); volWidget = new Ui::TSVolSignalWidget(); volWidget->setupUi(mvlDialog); volWidget->MVL->setText("50%"); mvlDialog->setModal(false); mvlDialog->show(); ui->startExam->setEnabled(false); ui->horizontalScrollBar->setEnabled(false); }
QWebView *QgsIdentifyResultsWebView::createWindow( QWebPage::WebWindowType type ) { QDialog *d = new QDialog( this ); QLayout *l = new QVBoxLayout( d ); QWebView *wv = new QWebView( d ); l->addWidget( wv ); wv->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ); wv->page()->setNetworkAccessManager( QgsNetworkAccessManager::instance() ); wv->settings()->setAttribute( QWebSettings::LocalContentCanAccessRemoteUrls, true ); wv->settings()->setAttribute( QWebSettings::JavascriptCanOpenWindows, true ); #ifdef QGISDEBUG wv->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled, true ); #endif d->setModal( type != QWebPage::WebBrowserWindow ); d->show(); return wv; }
void Fenetre::modifArcArrivee(Arete* arc) { Graphe* graph=(Graphe*)graphe.getGraph(); vector<Sommet*> listeSommets=graph->getListeSommets(); //Création d'une boîte de dialogue QDialog fenDiag; //Boutons OK et Annuler QHBoxLayout *layoutButton=new QHBoxLayout; QPushButton *okFenDiag=new QPushButton("&OK"); QPushButton *cancFenDiag=new QPushButton("&Annuler"); layoutButton->addWidget(okFenDiag); layoutButton->addWidget(cancFenDiag); connect(okFenDiag, SIGNAL(clicked()), &fenDiag, SLOT(accept())); connect(cancFenDiag, SIGNAL(clicked()), &fenDiag, SLOT(reject())); //Création de la liste des sommets QComboBox *boxSommets=new QComboBox; for (int i = 0 ; i < listeSommets.size(); i++){ boxSommets->addItem(listeSommets[i]->getNom()); } //Ajout de tout ça à la fenêtre de dialogue QVBoxLayout *layoutFenetre=new QVBoxLayout; layoutFenetre->addWidget(boxSommets); layoutFenetre->addLayout(layoutButton); fenDiag.setLayout(layoutFenetre); //On affiche la fenêtre fenDiag.setVisible(true); fenDiag.setModal(true); //On traîte la demande if(fenDiag.exec()) //Si on a cliqué sur ok ! arc->setArrivee(listeSommets[boxSommets->currentIndex()]); affichageSVG->drawGraph(); redessinerComboArc(); }
/* * Створюємо новий пустий шаблон кросворду */ void tableTemplateWidget::createNew(void) { QDialog *dialog = new QDialog(); sizeOfTemplate = new Ui::SizeOfTemplate(); sizeOfTemplate->setupUi(dialog); dialog->setModal(true); dialog->exec(); if (dialog->result() == QDialog::Accepted) { numRow = sizeOfTemplate->spinRows->value(); numCol = sizeOfTemplate->spinColumns->value(); QSqlQuery query; query.prepare("INSERT INTO crossword.templates (_rows, _columns) VALUES (?, ?);"); query.addBindValue(QVariant(numRow)); query.addBindValue(QVariant(numCol)); query.exec(); QSqlError le = query.lastError(); if (le.type() == QSqlError::NoError) templateId = query.lastInsertId().toInt(); else qDebug() << "createNew: " << le.text(); wi.clear(); setRowCount(numRow); setColumnCount(numCol); for (int i = 0; i < numRow; i++) for (int j = 0; j < numCol; j++) newCell(i, j, 0); isDirty = true; } delete dialog; }
void RbUtilQt::about() { QDialog *window = new QDialog(this); Ui::aboutBox about; about.setupUi(window); window->setLayoutDirection(Qt::LeftToRight); window->setModal(true); QFile licence(":/docs/gpl-2.0.html"); licence.open(QIODevice::ReadOnly); QTextStream c(&licence); about.browserLicense->insertHtml(c.readAll()); about.browserLicense->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor); QFile speexlicense(":/docs/COPYING.SPEEX"); speexlicense.open(QIODevice::ReadOnly); QTextStream s(&speexlicense); about.browserSpeexLicense->insertHtml("<pre>" + s.readAll() + "</pre>"); about.browserSpeexLicense->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor); QFile credits(":/docs/CREDITS"); credits.open(QIODevice::ReadOnly); QTextStream r(&credits); r.setCodec(QTextCodec::codecForName("UTF-8")); while(!r.atEnd()) { QString line = r.readLine(); // filter out header. line.remove(QRegExp("^ +.*")); line.remove(QRegExp("^People.*")); about.browserCredits->append(line); } about.browserCredits->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor); QString title = QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION); about.labelTitle->setText(title); window->show(); }
void Fenetre::modifSommetNom(Sommet *sommet) { //Création d'une boîte de dialogue QDialog fenDiag; //Boutons OK et Annuler QHBoxLayout *layoutButton=new QHBoxLayout; QPushButton *okFenDiag=new QPushButton("&OK"); QPushButton *cancFenDiag=new QPushButton("&Annuler"); layoutButton->addWidget(okFenDiag); layoutButton->addWidget(cancFenDiag); connect(okFenDiag, SIGNAL(clicked()), &fenDiag, SLOT(accept())); connect(cancFenDiag, SIGNAL(clicked()), &fenDiag, SLOT(reject())); //Champ pour entrer un nom de sommet QLineEdit *lineEdit = new QLineEdit("Entrez un nouveau nom pour le sommet"); //Ajout de tout ça à la fenêtre de dialogue QVBoxLayout *layoutFenetre=new QVBoxLayout; layoutFenetre->addWidget(lineEdit); layoutFenetre->addLayout(layoutButton); fenDiag.setLayout(layoutFenetre); //On affiche la fenêtre fenDiag.setVisible(true); fenDiag.setModal(true); //On traîte la demande if(fenDiag.exec()){ //Si on a cliqué sur ok ! QString nvid=lineEdit->text(); if(graphe.contains(nvid)) QMessageBox::warning(window(), tr("GraphCalculus"), tr("Le nom du sommet existe déjà !")); else sommet->setNom(nvid); } }
void MainWindow::callOptionDialog (QVector<ConsoleInterface::optionDialogEntry> * options,bool * ret) { if (options->isEmpty()) return; QVectorIterator<ConsoleInterface::optionDialogEntry> it(*options); QDialog * d = new QDialog(this); d->setModal(true); QVBoxLayout * dbl = new QVBoxLayout(); d->setLayout(dbl); QList <QWidget * > ents; QHBoxLayout * sl; QLabel * l; QLineEdit * lew; QCheckBox * chw; QComboBox * cbl; for(int i=0;i< (*options).size();i++) { sl = new QHBoxLayout(); l = new QLabel(d); l->setText(it.next().text); sl->addWidget(l); if((*options)[i].type == ConsoleInterface::OPT_DEC) { lew = new QLineEdit(d); lew->setValidator(new QIntValidator( d )); QString s; s.setNum((*options)[i].valueInt); lew->setText(s); sl->addWidget(lew); ents.append(lew); } if((*options)[i].type == ConsoleInterface::OPT_HEX) { lew = new QLineEdit(d); lew->setValidator(new QRegExpValidator(QRegExp("([A-Fa-f0-9][A-Fa-f0-9])+"),d)); QString s; s.setNum((*options)[i].valueInt,16); lew->setText(s); sl->addWidget(lew); ents.append(lew); } if((*options)[i].type == ConsoleInterface::OPT_STR) { lew = new QLineEdit(d); lew->setValidator(NULL); QString s = (*options)[i].valueStr; lew->setText(s); sl->addWidget(lew); ents.append(lew); } if((*options)[i].type == ConsoleInterface::OPT_CHK) { chw = new QCheckBox(d); chw->setChecked((*options)[i].valueInt == 0 ? false : true); sl->addWidget(chw); ents.append(chw); } if((*options)[i].type == ConsoleInterface::OPT_LIST) { cbl = new QComboBox(d); cbl->addItems((*options)[i].variants); sl->addWidget(cbl); ents.append(cbl); } dbl->addLayout(sl); } QHBoxLayout * hbl = new QHBoxLayout(d); QPushButton * obOK = new QPushButton(tr("OK"),d); QPushButton * obCancel = new QPushButton(tr("Cancel"),d); QPushButton * obAbort = new QPushButton(tr("Abort"),d); connect(obOK,SIGNAL(clicked()),d,SLOT(accept())); connect(obCancel,SIGNAL(clicked()),d,SLOT(reject())); connect(obAbort,SIGNAL(clicked()),d,SLOT(reject())); connect(obAbort,SIGNAL(clicked()),this,SLOT(on_stopButton_clicked()),Qt::QueuedConnection); hbl->addStretch(10); hbl->addWidget(obOK); hbl->addWidget(obCancel); hbl->addWidget(obAbort); dbl->addLayout(hbl); if(d->exec()==QDialog::Accepted) { for(int i=0;i< (*options).size();i++) { if((*options)[i].type == ConsoleInterface::OPT_DEC) { (*options)[i].valueInt = dynamic_cast<QLineEdit*>(ents[i])->text().toInt(); } if((*options)[i].type == ConsoleInterface::OPT_HEX) { (*options)[i].valueInt = dynamic_cast<QLineEdit*>(ents[i])->text().toInt(0,16); } if((*options)[i].type == ConsoleInterface::OPT_STR) { QString t = dynamic_cast<QLineEdit*>(ents[i])->text(); (*options)[i].valueStr = t; } if((*options)[i].type == ConsoleInterface::OPT_CHK) { (*options)[i].valueInt = dynamic_cast<QCheckBox*>(ents[i])->isChecked(); } if((*options)[i].type == ConsoleInterface::OPT_LIST) { (*options)[i].valueInt = dynamic_cast<QComboBox*>(ents[i])->currentIndex(); } } *ret =true; } else { *ret =false; } delete d; }
void GUI::sNewGame() { QDialog dialog; QVBoxLayout *mainLayout = new QVBoxLayout(&dialog); int AIalgorithmCount = AI::getAlgorithmCount(); pobj.clear(); QGroupBox *sizes = new QGroupBox(tr("Board size")); QGridLayout *sizesLayout = new QGridLayout; QComboBox *sizesList = new QComboBox; for(auto s : Board::SIZES) { QString ss = QString::number(s); sizesList->addItem(ss + " x " + ss); } sizesLayout->addWidget(sizesList); sizes->setLayout(sizesLayout); mainLayout->addWidget(sizes); QGroupBox *algo = new QGroupBox(tr("AI algorithms")); QGridLayout *algoLayout = new QGridLayout; algoList = new QComboBox; for(int i = 0; i < AIalgorithmCount; i++) { algoList->addItem(tr("Algorithm %1").arg(i + 1)); } algoList->setEnabled(false); algoLayout->addWidget(algoList); algo->setLayout(algoLayout); mainLayout->addWidget(algo); for(int i = 0; i < 2; i++) { QGridLayout *innerLayout = new QGridLayout; QGroupBox *gb = new QGroupBox(tr("Player %1").arg(i + 1)); QLabel *nameLabel = new QLabel(tr("Name:")); QLineEdit *nameEdit = new QLineEdit; nameEdit->setMaxLength(12); innerLayout->addWidget(nameLabel, 0, 0); innerLayout->addWidget(nameEdit, 0, 1, 1, 2); QLabel *typeLabel = new QLabel(tr("Type:")); QRadioButton *human = new QRadioButton(tr("Human")); QRadioButton *ai = new QRadioButton(tr("AI")); connect(ai, SIGNAL(toggled(bool)), this, SLOT(sCheckAIButtons(bool))); human->setChecked(true); innerLayout->addWidget(typeLabel, 1, 0); innerLayout->addWidget(human, 1, 1); innerLayout->addWidget(ai, 1, 2); pobj.push_back(PlayerObjects(nameEdit, human, ai)); gb->setLayout(innerLayout); mainLayout->addWidget(gb); } QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok| QDialogButtonBox::Cancel); connect(buttons, SIGNAL(accepted()), &dialog, SLOT(accept())); connect(buttons, SIGNAL(rejected()), &dialog, SLOT(reject())); mainLayout->addWidget(buttons); dialog.setLayout(mainLayout); dialog.setModal(true); if(dialog.exec() != QDialog::Accepted || pobj.size() != 2) return; if(game != nullptr) { delete game; game = nullptr; } // Get board size from list index try { std::set<int>::iterator it = Board::SIZES.begin(); std::advance(it, sizesList->currentIndex()); game = new Game(*it); } catch(const std::exception &e) { QMessageBox::critical(this, QGuiApplication::applicationDisplayName(), tr("Couldn't create game board: ").arg(e.what())); return; } const Player *p; for(auto player : pobj) { if(player.human->isChecked()) { game->addPlayer(player.name->text().toStdString()); } else { p = game->addPlayer(player.name->text().toStdString(), Player::AI); ((AI*)p)->setAlgorithm(algoList->currentIndex()); } } game->initGame(); enableHistory(); drawBoard(); }
void Fenetre::changeAttributSommetGraphe(GrapheColore* graph) { vector<SommetColore*> listeSommets=graph->getListeSommets(); //Création d'une boîte de dialogue QDialog fenDiag; //Boutons OK et Annuler QHBoxLayout *layoutButton=new QHBoxLayout; QPushButton *okFenDiag=new QPushButton("&OK"); QPushButton *cancFenDiag=new QPushButton("&Annuler"); layoutButton->addWidget(okFenDiag); layoutButton->addWidget(cancFenDiag); connect(okFenDiag, SIGNAL(clicked()), &fenDiag, SLOT(accept())); connect(cancFenDiag, SIGNAL(clicked()), &fenDiag, SLOT(reject())); //Création de la liste des sommets QComboBox *boxSommets=new QComboBox; for (int i = 0 ; i < listeSommets.size(); i++){ boxSommets->addItem(listeSommets[i]->getNom()); } //Ajout de tout ça à la fenêtre de dialogue QVBoxLayout *layoutFenetre=new QVBoxLayout; layoutFenetre->addWidget(boxSommets); layoutFenetre->addLayout(layoutButton); fenDiag.setLayout(layoutFenetre); //On affiche la fenêtre fenDiag.setVisible(true); fenDiag.setModal(true); //On traîte la demande if(fenDiag.exec()){ //Si on a cliqué sur ok ! int currentIndex=boxSommets->currentIndex(); SommetColore *sommetModif=listeSommets[currentIndex]; //On demande ce qu'on veut modifier à ce sommet QDialog fenDiag2; //On réutilise les mêmes boutons qu'avant disconnect(okFenDiag, SIGNAL(clicked()), &fenDiag, SLOT(accept())); disconnect(cancFenDiag, SIGNAL(clicked()), &fenDiag, SLOT(reject())); connect(okFenDiag, SIGNAL(clicked()), &fenDiag2, SLOT(accept())); connect(cancFenDiag, SIGNAL(clicked()), &fenDiag2, SLOT(reject())); QComboBox *boxOptions=new QComboBox; QStringList options; options<<"Modifier le nom du sommet"<<"Modifier la forme du sommet"<<"Modifier la couleur du sommet"; boxOptions->addItems(options); QVBoxLayout *layoutFenetre2=new QVBoxLayout; layoutFenetre->removeItem(layoutButton); layoutFenetre2->addWidget(boxOptions); layoutFenetre2->addLayout(layoutButton); fenDiag2.setLayout(layoutFenetre2); fenDiag2.setVisible(true); fenDiag2.setModal(true); if(fenDiag2.exec()){ switch(boxOptions->currentIndex()){ case 0 : { modifSommetNom(sommetModif); graph->notifyArete(sommetModif); redessinerComboArc(); break; } case 1 : { modifSommetForme(sommetModif); break; } case 2 : { modifSommetCouleur(sommetModif); break; } } } } }
QString AddImagesDialog::getDirectory(const QStringList &fileNames, const QString &defaultDirectory) { QDialog *dialog = new QDialog(Core::ICore::dialogParent()); dialog->setMinimumWidth(480); QString result; QString directory = defaultDirectory; dialog->setModal(true); dialog->setWindowFlags(dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint); dialog->setWindowTitle(QCoreApplication::translate("AddImageToResources","Add Resources")); QTableWidget *table = createFilesTable(fileNames); table->setParent(dialog); QGridLayout *mainLayout = new QGridLayout(dialog); mainLayout->addWidget(table, 0, 0, 1, 4); QComboBox *directoryComboBox = createDirectoryComboBox(defaultDirectory); auto setDirectoryForComboBox = [directoryComboBox, &directory](const QString &newDir) { if (directoryComboBox->findText(newDir) < 0) directoryComboBox->addItem(newDir); directoryComboBox->setCurrentText(newDir); directory = newDir; }; QObject::connect(directoryComboBox, &QComboBox::currentTextChanged, dialog, [&directory](const QString &text){ directory = text; }); QPushButton *browseButton = new QPushButton(QCoreApplication::translate("AddImageToResources", "&Browse..."), dialog); QObject::connect(browseButton, &QPushButton::clicked, dialog, [setDirectoryForComboBox, &directory]() { const QString newDir = QFileDialog::getExistingDirectory(Core::ICore::dialogParent(), QCoreApplication::translate("AddImageToResources", "Target Directory"), directory); if (!newDir.isEmpty()) setDirectoryForComboBox(newDir); }); mainLayout->addWidget(new QLabel(QCoreApplication::translate("AddImageToResources", "In directory:")), 1, 0); mainLayout->addWidget(directoryComboBox, 1, 0, 1, 3); mainLayout->addWidget(browseButton, 1, 3, 1 , 1); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); mainLayout->addWidget(buttonBox, 3, 2, 1, 2); QObject::connect(buttonBox, &QDialogButtonBox::accepted, dialog, [dialog](){ dialog->accept(); dialog->deleteLater(); }); QObject::connect(buttonBox, &QDialogButtonBox::rejected, dialog, [dialog, &directory](){ dialog->reject(); dialog->deleteLater(); directory = QString(); }); QObject::connect(dialog, &QDialog::accepted, [&directory, &result](){ result = directory; }); dialog->exec(); return result; }
void ImageComparator::Compare( QString const&filepath, QImage const &img ) { QSettings sett(SettingsValues::filename(),QSettings::IniFormat); sett.beginGroup(SettingsValues::comparatorGroupName()); QString goldenPath = sett.value(SettingsValues::goldenPathValueName(), SettingsValues::goldenPathDefault()).toString() + "/"; QString diffPath = sett.value(SettingsValues::diffPathValueName(), SettingsValues::diffPathDefault()).toString() + "/"; sett.endGroup(); QFileInfo info(filepath); QString const samplePath = goldenPath + info.fileName(); if(!QFile::exists(samplePath)) { QMessageBox::critical(NULL, "Error!", QString("Golden image \"%1\" does not exist!").arg(samplePath)); return; } QImage sample(samplePath); sample = sample.convertToFormat(QImage::Format_ARGB32_Premultiplied); if(sample.isNull()) { QMessageBox::critical(NULL, "Error!", QString("Could not open file \"%1\"!").arg(samplePath)); return; } if(sample.size() != img.size()) { QMessageBox::critical(NULL, "Error!", QString("Sample and current images have different sizes!")); return; } unsigned long long accum = 0; int sx = sample.width(); int sy = sample.height(); int bpl = sample.bytesPerLine(); QImage diffImg(sample.size(), QImage::Format_ARGB32); for (int y = 0; y < sy; ++y) { for (int x = 0; x < sx; ++x) { for (int c = 0; c < 3; ++c) { unsigned idx = y * bpl + (x << 2) + c; uchar diff = abs((int)sample.constBits()[idx] - (int)img.constBits()[idx]); diffImg.bits()[idx] = diff; accum += diff; } diffImg.bits()[y * bpl + (x << 2) + 3] = sample.bits()[y * bpl + (x << 2) + 3]; } } QString const diffName = diffPath + info.fileName(); QDir diffDir(diffPath); if(!diffDir.exists(diffPath)) { if(!QDir(diffPath + "/..").mkpath(diffDir.dirName())) { QMessageBox::critical(NULL, "Error!", QString("Could not create diff folder \"%1\"!").arg(diffPath)); return; } } if(!diffImg.save(diffName, info.suffix().toAscii().data())) { QMessageBox::critical(NULL, "Error!", QString("Could not save the difference image \"%1\"!").arg(diffName)); return; } double diff = ((double)accum / (img.size().width() * img.size().height() * 3) * 100.0 / 255.0); QDialog dlg; Ui::ImgDifferenceDialog ui; ui.setupUi(&dlg); dlg.setModal(true); dlg.setSizeGripEnabled(false); dlg.layout()->setSizeConstraint( QLayout::SetFixedSize ); ui.label->setText(QString("The difference is: %1").arg(diff, 0, 'f', 2)); QPixmap pxmp = QPixmap::fromImage(diffImg); QRect r = ui.frame->frameRect(); if(r.width() < pxmp.width()) pxmp = pxmp.scaledToWidth(r.width(), Qt::SmoothTransformation); if(r.height() < pxmp.height()) pxmp = pxmp.scaledToHeight(r.height(), Qt::SmoothTransformation); //ui.differenceLabel->resize(pxmp.size()); ui.differenceLabel->setPixmap(pxmp); dlg.exec(); }
bool ShaderFactory::loadShader(GLhandleARB &progObj, QString shaderString) { GLhandleARB fragObj = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); glAttachObjectARB(progObj, fragObj); GLhandleARB vertObj = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); glAttachObjectARB(progObj, vertObj); { // vertObj QString qstr; qstr = "varying vec3 pointpos;\n"; qstr += "void main(void)\n"; qstr += "{\n"; qstr += " // Transform vertex position into homogenous clip-space.\n"; qstr += " gl_FrontColor = gl_Color;\n"; qstr += " gl_BackColor = gl_Color;\n"; qstr += " gl_Position = ftransform();\n"; qstr += " gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;\n"; qstr += " gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord1;\n"; qstr += " gl_TexCoord[2] = gl_TextureMatrix[2] * gl_MultiTexCoord2;\n"; qstr += " gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n"; qstr += " pointpos = gl_Vertex.xyz;\n"; qstr += "}\n"; int len = qstr.length(); char *tbuffer = new char[len+1]; sprintf(tbuffer, qstr.toLatin1().data()); const char *sstr = tbuffer; glShaderSourceARB(vertObj, 1, &sstr, NULL); delete [] tbuffer; GLint compiled = -1; glCompileShaderARB(vertObj); glGetObjectParameterivARB(vertObj, GL_OBJECT_COMPILE_STATUS_ARB, &compiled); if (!compiled) { GLcharARB str[1000]; GLsizei len; glGetInfoLogARB(vertObj, (GLsizei) 1000, &len, str); QMessageBox::information(0, "Error : Vertex Shader", str); return false; } } { // fragObj int len = shaderString.length(); char *tbuffer = new char[len+1]; sprintf(tbuffer, shaderString.toLatin1().data()); const char *sstr = tbuffer; glShaderSourceARB(fragObj, 1, &sstr, NULL); delete [] tbuffer; GLint compiled = -1; glCompileShaderARB(fragObj); glGetObjectParameterivARB(fragObj, GL_OBJECT_COMPILE_STATUS_ARB, &compiled); if (!compiled) { GLcharARB str[1000]; GLsizei len; glGetInfoLogARB(fragObj, (GLsizei) 1000, &len, str); //----------------------------------- // display error //qApp->beep(); QString estr; QStringList slist = shaderString.split("\n"); for(int i=0; i<slist.count(); i++) estr += QString("%1 : %2\n").arg(i+1).arg(slist[i]); QTextEdit *tedit = new QTextEdit(); tedit->insertPlainText("-------------Error----------------\n\n"); tedit->insertPlainText(str); tedit->insertPlainText("\n-----------Shader---------------\n\n"); tedit->insertPlainText(estr); QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(tedit); QDialog *showError = new QDialog(); showError->setWindowTitle("Error in Fragment Shader"); showError->setSizeGripEnabled(true); showError->setModal(true); showError->setLayout(layout); showError->exec(); //----------------------------------- return false; } } //----------- link program shader ---------------------- GLint linked = -1; glLinkProgramARB(progObj); glGetObjectParameterivARB(progObj, GL_OBJECT_LINK_STATUS_ARB, &linked); if (!linked) { GLcharARB str[1000]; GLsizei len; QMessageBox::information(0, "ProgObj", "error linking texProgObj"); glGetInfoLogARB(progObj, (GLsizei) 1000, &len, str); QMessageBox::information(0, "Error", QString("%1\n%2").arg(len).arg(str)); return false; } glDeleteObjectARB(fragObj); glDeleteObjectARB(vertObj); return true; }