From 89fd56c23bc19812d3514991a6eeb9f27c2cb742 Mon Sep 17 00:00:00 2001 From: Jonathan Doman Date: Wed, 9 Apr 2014 23:29:13 +0200 Subject: [PATCH 1/5] Launch documents from external sources in new tabs FIXED-IN: 4.13.0 BUGS: 331872 BUGS: 332238 REVIEW: 116700 --- part.cpp | 14 ++++++- part.h | 2 + shell/main.cpp | 96 +++++++++++++++++++++++++++++++++++++++----- shell/shell.cpp | 71 +++++++++++++++++++++++++++----- shell/shell.h | 5 +++ ui/pageview.cpp | 25 +----------- ui/pageview.h | 7 ---- ui/sidebar.cpp | 13 ++++++ ui/sidebar.h | 8 ++++ ui/thumbnaillist.cpp | 17 -------- ui/thumbnaillist.h | 6 --- 11 files changed, 189 insertions(+), 75 deletions(-) diff --git a/part.cpp b/part.cpp index 4ce7e28e1..49eedf795 100644 --- a/part.cpp +++ b/part.cpp @@ -346,6 +346,7 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW m_sidebar = new Sidebar( parentWidget ); setWidget( m_sidebar ); + connect( m_sidebar, SIGNAL(urlsDropped(KUrl::List)), SLOT(handleDroppedUrls(KUrl::List)) ); // build the document m_document = new Okular::Document(widget()); @@ -382,7 +383,6 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW m_searchWidget = new SearchWidget( thumbsBox, m_document ); m_thumbnailList = new ThumbnailList( thumbsBox, m_document ); // ThumbnailController * m_tc = new ThumbnailController( thumbsBox, m_thumbnailList ); - connect( m_thumbnailList, SIGNAL(urlDropped(KUrl)), SLOT(openUrlFromDocument(KUrl)) ); connect( m_thumbnailList, SIGNAL(rightClick(const Okular::Page*,QPoint)), this, SLOT(slotShowMenu(const Okular::Page*,QPoint)) ); tbIndex = m_sidebar->addItem( thumbsBox, KIcon( "view-preview" ), i18n("Thumbnails") ); m_sidebar->setCurrentIndex( tbIndex ); @@ -433,7 +433,6 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW m_pageView = new PageView( rightContainer, m_document ); QMetaObject::invokeMethod( m_pageView, "setFocus", Qt::QueuedConnection ); //usability setting // m_splitter->setFocusProxy(m_pageView); - connect( m_pageView, SIGNAL(urlDropped(KUrl)), SLOT(openUrlFromDocument(KUrl))); connect( m_pageView, SIGNAL(rightClick(const Okular::Page*,QPoint)), this, SLOT(slotShowMenu(const Okular::Page*,QPoint)) ); connect( m_document, SIGNAL(error(QString,int)), m_pageView, SLOT(errorMessage(QString,int)) ); connect( m_document, SIGNAL(warning(QString,int)), m_pageView, SLOT(warningMessage(QString,int)) ); @@ -989,6 +988,17 @@ void Part::openUrlFromBookmarks(const KUrl &_url) openUrl( url ); } +void Part::handleDroppedUrls( const KUrl::List& urls ) +{ + if( m_embedMode != NativeShellMode || !openNewFilesInTabs() ) + { + openUrlFromDocument( urls.first() ); + return; + } + + emit urlsDropped( urls ); +} + void Part::slotJobStarted(KIO::Job *job) { if (job) diff --git a/part.h b/part.h index 010e9de1f..2776559bb 100644 --- a/part.h +++ b/part.h @@ -158,6 +158,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc void viewerMenuStateChange(bool enabled); void enableCloseAction(bool enable); void mimeTypeChanged(KMimeType::Ptr mimeType); + void urlsDropped( const KUrl::List& urls ); protected: // reimplemented from KParts::ReadWritePart @@ -176,6 +177,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc // connected to actions void openUrlFromDocument(const KUrl &url); void openUrlFromBookmarks(const KUrl &url); + void handleDroppedUrls( const KUrl::List& urls ); void slotGoToPage(); void slotHistoryBack(); void slotHistoryNext(); diff --git a/shell/main.cpp b/shell/main.cpp index e0ca587ba..b84191373 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "aboutdata.h" #include "shellutils.h" @@ -44,6 +45,77 @@ static bool attachUniqueInstance(KCmdLineArgs* args) return true; } +// 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) ) + 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) { KAboutData about = okularAboutData( "okular", I18N_NOOP( "Okular" ) ); @@ -69,19 +141,14 @@ int main(int argc, char** argv) // no session.. just start up normally KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); - // try to attach the "unique" session: if we succeed, do nothing more and exit - if (attachUniqueInstance(args)) + // try to attach to existing session, unique or not + if (attachUniqueInstance(args) || attachExistingInstance(args)) { args->clear(); return 0; } - if (args->count() == 0) - { - Shell* widget = new Shell(args); - widget->show(); - } - else if (args->isSet( "unique" ) && args->count() > 1) + if (args->isSet( "unique" ) && args->count() > 1) { QTextStream stream(stderr); stream << i18n( "Error: Can't open more than one document with the --unique switch" ) << endl; @@ -89,11 +156,18 @@ int main(int argc, char** argv) } else { - for (int i = 0; i < args->count(); ++i) + Shell* shell = new Shell( args ); + shell->show(); + for( int i = 0; i < args->count(); ) + { + if( shell->openDocument(args->arg(i)) ) + ++i; + else { - Shell* widget = new Shell(args, i); - widget->show(); + shell = new Shell( args ); + shell->show(); } + } } } diff --git a/shell/shell.cpp b/shell/shell.cpp index 01a9f1b1d..d67d93f9d 100644 --- a/shell/shell.cpp +++ b/shell/shell.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #ifdef KActivities_FOUND #include @@ -104,6 +105,8 @@ void Shell::init() m_tabWidget->setDocumentMode( true ); connect( m_tabWidget, SIGNAL(currentChanged(int)), SLOT(setActiveTab(int)) ); connect( m_tabWidget, SIGNAL(tabCloseRequested(int)), SLOT(closeTab(int)) ); + connect( m_tabWidget, SIGNAL(testCanDecode(const QDragMoveEvent*,bool&)), SLOT(testTabDrop(const QDragMoveEvent*,bool&)) ); + connect( m_tabWidget, SIGNAL(receivedDropEvent(QDropEvent*)), SLOT(handleTabDrop(QDropEvent*)) ); setCentralWidget( m_tabWidget ); @@ -119,11 +122,6 @@ void Shell::init() readSettings(); - if (m_args && m_args->isSet("unique") && m_args->count() == 1) - { - QDBusConnection::sessionBus().registerService("org.kde.okular"); - } - m_unique = false; if (m_args && m_args->isSet("unique") && m_args->count() <= 1) { @@ -171,6 +169,43 @@ Shell::~Shell() m_args->clear(); } +// Open a new document if we have space for it +// This can hang if called on a unique instance and openUrl pops a messageBox +bool Shell::openDocument( const QString& doc ) +{ + if( m_tabs.size() <= 0 ) + return false; + + KParts::ReadWritePart* const part = m_tabs[0].part; + + // Return false if we can't open new tabs and the only part is occupied + if( !dynamic_cast(part)->openNewFilesInTabs() + && !part->url().isEmpty() ) + return false; + + openUrl( ShellUtils::urlFromArg(doc,ShellUtils::qfileExistFunc()) ); + + return true; +} + +bool Shell::canOpenDocs( int numDocs, int desktop ) +{ + if( m_tabs.size() <= 0 || numDocs <= 0 || m_unique ) + return false; + + KParts::ReadWritePart* const part = m_tabs[0].part; + const bool allowTabs = dynamic_cast(part)->openNewFilesInTabs(); + + if( !allowTabs && (numDocs > 1 || !part->url().isEmpty()) ) + return false; + + const KWindowInfo winfo( window()->effectiveWinId(), KWindowSystem::WMDesktop ); + if( winfo.desktop() != desktop ) + return false; + + return true; +} + void Shell::openUrl( const KUrl & url ) { const int activeTab = m_tabWidget->currentIndex(); @@ -382,10 +417,7 @@ void Shell::slotQuit() void Shell::tryRaise() { - if (m_unique) - { - KWindowSystem::forceActiveWindow( window()->effectiveWinId() ); - } + KWindowSystem::forceActiveWindow( window()->effectiveWinId() ); } // only called when starting the program @@ -521,6 +553,7 @@ void Shell::connectPart( QObject* part ) connect( part, SIGNAL(enablePrintAction(bool)), this, SLOT(setPrintEnabled(bool))); connect( part, SIGNAL(enableCloseAction(bool)), this, SLOT(setCloseEnabled(bool))); connect( part, SIGNAL(mimeTypeChanged(KMimeType::Ptr)), this, SLOT(setTabIcon(KMimeType::Ptr))); + connect( part, SIGNAL(urlsDropped(KUrl::List)), this, SLOT(handleDroppedUrls(KUrl::List)) ); } void Shell::print() @@ -593,6 +626,26 @@ int Shell::findTabIndex( QObject* sender ) return -1; } +void Shell::handleDroppedUrls( const KUrl::List& urls ) +{ + foreach( const KUrl& url, urls ) + { + openUrl( url ); + } +} + +void Shell::testTabDrop( const QDragMoveEvent* event, bool& accept ) +{ + accept = KUrl::List::canDecode( event->mimeData() ); +} + +void Shell::handleTabDrop( QDropEvent* event ) +{ + const KUrl::List list = KUrl::List::fromMimeData( event->mimeData() ); + if( !list.isEmpty() ) + handleDroppedUrls( list ); +} + #include "shell.moc" /* kate: replace-tabs on; indent-width 4; */ diff --git a/shell/shell.h b/shell/shell.h index 3b9aae061..f25b3d8c0 100644 --- a/shell/shell.h +++ b/shell/shell.h @@ -63,6 +63,8 @@ public slots: void slotQuit(); Q_SCRIPTABLE Q_NOREPLY void tryRaise(); + Q_SCRIPTABLE bool openDocument( const QString& doc ); + Q_SCRIPTABLE bool canOpenDocs( int numDocs, int desktop ); protected: /** @@ -98,12 +100,15 @@ private slots: void setPrintEnabled( bool enabled ); void setCloseEnabled( bool enabled ); void setTabIcon( KMimeType::Ptr mimeType ); + void handleDroppedUrls( const KUrl::List& urls ); // Tab event handlers void setActiveTab( int tab ); void closeTab( int tab ); void activateNextTab(); void activatePrevTab(); + void testTabDrop( const QDragMoveEvent* event, bool& accept ); + void handleTabDrop( QDropEvent* event ); signals: void restoreDocument(const KConfigGroup &group); diff --git a/ui/pageview.cpp b/ui/pageview.cpp index dd4199450..b00dd3e92 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -260,7 +260,7 @@ OkularTTS* PageViewPrivate::tts() * Code weight (in rows) and meaning: * 160 - constructor and creating actions plus their connected slots (empty stuff) * 70 - DocumentObserver inherited methodes (important) - * 550 - events: mouse, keyboard, drag/drop + * 550 - events: mouse, keyboard, drag * 170 - slotRelayoutPages: set contents of the scrollview on continuous/single modes * 100 - zoom: zooming pages in different ways, keeping update the toolbar actions, etc.. * other misc functions: only slotRequestVisiblePixmaps and pickItemOnPoint noticeable, @@ -362,12 +362,11 @@ PageView::PageView( QWidget *parent, Okular::Document *document ) setObjectName( QLatin1String( "okular::pageView" ) ); - // viewport setup: setup focus, accept drops and track mouse + // viewport setup: setup focus, and track mouse viewport()->setFocusProxy( this ); viewport()->setFocusPolicy( Qt::StrongFocus ); viewport()->setAttribute( Qt::WA_OpaquePaintEvent ); viewport()->setAttribute( Qt::WA_NoSystemBackground ); - setAcceptDrops( true ); viewport()->setMouseTracking( true ); viewport()->setAutoFillBackground( false ); // the apparently "magic" value of 20 is the same used internally in QScrollArea @@ -3088,26 +3087,6 @@ void PageView::wheelEvent( QWheelEvent *e ) updateCursor(); } -void PageView::dragEnterEvent( QDragEnterEvent * ev ) -{ - ev->accept(); -} - -void PageView::dragMoveEvent( QDragMoveEvent * ev ) -{ - ev->accept(); -} - -void PageView::dropEvent( QDropEvent * ev ) -{ - if ( KUrl::List::canDecode( ev->mimeData() ) ) - { - const KUrl::List list = KUrl::List::fromMimeData( ev->mimeData() ); - if ( !list.isEmpty() ) - emit urlDropped( list.first() ); - } -} - bool PageView::viewportEvent( QEvent * e ) { if ( e->type() == QEvent::ToolTip && Okular::Settings::mouseMode() == Okular::Settings::EnumMouseMode::Browse ) diff --git a/ui/pageview.h b/ui/pageview.h index 577b90863..287da3a26 100644 --- a/ui/pageview.h +++ b/ui/pageview.h @@ -30,7 +30,6 @@ class KAction; class KActionCollection; class KMenu; -class KUrl; namespace Okular { class Action; @@ -136,7 +135,6 @@ Q_OBJECT void openAnnotationWindow( Okular::Annotation *annotation, int pageNumber ); signals: - void urlDropped( const KUrl& ); void rightClick( const Okular::Page *, const QPoint & ); void mouseBackButtonClick(); void mouseForwardButtonClick(); @@ -151,11 +149,6 @@ Q_OBJECT void inputMethodEvent( QInputMethodEvent * ); void wheelEvent( QWheelEvent* ); - // drag and drop related events - void dragEnterEvent( QDragEnterEvent* ); - void dragMoveEvent( QDragMoveEvent* ); - void dropEvent( QDropEvent* ); - void paintEvent( QPaintEvent *e ); void tabletEvent (QTabletEvent *e ); void mouseMoveEvent( QMouseEvent *e ); diff --git a/ui/sidebar.cpp b/ui/sidebar.cpp index 2474db8c3..f2a5ee977 100644 --- a/ui/sidebar.cpp +++ b/ui/sidebar.cpp @@ -449,6 +449,7 @@ Sidebar::Sidebar( QWidget *parent ) mainlay->setSpacing( 0 ); setAutoFillBackground( true ); + setAcceptDrops( true ); d->list = new SidebarListWidget( this ); mainlay->addWidget( d->list ); @@ -753,4 +754,16 @@ void Sidebar::appearanceChanged() d->sideDelegate->updateBrushCache(); } +void Sidebar::dragEnterEvent( QDragEnterEvent* event ) +{ + event->setAccepted( KUrl::List::canDecode(event->mimeData()) ); +} + +void Sidebar::dropEvent( QDropEvent* event ) +{ + const KUrl::List list = KUrl::List::fromMimeData( event->mimeData() ); + if( !list.isEmpty() ) + emit urlsDropped( list ); +} + #include "sidebar.moc" diff --git a/ui/sidebar.h b/ui/sidebar.h index 036d77880..cf5dfc6ce 100644 --- a/ui/sidebar.h +++ b/ui/sidebar.h @@ -11,6 +11,7 @@ #define _SIDEBAR_H_ #include +#include class QIcon; class QListWidgetItem; @@ -41,6 +42,13 @@ class Sidebar : public QWidget void setCollapsed( bool collapsed ); bool isCollapsed() const; + signals: + void urlsDropped( const KUrl::List& urls ); + + protected: + void dragEnterEvent( QDragEnterEvent* event ); + void dropEvent( QDropEvent* event ); + private slots: void itemClicked( QListWidgetItem *item ); void splitterMoved( int pos, int index ); diff --git a/ui/thumbnaillist.cpp b/ui/thumbnaillist.cpp index 72b557e66..8704bfa82 100644 --- a/ui/thumbnaillist.cpp +++ b/ui/thumbnaillist.cpp @@ -208,8 +208,6 @@ ThumbnailList::ThumbnailList( QWidget *parent, Okular::Document *document ) setAttribute( Qt::WA_StaticContents ); - setAcceptDrops( true ); - viewport()->setBackgroundRole( QPalette::Base ); setWidget( d ); @@ -600,21 +598,6 @@ void ThumbnailListPrivate::viewportResizeEvent( QResizeEvent * e ) // update Thumbnails since width has changed or height has increased delayedRequestVisiblePixmaps( 500 ); } - -void ThumbnailList::dragEnterEvent( QDragEnterEvent * ev ) -{ - ev->accept(); -} - -void ThumbnailList::dropEvent( QDropEvent * ev ) -{ - if ( KUrl::List::canDecode( ev->mimeData() ) ) - { - const KUrl::List list = KUrl::List::fromMimeData( ev->mimeData() ); - if ( !list.isEmpty() ) - emit urlDropped( list.first() ); - } -} //END widget events //BEGIN internal SLOTS diff --git a/ui/thumbnaillist.h b/ui/thumbnaillist.h index 61601c228..815e14ac9 100644 --- a/ui/thumbnaillist.h +++ b/ui/thumbnaillist.h @@ -17,7 +17,6 @@ #include "core/observer.h" -class KUrl; class ThumbnailListPrivate; namespace Okular { @@ -63,12 +62,7 @@ Q_OBJECT // catch the viewport event and filter them if necessary bool viewportEvent( QEvent * ); - // file drop related events (an url may be dropped even here) - void dragEnterEvent( QDragEnterEvent* ); - void dropEvent( QDropEvent* ); - signals: - void urlDropped( const KUrl& ); void rightClick( const Okular::Page *, const QPoint & ); private: From cd02dd6d3c04940c95c9a7657230bfb8032f8327 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 9 Apr 2014 23:34:18 +0200 Subject: [PATCH 2/5] Minor changes Make the receivers be the ones that check for empty, not the senders --- part.cpp | 5 ++++- shell/shell.cpp | 3 +-- ui/sidebar.cpp | 3 +-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/part.cpp b/part.cpp index 49eedf795..9a9979ec5 100644 --- a/part.cpp +++ b/part.cpp @@ -990,7 +990,10 @@ void Part::openUrlFromBookmarks(const KUrl &_url) void Part::handleDroppedUrls( const KUrl::List& urls ) { - if( m_embedMode != NativeShellMode || !openNewFilesInTabs() ) + if ( urls.isEmpty() ) + return; + + if ( m_embedMode != NativeShellMode || !openNewFilesInTabs() ) { openUrlFromDocument( urls.first() ); return; diff --git a/shell/shell.cpp b/shell/shell.cpp index d67d93f9d..9ee422a60 100644 --- a/shell/shell.cpp +++ b/shell/shell.cpp @@ -642,8 +642,7 @@ void Shell::testTabDrop( const QDragMoveEvent* event, bool& accept ) void Shell::handleTabDrop( QDropEvent* event ) { const KUrl::List list = KUrl::List::fromMimeData( event->mimeData() ); - if( !list.isEmpty() ) - handleDroppedUrls( list ); + handleDroppedUrls( list ); } #include "shell.moc" diff --git a/ui/sidebar.cpp b/ui/sidebar.cpp index f2a5ee977..0c722a9d9 100644 --- a/ui/sidebar.cpp +++ b/ui/sidebar.cpp @@ -762,8 +762,7 @@ void Sidebar::dragEnterEvent( QDragEnterEvent* event ) void Sidebar::dropEvent( QDropEvent* event ) { const KUrl::List list = KUrl::List::fromMimeData( event->mimeData() ); - if( !list.isEmpty() ) - emit urlsDropped( list ); + emit urlsDropped( list ); } #include "sidebar.moc" From 2c7baf1a9adb671a8b2338c8bb6fcd526f6d8dae Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 9 Apr 2014 23:35:23 +0200 Subject: [PATCH 3/5] Prepere for 4.13.0 --- VERSION | 2 +- core/version.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index e93251cf4..47903cb3a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -okular v0.18.97 +okular v0.19.0 diff --git a/core/version.h b/core/version.h index 2355edbe2..65d205181 100644 --- a/core/version.h +++ b/core/version.h @@ -10,10 +10,10 @@ #ifndef _OKULAR_VERSION_H_ #define _OKULAR_VERSION_H_ -#define OKULAR_VERSION_STRING "0.18.97" +#define OKULAR_VERSION_STRING "0.19.0" #define OKULAR_VERSION_MAJOR 0 -#define OKULAR_VERSION_MINOR 18 -#define OKULAR_VERSION_RELEASE 97 +#define OKULAR_VERSION_MINOR 19 +#define OKULAR_VERSION_RELEASE 0 #define OKULAR_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c)) #define OKULAR_VERSION \ From 6112a797653ccc06337a29f78a502b9802acf154 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 9 Apr 2014 23:39:04 +0200 Subject: [PATCH 4/5] Minor version updates to generators with changes since 4.12 --- generators/dvi/generator_dvi.cpp | 2 +- generators/epub/generator_epub.cpp | 2 +- generators/mobipocket/generator_mobi.cpp | 2 +- generators/poppler/generator_pdf.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generators/dvi/generator_dvi.cpp b/generators/dvi/generator_dvi.cpp index ba4e71fce..94315a3da 100644 --- a/generators/dvi/generator_dvi.cpp +++ b/generators/dvi/generator_dvi.cpp @@ -52,7 +52,7 @@ static KAboutData createAboutData() "okular_dvi", "okular_dvi", ki18n( "DVI Backend" ), - "0.3.5", + "0.3.6", ki18n( "A DVI file renderer" ), KAboutData::License_GPL, ki18n( "© 2006 Luigi Toscano" ) diff --git a/generators/epub/generator_epub.cpp b/generators/epub/generator_epub.cpp index 54512a845..48e731489 100644 --- a/generators/epub/generator_epub.cpp +++ b/generators/epub/generator_epub.cpp @@ -20,7 +20,7 @@ static KAboutData createAboutData() "okular_epub", "okular_epub", ki18n("EPub Backend"), - "0.2.2", + "0.2.3", ki18n("An EPub backend"), KAboutData::License_GPL, ki18n("© 2008 Ely Levy") diff --git a/generators/mobipocket/generator_mobi.cpp b/generators/mobipocket/generator_mobi.cpp index 5c6d3ab63..3040745d1 100644 --- a/generators/mobipocket/generator_mobi.cpp +++ b/generators/mobipocket/generator_mobi.cpp @@ -19,7 +19,7 @@ static KAboutData createAboutData() "okular_mobi", "okular_mobi", ki18n("Mobipocket Backend"), - "0.1", + "0.1.1", ki18n("A mobipocket backend"), KAboutData::License_GPL, ki18n("© 2008-2009 Jakub Stachowski") diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp index f08a5714a..95d9f977e 100644 --- a/generators/poppler/generator_pdf.cpp +++ b/generators/poppler/generator_pdf.cpp @@ -402,7 +402,7 @@ static KAboutData createAboutData() "okular_poppler", "okular_poppler", ki18n( "PDF Backend" ), - "0.6.3", + "0.6.4", ki18n( "A PDF file renderer" ), KAboutData::License_GPL, ki18n( "© 2005-2008 Albert Astals Cid" ) From 49dc7dcb5953e09dd465737a01b0513ebfbe0607 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 9 Apr 2014 23:57:38 +0200 Subject: [PATCH 5/5] 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; */