From ecd2a52034f4b3a64a17dfd6e33a05683076efa6 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 20 Sep 2009 01:21:19 +0200 Subject: Applied (and refactored) patch from Matgic78 about smart opening of external links. rekonq now behaves as discussed (no settings required). So, it opens links in a window in the current desktop Every other behaviour... is a bug!! --- src/application.cpp | 62 ++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'src/application.cpp') diff --git a/src/application.cpp b/src/application.cpp index 4c819aba..ffde7203 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -52,6 +52,7 @@ #include #include #include +#include // Qt Includes #include @@ -87,43 +88,46 @@ int Application::newInstance() KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); + // is your app session restored? restore session... + if (isSessionRestored()) + { + sessionManager()->restoreSession(); + return 0; + } + if (args->count() > 0) { - // opening links in new tabs in ONE window - if(ReKonfig::externalUrlNewTab()) - { - // creating 1st new window - newMainWindow(); - loadUrl(args->arg(0)); - - for (int i = 1; i < args->count(); ++i) - { - loadUrl(args->arg(i), Rekonq::NewCurrentTab); - } - args->clear(); - - } - else + // is there a window open on the current desktop ? use it! + for (int i = 0; i < m_mainWindows.size(); ++i) { - // opening ONE window for each URL - for (int i = 0; i < args->count(); ++i) + MainWindow *m = m_mainWindows.at(i); + KWindowInfo w = KWindowInfo(m->winId(), NET::WMDesktop); + if(w.isOnCurrentDesktop()) { - loadUrl(args->arg(i), Rekonq::NewWindow); + m->activateWindow(); + m->raise(); + + for (int i = 0; i < args->count(); ++i) + loadUrl(args->arg(i), Rekonq::NewCurrentTab); + + return 1; } - args->clear(); - } - } - else - { - if(!isSessionRestored()) - { - // creating new window - MainWindow *w = newMainWindow(); - w->slotHome(); } + + // No windows in the current desktop? No windows at all? + // Create a new one and load there sites... + loadUrl(args->arg(0), Rekonq::NewWindow); + for (int i = 1; i < args->count(); ++i) + loadUrl(args->arg(i), Rekonq::SettingOpenTab); + + return 2; } + + // creating new window + MainWindow *w = newMainWindow(); + w->slotHome(); - return 0; + return 3; } -- cgit v1.2.1