void ReportWizard::on_pushButton_submit_clicked() { QDate startDate = ui->dateEdit_startDate->date(), endDate = ui->dateEdit_endDate->date(); if (endDate < startDate) { showErrorDialog("Start date must be before end date"); return; } QString reportPath = SettingForm::getPdfDirectoryWithoutSlash() + "/reports"; if (!QDir(reportPath).exists()) QDir().mkpath(reportPath); QString suggestedFilename = reportPath + "/report_" + toString(startDate.day()).c_str() + QDate::longMonthName(startDate.month()) + toString(startDate.year()).c_str() + "_to_" + toString(endDate.day()).c_str() + QDate::longMonthName(endDate.month()) + '_' + toString(endDate.year()).c_str() + ".pdf"; QString filename = QFileDialog::getSaveFileName(this, "Save Report As", suggestedFilename, "PDF (*.pdf)"); if (filename.isEmpty()) return; if (PdfGenerator::generateReport(filename.toStdString().c_str(), startDate, endDate)) { showInfoDialog("Report generated successfully"); QDesktopServices::openUrl(QUrl("file:///" + filename)); done(Accepted); } else showErrorDialog("Report could not be generated"); }
bool PartController::Update(const Part &part, QWidget *) { bool success = false; try { success = Databases::parts().updateRecord(part); } catch (const std::exception &e) { showErrorDialog(e.what()); return false; } if (!success) showErrorDialog("There was an error with updating the part in the database"); return success; }
bool TaskController::Destroy(const int taskId, QWidget *) { bool success = false; try { success = Databases::tasks().deleteRecord(taskId); } catch (const std::exception &e) { showErrorDialog(e.what()); return false; } if (!success) showErrorDialog("There was an error with removing the task from the database"); return success; }
bool TaskController::Update(const Task &task, QWidget *) { bool success = false; try { success = Databases::tasks().updateRecord(task); } catch (const std::exception &e) { showErrorDialog(e.what()); return false; } if (!success) showErrorDialog("There was an error with updating the task in the database"); return success; }
bool VatRateController::Update(const VatRate &vatRate, QWidget *) { bool success = false; try { success = Databases::vatRates().updateRecord(vatRate); } catch (const std::exception &e) { showErrorDialog(e.what()); return false; } if (!success) showErrorDialog("There was an error with updating the VAT rate in the database"); return success; }
void PresentationAudioListItem::slotMediaStateChanged(QMediaPlayer::MediaStatus status) { if (status == QMediaPlayer::UnknownMediaStatus || status == QMediaPlayer::NoMedia || status == QMediaPlayer::InvalidMedia) { showErrorDialog(); return; } qint64 total = d->mediaObject->duration(); int hours = (int)(total / (long int)( 60 * 60 * 1000 )); int mins = (int)((total / (long int)( 60 * 1000 )) - (long int)(hours * 60)); int secs = (int)((total / (long int)1000) - (long int)(hours * 60 * 60) - (long int)(mins * 60)); d->totalTime = QTime(hours, mins, secs); d->artist = (d->mediaObject->metaData(QMediaMetaData::Author)).toStringList().join(QString::fromLatin1(",")); d->title = (d->mediaObject->metaData(QMediaMetaData::Title)).toString(); if ( d->artist.isEmpty() && d->title.isEmpty() ) setText(d->url.fileName()); else setText(i18nc("artist - title", "%1 - %2", artist(), title())); emit signalTotalTimeReady(d->url, d->totalTime); }
void MainWindow::rotateSelectedObj(GtkBuilder* builder){ RotateDialog dialog(GTK_BUILDER(builder)); bool finish = false; std::string name; GtkTreeIter iter; if(!getSelectedObjName(name, &iter)) return; while(!finish){ if(dialog.run() == 1){ try{ Object* obj = _world->rotateObj(name, dialog.getAngulo(), Coordinate(dialog.getCX(), dialog.getCY()), dialog.getRotateType()); _viewport->transformObj(obj); gtk_widget_queue_draw(_mainWindow); log("Objeto rotacionado.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
void FvUpdater::httpFeedDownloadFinished() { if (m_httpRequestAborted) { m_reply->deleteLater(); return; } QVariant redirectionTarget = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute); if (m_reply->error()) { qDebug() << " error value " << m_reply->error(); // Error. showErrorDialog(tr("Updates are unable to detect: %1.").arg(m_reply->errorString()), NO_UPDATE_MESSAGE); emit updatesDownloaded(false); } else if (! redirectionTarget.isNull()) { QUrl newUrl = m_feedURL.resolved(redirectionTarget.toUrl()); m_feedURL = newUrl; m_reply->deleteLater(); startDownloadFeed(m_feedURL); return; } else { // Done. xmlParseFeed(); emit updatesDownloaded(true); } m_reply->deleteLater(); m_reply = 0; }
bool Material::loadAndInitializeMaterial(const string& effectName, ID3D11Device* pd3dDevice, const InputLayoutDescription& inputDescription) { bool succesfull = true; ID3D11InputLayout* layout; m_shader = new Shader(effectName, pd3dDevice); succesfull = m_shader->isShaderInitialized(); if (!succesfull) { return succesfull; } D3DX11_PASS_DESC PassDesc; m_shader->getEffect()->GetTechniqueByIndex(0)->GetPassByIndex( 0 )->GetDesc( &PassDesc ); HRESULT hr = pd3dDevice->CreateInputLayout(inputDescription.getElementDescriptions(), inputDescription.getElementCount(), PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &layout ); if(FAILED(hr)) showErrorDialog("Failed to create input layout"); m_layout = layout; layout->Release(); return succesfull; }
void AuthenticationDialog::urlChanged(const QUrl &url) { qDebug() << "Navigating to" << url; if (url.host() == QStringLiteral("oauth.vk.com") && url.path() == QStringLiteral("/blank.html")) { const QUrlQuery query(url); d->error = query.queryItemValue(QStringLiteral("error")); d->errorDescription = query.queryItemValue(QStringLiteral("error_description")).replace(QLatin1Char('+'), QLatin1Char(' ')); if (!d->error.isEmpty() || !d->errorDescription.isEmpty()) { QTimer::singleShot(0, this, SLOT(showErrorDialog())); return; } // The URL comes in the form "bla#access_token=bla&expires_in=foo", we need to convert from // # to ? const QUrl fixedURL = QUrl::fromUserInput(url.toString().replace(QLatin1Char('#'), QLatin1Char('?'))); const QUrlQuery fixedQuery(fixedURL); const QString accessToken = fixedQuery.queryItemValue(QStringLiteral("access_token")); const QString tokenExpiresIn = fixedQuery.queryItemValue(QStringLiteral("expires_in")); // TODO: use this for something? if (!accessToken.isEmpty()) { emit authenticated(accessToken); QTimer::singleShot(0, this, SLOT(close())); } } }
void MainWindow::openFile(GtkBuilder* builder){ FileDialog dialog(GTK_BUILDER(builder)); if(dialog.run() == 1){ char* filename = dialog.getFileName(); if(filename == NULL) return; std::string file(filename); delete filename; try{ ObjReader r(file); for(auto obj : r.getObjs()){ try{ _world->addObj(obj); _viewport->transformObj(obj); addObjOnListStore(obj->getName(), obj->getTypeName().c_str()); }catch(MyException& e){ log(e.what()); } } log("Arquivo carregado.\n"); }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } } }
void MainWindow::addPoint(GtkBuilder* builder){ PointDialog dialog(GTK_BUILDER(builder)); bool finish = false; while(!finish){ if(dialog.run() == 1){ try{ Coordinate c(dialog.getX(),dialog.getY(),dialog.getZ()); Object* obj = m_world->addPoint( dialog.getName(), dialog.getColor(), c); m_viewport->transformAndClipObj(obj); addObjOnListStore(dialog.getName(), "Point"); gtk_widget_queue_draw(m_mainWindow); log("Novo ponto adicionado.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
void QUPDUpdater::changelogHttpDownloadFinished() { if (_changelogReply ) { QVariant redirectionTarget = _changelogReply->attribute(QNetworkRequest::RedirectionTargetAttribute); if (_changelogRequestAborted) { _changelogReply->deleteLater(); _changelogReply = 0; } else if (_changelogReply->error()) { showErrorDialog(tr("New Version download failed: %1.").arg(_changelogReply->errorString()), false); emit downloadChangelogError(); _changelogReply->deleteLater(); _changelogReply = 0; } else if (! redirectionTarget.isNull()) { proposedUpdate()->setReleaseNoteLink(_changelogReply->url().resolved(redirectionTarget.toUrl()).toString()); _changelogReply->deleteLater(); startDownloadChangelog(); } else { emit downloadChangelogSuccess(); _changelogReply->deleteLater(); _changelogReply = 0; } } }
void MainWindow::addLine(GtkBuilder* builder){ LineDialog dialog(GTK_BUILDER(builder)); bool finish = false; while(!finish){ if(dialog.run() == 1){ try{ Coordinates c; c.emplace_back(dialog.getX1(), dialog.getY1()); c.emplace_back(dialog.getX2(), dialog.getY2()); Object* obj = _world->addLine( dialog.getName(), dialog.getColor(), c); _viewport->transformObj(obj); addObjOnListStore(dialog.getName(), "Line"); gtk_widget_queue_draw(_mainWindow); log("Nova reta adicionada.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
void MainWindow::addPolygon(GtkBuilder* builder){ PolygonDialog dialog(GTK_BUILDER(builder)); bool finish = false; while(!finish){ if(dialog.run() == 1){ try{ Coordinates c; dialog.getCoords(c); Object* obj = _world->addPolygon(dialog.getName(), dialog.getColor(), dialog.shouldBeFilled(), c); _viewport->transformObj(obj); addObjOnListStore(dialog.getName(), "Polygon"); gtk_widget_queue_draw(_mainWindow); log("Novo poligono adicionado.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
bool SubscriptionManager::checkSubscription(int& edition) { edition = Unknown; CoreInterface coreInterface; QString output; try { output = coreInterface.checkSubscription(); } catch (std::exception& e) { showErrorDialog(e.what()); return false; } if (output.contains("subscription will expire soon")) { QMessageBox::warning( this, tr("Activate Subscription"), tr("Your subscription will be expired soon.")); } edition = getEditionType(output); return true; }
void MainWindow::scaleSelectedObj(GtkBuilder* builder){ ScaleDialog dialog(GTK_BUILDER(builder)); bool finish = false; std::string name; GtkTreeIter iter; if(!getSelectedObjName(name, &iter)) return; while(!finish){ if(dialog.run() == 1){ try{ Object* obj = m_world->scaleObj(name, dialog.getSX(), dialog.getSY(), dialog.getSZ()); m_viewport->transformAndClipObj(obj); gtk_widget_queue_draw(m_mainWindow); log("Objeto escalonado.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
void MainWindow::addBSplineCurve(GtkBuilder* builder){ CurveDialog dialog(GTK_BUILDER(builder)); bool finish = false; while(!finish){ if(dialog.run() == 1){ try{ Coordinates c; dialog.getCoords(c); Object* obj = m_world->addBSplineCurve(dialog.getName(), dialog.getColor(), c); m_viewport->transformAndClipObj(obj); addObjOnListStore(dialog.getName(), "Curve"); gtk_widget_queue_draw(m_mainWindow); log("Nova curva adicionada.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
void MainWindow::addSurface(GtkBuilder* builder){ SurfaceDialog dialog(GTK_BUILDER(builder)); bool finish = false; while(!finish){ if(dialog.run() == 1){ try{ auto& c = dialog.getCoords(); Object* obj = m_world->addSurface(dialog.getName(), dialog.getColor(), dialog.getSurfaceType(), dialog.getMaxLines(), dialog.getMaxCols(), c); m_viewport->transformAndClipObj(obj); addObjOnListStore(dialog.getName(), obj->getTypeName().c_str()); gtk_widget_queue_draw(m_mainWindow); log("Novo poligono adicionado.\n"); finish = true; }catch(MyException& e){ log(e.what()); showErrorDialog(e.what()); } }else finish = true; } }
void FvUpdater::httpFeedDownloadFinished() { if (m_httpRequestAborted) { m_reply->deleteLater(); return; } QVariant redirectionTarget = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute); if (m_reply->error()) { // Error. showErrorDialog(tr("Feed download failed: %1.").arg(m_reply->errorString()), false); } else if (! redirectionTarget.isNull()) { QUrl newUrl = m_feedURL.resolved(redirectionTarget.toUrl()); m_feedURL = newUrl; m_reply->deleteLater(); startDownloadFeed(m_feedURL); return; } else { // Done. xmlParseFeed(); } m_reply->deleteLater(); m_reply = 0; }
void AssetUploadDialogFactory::showDialog() { auto nodeList = DependencyManager::get<NodeList>(); if (nodeList->getThisNodeCanRez()) { auto filename = QFileDialog::getOpenFileName(_dialogParent, "Select a file to upload"); if (!filename.isEmpty()) { qDebug() << "Selected filename for upload to asset-server: " << filename; auto assetClient = DependencyManager::get<AssetClient>(); auto upload = assetClient->createUpload(filename); if (upload) { // connect to the finished signal so we know when the AssetUpload is done QObject::connect(upload, &AssetUpload::finished, this, &AssetUploadDialogFactory::handleUploadFinished); // start the upload now upload->start(); } else { // show a QMessageBox to say that there is no local asset server QString messageBoxText = QString("Could not upload \n\n%1\n\nbecause you are currently not connected" \ " to a local asset-server.").arg(QFileInfo(filename).fileName()); QMessageBox::information(_dialogParent, "Failed to Upload", messageBoxText); } } } else { // we don't have permission to upload to asset server in this domain - show the permission denied error showErrorDialog(QString(), PERMISSION_DENIED_ERROR); } }
void AssetUploadDialogFactory::handleUploadFinished(AssetUpload* upload, const QString& hash) { if (upload->getError() == AssetUpload::NoError) { // show message box for successful upload, with copiable text for ATP hash QDialog* hashCopyDialog = new QDialog(_dialogParent); // delete the dialog on close hashCopyDialog->setAttribute(Qt::WA_DeleteOnClose); // set the window title hashCopyDialog->setWindowTitle(tr("Successful Asset Upload")); // setup a layout for the contents of the dialog QVBoxLayout* boxLayout = new QVBoxLayout; // set the label text (this shows above the text box) QLabel* lineEditLabel = new QLabel; lineEditLabel->setText(QString("ATP URL for %1").arg(QFileInfo(upload->getFilename()).fileName())); // setup the line edit to hold the copiable text QLineEdit* lineEdit = new QLineEdit; QString atpURL = QString("%1:%2.%3").arg(URL_SCHEME_ATP).arg(hash).arg(upload->getExtension()); // set the ATP URL as the text value so it's copiable lineEdit->insert(atpURL); // figure out what size this line edit should be using font metrics QFontMetrics textMetrics { lineEdit->font() }; // set the fixed width on the line edit // pad it by 10 to cover the border and some extra space on the right side (for clicking) static const int LINE_EDIT_RIGHT_PADDING { 10 }; lineEdit->setFixedWidth(textMetrics.width(atpURL) + LINE_EDIT_RIGHT_PADDING ); // left align the ATP URL line edit lineEdit->home(true); // add the label and line edit to the dialog boxLayout->addWidget(lineEditLabel); boxLayout->addWidget(lineEdit); // setup an OK button to close the dialog QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); connect(buttonBox, &QDialogButtonBox::accepted, hashCopyDialog, &QDialog::close); boxLayout->addWidget(buttonBox); // set the new layout on the dialog hashCopyDialog->setLayout(boxLayout); // show the new dialog hashCopyDialog->show(); } else { // display a message box with the error showErrorDialog(upload, _dialogParent); } upload->deleteLater(); }
bool VatRateController::Create(VatRate &vatRateAttributes, QWidget *) { try { Databases::vatRates().addRecord(vatRateAttributes); } catch (const std::exception &e) { showErrorDialog(e.what()); return false; } if (vatRateAttributes.null()) { showErrorDialog("There was an error with adding the VAT rate to the database"); return false; } return true; }
bool PartController::Create(Part &partAttributes, QWidget *) { try { Databases::parts().addRecord(partAttributes); } catch (const std::exception &e) { showErrorDialog(e.what()); return false; } if (partAttributes.null()) { showErrorDialog("There was an error with adding the part to the database"); return false; } return true; }
void PresentationAudioListItem::slotPlayerError(QMediaPlayer::Error err) { if (err != QMediaPlayer::NoError) { qCDebug(DIGIKAM_GENERAL_LOG) << "An error as occured while playing (" << err << ")"; showErrorDialog(); } }
bool TaskController::Create(Task &taskAttributes, QWidget *) { try { Databases::tasks().addRecord(taskAttributes); } catch (const std::exception &e) { showErrorDialog(e.what()); return false; } if (taskAttributes.null()) { showErrorDialog("There was an error with adding the task to the database"); return false; } return true; }
void VatRateController::Edit(const int vatRateId, QWidget *caller) { VatRate vatRate; try { vatRate = Databases::vatRates().findRecord("id", vatRateId); } catch (const std::exception &e) { showErrorDialog(e.what()); return; } if (vatRate.null()) { showErrorDialog(("VAT rate with ID " + toString(vatRateId) + " could not be found").c_str()); return; } Edit(vatRate, caller); }
void MainWindow::on_pushButton_help_clicked() { const QString userGuideFileName = QDir::currentPath() + "/user_guide.html"; QFile::copy(":html/user_guide.html", userGuideFileName); if (QFile::exists(userGuideFileName)) QDesktopServices::openUrl(QUrl("file:///" + userGuideFileName)); else showErrorDialog(("File '" + userGuideFileName + "' could not be opened").toStdString().c_str()); }
void TaskController::Edit(const int taskId, QWidget *caller) { Task task; try { Databases::tasks().findRecord("id", taskId); } catch (const std::exception &e) { showErrorDialog(e.what()); return; } if (task.null()) { showErrorDialog(("Task with ID " + toString(taskId) + " could not be found").c_str()); return; } Edit(task, caller); }
void PartController::Edit(const int partId, QWidget *caller) { Part part; try { Databases::parts().findRecord("id", partId); } catch (const std::exception &e) { showErrorDialog(e.what()); return; } if (part.null()) { showErrorDialog(("Part with ID " + toString(partId) + " could not be found").c_str()); return; } Edit(part, caller); }