summaryrefslogtreecommitdiff
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
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!!
-rw-r--r--src/application.cpp62
-rw-r--r--src/main.cpp5
-rw-r--r--src/rekonq.kcfg3
-rw-r--r--src/settings_general.ui7
4 files changed, 33 insertions, 44 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;
}
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 @@
<entry name="openTabNoWindow" type="Bool">
<default>true</default>
</entry>
- <entry name="externalUrlNewTab" type="Bool">
- <default>true</default>
- </entry>
<entry name="alwaysShowTabBar" type="Bool">
<default>true</default>
</entry>
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
@@ -119,13 +119,6 @@
</widget>
</item>
<item>
- <widget class="QCheckBox" name="kcfg_externalUrlNewTab">
- <property name="text">
- <string>Open external URLs as new tab in existing window</string>
- </property>
- </widget>
- </item>
- <item>
<widget class="QCheckBox" name="kcfg_alwaysShowTabBar">
<property name="text">
<string>Always show tab bar</string>