From 49dc7dcb5953e09dd465737a01b0513ebfbe0607 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 9 Apr 2014 23:57:38 +0200 Subject: [PATCH] Indent --- shell/main.cpp | 146 ++++++++++++++++++++++++------------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/shell/main.cpp b/shell/main.cpp index b84191373..d2e0ec72f 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -33,13 +33,13 @@ static bool attachUniqueInstance(KCmdLineArgs* args) return false; if (args->isSet("print")) - iface.call("enableStartWithPrint"); + iface.call("enableStartWithPrint"); if (args->isSet("page")) iface.call("openDocument", ShellUtils::urlFromArg(args->arg(0), ShellUtils::qfileExistFunc(), args->getOption("page")).url()); else iface.call("openDocument", ShellUtils::urlFromArg(args->arg(0), ShellUtils::qfileExistFunc()).url()); - if (args->isSet("raise")){ - iface2.call("tryRaise"); + if (args->isSet("raise")) { + iface2.call("tryRaise"); } return true; @@ -48,72 +48,72 @@ static bool attachUniqueInstance(KCmdLineArgs* args) // Ask an existing non-unique instance to open new tabs static bool attachExistingInstance( KCmdLineArgs* args ) { - if( args->count() < 1 ) - return false; - - const QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); - - // Don't match the service without trailing "-" (unique instance) - const QString pattern = "org.kde.okular-"; - const QString myPid = QString::number( kapp->applicationPid() ); - QScopedPointer bestService; - const int desktop = KWindowSystem::currentDesktop(); - - // Select the first instance that isn't us (metric may change in future) - foreach( const QString& service, services ) - { - if( service.startsWith(pattern) && !service.endsWith(myPid) ) - { - bestService.reset( new QDBusInterface(service,"/okularshell","org.kde.okular") ); - - // Find a window that can handle our documents - const QDBusReply reply = bestService->call( "canOpenDocs", args->count(), desktop ); - if( reply.isValid() && reply.value() ) - break; - - bestService.reset(); - } - } - - if( !bestService ) - return false; - - for( int i = 0; i < args->count(); ++i ) - { - QString arg = args->arg( i ); - - // Copy stdin to temporary file which can be opened by the existing - // window. The temp file is automatically deleted after it has been - // opened. Not sure if this behavior is safe on all platforms. - QScopedPointer tempFile; - if( arg == "-" ) - { - tempFile.reset( new QTemporaryFile ); - QFile stdinFile; - if( !tempFile->open() || !stdinFile.open(stdin,QIODevice::ReadOnly) ) + if ( args->count() < 1 ) return false; - const size_t bufSize = 1024*1024; - QScopedPointer > buf( new char[bufSize] ); - size_t bytes; - do - { - bytes = stdinFile.read( buf.data(), bufSize ); - tempFile->write( buf.data(), bytes ); - } while( bytes != 0 ); + const QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); - arg = tempFile->fileName(); + // Don't match the service without trailing "-" (unique instance) + const QString pattern = "org.kde.okular-"; + const QString myPid = QString::number( kapp->applicationPid() ); + QScopedPointer bestService; + const int desktop = KWindowSystem::currentDesktop(); + + // Select the first instance that isn't us (metric may change in future) + foreach ( const QString& service, services ) + { + if ( service.startsWith(pattern) && !service.endsWith( myPid ) ) + { + bestService.reset( new QDBusInterface(service, "/okularshell", "org.kde.okular") ); + + // Find a window that can handle our documents + const QDBusReply reply = bestService->call( "canOpenDocs", args->count(), desktop ); + if( reply.isValid() && reply.value() ) + break; + + bestService.reset(); + } } - // Returns false if it can't fit another document - const QDBusReply reply = bestService->call( "openDocument", arg ); - if( !reply.isValid() || !reply.value() ) - return false; - } + if ( !bestService ) + return false; - bestService->call( "tryRaise" ); + for( int i = 0; i < args->count(); ++i ) + { + QString arg = args->arg( i ); - return true; + // Copy stdin to temporary file which can be opened by the existing + // window. The temp file is automatically deleted after it has been + // opened. Not sure if this behavior is safe on all platforms. + QScopedPointer tempFile; + if( arg == "-" ) + { + tempFile.reset( new QTemporaryFile ); + QFile stdinFile; + if( !tempFile->open() || !stdinFile.open(stdin,QIODevice::ReadOnly) ) + return false; + + const size_t bufSize = 1024*1024; + QScopedPointer > buf( new char[bufSize] ); + size_t bytes; + do + { + bytes = stdinFile.read( buf.data(), bufSize ); + tempFile->write( buf.data(), bytes ); + } while( bytes != 0 ); + + arg = tempFile->fileName(); + } + + // Returns false if it can't fit another document + const QDBusReply reply = bestService->call( "openDocument", arg ); + if( !reply.isValid() || !reply.value() ) + return false; + } + + bestService->call( "tryRaise" ); + + return true; } int main(int argc, char** argv) @@ -156,22 +156,22 @@ int main(int argc, char** argv) } else { - Shell* shell = new Shell( args ); - shell->show(); - for( int i = 0; i < args->count(); ) - { - if( shell->openDocument(args->arg(i)) ) - ++i; - else + Shell* shell = new Shell( args ); + shell->show(); + for ( int i = 0; i < args->count(); ) { - shell = new Shell( args ); - shell->show(); + if ( shell->openDocument( args->arg(i)) ) + ++i; + else + { + shell = new Shell( args ); + shell->show(); + } } - } } } return app.exec(); } -// vim:ts=2:sw=2:tw=78:et +/* kate: replace-tabs on; indent-width 4; */