void Gitarre::onFindRepoAction() { int i = RepoView->currentIndex().row(); QTreeWidgetItem *item = RepoView->topLevelItem(i); QString itemName = item->text(0); QString dirPath = QFileDialog::getExistingDirectory(this, tr("Open Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if (!dirPath.isEmpty()) { QDir dir (dirPath); if (dir.dirName() == itemName) { if (FindRepoIndex (dirPath) != -1) { QMessageBox::information(this, "Find repository", "This repository already exists in the list"); onFindRepoAction(); } else ReplaceRepo (dirPath, i); } else { QMessageBox messageBox (QMessageBox::NoIcon, "Find repository", "The name of this repository does not match"); QPushButton *buttonReplace = messageBox.addButton ("Replace", QMessageBox::AcceptRole); QPushButton *buttonBrowse = messageBox.addButton ("Browse...", QMessageBox::RejectRole); messageBox.addButton (QMessageBox::Cancel); if (messageBox.clickedButton() == buttonReplace) ReplaceRepo (dirPath, i); else if (messageBox.clickedButton() == buttonBrowse) onFindRepoAction(); } } }
void GameWidget::nextMove() { _gameController->nextMove(); bool gameFinished = _gameController->gameOver(); this->updateActor(); _lblMovementGhostCounter->setText(QString::number(_gameController->getGhostMovementCounter())); if(gameFinished) { QMessageBox msgBox; msgBox.setText("Le Pacman a été attrapé !"); QString text = "Les ghosts ont mis "; text += QString("%1").arg( _gameController->getGhostMovementCounter() ); text += " coups pour attraper le Pacman.\n"; msgBox.setDetailedText(text); QPushButton *btnRestart = msgBox.addButton(tr("&Recommener"), QMessageBox::AcceptRole); QPushButton *btnMenu = msgBox.addButton(tr("Revenir au &menu"), QMessageBox::RejectRole); msgBox.exec(); if (msgBox.clickedButton() == btnRestart) { emit restarted(); } else if (msgBox.clickedButton() == btnMenu) { emit terminated(); } } }
void TicTacToe::on_win(int k) { QMessageBox message; message.setWindowTitle("garble!"); if (k) { if (k > 0) message.setText("Cross guy won"); else message.setText("Circle guy won"); } if (!k) message.setText("A tie!"); message.setInformativeText("Would you like to start a new game?"); QPushButton* newGame = message.addButton("New Game", QMessageBox::ActionRole); QPushButton* end = message.addButton("Close", QMessageBox::ActionRole); message.exec(); if (message.clickedButton() == newGame) emit(reboot()); else if (message.clickedButton() == end) close(); }
//maybeSave() bool MdiChild::maybeSave() { //如果文档被更改过 if(document()->isModified()) { QMessageBox box; box.setWindowTitle("多文档编辑器"); box.setText(tr("是否保存对%1的更改?").arg(userFriendlyCurrentFile())); box.setIcon(QMessageBox::Warning); //添加按钮,QMessgaeBox::YesRole可以表明这个按钮的行为 QPushButton *yesBtn=box.addButton("是(&Y)",QMessageBox::YesRole); box.addButton("否(&N)",QMessageBox::NoRole); QPushButton *cancelBtn=box.addButton("取消",QMessageBox::RejectRole); box.exec();//弹出对话框,让用户选择是否保存修改,或者取消关闭操作 //如果用户选择是,则返回保存操作的结果;如果选择取消,则返回false if(box.clickedButton()==yesBtn) { return save(); } else if(box.clickedButton()==cancelBtn) { return false; } return true;//如果文档未被修改,则直接返回true } }
void ResourceDock::removeAct() { auto item = resTree->currentItem(); if (item->parent() != nullptr) { auto found = resMap.find(item->text(0)); QMessageBox::StandardButton reply; QMessageBox msgBox; msgBox.setText("Choose Remove to remove \'" + item->text(0) + "\' from project.\n" "Choose Delete to permanently delete \'" + item->text(0) + "\' from project."); QAbstractButton *btnRemove = msgBox.addButton("Remove", QMessageBox::YesRole); QAbstractButton *btnDelete = msgBox.addButton("Delete", QMessageBox::DestructiveRole); QAbstractButton *btnCancel = msgBox.addButton("Cancel", QMessageBox::NoRole); msgBox.setIcon(QMessageBox::Question); msgBox.exec(); if (msgBox.clickedButton() == btnCancel) { return; } else if (msgBox.clickedButton() == btnRemove) { emit(resDeleted(found.key(), found->second)); } else if (msgBox.clickedButton() == btnDelete) { emit(resDeleted(found.key(), found->second)); QFile file(resDir + item->text(0)); file.remove(); } delete item; resMap.erase(found); } }
void LightscreenWindow::updaterDone(bool result) { mUpdater->deleteLater(); settings()->setValue("lastUpdateCheck", QDate::currentDate().dayOfYear()); if (!result) { return; } QMessageBox msgBox; msgBox.setWindowTitle(tr("Lightscreen")); msgBox.setText(tr("There's a new version of Lightscreen available.<br>Would you like to see more information?<br>(<em>You can turn this notification off</em>)")); msgBox.setIcon(QMessageBox::Information); QPushButton *yesButton = msgBox.addButton(QMessageBox::Yes); QPushButton *turnOffButton = msgBox.addButton(tr("Turn Off"), QMessageBox::ActionRole); QPushButton *remindButton = msgBox.addButton(tr("Remind Me Later"), QMessageBox::RejectRole); Q_UNUSED(remindButton); msgBox.exec(); if (msgBox.clickedButton() == yesButton) { QDesktopServices::openUrl(QUrl("https://lightscreen.com.ar/whatsnew?from=" + qApp->applicationVersion())); } else if (msgBox.clickedButton() == turnOffButton) { settings()->setValue("options/disableUpdater", true); } }
//################################################################################################### // new gender check for 0.4 bool SettingsManager::GenderCheck(){ using namespace std; QMessageBox m; m.setText("Please select your gender:"); m.setWindowTitle("RoboJournal"); m.setIcon(QMessageBox::Question); QPushButton *male=m.addButton("Male",QMessageBox::AcceptRole); QPushButton *female=m.addButton("Female",QMessageBox::AcceptRole); m.setStandardButtons(NULL); m.exec(); bool isMale; if(m.clickedButton() == male){ //cout << "User chose male" << endl; isMale=true; } if(m.clickedButton() == female){ //cout << "User chose female" << endl; isMale=false; } return isMale; }
bool MainWindow::saveChanges() { if(!m_modified) { return true; } else { QMessageBox closeMessageBox; closeMessageBox.setText("You have unsaved changes."); closeMessageBox.setInformativeText("Do you want to save your changes?"); QPushButton *saveButton = closeMessageBox.addButton("Save", QMessageBox::ActionRole); QPushButton *discardButton = closeMessageBox.addButton("Discard", QMessageBox::ActionRole); closeMessageBox.addButton("Cancel", QMessageBox::RejectRole); closeMessageBox.exec(); if( closeMessageBox.clickedButton() == saveButton ) { saveFile(); return true; } else if( closeMessageBox.clickedButton() == discardButton ) { return true; } else { return false; } } }
void UserManagement::createUser(QString name) { //CREATES A USER QString time=QString::number(QDateTime::currentDateTime().toTime_t());//GETS A CURRENT TIMESTAMP userTimestamp.append(time); if(nameValidation(name)) { //CUSTOM MESSAGE BOX TO CONFIRM USER CREATION QMessageBox invalidName; invalidName.setText("Are you sure you want to create this user?"); QAbstractButton *okayButton =invalidName.addButton(QObject::tr("OKAY"),QMessageBox::ActionRole); QAbstractButton *cancelButton =invalidName.addButton(QObject::tr("CANCEL"),QMessageBox::ActionRole); invalidName.exec(); if(invalidName.clickedButton() == okayButton) { userPlayer.append(name); userLevel.append("1"); } if(invalidName.clickedButton()==cancelButton) { userPlayer.append(""); userLevel.append(""); } } else { userPlayer.append(""); userLevel.append(""); } userSort(); }
void proje::sonucKapat() { if(formEkleSonuc.ekleSonucDegisiklikVar==true) { if(formEkleSonuc.ekleSonucDegisiklikVar==true) { QMessageBox msgBox; msgBox.setText("Değişiklikler kaydedilsin mi?"); msgBox.setIcon(QMessageBox::Warning); QPushButton *tamam = msgBox.addButton("Tamam", QMessageBox::ActionRole); QPushButton *iptal = msgBox.addButton("İptal", QMessageBox::ActionRole); msgBox.exec(); if (msgBox.clickedButton() == tamam) { tamamSonuc(); } else if (msgBox.clickedButton() == iptal) { formEkleSonuc.ekleSonucDegisiklikVar=false; formEkleSonuc.degisenIDOgrenci.clear(); msgBox.close(); } } } formEkleSonuc.close(); }
void FenEdition::on_nouveau_clicked() { QMessageBox confirmationNouveau; confirmationNouveau.setText(tr("Voulez-vous enregistrer ?")); confirmationNouveau.setWindowTitle("DrumMastery"); QAbstractButton* boutonOui = confirmationNouveau.addButton(tr("Oui"), QMessageBox::YesRole); QAbstractButton* boutonNon = confirmationNouveau.addButton(tr("Non"), QMessageBox::NoRole); confirmationNouveau.addButton(tr("Annuler"), QMessageBox::RejectRole); confirmationNouveau.exec(); if (confirmationNouveau.clickedButton()==boutonOui) { FenEdition *nouvelleFenetre; nouvelleFenetre = new FenEdition; nouvelleFenetre->show(); } if (confirmationNouveau.clickedButton()==boutonNon) { FenEdition *nouvelleFenetre; nouvelleFenetre = new FenEdition; nouvelleFenetre->show(); } }
bool xTupleDesignerActions::sSave() { QMessageBox save; save.setText("How do you want to save your changes?"); QPushButton *cancel= save.addButton(QMessageBox::Cancel); QPushButton *db = save.addButton(tr("Database only"), QMessageBox::AcceptRole); QPushButton *file = save.addButton(tr("File only"), QMessageBox::AcceptRole); QPushButton *both = save.addButton(tr("Database and File"),QMessageBox::AcceptRole); save.setDefaultButton(_designer->formwindow()->fileName().isEmpty() ? db : both); save.setEscapeButton((QAbstractButton*)cancel); save.exec(); if (save.clickedButton() == (QAbstractButton*)db) return sSaveToDB(); else if (save.clickedButton() == (QAbstractButton*)file) return sSaveFile(); else if (save.clickedButton() == (QAbstractButton*)both) return sSaveFile() && sSaveToDB(); else if (save.clickedButton() == (QAbstractButton*)cancel) return false; else { qWarning("xTupleDesignerActions::sSave() bug - unknown button clicked"); return false; } }
void KviInput::keyPressEvent(QKeyEvent * e) { if(e->modifiers() & Qt::ControlModifier) { switch(e->key()) { case Qt::Key_Enter: case Qt::Key_Return: { if(m_pMultiLineEditor) { QString szText; m_pMultiLineEditor->getText(szText); if(szText.isEmpty()) return; if(KVI_OPTION_BOOL(KviOption_boolWarnAboutPastingMultipleLines)) { if(szText.length() > 256) { if(szText[0] != '/') { int nLines = szText.count('\n') + 1; if(nLines > 15) { QMessageBox pMsgBox; pMsgBox.setText(__tr2qs("You're about to send a message with %1 lines of text.<br><br>" "This warning is here to prevent you from accidentally " "pasting and sending a really large, potentially unedited message from your clipboard.<br><br>" "Some IRC servers may also consider %1 lines of text a flood, " "in which case you will be disconnected from said server.<br><br>" "Do you still want the message to be sent?").arg(nLines)); pMsgBox.setWindowTitle(__tr2qs("Confirm Sending a Large Message - KVIrc")); pMsgBox.setIcon(QMessageBox::Question); QAbstractButton * pAlwaysButton = pMsgBox.addButton(__tr2qs("Always"), QMessageBox::YesRole); /* QAbstractButton *pYesButton = */ pMsgBox.addButton(__tr2qs("Yes"), QMessageBox::YesRole); QAbstractButton * pNoButton = pMsgBox.addButton(__tr2qs("No"), QMessageBox::NoRole); pMsgBox.setDefaultButton(qobject_cast<QPushButton *>(pNoButton)); pMsgBox.exec(); if(pMsgBox.clickedButton() == pAlwaysButton) { KVI_OPTION_BOOL(KviOption_boolWarnAboutPastingMultipleLines) = false; } else if(pMsgBox.clickedButton() == pNoButton || pMsgBox.clickedButton() == nullptr) { return; } } } } } szText.replace('\t', QString(KVI_OPTION_UINT(KviOption_uintSpacesToExpandTabulationInput), ' ')); //expand tabs to spaces KviUserInput::parse(szText, m_pWindow, QString(), m_pCommandlineModeButton->isChecked()); m_pMultiLineEditor->setText(""); } } break; } } }
Workflow WorkflowManager::determinWorkflow( App::Document *doc) { Workflow rv = getWorkflowForDocument (doc); if (rv != Workflow::Undetermined) { // Return if workflow is known return rv; } // Guess the workflow again rv = guessWorkflow (doc); if (rv != Workflow::Modern) { QMessageBox msgBox; if ( rv == Workflow::Legacy ) { // legacy messages msgBox.setText( QObject::tr( "The document \"%1\" you are editing was design with old version of " "PartDesign workbench." ).arg( QString::fromStdString ( doc->getName()) ) ); msgBox.setInformativeText ( QObject::tr( "Do you want to migrate in order to use modern PartDesign features?" ) ); } else { // The document is already in the middle of migration msgBox.setText( QObject::tr( "The document \"%1\" seems to be either in the middle of" " the migration process from legacy PartDesign or have a slightly broken structure." ).arg( QString::fromStdString ( doc->getName()) ) ); msgBox.setInformativeText ( QObject::tr( "Do you want to make the migration automatically?" ) ); } msgBox.setDetailedText( QObject::tr( "Note If you choose to migrate you won't be able to edit" " the file wtih old FreeCAD versions.\n" "If you refuse to migrate you won't be able to use new PartDesign features" " like Bodies and Parts. As a result you also won't be able to use your parts" " in the assembly workbench.\n" "Although you will be able to migrate any moment later with 'Part Design->Migrate...'." ) ); msgBox.setIcon( QMessageBox::Question ); QPushButton * yesBtn = msgBox.addButton ( QMessageBox::Yes ); QPushButton * manuallyBtn = msgBox.addButton ( QObject::tr ( "Migrate manually" ), QMessageBox::YesRole ); // If it is already a document in the middle of the migration the user shouldn't refuse to migrate if ( rv != Workflow::Undetermined ) { msgBox.addButton ( QMessageBox::No ); } msgBox.setDefaultButton ( yesBtn ); // TODO Add some description of manual migration mode (2015-08-09, Fat-Zer) msgBox.exec(); if ( msgBox.clickedButton() == yesBtn ) { Gui::Application::Instance->commandManager().runCommandByName("PartDesign_Migrate"); rv = Workflow::Modern; } else if ( msgBox.clickedButton() == manuallyBtn ) { rv = Workflow::Modern; } else { rv = Workflow::Legacy; } } // Actually set the result in our map dwMap[ doc ] = rv; return rv; }
void ManagerWindow::agentStartPause() { bool allAccounts; if (this->ui->accountsTabWidget->count() > 1) { QMessageBox msgBox; msgBox.setText(tr("You have more than one account.")); msgBox.setInformativeText(tr("Do you want to start/pause all accounts " "or only the current account?")); QAbstractButton* allBtn = msgBox.addButton(tr("All accounts"), QMessageBox::YesRole); QAbstractButton* currentBtn = msgBox.addButton(tr("Current account only"), QMessageBox::NoRole); msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole); msgBox.setIcon(QMessageBox::Question); msgBox.exec(); if (msgBox.clickedButton() == allBtn) allAccounts = true; else if (msgBox.clickedButton() == currentBtn) allAccounts = false; else return; } //Disable all buttons this->ui->startPauseButton->setEnabled(false); for (QHash<QToolButton*, QString>::const_iterator i = this->queueButtons.constBegin(); i != this->queueButtons.constEnd(); i++) { QToolButton* const queueButton = i.key(); queueButton->setEnabled(false); } bool paused = this->ui->accountsTabWidget->currentWidget()->property("Paused").toBool(); const int listSize = this->config->extensions.size(); for (int i = 0; i < listSize; i++) { if (allAccounts || i == this->ui->accountsTabWidget->currentIndex()) { //Send start/pause request for all queues this account belongs to AstCtiExtensionPtr extension = this->config->extensions.at(i); if (paused == this->ui->accountsTabWidget->widget(i)->property("Paused").toBool()) { for (AstCtiAgentStatusHash::const_iterator i = extension->queues.constBegin(); i != extension->queues.constEnd(); i++) { const QString queue = i.key(); if (paused) if (i.value() == AgentStatusPaused) emit this->pauseRequest(queue, extension->channelName); else emit this->startRequest(queue, extension->channelName); else if (i.value() == AgentStatusLoggedIn) emit this->pauseRequest(queue, extension->channelName); } } } } }
/** * @brief RsCollectionDialog::changeFileName: Change the name of saved file */ void RsCollectionDialog::changeFileName() { QString fileName; if(!misc::getSaveFileName(this, RshareSettings::LASTDIR_EXTRAFILE , QApplication::translate("RsCollectionFile", "Create collection file") , QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")" , fileName,0, QFileDialog::DontConfirmOverwrite)) return; if (!fileName.endsWith("." + RsCollectionFile::ExtensionString)) fileName += "." + RsCollectionFile::ExtensionString ; std::cerr << "Got file name: " << fileName.toStdString() << std::endl; QFile file(fileName) ; if(file.exists()) { RsCollectionFile collFile; if (!collFile.checkFile(fileName,true)) return; QMessageBox mb; mb.setText(tr("Save Collection File.")); mb.setInformativeText(tr("File already exists.")+"\n"+tr("What do you want to do?")); QAbstractButton *btnOwerWrite = mb.addButton(tr("Overwrite"), QMessageBox::YesRole); QAbstractButton *btnMerge = mb.addButton(tr("Merge"), QMessageBox::NoRole); QAbstractButton *btnCancel = mb.addButton(tr("Cancel"), QMessageBox::ResetRole); mb.setIcon(QMessageBox::Question); mb.exec(); if (mb.clickedButton()==btnOwerWrite) { //Nothing to do } else if (mb.clickedButton()==btnMerge) { //Open old file to merge it with RsCollection QDomDocument qddOldFile("RsCollection"); if (qddOldFile.setContent(&file)) { QDomElement docOldElem = qddOldFile.elementsByTagName("RsCollection").at(0).toElement(); collFile.recursCollectColFileInfos(docOldElem,_newColFileInfos,QString(),false); }//(qddOldFile.setContent(&file)) } else if (mb.clickedButton()==btnCancel) { return; } else { return; } } else {//if(file.exists()) //create a new empty file to check if name if good. if (!file.open(QFile::WriteOnly)) return; file.remove(); }//if(file.exists()) _fileName = fileName; updateList(); }
StitchSet* StitchLibraryUi::addStitchSet(QString fileName) { if(fileName.isEmpty()) return 0; if(!QFileInfo(fileName).exists()) return 0; QString dest = StitchLibrary::inst()->nextSetSaveFile(); //make a set folder QFileInfo info(dest); QDir(info.path()).mkpath(info.path() + "/" + info.baseName()); StitchSet* set = new StitchSet(); set->loadDataFile(fileName, dest); StitchSet* test = 0; test = StitchLibrary::inst()->findStitchSet(set->name()); if(test) { QMessageBox msgbox; msgbox.setText(tr("A stitch set with the name '%1' already exists in your library.").arg(set->name())); msgbox.setInformativeText(tr("What would you like to do?")); msgbox.setIcon(QMessageBox::Question); QPushButton* overwrite = msgbox.addButton(tr("Replace the existing set"), QMessageBox::AcceptRole); QPushButton* rename = msgbox.addButton(tr("Rename the new set"), QMessageBox::ApplyRole); /*QPushButton* cancel =*/ msgbox.addButton(tr("Don't add the new set"), QMessageBox::RejectRole); msgbox.exec(); if(msgbox.clickedButton() == overwrite) { StitchLibrary::inst()->removeSet(test); //FIXME: this is going to cause crashes when removing sets with sts in the master list! } else if(msgbox.clickedButton() == rename) { bool ok = false; QString text; while(!ok || text.isEmpty() || text == set->name() ){ text = QInputDialog::getText(0, tr("New Set Name"), tr("Stitch set name:"), QLineEdit::Normal, set->name(), &ok); } //TODO: allow the user to 'cancel out' of this loop. set->setName(text); } else { set->deleteLater(); return 0; } } StitchLibrary::inst()->addStitchSet(set); return set; }
bool MantidApplication::notify( QObject * receiver, QEvent * event ) { bool res = false; try { res = QApplication::notify(receiver,event); } catch(std::exception& e) { if (MantidQt::API::MantidDialog::handle(receiver,e)) return true; // stops event propagation // Restore possible override cursor while(QApplication::overrideCursor()) { QApplication::restoreOverrideCursor(); } g_log.fatal()<<"Unexpected exception: "<<e.what()<<"\n"; QMessageBox ask; QAbstractButton *terminateButton = ask.addButton(tr("Terminate"), QMessageBox::ActionRole); ask.addButton(tr("Continue"), QMessageBox::ActionRole); ask.setText("Sorry, MantidPlot has caught an unexpected exception:\n\n"+QString::fromStdString(e.what())+ "\n\nWould you like to terminate MantidPlot or try to continue working?\nIf you choose to continue it is advisable to save your data and restart the application."); ask.setIcon(QMessageBox::Critical); ask.exec(); if (ask.clickedButton() == terminateButton) { g_log.fatal("Terminated by user."); quit(); }else g_log.fatal("Continue working."); } catch(...) { g_log.fatal()<<"Unknown exception\n"; QMessageBox ask; QAbstractButton *terminateButton = ask.addButton(tr("Terminate"), QMessageBox::ActionRole); ask.addButton(tr("Continue"), QMessageBox::ActionRole); ask.setText("Sorry, MantidPlot has caught an unexpected exception"\ "\n\nWould you like to terminate MantidPlot or try to continue working?\nIf you choose to continue it is advisable to save your data and restart the application."); ask.setIcon(QMessageBox::Critical); ask.exec(); if (ask.clickedButton() == terminateButton) { g_log.fatal("Terminated by user."); quit(); }else g_log.fatal("Continue working."); } return res; }
void MainWindowView::closeEvent(QCloseEvent* event) { //per fermare la chiusura utilizzare event->ignore(); //Check if there's some file modified and ask to the user what he wanna do for(int i=0; i < m_openedXmlDocuments.size(); ++i) { //If it's modified if(m_openedXmlDocuments.at(i)->IsModified()) { //Ask to the user QMessageBox msgBox; msgBox.setText(m_openedXmlDocuments.at(i)->GetAbsoluteFileName() + "\n\n This file has been modified. Do you want to save the modifies?"); msgBox.setIcon(QMessageBox::Question); //Buttons QPushButton* saveBnt = new QPushButton("Save"); msgBox.addButton(saveBnt, QMessageBox::AcceptRole); connect(saveBnt, SIGNAL(clicked()), &msgBox, SLOT(accept())); QPushButton* cancelBnt = msgBox.addButton("Discard", QMessageBox::RejectRole); connect(cancelBnt, SIGNAL(clicked()), &msgBox, SLOT(reject())); QPushButton* abortBnt = msgBox.addButton("Cancel", QMessageBox::RejectRole); connect(abortBnt, SIGNAL(clicked()), &msgBox, SLOT(reject())); //Set yes as defalut button msgBox.setDefaultButton(saveBnt); //Show the dialog and store the result msgBox.exec(); //If the user has confirmed if(msgBox.clickedButton() == saveBnt) { //Save the file and continue m_openedXmlDocuments.at(i)->SaveXmlFile(); } //Stop the closing of the programm else if(msgBox.clickedButton() == abortBnt) { event->ignore(); return; } } } //Also close the error result window if it's if(m_pXmlErrorWidget) { delete m_pXmlErrorWidget; m_pXmlErrorWidget = 0; } ClearAllXml(); }
bool MainForm::load_settings() { options = new Options(); if (!options->read()) { options = DEFAULT_SETTINGS; } edit_username->setText(options->get_hoster()->get_username().c_str()); edit_password->setText(options->get_hoster()->get_password().c_str()); mpv_settings->setPlainText(options->mpv_settings.c_str()); //todo hoster edit_down_speed->setValue(options->download_speed / 1024.0 / 1024.0); edit_memory->setValue(options->memory / 1024.0 / 1024.0); archive_directory->setFile(options->archive_directory.c_str()); download_directory->setFile(options->download_directory.c_str()); QFileInfo file(options->archive_directory.c_str()); create_directories(file.absoluteDir().absolutePath()); create_directories(options->download_directory.c_str()); disclaimer = options->disclaimer; bool first_run = disclaimer; if (disclaimer) { QMessageBox box; box.setText( "I will not take any responsibility for any of your actions. This program is maybe against your state's law."); box.setWindowTitle("Disclaimer"); box.setIcon(QMessageBox::Information); QPushButton *ok_button = box.addButton("Yes, I understand.", QMessageBox::ActionRole); QPushButton *abortButton = box.addButton("Terminate this programm.", QMessageBox::ActionRole); box.exec(); if (box.clickedButton() == ok_button) { disclaimer = false; } else if (box.clickedButton() == abortButton) { disclaimer = true; } } options->disclaimer = disclaimer; options->write(); return first_run; }
void QgsProjectBadLayerGuiHandler::handleBadLayers( QList<QDomNode> layers, QDomDocument projectDom ) { Q_UNUSED( projectDom ); QgsDebugMsg( QString( "%1 bad layers found" ).arg( layers.size() ) ); // make sure we have arrow cursor (and not a wait cursor) QApplication::setOverrideCursor( Qt::ArrowCursor ); QMessageBox messageBox; QAbstractButton *ignoreButton = messageBox.addButton( tr( "Ignore" ), QMessageBox::ActionRole ); QAbstractButton *okButton = messageBox.addButton( QMessageBox :: Ok ); messageBox.addButton( QMessageBox :: Cancel ); messageBox.setWindowTitle( tr( "QGIS Project Read Error" ) ); messageBox.setText( tr( "Unable to open one or more project layers.\nChoose " "ignore to continue loading without the missing layers. Choose cancel to " "return to your pre-project load state. Choose OK to try to find the " "missing layers." ) ); messageBox.setIcon( QMessageBox::Critical ); messageBox.exec(); QgsProjectBadLayerGuiHandler::mIgnore = false; if ( messageBox.clickedButton() == okButton ) { QgsDebugMsg( "want to find missing layers is true" ); // attempt to find the new locations for missing layers // XXX vector file hard-coded -- but what if it's raster? QString filter = QgsProviderRegistry::instance()->fileVectorFilters(); findLayers( filter, layers ); } else if ( messageBox.clickedButton() == ignoreButton ) { QgsProjectBadLayerGuiHandler::mIgnore = true; } else { // Do nothing } QApplication::restoreOverrideCursor(); }
void MainWindowView::dropEvent(QDropEvent *event) { //Take the ulrs const QList<QUrl>& urls = event->mimeData()->urls(); //Controlf if the url list is not empty if (urls.isEmpty()) { return; } //If it's not a valid file in the local file system const QString& fileName = urls.first().toLocalFile(); if (fileName.isEmpty()) { return; } //All it's ok try to open the new file asking the action that the user wants QMessageBox msgBox; msgBox.setText("Do you want to open the file as main file or add as associate file?\n\n" + fileName); msgBox.setIcon(QMessageBox::Question); //Buttons QPushButton* openAsMainFileBnt = msgBox.addButton(tr("Open as main file"), QMessageBox::ActionRole); QPushButton* openAsAssociateFileBnt = msgBox.addButton(tr("Open as associate file"), QMessageBox::ActionRole); msgBox.addButton(QMessageBox::Abort); //Set yes as defalut button msgBox.setDefaultButton(openAsMainFileBnt); //Show the dialog msgBox.exec(); if(msgBox.clickedButton() == openAsMainFileBnt) { //Open as main file OpenXmlFile(fileName, true); } else if(msgBox.clickedButton() == openAsAssociateFileBnt) { //Add to the associate files m_pAssociatedFiles->AddAssociatedFileName(fileName); //It's not needed to insert the file because if it's iserted, tha min will open the file automatically } }
void US_Win::closeProcs( void ) { QString names; QList<procData*>::iterator p; for ( p = procs.begin(); p != procs.end(); p++ ) { procData* d = *p; names += d->name + "\n"; } QString isAre = ( procs.size() > 1 ) ? "es are" : " is"; QString itThem = ( procs.size() > 1 ) ? "them" : "it"; QMessageBox box; box.setWindowTitle( tr( "Attention" ) ); box.setText( QString( tr( "The following process%1 still running:\n%2" "Do you want to close %3?" ) .arg( isAre ).arg( names ).arg( itThem ) ) ); QString killText = tr( "&Kill" ); QString closeText = tr( "&Close Gracefully" ); QString leaveText = tr( "&Leave Running" ); QPushButton* kill = box.addButton( killText , QMessageBox::YesRole ); box.addButton( closeText, QMessageBox::YesRole ); QPushButton* leave = box.addButton( leaveText, QMessageBox::NoRole ); box.exec(); if ( box.clickedButton() == leave ) return; for ( p = procs.begin(); p != procs.end(); p++ ) { procData* d = *p; QProcess* process = d->proc; if ( box.clickedButton() == kill ) process->kill(); else process->terminate(); } // We need to sleep slightly (one millisecond) so that the system can clean // up and properly release shared memory. g.scheduleDelete(); US_Sleep::msleep( 1 ); }
void clientView::on_reqBtn_clicked() /*Request to open or close an account*/ { MaintanenceView mainview; qDebug()<<(client.cheqBal); QMessageBox accountClose; //Ask client what they would like to close accountClose.setText("What would you like to close?"); accountClose.setInformativeText("Which account would you like to close?"); QPushButton *Chequing = accountClose.addButton(tr("Request Chequing"), QMessageBox::ActionRole); QPushButton *Savings = accountClose.addButton(tr("Request Savings"),QMessageBox::ActionRole); QPushButton *Both = accountClose.addButton(tr("Both"),QMessageBox::ActionRole); accountClose.exec(); if(accountClose.clickedButton() == Chequing && client.cheqBal == 0){ //If they want to close chequing //Log action to file QString action = "REQUESTING CLOSURE OF ACCOUNT: CHEQ"; mainview.isTrail(client.isTrail, action); QSqlQuery insert; insert.prepare("INSERT INTO CLIENT_REQUEST (name, openSav, openCheq, done) VALUES('"+client.name+"', 0,1,0)"); insert.exec(); QMessageBox::information(this,"Done","Your request will be completed in the next 24 hours"); }else if(accountClose.clickedButton() == Savings && client.savBal == 0){ //If they want to close savings QString action = "REQUESTING CLOSURE OF ACCOUNT: SAV"; mainview.isTrail(client.isTrail, action); QSqlQuery insert; insert.prepare("INSERT INTO CLIENT_REQUEST (name, openSav, openCheq, done) VALUES('"+client.name+"', 1,0,0)"); insert.exec(); QMessageBox::information(this,"Done","Your request will be completed in the next 24 hours"); }else if(accountClose.clickedButton() == Both && client.cheqBal == 0 && client.savBal == 0){ //If they want to close both (create two tickets) QString action = "REQUESTING CLOSURE OF ACCOUNT: CHEQ & SAV"; mainview.isTrail(client.isTrail, action); QSqlQuery insert; insert.prepare("INSERT INTO CLIENT_REQUEST (name, openSav, openCheq, done) VALUES('"+client.name+"', 1,0,0)"); insert.prepare("INSERT INTO CLIENT_REQUEST (name, openSav, openCheq, done) VALUES('"+client.name+"', 0,1,0)"); insert.exec(); QMessageBox::information(this,"Done","Your request will be completed in the next 24 hours"); }else{ QMessageBox::information(this,"Cancelled","Please empty your funds before submitting a request"); } }
void WorkoutWindow::ergFileSelected(ErgFile*f) { if (active) return; if (workout->isDirty()) { QMessageBox msgBox; msgBox.setText(tr("You have unsaved changes to a workout.")); msgBox.setInformativeText(tr("Do you want to save them?")); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Cancel); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); // save first, otherwise changes lost if(msgBox.clickedButton() == msgBox.button(QMessageBox::Yes)) { active = true; saveFile(); active = false; } } // just get on with it. ergFile = f; workout->ergFileSelected(f); // almost certainly hides it on load setScroller(QPointF(workout->minVX(), workout->maxVX())); }
void StitchLibraryUi::resetLibrary() { QMessageBox msgbox; msgbox.setText(tr("If you reset the stitch library you will lose any changes you have made.")); msgbox.setInformativeText(tr("Are you sure you want to continue?")); msgbox.setIcon(QMessageBox::Question); QPushButton* reset = msgbox.addButton(tr("Yes, reset the library"), QMessageBox::AcceptRole); /*QPushButton* cancel =*/ msgbox.addButton(tr("No, keep the library as is"), QMessageBox::RejectRole); msgbox.exec(); if(msgbox.clickedButton() != reset) return; QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); //TODO: clean up this code. bring all the reset code together. //FIXME: resetting a user set returns it to it's first save. keep user set's in a different folder? ui->listView->clearSelection(); QString curSet = ui->stitchSource->currentText(); updateSourceDropDown(StitchLibrary::inst()->overlay()->name()); StitchLibrary::inst()->resetMasterStitchSet(); if(curSet != StitchLibrary::inst()->overlay()->name()) updateSourceDropDown(curSet); ui->listView->resizeColumnsToContents(); ui->listView->resizeRowsToContents(); QApplication::restoreOverrideCursor(); }
bool Upgrade::askReanalyzeBeats() { QString windowTitle = QMessageBox::tr("Upgrading Mixxx from v1.9.x/1.10.x."); QString mainHeading = QMessageBox::tr("Mixxx has a new and improved beat detector."); QString paragraph1 = QMessageBox::tr( "When you load tracks, Mixxx can re-analyze them " "and generate new, more accurate beatgrids. This will make " "automatic beatsync and looping more reliable."); QString paragraph2 = QMessageBox::tr( "This does not affect saved cues, hotcues, playlists, or crates."); QString paragraph3 = QMessageBox::tr( "If you do not want Mixxx to re-analyze your tracks, choose " "\"Keep Current Beatgrids\". You can change this setting at any time " "from the \"Beat Detection\" section of the Preferences."); QString keepCurrent = QMessageBox::tr("Keep Current Beatgrids"); QString generateNew = QMessageBox::tr("Generate New Beatgrids"); QMessageBox msgBox; msgBox.setIconPixmap(QPixmap(":/images/mixxx_icon.svg")); msgBox.setWindowTitle(windowTitle); msgBox.setText(QString("<html><h2>%1</h2><p>%2</p><p>%3</p><p>%4</p></html>") .arg(mainHeading, paragraph1, paragraph2, paragraph3)); msgBox.addButton(keepCurrent, QMessageBox::NoRole); QPushButton* OverwriteButton = msgBox.addButton( generateNew, QMessageBox::YesRole); msgBox.setDefaultButton(OverwriteButton); msgBox.exec(); if (msgBox.clickedButton() == (QAbstractButton*)OverwriteButton) { return true; } return false; }
bool userAgreesWithLegalNotice() { Preferences* const pref = Preferences::instance(); if (pref->getAcceptedLegal()) // Already accepted once return true; #ifdef DISABLE_GUI std::cout << std::endl << "*** " << qPrintable(QObject::tr("Legal Notice")) << " ***" << std::endl; std::cout << qPrintable(QObject::tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.\n\nNo further notices will be issued.")) << std::endl << std::endl; std::cout << qPrintable(QObject::tr("Press %1 key to accept and continue...").arg("'y'")) << std::endl; char ret = getchar(); // Read pressed key if (ret == 'y' || ret == 'Y') { // Save the answer pref->setAcceptedLegal(true); return true; } #else QMessageBox msgBox; msgBox.setText(QObject::tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.\n\nNo further notices will be issued.")); msgBox.setWindowTitle(QObject::tr("Legal notice")); msgBox.addButton(QObject::tr("Cancel"), QMessageBox::RejectRole); QAbstractButton *agree_button = msgBox.addButton(QObject::tr("I Agree"), QMessageBox::AcceptRole); msgBox.show(); // Need to be shown or to moveToCenter does not work msgBox.move(Utils::Misc::screenCenter(&msgBox)); msgBox.exec(); if (msgBox.clickedButton() == agree_button) { // Save the answer pref->setAcceptedLegal(true); return true; } #endif return false; }
void TargetSettingsPanelWidget::removeTarget(int targetIndex) { Target *t = m_targets.at(targetIndex); ProjectExplorer::BuildManager *bm = ProjectExplorerPlugin::instance()->buildManager(); if (bm->isBuilding(t)) { QMessageBox box; QPushButton *closeAnyway = box.addButton(tr("Cancel Build && Remove Kit"), QMessageBox::AcceptRole); QPushButton *cancelClose = box.addButton(tr("Do Not Remove"), QMessageBox::RejectRole); box.setDefaultButton(cancelClose); box.setWindowTitle(tr("Remove Kit %1?").arg(t->displayName())); box.setText(tr("The kit <b>%1</b> is currently being built.").arg(t->displayName())); box.setInformativeText(tr("Do you want to cancel the build process and remove the Kit anyway?")); box.exec(); if (box.clickedButton() != closeAnyway) return; bm->cancel(); } else { // We don't show the generic message box on removing the target, if we showed the still building one int ret = QMessageBox::warning(this, tr("Qt Creator"), tr("Do you really want to remove the\n" "\"%1\" kit?").arg(t->displayName()), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (ret != QMessageBox::Yes) return; } m_project->removeTarget(t); }
void XtalOptDialog::showTutorialDialog() const { QMessageBox mbox; mbox.setText("There is a tutorial available for new XtalOpt users at\n\n" "http://xtalopt.openmolecules.net/globalsearch/docs/tut-xo.html" "\n\nWould you like to go there now?"); mbox.setIcon(QMessageBox::Information); QPushButton *yes = mbox.addButton(tr("&Yes"), QMessageBox::YesRole); QPushButton *no = mbox.addButton(tr("&No"), QMessageBox::NoRole); QPushButton *never = mbox.addButton(tr("No, stop asking!"), QMessageBox::NoRole); mbox.exec(); QAbstractButton *clicked = mbox.clickedButton(); if (clicked == yes) { QDesktopServices::openUrl (QUrl("http://xtalopt.openmolecules.net/globalsearch/docs/tut-xo.html", QUrl::TolerantMode)); } else if (clicked == never) { QSettings settings; settings.setValue("xtalopt/showTutorialLink", false); } // else ("no" clicked) just return; return; }