summaryrefslogtreecommitdiff
path: root/src/application.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-09-20 01:21:19 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-09-20 01:21:19 +0200
commitecd2a52034f4b3a64a17dfd6e33a05683076efa6 (patch)
treef809f1430bf823a9d5e0f56a61675bbe3d165bed /src/application.cpp
parentopen a new tab on double click on empty tab area (diff)
downloadrekonq-ecd2a52034f4b3a64a17dfd6e33a05683076efa6.tar.xz
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!!
Diffstat (limited to 'src/application.cpp')
-rw-r--r--src/application.cpp62
1 files changed, 33 insertions, 29 deletions
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 <KUriFilter>
#include <KMessageBox>
#include <KProtocolInfo>
+#include <KWindowInfo>
// Qt Includes
#include <QRegExp>
@@ -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;
}