int MainWindow::deniedEvent(QString &login){ QMessageBox* note = new QMessageBox(QMessageBox::Information, tr("The application was not accepted"), login + tr(" has not received your application."), QMessageBox::Retry|QMessageBox::Cancel); note->addButton(tr("Delete"), QMessageBox::ApplyRole); int result = note->exec(); qDebug() << result << note->clickedButton() << note->buttonRole(note->clickedButton()); delete note; switch(note->buttonRole(note->clickedButton())){ case QMessageBox::AcceptRole: return account.friendRequest(login, contact_action::add).statusCode; case QMessageBox::RejectRole: break; case QMessageBox::ApplyRole: return on_DeleteContactButton_clicked(); default: break; } return 0; }
bool QtWebKitWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type) { if (request.url().scheme() == QLatin1String("javascript") && frame) { frame->evaluateJavaScript(request.url().path()); return true; } if (type == QWebPage::NavigationTypeFormResubmitted && SettingsManager::getValue(QLatin1String("Choices/WarnFormResend")).toBool()) { QMessageBox dialog; dialog.setWindowTitle(tr("Question")); dialog.setText(tr("Are you sure that you want to send form data again?")); dialog.setInformativeText("Do you want to resend data?"); dialog.setIcon(QMessageBox::Question); dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); dialog.setDefaultButton(QMessageBox::Cancel); dialog.setCheckBox(new QCheckBox(tr("Do not show this message again"))); bool cancel = false; if (m_webWidget) { dialog.setModal(false); QEventLoop eventLoop; m_webWidget->showDialog(&dialog); connect(&dialog, SIGNAL(finished(int)), &eventLoop, SLOT(quit())); connect(this, SIGNAL(destroyed()), &eventLoop, SLOT(quit())); eventLoop.exec(); m_webWidget->hideDialog(&dialog); cancel = (dialog.buttonRole(dialog.clickedButton()) == QMessageBox::RejectRole); } else {
void plotsDialog::deleteCurrentPlot() { QMessageBox * askBox = new QMessageBox(this); askBox->addButton("Delete",QMessageBox::YesRole); askBox->addButton("Cancel",QMessageBox::NoRole); askBox->setText("Confirm to delete the plot?"); askBox->setWindowTitle("Warning"); askBox->exec(); if(askBox->buttonRole(askBox->clickedButton())==QMessageBox::YesRole) { Plot* plotToDelete = dynamic_cast<Plot*>(tabs->currentWidget()); #ifdef Q_OS_WIN32 QFile file("plotTemp.xml"); #endif #ifdef Q_OS_MAC QDir dir = qApp->applicationDirPath(); /*dir.cdUp();*/ /*dir.cdUp();*/ /*dir.cdUp();*/ QString bundleDir(dir.absolutePath()); QFile file(bundleDir+"/plotTemp.xml"); #endif if(!file.open(QIODevice::ReadWrite|QIODevice::Text)) { return; globalpara.reportError("Fail to open xml file for plots!",this); } else { QDomDocument doc; QTextStream stream; stream.setDevice(&file); if(!doc.setContent(&file)) { globalpara.reportError("Fail to load xml document for plots!",this); file.close(); return; } else { QDomElement plotData = doc.elementsByTagName("plotData").at(0).toElement(); plotData.removeChild(plotData.elementsByTagName(tabs->tabText(tabs->currentIndex())).at(0)); } file.resize(0); doc.save(stream,4); file.close(); stream.flush(); } if(tabs->count()>1) { tabs->removeTab(tabs->currentIndex()); } else if(tabs->count()==1) { this->close(); } } else return; }
void UpdateChecker::resultReceiver(QString data) { QDomDocument xml; qDebug() << data; xml.setContent(data); QDomElement productxml = xml.firstChildElement("product"); if (productxml.isNull()) { QMessageBox::critical(NULL, tr("Error"), tr("Could not check for updates. Wrong server response.")); inProgress = false; return; } QDomElement urlxml = productxml.firstChildElement("url"); QString url = urlxml.text(); QDomNodeList versionsx = xml.elementsByTagName("version"); if (versionsx.length()==0) { QMessageBox::critical(NULL, tr("Error"), tr("Could not check for updates. No versions found.")); inProgress = false; return; } QString platform; #ifdef Q_OS_WIN platform = "WIN"; #endif #ifdef Q_OS_MAC platform = "MAC"; #endif if (platform.isEmpty()) platform = "UNIX"; QStringList versions; QMap<QString, QUrl> urls; for(unsigned int i=0; i<versionsx.length(); i++) { QDomNode version = versionsx.at(i); QDomNode platformx = version.attributes().namedItem("platform"); if (platformx.isNull()) continue; QString vpl = platformx.nodeValue(); if ((vpl != platform) && (vpl != "ALL")) continue; QString ver = version.attributes().namedItem("id").nodeValue(); versions.append(ver); QDomElement xurl = version.toElement().firstChildElement("url"); urls[ver] = QUrl(xurl.text()); } if (!versions.size()) { if (!workSilent) QMessageBox::information(NULL, tr("No updates available"), tr("You have the latest version of this application.")); inProgress = false; return; } qSort( versions.begin(), versions.end(), versionCompare); // I should write Version class with right compare QString version = versions.first(); // operator and use QMap's auto sorting. if (versionCompare(version, QApplication::applicationVersion())) { QMessageBox msg; msg.addButton(tr("Yes"), QMessageBox::YesRole); msg.addButton(tr("No"), QMessageBox::NoRole); msg.setText(tr("Lastest version is %1. Do you want to update?").arg(version)); msg.setWindowTitle(tr("Update available")); msg.exec(); if (msg.buttonRole(msg.clickedButton()) == QMessageBox::YesRole) { QDesktopServices().openUrl(urls[version]); } } else { if (!workSilent) { QMessageBox::information(NULL, tr("No updates available"), tr("You have the latest version of this application.")); } } inProgress = false; }
void mADocumentView::readOnlySaveDialogClicked(QAbstractButton *button) { QMessageBox * messageBox = (QMessageBox *) sender(); if(messageBox->buttonRole(button) == QMessageBox::AcceptRole) this->saveAs(); }