MateAppProgressKey mate_app_progress_manual (MateApp * app, const gchar * description, MateAppProgressCancelFunc cancel_cb, gpointer data) { ProgressKeyReal * key; g_return_val_if_fail (app != NULL, NULL); g_return_val_if_fail (MATE_IS_APP(app), NULL); g_return_val_if_fail (description != NULL, NULL); key = g_new (ProgressKeyReal, 1); key->app = app; key->cancel_cb = cancel_cb; key->data = data; key->timeout_tag = INVALID_TIMEOUT; if ( mate_app_has_appbar_progress(app) && /* FIXME !!! */ 0 /*mate_preferences_get_statusbar_dialog() */) { progress_bar (description, key); } else { progress_dialog (description, key); } /* Make sure progress stops if the app is destroyed. */ key->handler_id = g_signal_connect(app, "destroy", G_CALLBACK(stop_progress_cb), key); return key; }
void InfoPanel::OnComputeMD5(wxCommandEvent& WXUNUSED(event)) { wxProgressDialog progress_dialog(_("Computing MD5 checksum"), _("Working..."), 100, this, wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME | wxPD_SMOOTH); const auto result = MD5::MD5Sum(m_game_list_item.GetFileName(), [&progress_dialog](int progress) { return progress_dialog.Update(progress); }); if (progress_dialog.WasCancelled()) return; m_md5_sum->SetValue(result); }
void UnitsDialog::saveAllRatios( UnitRatioList &/*ratioList*/ ) { #if 0 ConversionTable *conversionTable = massConversionTable; KProgressDialog progress_dialog( this, "progress_dialog", i18nc( "@title:window", "Finding Unit Ratios" ), QString(), true ); progress_dialog.progressBar() ->setTotalSteps( ratioList.count() * ratioList.count() ); for ( UnitRatioList::const_iterator current_it = ratioList.begin(); current_it != ratioList.end(); ++current_it ) { UnitRatio current_ratio = *current_it; for ( UnitRatioList::const_iterator ratio_it = ratioList.begin(); ratio_it != ratioList.end(); ++ratio_it ) { if ( progress_dialog.wasCancelled() ) return ; progress_dialog.progressBar() ->advance( 1 ); kapp->processEvents(); UnitRatio new_ratio; new_ratio.uID1 = current_ratio.uID1; new_ratio.uID2 = ( *ratio_it ).uID2; new_ratio.ratio = ( *ratio_it ).ratio * current_ratio.ratio; if ( ratioList.contains( new_ratio ) ) continue; if ( ( ( *ratio_it ).uID1 == current_ratio.uID2 ) && ( ( *ratio_it ).uID2 != current_ratio.uID1 ) ) { UnitRatio reverse_ratio; reverse_ratio.uID1 = new_ratio.uID2; reverse_ratio.uID2 = new_ratio.uID1; reverse_ratio.ratio = 1.0 / new_ratio.ratio; database->saveUnitRatio( &new_ratio ); database->saveUnitRatio( &reverse_ratio ); conversionTable->setRatio( new_ratio ); conversionTable->setRatio( reverse_ratio ); //ratioList.append(new_ratio); ratioList.append(reverse_ratio); } } } #endif }
void GameList::CompressISO() { const auto original_path = GetSelectedGame(); auto file = GameFile(original_path); const bool compressed = (file.GetBlobType() == DiscIO::BlobType::GCZ); if (!compressed && file.GetPlatformID() == DiscIO::Platform::WII_DISC) { QMessageBox wii_warning(this); wii_warning.setIcon(QMessageBox::Warning); wii_warning.setText(tr("Are you sure?")); wii_warning.setInformativeText( tr("Compressing a Wii disc image will irreversibly change the compressed copy by removing " "padding data. Your disc image will still work.")); wii_warning.setStandardButtons(QMessageBox::Yes | QMessageBox::No); if (wii_warning.exec() == QMessageBox::No) return; } QString dst_path = QFileDialog::getSaveFileName( this, compressed ? tr("Select where you want to save the decompressed image") : tr("Select where you want to save the compressed image"), QFileInfo(GetSelectedGame()) .dir() .absoluteFilePath(file.GetGameID()) .append(compressed ? QStringLiteral(".gcm") : QStringLiteral(".gcz")), compressed ? tr("Uncompressed GC/Wii images (*.iso *.gcm") : tr("Compressed GC/Wii images (*.gcz)")); if (dst_path.isEmpty()) return; QProgressDialog progress_dialog(compressed ? tr("Decompressing...") : tr("Compressing..."), tr("Abort"), 0, 100, this); progress_dialog.setWindowModality(Qt::WindowModal); bool good; if (compressed) { good = DiscIO::DecompressBlobToFile(original_path.toStdString(), dst_path.toStdString(), &CompressCB, &progress_dialog); } else { good = DiscIO::CompressFileToBlob(original_path.toStdString(), dst_path.toStdString(), file.GetPlatformID() == DiscIO::Platform::WII_DISC ? 1 : 0, 16384, &CompressCB, &progress_dialog); } if (good) { QMessageBox(QMessageBox::Information, tr("Success!"), tr("Successfully compressed image."), QMessageBox::Ok, this) .exec(); } else { QErrorMessage(this).showMessage(tr("Dolphin failed to complete the requested action.")); } }
void GameList::CompressISO(bool decompress) { auto files = GetSelectedGames(); const auto game = GetSelectedGame(); if (files.empty() || !game) return; bool wii_warning_given = false; for (QMutableListIterator<std::shared_ptr<const UICommon::GameFile>> it(files); it.hasNext();) { auto file = it.next(); if ((file->GetPlatform() != DiscIO::Platform::GameCubeDisc && file->GetPlatform() != DiscIO::Platform::WiiDisc) || (decompress && file->GetBlobType() != DiscIO::BlobType::GCZ) || (!decompress && file->GetBlobType() != DiscIO::BlobType::PLAIN)) { it.remove(); continue; } if (!wii_warning_given && !decompress && file->GetPlatform() == DiscIO::Platform::WiiDisc) { ModalMessageBox wii_warning(this); wii_warning.setIcon(QMessageBox::Warning); wii_warning.setWindowTitle(tr("Confirm")); wii_warning.setText(tr("Are you sure?")); wii_warning.setInformativeText(tr( "Compressing a Wii disc image will irreversibly change the compressed copy by removing " "padding data. Your disc image will still work. Continue?")); wii_warning.setStandardButtons(QMessageBox::Yes | QMessageBox::No); if (wii_warning.exec() == QMessageBox::No) return; wii_warning_given = true; } } QString dst_dir; QString dst_path; if (files.size() > 1) { dst_dir = QFileDialog::getExistingDirectory( this, decompress ? tr("Select where you want to save the decompressed images") : tr("Select where you want to save the compressed images"), QFileInfo(QString::fromStdString(game->GetFilePath())).dir().absolutePath()); if (dst_dir.isEmpty()) return; } else { dst_path = QFileDialog::getSaveFileName( this, decompress ? tr("Select where you want to save the decompressed image") : tr("Select where you want to save the compressed image"), QFileInfo(QString::fromStdString(game->GetFilePath())) .dir() .absoluteFilePath( QFileInfo(QString::fromStdString(files[0]->GetFilePath())).completeBaseName()) .append(decompress ? QStringLiteral(".gcm") : QStringLiteral(".gcz")), decompress ? tr("Uncompressed GC/Wii images (*.iso *.gcm)") : tr("Compressed GC/Wii images (*.gcz)")); if (dst_path.isEmpty()) return; } for (const auto& file : files) { const auto original_path = file->GetFilePath(); if (files.size() > 1) { dst_path = QDir(dst_dir) .absoluteFilePath(QFileInfo(QString::fromStdString(original_path)).completeBaseName()) .append(decompress ? QStringLiteral(".gcm") : QStringLiteral(".gcz")); QFileInfo dst_info = QFileInfo(dst_path); if (dst_info.exists()) { ModalMessageBox confirm_replace(this); confirm_replace.setIcon(QMessageBox::Warning); confirm_replace.setWindowTitle(tr("Confirm")); confirm_replace.setText(tr("The file %1 already exists.\n" "Do you wish to replace it?") .arg(dst_info.fileName())); confirm_replace.setStandardButtons(QMessageBox::Yes | QMessageBox::No); if (confirm_replace.exec() == QMessageBox::No) continue; } } QProgressDialog progress_dialog(decompress ? tr("Decompressing...") : tr("Compressing..."), tr("Abort"), 0, 100, this); progress_dialog.setWindowModality(Qt::WindowModal); progress_dialog.setWindowFlags(progress_dialog.windowFlags() & ~Qt::WindowContextHelpButtonHint); progress_dialog.setWindowTitle(tr("Progress")); bool good; if (decompress) { if (files.size() > 1) progress_dialog.setLabelText(tr("Decompressing...") + QStringLiteral("\n") + QFileInfo(QString::fromStdString(original_path)).fileName()); good = DiscIO::DecompressBlobToFile(original_path, dst_path.toStdString(), &CompressCB, &progress_dialog); } else { if (files.size() > 1) progress_dialog.setLabelText(tr("Compressing...") + QStringLiteral("\n") + QFileInfo(QString::fromStdString(original_path)).fileName()); good = DiscIO::CompressFileToBlob(original_path, dst_path.toStdString(), file->GetPlatform() == DiscIO::Platform::WiiDisc ? 1 : 0, 16384, &CompressCB, &progress_dialog); } if (!good) { QErrorMessage(this).showMessage(tr("Dolphin failed to complete the requested action.")); return; } } ModalMessageBox::information(this, tr("Success"), decompress ? tr("Successfully decompressed %n image(s).", "", files.size()) : tr("Successfully compressed %n image(s).", "", files.size())); }
void RecipeActionsHandler::exportRecipes( const QList<int> &ids, const QString & caption, const QString &selection, RecipeDB *database ) { KFileDialog * fd = new KFileDialog( KUrl(), QString( "*.kre|%1 (*.kre)\n" "*.kreml|Krecipes (*.kreml)\n" "*.txt|%3 (*.txt)\n" //"*.cml|CookML (*.cml)\n" "*|%4\n" "*.html|%2 (*.html)\n" "*.mmf|Meal-Master (*.mmf)\n" "*.xml|RecipeML (*.xml)\n" "*.mx2|MasterCook (*.mx2)\n" "*.rk|Rezkonv (*.rk)" ).arg( i18n( "Compressed Krecipes format" ) ) .arg( i18n( "Web page" ) ) .arg( i18n("Plain Text") ) .arg( i18n("Web Book") ), 0 ); fd->setObjectName( "export_dlg" ); fd->setModal( true ); fd->setCaption( caption ); fd->setOperationMode( KFileDialog::Saving ); fd->setSelection( selection ); fd->setMode( KFile::File | KFile::Directory ); if ( fd->exec() == KFileDialog::Accepted ) { QString fileName = fd->selectedFile(); if ( !fileName.isEmpty() ) { BaseExporter * exporter; if ( fd->currentFilter() == "*.xml" ) exporter = new RecipeMLExporter( fileName, fd->currentFilter() ); else if ( fd->currentFilter() == "*.mx2" ) exporter = new MX2Exporter( fileName, fd->currentFilter() ); else if ( fd->currentFilter() == "*.mmf" ) exporter = new MMFExporter( fileName, fd->currentFilter() ); else if ( fd->currentFilter() == "*" ) { CategoryTree *cat_structure = new CategoryTree; database->loadCategories( cat_structure ); exporter = new HTMLBookExporter( cat_structure, fd->baseUrl().path(), "*.html" ); } else if ( fd->currentFilter() == "*.html" ) { exporter = new HTMLExporter( fileName, fd->currentFilter() ); XSLTExporter exporter_junk( fileName, "*.html" ); // AGH, i don't get build systems... } else if ( fd->currentFilter() == "*.cml" ) exporter = new CookMLExporter( fileName, fd->currentFilter() ); else if ( fd->currentFilter() == "*.txt" ) exporter = new PlainTextExporter( fileName, fd->currentFilter() ); else if ( fd->currentFilter() == "*.rk" ) exporter = new RezkonvExporter( fileName, fd->currentFilter() ); else { CategoryTree *cat_structure = new CategoryTree; database->loadCategories( cat_structure ); exporter = new KreExporter( cat_structure, fileName, fd->currentFilter() ); } int overwrite = -1; if ( QFile::exists( exporter->fileName() ) ) { overwrite = KMessageBox::warningYesNo( 0, i18n( "File \"%1\" exists. Are you sure you want to overwrite it?" , exporter->fileName()), i18nc( "@title:window", "Saving recipe" ) ); } if ( overwrite == KMessageBox::Yes || overwrite == -1 ) { KProgressDialog progress_dialog( 0, QString(), i18nc( "@info:progress", "Saving recipes..." ) ); progress_dialog.setObjectName("export_progress_dialog"); exporter->exporter( ids, database, &progress_dialog ); } delete exporter; } } delete fd; }