[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Patch: Dolpin launches in split view when two URLs are passed as
From:       David Edmundson <david () davidedmundson ! co ! uk>
Date:       2008-03-22 10:57:01
Message-ID: 200803221057.01462.david () davidedmundson ! co ! uk
[Download RAW message or body]

Hi,

I've just written a patch for Dolphin for something that was bugging me. In 
the existing code, typing any number of URLs when launching dolphin from a 
command line opens that many windows. It seems a bit daft when Dolphin has 
that lovely split view. 

With this patch, one URL opens a single window, 2 urls open a single window in 
split view, any more than that reverts back to the original window for each 
approach.

I wrote it against KDE 4.02, but it seems unchanged in current SVN.

This is my first real patch outside of my KDE project, so I thought I'd submit 
it here first to be checked.

Thanks

David

["dolphinsplit.patch" (text/x-diff)]

Index: dolphinapplication.h
===================================================================
--- dolphinapplication.h	(revision 787931)
+++ dolphinapplication.h	(working copy)
@@ -58,6 +58,7 @@
 
 public slots:
     int openWindow(const KUrl& url);
+    int openWindow(const KUrl& url,const KUrl& url2);
 
 protected:
     /** Called by the DolphinMainWindow to deregister. */
Index: dolphinapplication.cpp
===================================================================
--- dolphinapplication.cpp	(revision 787931)
+++ dolphinapplication.cpp	(working copy)
@@ -76,17 +76,26 @@
     KCmdLineArgs::setCwd(QDir::currentPath().toUtf8());
     KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
     static bool first = true;
-    if (args->count() > 0) {
-        for (int i = 0; i < args->count(); ++i) {
+    switch (args->count())
+    {
+      case 0:
+        if( !first || !isSessionRestored()) {
+          openWindow(KUrl());
+        }
+        break;
+      case 1:
+        openWindow(args->url(0));
+        break;
+      case 2:
+        openWindow(args->url(0),args->url(1));
+        break;
+       default:
+          for (int i = 0; i < args->count(); ++i) {
             openWindow(args->url(i));
         }
-    } else if( !first || !isSessionRestored()) {
-        openWindow(KUrl());
-    }
+    } 
     first = false;
-
     args->clear();
-
     return 0;
 }
 
@@ -100,4 +109,19 @@
     return win->getId();
 }
 
+int DolphinApplication::openWindow(const KUrl& url,const KUrl& url2)
+{
+    DolphinMainWindow* win = createMainWindow();
+    if ((win->activeViewContainer() != 0) && url.isValid()){
+        win->activeViewContainer()->setUrl(url);
+    }
+    win->toggleSplitView();
+    if ((win->activeViewContainer() != 0) && url2.isValid()){
+      win->activeViewContainer()->setUrl(url2);
+    }
+    win->show();
+    return win->getId();
+}
+
+
 #include "dolphinapplication.moc"


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic