kde-extraapps/ark/kerfuffle/extractiondialog.cpp

151 lines
4 KiB
C++
Raw Permalink Normal View History

2014-11-18 17:46:34 +00:00
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2009 Harald Hvaal <haraldhv@stud.ntnu.no>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "extractiondialog.h"
#include "settings.h"
#include <KLocale>
#include <KIconLoader>
#include <KMessageBox>
#include <KStandardDirs>
#include <KDebug>
#include <KIO/NetAccess>
#include <kfilewidget.h>
2014-11-18 17:46:34 +00:00
#include <QDir>
#include "ui_extractiondialog.h"
namespace Kerfuffle
{
class ExtractionDialogUI: public QFrame, public Ui::ExtractionDialog
{
public:
ExtractionDialogUI(QWidget *parent = 0)
: QFrame(parent)
{
2014-11-18 17:46:34 +00:00
setupUi(this);
}
};
ExtractionDialog::ExtractionDialog(QWidget *parent)
: KFileDialog(KUrl(), QString(), parent)
2014-11-18 17:46:34 +00:00
{
setOperationMode(KFileDialog::Opening);
setMode(KFile::Directory | KFile::ExistingOnly);
2014-11-18 17:46:34 +00:00
m_ui = new ExtractionDialogUI(this);
fileWidget()->setCustomWidget(m_ui);
2014-11-18 17:46:34 +00:00
setCaption(i18nc("@title:window", "Extract"));
loadSettings();
connect(this, SIGNAL(finished(int)), SLOT(writeSettings()));
}
void ExtractionDialog::loadSettings()
{
setOpenDestinationFolderAfterExtraction(ArkSettings::openDestinationFolderAfterExtraction());
setCloseAfterExtraction(ArkSettings::closeAfterExtraction());
setPreservePaths(ArkSettings::preservePaths());
}
ExtractionDialog::~ExtractionDialog()
{
delete m_ui;
m_ui = 0;
}
void ExtractionDialog::setAutoSubfolder(bool value)
{
m_ui->autoSubfolders->setChecked(value);
}
bool ExtractionDialog::autoSubfolders() const
{
return m_ui->autoSubfolders->isChecked();
}
void ExtractionDialog::setOpenDestinationFolderAfterExtraction(bool value)
{
m_ui->openFolderCheckBox->setChecked(value);
}
void ExtractionDialog::setCloseAfterExtraction(bool value)
{
m_ui->closeAfterExtraction->setChecked(value);
}
void ExtractionDialog::setPreservePaths(bool value)
{
m_ui->preservePaths->setChecked(value);
}
bool ExtractionDialog::preservePaths() const
{
return m_ui->preservePaths->isChecked();
}
bool ExtractionDialog::openDestinationAfterExtraction() const
{
return m_ui->openFolderCheckBox->isChecked();
}
bool ExtractionDialog::closeAfterExtraction() const
{
return m_ui->closeAfterExtraction->isChecked();
}
QString ExtractionDialog::destinationDirectory() const
2014-11-18 17:46:34 +00:00
{
return selectedUrl().pathOrUrl(KUrl::AddTrailingSlash);
}
void ExtractionDialog::selectionModeOption()
{
setCaption(i18n("Extract selected"));
}
void ExtractionDialog::batchModeOption()
{
setCaption(i18n("Extract multiple archives"));
2014-11-18 17:46:34 +00:00
}
void ExtractionDialog::writeSettings()
{
ArkSettings::setOpenDestinationFolderAfterExtraction(openDestinationAfterExtraction());
ArkSettings::setCloseAfterExtraction(closeAfterExtraction());
ArkSettings::setPreservePaths(preservePaths());
ArkSettings::self()->writeConfig();
}
}
2015-02-27 11:02:43 +00:00
#include "moc_extractiondialog.cpp"