Commit 508cc2b7 authored by Csaba Karai's avatar Csaba Karai
Browse files

ADDED: archive packing / unpacking are now in the background

parent bc0dbbba
ADDED: archive packing / unpacking are now in the background
ADDED: renaming of just the filename, without extension
ADDED: full screen terminal window (mc-style)
ADDED: Inactive panel color dimming (thanks to Heiner)
......
......@@ -39,9 +39,10 @@
#include <kcursor.h>
KRPleaseWait::KRPleaseWait( QString msg, int count, bool cancel ):
QProgressDialog(krApp,0,true) , inc(true) {
QProgressDialog( cancel ? 0 : krApp,0, !cancel) , inc(true) {
timer = new QTimer(this);
setCaption( i18n( "Krusader::Wait" ) );
setMinimumDuration(500);
setAutoClose(false);
......@@ -67,9 +68,10 @@ KRPleaseWait::KRPleaseWait( QString msg, int count, bool cancel ):
void KRPleaseWait::closeEvent ( QCloseEvent * e )
{
if( canClose )
if( canClose ) {
emit cancelled();
e->accept();
else /* if cancel is not allowed, we disable */
} else /* if cancel is not allowed, we disable */
e->ignore(); /* the window closing [x] also */
}
......@@ -84,6 +86,9 @@ void KRPleaseWait::cycleProgress(){
if ( progress() <= 0 ) inc = true;
}
KRPleaseWaitHandler::KRPleaseWaitHandler() : QObject(), job(), dlg( 0 ) {
}
void KRPleaseWaitHandler::stopWait(){
if( dlg != 0 ) delete dlg;
dlg=0;
......@@ -121,8 +126,6 @@ void KRPleaseWaitHandler::cycleProgress(){
cycleMutex=false;
}
KRPleaseWait* KRPleaseWaitHandler::dlg = 0;
void KRPleaseWaitHandler::killJob(){
if( !job.isNull() ) job->kill(false);
stopWait();
......@@ -138,4 +141,13 @@ void KRPleaseWaitHandler::incProgress(int i){
incMutex=false;
}
void KRPleaseWaitHandler::incProgress( KProcess *, char *buffer, int buflen ) {
int howMuch = 0;
for ( int i = 0 ; i < buflen; ++i )
if ( buffer[ i ] == '\n' )
++howMuch;
incProgress( howMuch );
}
#include "krpleasewait.moc"
......@@ -36,22 +36,29 @@
#include <qguardedptr.h>
#include <kio/jobclasses.h>
class KProcess;
class KRPleaseWait;
class KRPleaseWaitHandler : public QObject {
Q_OBJECT
public:
KRPleaseWaitHandler();
public slots:
void startWaiting(QString msg, int count, bool cancel);
void startWaiting(QString msg, int count = 0, bool cancel = false);
void stopWait();
void cycleProgress();
void incProgress(int i);
void incProgress( KProcess *, char *buffer, int buflen );
void killJob();
void setJob(KIO::Job* j);
bool wasCancelled() const { return _wasCancelled; }
private:
QGuardedPtr<KIO::Job> job;
static KRPleaseWait * dlg;
KRPleaseWait * dlg;
bool cycle, cycleMutex, incMutex, _wasCancelled;
};
......
......@@ -795,7 +795,7 @@ void ListPanelFunc::pack() {
return ; // stop operation
}
// tell the user to wait
krApp->startWaiting( i18n( "Counting files to pack" ), 0 );
krApp->startWaiting( i18n( "Counting files to pack" ), 0, true );
// get the files to be packed:
files() ->vfs_getFiles( &fileNames );
......
......@@ -44,6 +44,7 @@
#include "../krusader.h"
#include "../defaults.h"
#include "../krservices.h"
#include "../Dialogs/krpleasewait.h"
static QStringList arcProtocols = QStringList::split(";", "tar;bzip;bzip2;gzip;krarc;zip");
......@@ -182,7 +183,7 @@ long KRarcHandler::arcFileCount( QString archive, QString type, QString password
}
// tell the user to wait
krApp->startWaiting( i18n( "Counting files in archive" ) );
krApp->startWaiting( i18n( "Counting files in archive" ), 0, true );
// count the number of files in the archive
long count = 1;
......@@ -191,7 +192,14 @@ long KRarcHandler::arcFileCount( QString archive, QString type, QString password
list << lister << KrServices::quote( archive ) << ">" << tmpFile.name() ;
if( type == "-ace" && QFile( "/dev/ptmx" ).exists() ) // Don't remove, unace crashes if missing!!!
list<< "<" << "/dev/ptmx";
list.start( KProcess::Block, KProcess::AllOutput );
list.start( KProcess::NotifyOnExit, KProcess::AllOutput );
while ( list.isRunning() ) {
usleep( 1000 );
qApp->processEvents();
if( krApp->wasWaitingCancelled() )
list.kill();
}
; // busy wait - need to find something better...
krApp->stopWait();
......@@ -304,7 +312,7 @@ bool KRarcHandler::unpack( QString archive, QString type, QString password, QStr
chdir( dest.local8Bit() );
// tell the user to wait
krApp->startWaiting( i18n( "Unpacking File(s)" ), count );
krApp->startWaiting( i18n( "Unpacking File(s)" ), count, true );
if ( count != 0 ) {
connect( &proc, SIGNAL( receivedStdout( KProcess*, char*, int ) ),
krApp, SLOT( incProgress( KProcess*, char*, int ) ) );
......@@ -318,6 +326,8 @@ bool KRarcHandler::unpack( QString archive, QString type, QString password, QStr
while ( proc.isRunning() ) {
usleep( 1000 );
qApp->processEvents();
if( krApp->wasWaitingCancelled() )
proc.kill();
}
; // busy wait - need to find something better...
krApp->stopWait();
......@@ -329,6 +339,7 @@ bool KRarcHandler::unpack( QString archive, QString type, QString password, QStr
// check the return value
if ( !proc.normalExit() || !checkStatus( type, proc.exitStatus() ) ) {
KMessageBox::detailedError (krApp, i18n( "Failed to unpack %1!" ).arg( archive ),
krApp->wasWaitingCancelled() ? i18n( "User cancelled." ) :
proc.getErrorMsg(), i18n("Error" ) );
return false;
}
......@@ -372,7 +383,7 @@ bool KRarcHandler::test( QString archive, QString type, QString password, long c
proc << "<" << "/dev/ptmx";
// tell the user to wait
krApp->startWaiting( i18n( "Testing Archive" ), count );
krApp->startWaiting( i18n( "Testing Archive" ), count, true );
if ( count != 0 ) connect( &proc, SIGNAL( receivedStdout( KProcess*, char*, int ) ),
krApp, SLOT( incProgress( KProcess*, char*, int ) ) );
......@@ -381,6 +392,8 @@ bool KRarcHandler::test( QString archive, QString type, QString password, long c
while ( proc.isRunning() ) {
usleep( 1000 );
qApp->processEvents();
if( krApp->wasWaitingCancelled() )
proc.kill();
}
; // busy wait - need to find something better...
krApp->stopWait();
......@@ -476,7 +489,7 @@ bool KRarcHandler::pack( QStringList fileNames, QString type, QString dest, long
}
// tell the user to wait
krApp->startWaiting( i18n( "Packing File(s)" ), count );
krApp->startWaiting( i18n( "Packing File(s)" ), count, true );
if ( count != 0 )
connect( &proc, SIGNAL( receivedStdout( KProcess*, char*, int ) ),
krApp, SLOT( incProgress( KProcess*, char*, int ) ) );
......@@ -486,6 +499,8 @@ bool KRarcHandler::pack( QStringList fileNames, QString type, QString dest, long
while ( proc.isRunning() ) {
usleep( 1000 );
qApp->processEvents();
if( krApp->wasWaitingCancelled() )
proc.kill();
}
; // busy wait - need to find something better...
krApp->stopWait();
......@@ -493,7 +508,8 @@ bool KRarcHandler::pack( QStringList fileNames, QString type, QString dest, long
// check the return value
if ( !proc.normalExit() || !checkStatus( type, proc.exitStatus() ) ) {
KMessageBox::detailedError (krApp, i18n( "Failed to pack %1!" ).arg( dest ),
proc.getErrorMsg(), i18n("Error" ) );
krApp->wasWaitingCancelled() ? i18n( "User cancelled." ) : proc.getErrorMsg(),
i18n("Error" ) );
return false;
}
......
......@@ -62,6 +62,7 @@ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
#include <qwhatsthis.h>
#include <qwidgetlist.h>
#include <qdatetime.h>
#include <dcopclient.h>
// Krusader includes
#include "krusader.h"
#include "kicons.h"
......@@ -934,6 +935,9 @@ bool Krusader::queryClose() {
isExiting = true;
hide(); // hide
kapp->dcopClient()->detach(); // detach from DCOP
kapp->deref(); // FIX: krusader exits at closing the viewer when minimized to tray
kapp->deref(); // and close the application
return false; // don't let the main widget close. It stops the pending copies!
......
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