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

Adhere do kdelibs' coding style.

svn path=/trunk/KDE/kdeutils/ark/; revision=980565
parent 69b9b14c
......@@ -34,56 +34,56 @@
using Kerfuffle::BatchExtract;
K_PLUGIN_FACTORY(ExtractHerePluginFactory,
registerPlugin<ExtractHereDndPlugin>();
)
registerPlugin<ExtractHereDndPlugin>();
)
K_EXPORT_PLUGIN(ExtractHerePluginFactory("stupidname"))
void ExtractHereDndPlugin::slotTriggered()
{
kDebug() << "Preparing job";
BatchExtract *batchJob = new BatchExtract();
kDebug() << "Preparing job";
BatchExtract *batchJob = new BatchExtract();
batchJob->setAutoSubfolder(true);
batchJob->setDestinationFolder(m_dest.path());
batchJob->setPreservePaths(true);
foreach(const KUrl& url, m_urls) {
batchJob->addInput(url);
}
batchJob->setAutoSubfolder(true);
batchJob->setDestinationFolder(m_dest.path());
batchJob->setPreservePaths(true);
foreach(const KUrl& url, m_urls) {
batchJob->addInput(url);
}
batchJob->start();
kDebug() << "Started job";
batchJob->start();
kDebug() << "Started job";
}
ExtractHereDndPlugin::ExtractHereDndPlugin(QObject* parent, const QVariantList&)
: KonqDndPopupMenuPlugin(parent)
ExtractHereDndPlugin::ExtractHereDndPlugin(QObject* parent, const QVariantList&)
: KonqDndPopupMenuPlugin(parent)
{
}
void ExtractHereDndPlugin::setup(const KFileItemListProperties& popupMenuInfo,
KUrl destination,
QList<QAction*>& userActions)
KUrl destination,
QList<QAction*>& userActions)
{
kDebug() << "plugin setup";
QString extractHereMessage = i18n("Extract here");
kDebug() << "plugin setup";
QString extractHereMessage = i18n("Extract here");
if (!Kerfuffle::supportedMimeTypes().contains(popupMenuInfo.mimeType())) {
kDebug(1601) << "Unsupported file" << popupMenuInfo.mimeType() << Kerfuffle::supportedMimeTypes();
return;
}
if (!Kerfuffle::supportedMimeTypes().contains(popupMenuInfo.mimeType())) {
kDebug(1601) << "Unsupported file" << popupMenuInfo.mimeType() << Kerfuffle::supportedMimeTypes();
return;
}
kDebug() << "Plugin executed";
//<< popupMenuInfo.mimeGroup()
//<< popupMenuInfo.mimeType();
kDebug() << "Plugin executed";
//<< popupMenuInfo.mimeGroup()
//<< popupMenuInfo.mimeType();
KAction *action = new KAction(KIcon("archive-extract"), extractHereMessage, NULL);
connect(action, SIGNAL(triggered()),
this, SLOT(slotTriggered()));
KAction *action = new KAction(KIcon("archive-extract"), extractHereMessage, NULL);
connect(action, SIGNAL(triggered()),
this, SLOT(slotTriggered()));
userActions.append(action);
m_dest = destination;
m_urls = popupMenuInfo.urlList();
userActions.append(action);
m_dest = destination;
m_urls = popupMenuInfo.urlList();
}
......
......@@ -31,20 +31,20 @@
class ExtractHereDndPlugin : public KonqDndPopupMenuPlugin
{
Q_OBJECT
Q_OBJECT
private slots:
void slotTriggered();
private slots:
void slotTriggered();
public:
ExtractHereDndPlugin(QObject* parent, const QVariantList&);
public:
ExtractHereDndPlugin(QObject* parent, const QVariantList&);
virtual void setup(const KFileItemListProperties& popupMenuInfo,
KUrl destination,
QList<QAction*>& userActions);
private:
KUrl m_dest;
QList<KUrl> m_urls;
virtual void setup(const KFileItemListProperties& popupMenuInfo,
KUrl destination,
QList<QAction*>& userActions);
private:
KUrl m_dest;
QList<KUrl> m_urls;
};
#endif /* _EXTRACTHEREDNDPLUGIN_H_ */
......@@ -36,191 +36,191 @@
using Kerfuffle::BatchExtract;
using Kerfuffle::AddToArchive;
int main( int argc, char **argv )
int main(int argc, char **argv)
{
KAboutData aboutData( "ark", 0, ki18n( "Ark" ),
"2.13", ki18n( "KDE Archiving tool" ),
KAboutData::License_GPL,
ki18n( "(c) 1997-2008, The Various Ark Developers" ),
KLocalizedString(),
"http://utils.kde.org/projects/ark"
);
aboutData.addAuthor( ki18n("Harald Hvaal"),
ki18n( "Maintainer" ),
"haraldhv@stud.ntnu.no" );
aboutData.addAuthor( ki18n("Henrique Pinto"),
ki18n( "Former Maintainer" ),
"henrique.pinto@kdemail.net" );
aboutData.addAuthor( ki18n("Helio Chissini de Castro"),
ki18n( "Former maintainer" ),
"helio@kde.org" );
aboutData.addAuthor( ki18n("Georg Robbers"),
KLocalizedString(),
"Georg.Robbers@urz.uni-hd.de" );
aboutData.addAuthor( ki18n("Roberto Selbach Teixeira"),
KLocalizedString(),
"maragato@kde.org" );
aboutData.addAuthor( ki18n("Francois-Xavier Duranceau"),
KLocalizedString(),
"duranceau@kde.org" );
aboutData.addAuthor( ki18n("Emily Ezust (Corel Corporation)"),
KLocalizedString(),
"emilye@corel.com" );
aboutData.addAuthor( ki18n("Michael Jarrett (Corel Corporation)"),
KLocalizedString(),
"michaelj@corel.com" );
aboutData.addAuthor( ki18n("Robert Palmbos"),
KLocalizedString(),
"palm9744@kettering.edu" );
aboutData.addCredit( ki18n("Bryce Corkins"),
ki18n( "Icons" ),
"dbryce@attglobal.net" );
aboutData.addCredit( ki18n("Liam Smit"),
ki18n( "Ideas, help with the icons" ),
"smitty@absamail.co.za" );
aboutData.addCredit( ki18n( "Andrew Smith" ),
ki18n( "bkisofs code" ),
QByteArray(),
"http://littlesvr.ca/misc/contactandrew.php" );
aboutData.setProgramIconName( "utilities-file-archiver" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions option;
option.add("+[url]", ki18n( "URL of an archive to be opened" ));
option.add("d").add("dialog", ki18n("Show a dialog for specifying the options for the operation (extract/add)"));
option.add("o").add("destination <directory>", ki18n("Destination folder to extract to. Defaults to current path if not specified."));
option.add(":", ki18n("Options for adding files"));
option.add("c").add("add", ki18n("Query the user for an archive filename and add specified files to it. Quit when finished."));
option.add("t").add("add-to <filename>", ki18n("Add the specified files to 'filename'. Create archive if it does not exist. Quit when finished."));
option.add("p").add("changetofirstpath", ki18n("Change the current dir to the first entry and add all other entries relative to this one."));
option.add("f").add("autofilename <suffix>", ki18n("Automatically choose a filename, with the selected suffix (for example rar, tar.gz, zip or any other supported types)"));
option.add(":", ki18n("Options for batch extraction:"));
option.add("b").add("batch", ki18n("Use the batch interface instead of the usual dialog. This option is implied if more than one url is specified."));
option.add("e").add("autodestination", ki18n("The destination argument will be set to the path of the first file supplied."));
option.add("a").add("autosubfolder", ki18n("Archive contents will be read, and if detected to not be a single folder archive, a subfolder by the name of the archive will be created."));
option.add("s").add("subfolder <directory>", ki18n("Create a subfolder under the destination directory and extract here."));
KCmdLineArgs::addCmdLineOptions( option );
KCmdLineArgs::addTempFileOption();
// We call application.exec() only when not using batch creation/extraction
bool startApplication = true;
KApplication application;
application.setQuitOnLastWindowClosed(false);
//session restoring
if ( application.isSessionRestored() ) {
MainWindow* window = NULL;
if (KMainWindow::canBeRestored(1)) {
window = new MainWindow;
window->restore(1);
if (!window->loadPart()) {
delete window;
window = NULL;
}
}
if (window == NULL) {
return -1;
}
} else { //new ark window (no restored session)
// open any given URLs
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->isSet("add") || args->isSet("add-to")) {
startApplication = false;
AddToArchive *addToArchiveJob = new AddToArchive();
if (args->isSet("changetofirstpath")) {
addToArchiveJob->setChangeToFirstPath(true);
}
if (args->isSet("add-to")) {
addToArchiveJob->setFilename(args->getOption("add-to"));
}
if (args->isSet("autofilename")) {
addToArchiveJob->setAutoFilenameSuffix(args->getOption("autofilename"));
}
for (int i = 0; i < args->count(); ++i) {
//TODO: use the returned value here?
addToArchiveJob->addInput(args->url(i));
}
if (args->isSet("dialog")) {
if (!addToArchiveJob->showAddDialog()) {
return 0;
}
}
addToArchiveJob->start();
} else if (args->isSet("batch")) {
startApplication = false;
//once the job has been started this interface can be safely
//deleted
BatchExtract *batchJob = new BatchExtract();
for (int i = 0; i < args->count(); ++i) {
batchJob->addInput(args->url(i));
}
if (args->isSet("autosubfolder")) {
kDebug( 1601 ) << "Setting autosubfolder";
batchJob->setAutoSubfolder(true);
}
if (args->isSet("subfolder")) {
kDebug( 1601 ) << "Setting subfolder to " << args->getOption("subfolder");
batchJob->setSubfolder(args->getOption("subfolder"));
}
if (args->isSet("autodestination")) {
QString autopath = QFileInfo(args->url(0).path()).path();
kDebug( 1601 ) << "By autodestination, setting path to " << autopath;
batchJob->setDestinationFolder(autopath);
}
if (args->isSet("destination")) {
kDebug( 1601 ) << "Setting destination to " << args->getOption("destination");
batchJob->setDestinationFolder(args->getOption("destination"));
}
if (args->isSet("dialog")) {
if (!batchJob->showExtractDialog()) {
return 0;
}
}
batchJob->start();
} else {
MainWindow *window = new MainWindow;
if(!window->loadPart()) { // if loading the part fails
return -1;
}
if (args->count()) {
kDebug() << "trying to open" << args->url(0);
if (args->isSet("dialog")) {
window->setShowExtractDialog(true);
}
window->openUrl(args->url(0));
}
window->show();
}
}
if (startApplication) {
kDebug (1601) << "Entering application loop";
return application.exec();
}
return 0;
KAboutData aboutData("ark", 0, ki18n("Ark"),
"2.13", ki18n("KDE Archiving tool"),
KAboutData::License_GPL,
ki18n("(c) 1997-2008, The Various Ark Developers"),
KLocalizedString(),
"http://utils.kde.org/projects/ark"
);
aboutData.addAuthor(ki18n("Harald Hvaal"),
ki18n("Maintainer"),
"haraldhv@stud.ntnu.no");
aboutData.addAuthor(ki18n("Henrique Pinto"),
ki18n("Former Maintainer"),
"henrique.pinto@kdemail.net");
aboutData.addAuthor(ki18n("Helio Chissini de Castro"),
ki18n("Former maintainer"),
"helio@kde.org");
aboutData.addAuthor(ki18n("Georg Robbers"),
KLocalizedString(),
"Georg.Robbers@urz.uni-hd.de");
aboutData.addAuthor(ki18n("Roberto Selbach Teixeira"),
KLocalizedString(),
"maragato@kde.org");
aboutData.addAuthor(ki18n("Francois-Xavier Duranceau"),
KLocalizedString(),
"duranceau@kde.org");
aboutData.addAuthor(ki18n("Emily Ezust (Corel Corporation)"),
KLocalizedString(),
"emilye@corel.com");
aboutData.addAuthor(ki18n("Michael Jarrett (Corel Corporation)"),
KLocalizedString(),
"michaelj@corel.com");
aboutData.addAuthor(ki18n("Robert Palmbos"),
KLocalizedString(),
"palm9744@kettering.edu");
aboutData.addCredit(ki18n("Bryce Corkins"),
ki18n("Icons"),
"dbryce@attglobal.net");
aboutData.addCredit(ki18n("Liam Smit"),
ki18n("Ideas, help with the icons"),
"smitty@absamail.co.za");
aboutData.addCredit(ki18n("Andrew Smith"),
ki18n("bkisofs code"),
QByteArray(),
"http://littlesvr.ca/misc/contactandrew.php");
aboutData.setProgramIconName("utilities-file-archiver");
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineOptions option;
option.add("+[url]", ki18n("URL of an archive to be opened"));
option.add("d").add("dialog", ki18n("Show a dialog for specifying the options for the operation (extract/add)"));
option.add("o").add("destination <directory>", ki18n("Destination folder to extract to. Defaults to current path if not specified."));
option.add(":", ki18n("Options for adding files"));
option.add("c").add("add", ki18n("Query the user for an archive filename and add specified files to it. Quit when finished."));
option.add("t").add("add-to <filename>", ki18n("Add the specified files to 'filename'. Create archive if it does not exist. Quit when finished."));
option.add("p").add("changetofirstpath", ki18n("Change the current dir to the first entry and add all other entries relative to this one."));
option.add("f").add("autofilename <suffix>", ki18n("Automatically choose a filename, with the selected suffix (for example rar, tar.gz, zip or any other supported types)"));
option.add(":", ki18n("Options for batch extraction:"));
option.add("b").add("batch", ki18n("Use the batch interface instead of the usual dialog. This option is implied if more than one url is specified."));
option.add("e").add("autodestination", ki18n("The destination argument will be set to the path of the first file supplied."));
option.add("a").add("autosubfolder", ki18n("Archive contents will be read, and if detected to not be a single folder archive, a subfolder by the name of the archive will be created."));
option.add("s").add("subfolder <directory>", ki18n("Create a subfolder under the destination directory and extract here."));
KCmdLineArgs::addCmdLineOptions(option);
KCmdLineArgs::addTempFileOption();
// We call application.exec() only when not using batch creation/extraction
bool startApplication = true;
KApplication application;
application.setQuitOnLastWindowClosed(false);
//session restoring
if (application.isSessionRestored()) {
MainWindow* window = NULL;
if (KMainWindow::canBeRestored(1)) {
window = new MainWindow;
window->restore(1);
if (!window->loadPart()) {
delete window;
window = NULL;
}
}
if (window == NULL) {
return -1;
}
} else { //new ark window (no restored session)
// open any given URLs
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->isSet("add") || args->isSet("add-to")) {
startApplication = false;
AddToArchive *addToArchiveJob = new AddToArchive();
if (args->isSet("changetofirstpath")) {
addToArchiveJob->setChangeToFirstPath(true);
}
if (args->isSet("add-to")) {
addToArchiveJob->setFilename(args->getOption("add-to"));
}
if (args->isSet("autofilename")) {
addToArchiveJob->setAutoFilenameSuffix(args->getOption("autofilename"));
}
for (int i = 0; i < args->count(); ++i) {
//TODO: use the returned value here?
addToArchiveJob->addInput(args->url(i));
}
if (args->isSet("dialog")) {
if (!addToArchiveJob->showAddDialog()) {
return 0;
}
}
addToArchiveJob->start();
} else if (args->isSet("batch")) {
startApplication = false;
//once the job has been started this interface can be safely
//deleted
BatchExtract *batchJob = new BatchExtract();
for (int i = 0; i < args->count(); ++i) {
batchJob->addInput(args->url(i));
}
if (args->isSet("autosubfolder")) {
kDebug(1601) << "Setting autosubfolder";
batchJob->setAutoSubfolder(true);
}
if (args->isSet("subfolder")) {
kDebug(1601) << "Setting subfolder to " << args->getOption("subfolder");
batchJob->setSubfolder(args->getOption("subfolder"));
}
if (args->isSet("autodestination")) {
QString autopath = QFileInfo(args->url(0).path()).path();
kDebug(1601) << "By autodestination, setting path to " << autopath;
batchJob->setDestinationFolder(autopath);
}
if (args->isSet("destination")) {
kDebug(1601) << "Setting destination to " << args->getOption("destination");
batchJob->setDestinationFolder(args->getOption("destination"));
}
if (args->isSet("dialog")) {
if (!batchJob->showExtractDialog()) {
return 0;
}
}
batchJob->start();
} else {
MainWindow *window = new MainWindow;
if (!window->loadPart()) { // if loading the part fails
return -1;
}
if (args->count()) {
kDebug() << "trying to open" << args->url(0);
if (args->isSet("dialog")) {
window->setShowExtractDialog(true);
}
window->openUrl(args->url(0));
}
window->show();
}
}
if (startApplication) {
kDebug(1601) << "Entering application loop";
return application.exec();
}
return 0;
}
......@@ -44,211 +44,201 @@
static bool isValidArchiveDrag(const QMimeData *data)
{
return
data->hasUrls() &&
data->urls().count() == 1;
return
data->hasUrls() &&
data->urls().count() == 1;
}
MainWindow::MainWindow( QWidget * )
: KParts::MainWindow( )
MainWindow::MainWindow(QWidget *)
: KParts::MainWindow()
{
setXMLFile( "arkui.rc" );
setXMLFile("arkui.rc");
setupActions();
statusBar();
setupActions();
statusBar();
if ( !initialGeometrySet() )
{
resize( 640, 480 );
}
setAutoSaveSettings( "MainWindow" );
if (!initialGeometrySet()) {
resize(640, 480);
}
setAutoSaveSettings("MainWindow");
setAcceptDrops(true);
setAcceptDrops(true);
}
MainWindow::~MainWindow()
{
if ( m_recentFilesAction )
{
m_recentFilesAction->saveEntries( KGlobal::config()->group( "Recent Files" ) );
}
delete m_part;
m_part = 0;
if (m_recentFilesAction) {
m_recentFilesAction->saveEntries(KGlobal::config()->group("Recent Files"));
}
delete m_part;
m_part = 0;
}
void MainWindow::dragEnterEvent ( QDragEnterEvent * event )
void MainWindow::dragEnterEvent(QDragEnterEvent * event)
{
kDebug(1601) << event;
kDebug(1601) << event;
Interface *iface = qobject_cast<Interface*>( m_part );
if (iface->isBusy()) return;
Interface *iface = qobject_cast<Interface*>(m_part);
if (iface->isBusy()) return;
if (event->source() == NULL &&
isValidArchiveDrag(event->mimeData()))
event->acceptProposedAction();
return;
if (event->source() == NULL &&
isValidArchiveDrag(event->mimeData()))
event->acceptProposedAction();
return;
}
void MainWindow::dropEvent ( QDropEvent * event )
void MainWindow::dropEvent(QDropEvent * event)
{
kDebug(1601) << event;