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 ++++++++++++++++++++++++++----------------------- src/main.cpp | 5 ---- src/rekonq.kcfg | 3 --- src/settings_general.ui | 7 ------ 4 files changed, 33 insertions(+), 44 deletions(-) (limited to 'src') 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; } diff --git a/src/main.cpp b/src/main.cpp index 01054fc3..4518d8cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -129,10 +129,5 @@ int main(int argc, char **argv) Application app; - if( app.isSessionRestored() ) - { - Application::sessionManager()->restoreSession(); - } - return app.exec(); } diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 3de675f8..1a190fff 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -37,9 +37,6 @@ true - - true - true diff --git a/src/settings_general.ui b/src/settings_general.ui index 6de49e64..66f9e7e9 100644 --- a/src/settings_general.ui +++ b/src/settings_general.ui @@ -118,13 +118,6 @@ - - - - Open external URLs as new tab in existing window - - - -- cgit v1.2.1