void MainWindow::GeneratePython() { QString fileName = ""; QFileDialog dlg(this, tr("Generate Python")); dlg.setFileMode(QFileDialog::AnyFile); if(dlg.exec()) { fileName = dlg.selectedFiles().at(0); /* check if file exists and notificate the user */ if(QFile(fileName).exists()) { if(QMessageBox(QMessageBox::Question, "File exists", "File already exists. Overwrite ?", QMessageBox::Ok | QMessageBox::No).exec() != QMessageBox::Ok) { return; } } } this->m_gen->GenerateCodePython(fileName.toStdString()); if(fileName != "") { QMessageBox(QMessageBox::Information, "Generatie Python", "Code saved at " + fileName).exec(); } }
void MainWindow::SaveXml() { QString fileName = ""; QFileDialog dlg(this, tr("Save XML")); dlg.setFileMode(QFileDialog::AnyFile); if(dlg.exec()) { fileName = dlg.selectedFiles().at(0); /* check if file exists and notificate the user */ if(QFile(fileName).exists()) { if(QMessageBox(QMessageBox::Question, "File exists", "File already exists. Overwrite ?", QMessageBox::Ok | QMessageBox::No).exec() != QMessageBox::Ok) { return; } } } //QString fileName = "test.xml"; QFile file(fileName); file.open(QFile::WriteOnly | QFile::Text); QXmlStreamWriter *writer = new QXmlStreamWriter(&file); guiUtils::saveXml(writer, this->m_gen, this->m_dw); file.close(); QMessageBox(QMessageBox::Information, "Save Simulation", "Simulation saved at " + fileName).exec(); }
void MainWindow::SavePicture() { QFileDialog dlg(this, tr("Save image")); dlg.setFileMode(QFileDialog::AnyFile); if(dlg.exec()) { QImage img = QPixmap::grabWidget(this->m_dw).toImage(); QString fileName = dlg.selectedFiles().at(0); /* check if file exists and notificate the user */ if(QFile(fileName).exists()) { if(QMessageBox(QMessageBox::Question, "File exists", "File already exists. Overwrite ?", QMessageBox::Ok | QMessageBox::No).exec() != QMessageBox::Ok) { return; } } if(img.save(fileName)) { QMessageBox(QMessageBox::Information, "Save picture", "Picture saved at " + fileName).exec(); } else { QMessageBox(QMessageBox::Warning, "Save picture", "Picture saving failed!").exec(); } } }
void MainWindow::LoadXml() { QString fileName = ""; QFileDialog dlg(this, tr("Load XML")); dlg.setFileMode(QFileDialog::AnyFile); if(dlg.exec()) { fileName = dlg.selectedFiles().at(0); if(!QFile(fileName).exists()) { QMessageBox(QMessageBox::Information, "File don't exists", "File don't exists.").exec(); return; } } QFile file(fileName); file.open(QFile::ReadOnly | QFile::Text); QXmlStreamReader *reader = new QXmlStreamReader(&file); guiUtils::loadXml(reader, this->m_gen, this->m_dw); file.close(); QMessageBox(QMessageBox::Information, "Load Simulation", "Simulation loaded.").exec(); }
bool Petanque::ameliorer() { try { if(niveau == 1) { niveau++; portee = 3 + niveau; frappe = 15 * pow(niveau,1.5); cout += amelioration_1; this->setPixmap(*etatTour.at(1)); return true; } else if(niveau == 2) { niveau++; portee = 3 + niveau; frappe = 15 * pow(niveau,1.5); cout += amelioration_2; this->setPixmap(*etatTour.at(2)); return true; } else throw std::exception(); } catch(std::exception& e) { QMessageBox(QMessageBox::Information,"Amelioration impossible","La tour est de niveau maximal").exec(); return false; } }
Task::Task(QDomElement &root) { QDomElement titleElement = root.firstChildElement("title"); if (titleElement.isNull()) QMessageBox(QMessageBox::Critical, "Error !", "Error : the xml input file is malformed"); /* FIXME : add it to the rest */ _title = titleElement.text(); QDomElement length = titleElement.nextSiblingElement("length"); QDomElement hours = length.firstChildElement("hours"); int hour = hours.text().toInt(); QDomElement minutes = hours.nextSiblingElement("minutes"); int minute = minutes.text().toInt(); _taskLength = QTime(hour, minute, 0); QDomElement remaining = length.nextSiblingElement("remaining"); hours = remaining.firstChildElement("hours"); hour = hours.text().toInt(); minutes = hours.nextSiblingElement("minutes"); minute = minutes.text().toInt(); _timeRemaining = QTime(hour, minute, 0); }
void depthProbe::button() { readSerial(true); sendSerial("$\r"); QString popochas = readSerial(false); QMessageBox(QMessageBox::Critical,"Interaction needed",popochas,QMessageBox::Ok).exec(); }
void Transport::onPlayClicked() { QString fileName = ((CommAudio*)parent())->getSelectedSong(); if (fileName.isEmpty()) { QMessageBox(QMessageBox::Warning, "No Music Files", "There were no music files found. Try adding a folder which contains audio files.").exec(); } switch (playingState) { case STOPPED: AudioManager::instance()->playMusic(fileName); ui->playPushButton->setIcon(QIcon(ICON_PAUSE)); emit songChanged(); playingState = PLAYING; break; case PLAYING: AudioManager::instance()->togglePause(); ui->playPushButton->setIcon(QIcon(ICON_PLAY)); ui->statusLabel->setText("Paused"); playingState = PAUSED; break; case PAUSED: AudioManager::instance()->togglePause(); ui->playPushButton->setIcon(QIcon(ICON_PAUSE)); QString text = ((CommAudio*) parent())->getMuted() ? "Mute" : ""; ui->statusLabel->setText(text); playingState = PLAYING; break; } }
/** * Shows file details for a playlist item. */ void VorbitalDlg::ShowFileInfo(int index) { QListWidgetItem* item = _lstPlaylist->item(index); QVariant variant = item->data(Qt::UserRole); QString filename = variant.toString(); QMessageBox(QMessageBox::Information, filename, "File Location", QMessageBox::Ok); }
void MainWindow::Quit() { if (QMessageBox::Yes == QMessageBox(QMessageBox::Warning, "Confirmation de sortie.", "Êtes-vous sûr de vouloir quitter BomberMan ?", QMessageBox::Yes|QMessageBox::No).exec()) { exit(true); } }
void MainWindow::slotNewProject() { NewProjectDialog npd(this); if (npd.exec() == QDialog::Accepted) { try { Project_sV *project = npd.buildProject(); // Save project XmlProjectRW_sV writer; //qDebug() << "Saving project as " << npd.filename; // check if directory exist ... QFileInfo projfile(npd.projectFilename()); QDir dir(projfile.absoluteDir()); if (!dir.exists()) { dir.mkpath("."); } try { writer.saveProject(project, npd.projectFilename()); statusBar()->showMessage(QString(tr("Saved project as: %1")).arg(npd.projectFilename())); setWindowModified(false); } catch (Error_sV &err) { QMessageBox(QMessageBox::Warning, tr("Error writing project file"), err.message()).exec(); } m_projectPath = npd.projectFilename(); project->preferences()->viewport_secRes() = QPointF(400, 400)/project->frameSource()->framesCount()*project->frameSource()->fps()->fps(); /* add a first (default) node */ Node_sV snode; snode.setX(0.0); snode.setY(0.0); project->nodes()->add(snode); loadProject(project); m_wCanvas->showHelp(true); setWindowModified(true); } catch (FrameSourceError &err) { QMessageBox(QMessageBox::Warning, "Frame source error", err.message()).exec(); } } }
// A suite of TestRail test cases contains trees. // The nodes of the trees are sections // The leaves are the test cases // // Each node and leaf have an ID and a parent ID. // Therefore, the tree is built top-down, using a stack to store the IDs of each node // void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirectory, const QString& userGitHub, const QString& branchGitHub) { QString filename = _outputDirectory + "/addTestCases.py"; if (QFile::exists(filename)) { QFile::remove(filename); } QFile file(filename); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Could not create 'addTestCases.py'"); exit(-1); } QTextStream stream(&file); // Code to access TestRail stream << "from testrail import *\n"; stream << "client = APIClient('" << _url.toStdString().c_str() << "')\n"; stream << "client.user = '******'\n"; stream << "client.password = '******'\n\n"; stream << "from stack import *\n"; stream << "parent_ids = Stack()\n\n"; // top-level section stream << "data = { 'name': '" << "Test Section - " << QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm") + "', " << "'suite_id': " + _suiteID + "}\n"; stream << "section = client.send_post('add_section/' + str(" << _projectID << "), data)\n"; // Now we push the parent_id, and recursively process each directory stream << "parent_ids.push(section['id'])\n\n"; processDirectoryPython(testDirectory, stream, userGitHub, branchGitHub); file.close(); if (QMessageBox::Yes == QMessageBox(QMessageBox::Information, "Python script has been created", "Do you want to run the script and update TestRail?", QMessageBox::Yes | QMessageBox::No).exec() ) { QProcess* process = new QProcess(); connect(process, &QProcess::started, this, [=]() { _busyWindow.exec(); }); connect(process, SIGNAL(finished(int)), process, SLOT(deleteLater())); connect(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, [=](int exitCode, QProcess::ExitStatus exitStatus) { _busyWindow.hide(); }); #ifdef Q_OS_WIN QStringList parameters = QStringList() << _outputDirectory + "/addTestCases.py"; process->start(_pythonCommand, parameters); #elif defined Q_OS_MAC QStringList parameters = QStringList() << "-c" << _pythonCommand + " " + _outputDirectory + "/addTestCases.py"; process->start("sh", parameters); #endif } }
void SimpleHtml::on_actionSave_triggered() { if (!ui->htmlProjectWidget->saveProject()) { QMessageBox(QMessageBox::Critical, "Error", "Unable to save the project", QMessageBox::Ok); } }
void jConference::s_conferenceInvite(const JID &room, const JID &from, const QString &reason_sent, const QString &password) { QString reason = reason_sent; if (reason.isEmpty()) reason = "no reason"; if (QMessageBox(QMessageBox::Question, tr("Invite to groupchat"), tr("User %1 invite you\nto conference %2\nwith reason \"%3\"\nAccept invitation?").arg(utils::fromStd(from.bare())).arg(utils::fromStd(room.full())).arg(reason), QMessageBox::Yes | QMessageBox::No).exec() == QMessageBox::Yes) joinGroupchat(utils::fromStd(room.full()), "", password, true); }
void MainWindow::slotShowRenderDialog() { if (m_project->renderTask() != NULL) { disconnect(SIGNAL(signalRendererContinue()), m_project->renderTask()); } RenderingDialog renderingDialog(m_project, this); if (renderingDialog.exec() == QDialog::Accepted) { RenderTask_sV *task = renderingDialog.buildTask(); if (task != 0) { task->moveToThread(&m_rendererThread); if (m_project->renderTask() != NULL) { disconnect(SIGNAL(signalRendererContinue()), m_project->renderTask()); } //m_project->replaceRenderTask(task); if (m_renderProgressDialog == NULL) { m_renderProgressDialog = new ProgressDialog(this); m_renderProgressDialog->setWindowTitle(tr("Rendering progress")); } else { m_renderProgressDialog->disconnect(); } connect(task, SIGNAL(signalNewTask(QString,int)), m_renderProgressDialog, SLOT(slotNextTask(QString,int))); connect(task, SIGNAL(signalItemDesc(QString)), m_renderProgressDialog, SLOT(slotTaskItemDescription(QString))); connect(task, SIGNAL(signalTaskProgress(int)), m_renderProgressDialog, SLOT(slotTaskProgress(int))); connect(task, SIGNAL(signalRenderingFinished(QString)), m_renderProgressDialog, SLOT(slotAllTasksFinished(QString))); connect(task, SIGNAL(signalRenderingAborted(QString)), this, SLOT(slotRenderingAborted(QString))); connect(task, SIGNAL(signalRenderingAborted(QString)), m_renderProgressDialog, SLOT(close())); connect(task, SIGNAL(signalRenderingStopped(QString)), m_renderProgressDialog, SLOT(slotAborted(QString))); connect(m_renderProgressDialog, SIGNAL(signalAbortTask()), task, SLOT(slotStopRendering())); //connect(this, SIGNAL(signalRendererContinue()), task, SLOT(slotContinueRendering()), Qt::UniqueConnection); connect(task, SIGNAL(workFlowRequested()), &m_rendererThread, SLOT(start())); connect(&m_rendererThread, SIGNAL(started()), task, SLOT(slotContinueRendering())); connect(task, SIGNAL(signalRenderingFinished(QString)), &m_rendererThread, SLOT(quit())); // done another way ?! connect(task, SIGNAL(signalRenderingFinished(QString)), task, SLOT(deleteLater())); //connect(&m_rendererThread, &QThread::finished, task, &QObject::deleteLater); // let's start m_rendererThread.wait(); // If the thread is not running, this will immediately return. m_renderProgressDialog->show(); //emit signalRendererContinue(); //m_rendererThread.exec (); m_rendererThread.start(); task->requestWork(); } } else { QMessageBox(QMessageBox::Warning, tr("Aborted"), tr("Aborted by user"), QMessageBox::Ok).exec(); } }
void MainWindow::loadProject(QString path) { m_settings.setValue("directories/lastOpenedProject", path); XmlProjectRW_sV reader; try { QString warning; Project_sV *project = reader.loadProject(path, &warning); if (warning.length() > 0) { QMessageBox(QMessageBox::Warning, tr("Warning"), warning).exec(); } m_projectPath = path; loadProject(project); } catch (FrameSourceError &err) { QMessageBox(QMessageBox::Warning, tr("Frame source error"), err.message()).exec(); } catch (Error_sV &err) { QMessageBox(QMessageBox::Warning, tr("Error"), err.message()).exec(); } }
bool MainWindow::warn(){ return QMessageBox::Yes == QMessageBox(QMessageBox::Warning, "Warning!", "This will erase your current save.\n" "Are you really sure you want to do this?", QMessageBox::Yes|QMessageBox::No ).exec(); }
void MainWindow::oProgramie() { QMessageBox( QMessageBox::Information, "O Programie...", "Projekt_OSM(7) \n" "dn. 21.04.2010 \n" "v1.2 \n" " \n" "Roman Modzelewski \n" "Michal Losicki \n" "Lukasz Zeleznicki \n").exec(); }
void SerialMonitor::readException(QString what){ disconnectSerial(); setSerialPort(ui->menuSerialPorts->getDefaultPort()); QMessageBox(QMessageBox::Critical, tr("Read error"), what, QMessageBox::Ok ).exec(); }
void MainWindow::processFinished(int exitCode, QProcess::ExitStatus exitStatus) { progress->hide(); progress->deleteLater(); QString msg = QString::fromUtf8(process->readAllStandardError()); if (exitCode == 0 || exitStatus != QProcess::NormalExit) { if (msg.isEmpty()) { if (processWasCanceled) msg = tr("The process was canceled."); else msg = tr("The operation completed successfully."); } QMessageBox(QMessageBox::Information, tr("rpgtools"), msg, QMessageBox::Ok).exec(); } else { if (msg.isEmpty()) msg = tr("The operation failed."); QMessageBox(QMessageBox::Critical, tr("rpgtools"), msg, QMessageBox::Ok).exec(); } process->deleteLater(); }
bool FileFormatMP3::Init() { int err = MPG123_OK; err = mpg123_init(); if( err != MPG123_OK || (_mpg123 = mpg123_new(NULL, &err)) == NULL) { QMessageBox(QMessageBox::Critical, QString("Unable to initialize MP3 playback library."), QString("ERROR"), QMessageBox::Ok ); return false; } return true; }
void CMainWindow::itemActivated(qulonglong hash, CPanelWidget *panel) { if (!ui->commandLine->currentText().isEmpty()) return; const FileOperationResultCode result = _controller->itemHashExists(panel->panelPosition(), hash) ? _controller->itemActivated(hash, panel->panelPosition()) : rcObjectDoesntExist; switch (result) { case rcObjectDoesntExist: QMessageBox(QMessageBox::Warning, tr("Error"), tr("The file doesn't exist.")).exec(); break; case rcFail: QMessageBox(QMessageBox::Critical, tr("Error"), tr("Failed to launch %1").arg(_controller->itemByHash(panel->panelPosition(), hash).fullAbsolutePath())).exec(); break; case rcDirNotAccessible: QMessageBox(QMessageBox::Critical, tr("No access"), tr("This item is not accessible.")).exec(); break; default: break; } }
void usage(QString const & err = QString()) { QTextStream(stderr) << err << (err.isEmpty() ? "" : "\n\n") << QObject::tr("Usage: %1 command [arguments...]\n\n" "GUI frontend for %2\n\n" "Arguments:\n" " command Command to run.\n" " arguments Optional arguments for command.\n\n").arg(app_master).arg(LXQTSUDO_SUDO); if (!err.isEmpty()) QMessageBox(QMessageBox::Critical, app_master, err, QMessageBox::Ok).exec(); }
void TimerWidget::deleteTimeEntry() { if (guid.isEmpty()) return; if (timeEntry->confirmlessDelete() || QMessageBox::Ok == QMessageBox( QMessageBox::Question, "Delete this time entry?", "Deleted time entries cannot be restored.", QMessageBox::Ok|QMessageBox::Cancel).exec()) { TogglApi::instance->deleteTimeEntry(guid); } }
bool DataMapping::askForNewRenderView(const QString & rendererName, const QList<DataObject *> & relevantObjects) { QString msg = "Cannot add some data to the current render view (" + rendererName + "):\n"; for (auto object : relevantObjects) { msg += object->name() + ", "; } msg.chop(2); msg += "\n\n"; msg += "Do you want to open them in a new view?"; return QMessageBox(QMessageBox::Question, "", msg, QMessageBox::Yes | QMessageBox::No).exec() == QMessageBox::Yes; }
void SerialMonitor::connectSerial(){ //Conectando ui->connectButton->setDisabled(true); ui->connectButton->setText(tr("Connecting...")); //Intentamos conectar try{ serial.connect(serialPort.toStdString(), baudRate); } catch(std::exception &e){ QMessageBox(QMessageBox::Warning, tr("unable to connect to port %1").arg(serialPort), e.what(), QMessageBox::Ok ).exec(); } catch(...){ QMessageBox(QMessageBox::Warning, tr("unable to connect to port %1").arg(serialPort), tr("unknown error"), QMessageBox::Ok ).exec(); } if(serial.port.is_open()){ try{ serial.start(); } catch(...){ std::cout << "Desconectado" << std::endl; } } else{ //Desconectado ui->connectButton->setEnabled(true); setSerialPort(serialPort); } }
void gm_mst::_end_gm() { vis_brd_->dctv(); int ww, bb; _get_sc(ww, bb); emit smb_sc(ww, bb); QMessageBox(QMessageBox::Information, QObject::tr("Game Over!"), ww == bb? tr("The game has ended in a draw.") : tr("%1 player has won!\nFinal score: %2 - %3").arg((ww > bb)? "Red" : "Black").arg(ww).arg(bb), QMessageBox::Ok) .exec(); }
void LinkInput::onDelClick() { if( QMessageBox( QMessageBox::Question, tr("del_link"), tr("ask_del_link %1 ?").arg(nameSelect->currentText()), QMessageBox::Yes | QMessageBox::No, this) .exec() == QMessageBox::Yes ) { config->delLink(nameSelect->currentText()); config->loadLink(links); nameSelect->removeItem(nameSelect->currentIndex()); } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); //Look for tools QDir tooldir(a.applicationDirPath() + "/tools"); if (!tooldir.exists()) { QMessageBox(QMessageBox::Critical, a.tr("Error"), a.tr("No tools folder found."), QMessageBox::Ok).exec(); return 1; } MainWindow w(tooldir); w.show(); return a.exec(); }
void MainWindowController::displayReminder( const QString title, const QString informative_text) { if (reminder) { return; } reminder = true; QMessageBox( QMessageBox::Information, title, informative_text, QMessageBox::Ok).exec(); reminder = false; }