Commit a06825f2 authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa
Browse files

Fix most Krazy errors related to using KDialog::exec.

See www.kdedevelopers.org/node/3919

svn path=/trunk/KDE/kdeutils/ark/; revision=978707
parent 804fc115
......@@ -40,6 +40,7 @@
#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include <QPointer>
static bool isValidArchiveDrag(const QMimeData *data)
{
......@@ -179,11 +180,14 @@ void MainWindow::editKeyBindings()
void MainWindow::editToolbars()
{
saveMainWindowSettings( KGlobal::config()->group( QLatin1String( "MainWindow") ) );
KEditToolBar dlg( factory(), this );
dlg.exec();
saveMainWindowSettings( KGlobal::config()->group( QLatin1String( "MainWindow" ) ) );
QPointer<KEditToolBar> dlg = new KEditToolBar( factory(), this );
dlg->exec();
createGUI( m_part );
applyMainWindowSettings( KGlobal::config()->group( QLatin1String("MainWindow") ) );
applyMainWindowSettings( KGlobal::config()->group( QLatin1String( "MainWindow" ) ) );
}
void MainWindow::openArchive()
......
......@@ -25,6 +25,7 @@
#include <QFileInfo>
#include <QDir>
#include <QPointer>
#include <KConfig>
#include <kdebug.h>
......@@ -46,20 +47,20 @@ namespace Kerfuffle
bool AddToArchive::showAddDialog( void )
{
Kerfuffle::AddDialog dialog(
m_inputs, // itemsToAdd
KUrl(m_firstPath), // startDir
"", // filter
NULL, // parent
NULL); // widget
QPointer<Kerfuffle::AddDialog> dialog = new Kerfuffle::AddDialog(
m_inputs, // itemsToAdd
KUrl(m_firstPath), // startDir
"", // filter
NULL, // parent
NULL); // widget
bool ret = dialog.exec();
bool ret = dialog->exec();
if (ret) {
kDebug( 1601 ) << "Returned URL:" << dialog.selectedUrl();
kDebug( 1601 ) << "Returned mime:" << dialog.currentMimeFilter();
setFilename(dialog.selectedUrl());
setMimeType(dialog.currentMimeFilter());
kDebug( 1601 ) << "Returned URL:" << dialog->selectedUrl();
kDebug( 1601 ) << "Returned mime:" << dialog->currentMimeFilter();
setFilename(dialog->selectedUrl());
setMimeType(dialog->currentMimeFilter());
}
return ret;
......
......@@ -31,6 +31,7 @@
#include <QCoreApplication>
#include <QApplication>
#include <QDesktopWidget>
#include <QPointer>
#include <KDebug>
#include <KGlobal>
......@@ -224,41 +225,40 @@ namespace Kerfuffle
{
kDebug( 1601 );
Kerfuffle::ExtractionDialog dialog(NULL);
QPointer<Kerfuffle::ExtractionDialog> dialog = new Kerfuffle::ExtractionDialog(NULL);
if (inputs.size() > 1) {
dialog.batchModeOption();
dialog->batchModeOption();
}
if (destinationFolder.isEmpty())
dialog.setCurrentUrl(QDir::currentPath());
dialog->setCurrentUrl(QDir::currentPath());
else
dialog.setCurrentUrl(destinationFolder);
dialog->setCurrentUrl(destinationFolder);
dialog.setAutoSubfolder(autoSubfolders);
dialog.setPreservePaths(m_preservePaths);
dialog->setAutoSubfolder(autoSubfolders);
dialog->setPreservePaths(m_preservePaths);
if (subfolder.isEmpty() && inputs.size() == 1) {
if (inputs.at(0)->isSingleFolderArchive()) {
dialog.setSingleFolderArchive(true);
dialog->setSingleFolderArchive(true);
}
dialog.setSubfolder(inputs.at(0)->subfolderName());
dialog->setSubfolder(inputs.at(0)->subfolderName());
}
else {
dialog.setSubfolder(subfolder);
dialog->setSubfolder(subfolder);
}
bool ret = dialog.exec();
bool ret = dialog->exec();
if (!ret) return false;
setDestinationFolder(dialog.destinationDirectory().path());
setDestinationFolder(dialog->destinationDirectory().path());
if (dialog.extractToSubfolder()) {
subfolder = dialog.subfolder();
if (dialog->extractToSubfolder()) {
subfolder = dialog->subfolder();
}
autoSubfolders = dialog.autoSubfolders();
m_preservePaths = dialog.preservePaths();
autoSubfolders = dialog->autoSubfolders();
m_preservePaths = dialog->preservePaths();
return true;
}
......
......@@ -20,18 +20,18 @@
*/
#include "queries.h"
#include <QMessageBox>
#include <KLocale>
#include <KPasswordDialog>
#include <QApplication>
#include <kdebug.h>
#include <kio/renamedialog.h>
#include <QApplication>
#include <QMessageBox>
#include <QPointer>
namespace Kerfuffle
{
Query::Query()
{
m_responseMutex.lock();
......@@ -50,7 +50,6 @@ namespace Kerfuffle
if (!m_data.contains("response"))
m_responseCondition.wait(&m_responseMutex);
m_responseMutex.unlock();
}
void Query::setResponse(QVariant response)
......@@ -61,8 +60,6 @@ namespace Kerfuffle
m_responseCondition.wakeAll();
}
//---
OverwriteQuery::OverwriteQuery( QString filename) :
m_noRenameMode(false),
m_multiMode(true)
......@@ -89,17 +86,17 @@ namespace Kerfuffle
sourceUrl.cleanPath();
destUrl.cleanPath();
KIO::RenameDialog dialog(
NULL,
i18n("File already exists"),
sourceUrl,
destUrl,
mode);
dialog.exec();
QPointer<KIO::RenameDialog> dialog = new KIO::RenameDialog(
NULL,
i18n("File already exists"),
sourceUrl,
destUrl,
mode);
dialog->exec();
m_data["newFilename"] = dialog.newDestUrl().path();
m_data["newFilename"] = dialog->newDestUrl().path();
setResponse(dialog.result());
setResponse(dialog->result());
QApplication::restoreOverrideCursor();
}
......@@ -167,24 +164,23 @@ namespace Kerfuffle
{
QApplication::setOverrideCursor( QCursor( Qt::ArrowCursor ) );
KPasswordDialog dlg( NULL );
dlg.setPrompt( i18n("The archive '%1' is password protected. Please enter the password to extract the file.",
m_data.value("archiveFilename").toString()));
QPointer<KPasswordDialog> dlg = new KPasswordDialog( NULL );
dlg->setPrompt( i18n("The archive '%1' is password protected. Please enter the password to extract the file.", m_data.value("archiveFilename").toString()) );
if (m_data.value("incorrectTryAgain").toBool()) {
dlg.showErrorMessage(i18n("Incorrect password, please try again."), KPasswordDialog::PasswordError);
dlg->showErrorMessage(i18n("Incorrect password, please try again."), KPasswordDialog::PasswordError);
}
if( !dlg.exec() )
if (!dlg->exec())
{
setResponse(false);
}
else
{
m_data["password"] = dlg.password();
m_data["password"] = dlg->password();
setResponse(true);
}
QApplication::restoreOverrideCursor();
}
......@@ -197,5 +193,4 @@ namespace Kerfuffle
{
return !m_data.value("response").toBool();
}
}
......@@ -58,6 +58,7 @@
#include <QtDBus/QtDBus>
#include <KInputDialog>
#include <QHeaderView>
#include <QPointer>
typedef KParts::GenericFactory<Part> Factory;
K_EXPORT_COMPONENT_FACTORY( libarkpart, Factory )
......@@ -519,31 +520,30 @@ void Part::slotExtractFiles()
kDebug( 1601 ) ;
if (!m_model) return;
QPointer<Kerfuffle::ExtractionDialog> dialog = new Kerfuffle::ExtractionDialog();
Kerfuffle::ExtractionDialog dialog;
if ( m_view->selectionModel()->selectedRows().count() > 0 )
{
dialog.setShowSelectedFiles(true);
dialog->setShowSelectedFiles(true);
}
if (isSingleFolderArchive())
{
dialog.setSingleFolderArchive(true);
dialog->setSingleFolderArchive(true);
}
dialog.setSubfolder(detectSubfolder());
dialog->setSubfolder(detectSubfolder());
dialog.setCurrentUrl( QFileInfo(m_model->archive()->fileName()).path() );
dialog->setCurrentUrl( QFileInfo(m_model->archive()->fileName()).path() );
dialog.setOpenDestinationFolderAfterExtraction( ArkSettings::openDestinationFolderAfterExtraction() );
dialog->setOpenDestinationFolderAfterExtraction( ArkSettings::openDestinationFolderAfterExtraction() );
//TODO: remember this in arksettings
dialog.setPreservePaths(true);
dialog->setPreservePaths(true);
if ( dialog.exec() )
if ( dialog->exec() )
{
ArkSettings::setOpenDestinationFolderAfterExtraction( dialog.openDestinationAfterExtraction() );
ArkSettings::setOpenDestinationFolderAfterExtraction( dialog->openDestinationAfterExtraction() );
ArkSettings::self()->writeConfig();
......@@ -551,10 +551,10 @@ void Part::slotExtractFiles()
updateActions();
QString destinationDirectory;
if (dialog.extractToSubfolder())
if (dialog->extractToSubfolder())
{
destinationDirectory = dialog.destinationDirectory().path() +
QDir::separator() + dialog.subfolder();
destinationDirectory = dialog->destinationDirectory().path() +
QDir::separator() + dialog->subfolder();
if( !KStandardDirs::makeDir( destinationDirectory) )
{
......@@ -566,7 +566,7 @@ void Part::slotExtractFiles()
}
else
{
destinationDirectory = dialog.destinationDirectory().path();
destinationDirectory = dialog->destinationDirectory().path();
if (isSingleFolderArchive())
lastExtractionFolder = destinationDirectory + QDir::separator() + detectSubfolder();
......@@ -578,7 +578,7 @@ void Part::slotExtractFiles()
//if the user has chosen to extract only selected entries, fetch these
//from the listview
if (!dialog.extractAllFiles()) {
if (!dialog->extractAllFiles()) {
files = selectedFilesWithChildren();
}
......@@ -586,7 +586,7 @@ void Part::slotExtractFiles()
Kerfuffle::ExtractionOptions options;
if (dialog.preservePaths())
if (dialog->preservePaths())
options["PreservePaths"] = true;
ExtractJob *job = m_model->extractFiles( files, destinationDirectory, options );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment