┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-02-18 17:01:36 +0000
committerPeter Penz <[email protected]>2007-02-18 17:01:36 +0000
commitabf17941f7a052d25788d2f2f3c84e5aae935e29 (patch)
tree4f89cd4d58b0b6033cc91f2eb14c02291f8c3a1c /src/main.cpp
parentfd43139134da394e413c5d7d5518275379e67798 (diff)
Dolphin is now a KUniqueApplication. A lot of thanks go to Oscar Blumberg, who submitted this patch.
svn path=/trunk/KDE/kdebase/apps/; revision=634862
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp45
1 files changed, 30 insertions, 15 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f5a51ee30..9de7b609a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -24,6 +24,8 @@
#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,8 +67,10 @@ int main(int argc, char **argv)
KCmdLineArgs::init(argc, argv, &about);
KCmdLineArgs::addCmdLineOptions(options);
-
- DolphinApplication app;
+ DolphinApplication *app = 0;
+ if (DolphinApplication::start()) {
+ app = new DolphinApplication();
+ }
#warning TODO, SessionManagement
@@ -68,18 +84,17 @@ int main(int argc, char **argv)
} else {
#endif
- KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
- if (args->count() > 0) {
- for (int i = 0; i < args->count(); ++i) {
- DolphinMainWindow *win = app.createMainWindow();
- win->activeView()->setUrl(args->url(i));
- win->show();
- }
- } else {
- DolphinMainWindow* mainWin = app.createMainWindow();
- mainWin->show();
+ 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();
+ }
}