]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/main.cpp
Allow zooming in and zooming out in the icons view.
[dolphin.git] / src / main.cpp
index eacff0cba5f97262b4039bf0be7bc9d7fbe1a95c..9de7b609a4accd9c560eec9c0de94c6835283c81 100644 (file)
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#include "dolphin.h"
-#include <kapplication.h>
+#include "dolphinapplication.h"
+#include "dolphinmainwindow.h"
 #include <kaboutdata.h>
 #include <kcmdlineargs.h>
 #include <klocale.h>
 #include <krun.h>
+#include <QDBusInterface>
+#include <QDBusReply>
 
 static KCmdLineOptions options[] =
 {
@@ -31,6 +33,18 @@ static KCmdLineOptions options[] =
     KCmdLineLastOption
 };
 
+void openWindow(DolphinApplication* app, const QString& url = QString())
+{
+    if (app != 0) {
+        app->openWindow(url);
+        return;
+    }
+
+    static QDBusInterface dbusIface("org.kde.dolphin", "/dolphin/Application", "",
+                                    QDBusConnection::connectToBus(QDBusConnection::SessionBus, "session_bus"));
+    QDBusReply<int> reply = dbusIface.call("openWindow", url);
+}
+
 int main(int argc, char **argv)
 {
     KAboutData about("dolphin",
@@ -53,12 +67,14 @@ int main(int argc, char **argv)
 
     KCmdLineArgs::init(argc, argv, &about);
     KCmdLineArgs::addCmdLineOptions(options);
+    DolphinApplication *app = 0;
+    if (DolphinApplication::start()) {
+        app = new DolphinApplication();
+    }
 
-    KApplication app;
-
-    Dolphin& mainWin = Dolphin::mainWin();
-    mainWin.show();
 
+#warning TODO, SessionManagement
+#if 0
     if (false /* KDE4-TODO: app.isSessionRestored() */) {
         int n = 1;
         while (KMainWindow::canBeRestored(n)){
@@ -66,16 +82,19 @@ int main(int argc, char **argv)
             ++n;
         }
     } else {
-        KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
-        if (args->count() > 0) {
-            mainWin.activeView()->setUrl(args->url(0));
+#endif
 
-            for (int i = 1; i < args->count(); ++i) {
-                KRun::run("dolphin", args->url(i));
-            }
+    KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
+    if (args->count() > 0) {
+        for (int i = 0; i < args->count(); ++i) {
+            openWindow(app, args->arg(i));
         }
-        args->clear();
     }
-
-    return app.exec();
+    else {
+        openWindow(app);
+    }
+    args->clear();
+    if (app != 0) {
+        return app->exec();
+    }
 }