summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-11-10 14:47:39 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-11-10 14:47:39 +0100
commitc7fa09a7b96e239ff6e7349c9d90e7409d7bbcb3 (patch)
tree9715e1f86daba6e14ec74625ae10cd85c23b2359 /src
parentSafer Application::mainWindow() call. No 0 return.. (diff)
downloadrekonq-c7fa09a7b96e239ff6e7349c9d90e7409d7bbcb3.tar.xz
fixing new mainWindow() behaviour, porting functions calling it
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp33
-rw-r--r--src/homepage.cpp3
-rw-r--r--src/homepage.h10
-rw-r--r--src/mainview.cpp30
-rw-r--r--src/mainview.h9
-rw-r--r--src/mainwindow.cpp12
-rw-r--r--src/mainwindow.h7
-rw-r--r--src/tabbar.h2
8 files changed, 47 insertions, 59 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 8e870764..d29bcc78 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -94,31 +94,28 @@ int Application::newInstance()
if(args->count() == 0)
{
- MainWindow *w = 0;
if(first) // we are starting rekonq, for the first time with no args: use startup behaviour
{
switch(ReKonfig::startupBehaviour())
{
case 0: // open home page
- w = newMainWindow();
- w->slotHome();
+ mainWindow()->homePage();
break;
case 1: // open new tab page
- w = newMainWindow();
- w->homePage();
+ kDebug() << "newInstance";
+ mainWindow()->newTabPage();
break;
case 2: // restore session
if(sessionManager()->restoreSession())
break;
default:
- w = newMainWindow();
- w->slotHome();
+ mainWindow()->homePage();
break;
}
}
else // rekonq has just been started. Just open a new window
{
- w = newMainWindow();
+ newMainWindow();
}
}
@@ -348,8 +345,8 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
}
// loading home pages
- kDebug() << "here..";
- if (mainWindow()->homePage(url))
+ kDebug() << "loadUrl loading " << url;
+ if (mainWindow()->newTabPage(url))
return;
if (url.scheme() == QLatin1String("mailto"))
@@ -360,17 +357,8 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
// first, create the webview(s) to not let hangs UI..
WebView *webView = 0;
- MainWindow *w = 0;
-
- if(type == Rekonq::NewWindow)
- {
- w = newMainWindow();
- }
- else
- {
- w = mainWindow();
- }
-
+ MainWindow *w = mainWindow();
+
switch(type)
{
case Rekonq::SettingOpenTab:
@@ -419,7 +407,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
// are considered as executables
if (KUriFilter::self()->filterUri(data))
{
- loadingUrl = data.uri().url();
+ loadingUrl = data.uri().url();
}
// ------------------- END WARNING --------------------------------------
@@ -445,6 +433,7 @@ void Application::loadUrl(const QString& urlString, const Rekonq::OpenType& typ
MainWindow *Application::newMainWindow()
{
MainWindow *w = new MainWindow();
+ kDebug() << "newMainWindow";
w->mainView()->newWebView(); // remember using newWebView and NOT newTab here!!
m_mainWindows.prepend(w);
diff --git a/src/homepage.cpp b/src/homepage.cpp
index 27d613ce..5c34bcd7 100644
--- a/src/homepage.cpp
+++ b/src/homepage.cpp
@@ -49,8 +49,7 @@
#include <QFile>
-HomePage::HomePage(QObject *parent)
- : QObject(parent)
+HomePage::HomePage()
{
m_homePagePath = KStandardDirs::locate("data", "rekonq/htmls/home.html");
}
diff --git a/src/homepage.h b/src/homepage.h
index 7963119c..abc28de0 100644
--- a/src/homepage.h
+++ b/src/homepage.h
@@ -39,18 +39,18 @@
class KBookmark;
-class HomePage : public QObject
+class HomePage
{
-Q_OBJECT
public:
- HomePage(QObject *parent = 0);
+ HomePage();
~HomePage();
QString rekonqHomePage(const KUrl &url = KUrl("rekonq:home"));
- QString homePageMenu(KUrl currentUrl);
-
+
private:
+ QString homePageMenu(KUrl currentUrl);
+
QString fillFavorites();
QString lastVisitedSites();
QString fillHistory();
diff --git a/src/mainview.cpp b/src/mainview.cpp
index c4b0cfc2..10007140 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -36,7 +36,6 @@
// Local Includes
#include "tabbar.h"
#include "application.h"
-#include "mainwindow.h"
#include "history.h"
#include "urlbar.h"
#include "webview.h"
@@ -64,12 +63,13 @@
#include <QtGui/QWidget>
-MainView::MainView(QWidget *parent)
+MainView::MainView(MainWindow *parent)
: KTabWidget(parent)
, m_urlBar(new UrlBar(this))
, m_tabBar(new TabBar(this))
, m_addTabButton(new QToolButton(this))
, m_currentTabIndex(0)
+ , m_parentWindow(parent)
{
// setting tabbar
setTabBar(m_tabBar);
@@ -109,17 +109,8 @@ void MainView::postLaunch()
// Session Manager
connect (this, SIGNAL(tabsChanged()), Application::sessionManager(), SLOT(saveSession()));
- // Find the correct MainWindow of this tab button
- MainWindowList list = Application::instance()->mainWindowList();
- Q_FOREACH(QPointer<MainWindow> w, list)
- {
- if (w->isAncestorOf(this))
- {
- m_addTabButton->setDefaultAction(w->actionByName("new_tab"));
- break;
- }
- }
-
+ m_addTabButton->setDefaultAction(m_parentWindow->actionByName("new_tab"));
+
m_addTabButton->setAutoRaise(true);
m_addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
}
@@ -356,6 +347,7 @@ WebView *MainView::newWebView(bool focused, bool nearParent)
else
addTab(webView, i18n("(Untitled)"));
+ kDebug() << "newWebView";
updateTabBar();
if (focused)
@@ -375,13 +367,14 @@ void MainView::newTab()
switch(ReKonfig::newTabsBehaviour())
{
- case 0:
- if(Application::instance()->mainWindow()->homePage())
+ case 0: // new tab page
+ kDebug() << "newTab";
+ if(m_parentWindow->newTabPage())
break;
- case 1:
+ case 1: // blank page
urlBar()->setUrl(KUrl(""));
break;
- case 2:
+ case 2: // homepage
w->load( QUrl(ReKonfig::homePage()) );
break;
default:
@@ -414,7 +407,7 @@ void MainView::windowCloseRequested()
{
if (count() == 1)
{
- Application::instance()->mainWindow()->close();
+ m_parentWindow->close();
}
else
{
@@ -669,6 +662,7 @@ QList<HistoryItem> MainView::recentlyClosedTabs()
void MainView::resizeEvent(QResizeEvent *event)
{
+ kDebug() << "resizeEvent";
updateTabBar();
KTabWidget::resizeEvent(event);
}
diff --git a/src/mainview.h b/src/mainview.h
index dc0393fa..3ddd9e24 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -36,6 +36,7 @@
#include "webpage.h"
#include "application.h"
#include "history.h"
+#include "mainwindow.h"
// KDE Includes
#include <KTabWidget>
@@ -54,8 +55,8 @@ class UrlBar;
/**
- * This class represent rekonq Main View. It contains all WebViews and a stack widget
- * of associated line edits.
+ * This class represent rekonq Main View.
+ * It contains all WebViews and the url bar.
*
*/
@@ -64,7 +65,7 @@ class REKONQ_TESTS_EXPORT MainView : public KTabWidget
Q_OBJECT
public:
- MainView(QWidget *parent = 0);
+ MainView(MainWindow *parent);
~MainView();
public:
@@ -174,6 +175,8 @@ private:
int m_currentTabIndex;
QList<HistoryItem> m_recentlyClosedTabs;
+
+ MainWindow *m_parentWindow;
};
#endif // MAINVIEW_H
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 194b141a..4d9cc89d 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -276,7 +276,7 @@ void MainWindow::setupActions()
shortcutFullScreenList << KStandardShortcut::fullScreen() << QKeySequence( Qt::Key_F11 );
a->setShortcuts( shortcutFullScreenList );
- KStandardAction::home(this, SLOT(slotHome()), actionCollection());
+ KStandardAction::home(this, SLOT(homePage()), actionCollection());
KStandardAction::preferences(this, SLOT(slotPreferences()), actionCollection());
a = KStandardAction::redisplay(m_view, SLOT(slotWebReload()), actionCollection());
@@ -462,6 +462,7 @@ void MainWindow::setupSidePanel()
void MainWindow::slotUpdateConfiguration()
{
// ============== General ==================
+ kDebug() << "update conf";
m_view->updateTabBar();
// =========== Fonts ==============
@@ -782,7 +783,7 @@ void MainWindow::slotViewPageSource()
}
-void MainWindow::slotHome()
+void MainWindow::homePage()
{
currentTab()->load( QUrl(ReKonfig::homePage()) );
}
@@ -1116,7 +1117,7 @@ void MainWindow::slotOpenActionUrl(QAction *action)
}
-bool MainWindow::homePage(const KUrl &url)
+bool MainWindow::newTabPage(const KUrl &url)
{
if ( url == KUrl("rekonq:closedTabs")
|| url == KUrl("rekonq:history")
@@ -1127,8 +1128,9 @@ bool MainWindow::homePage(const KUrl &url)
{
kDebug() << "loading home: " << url;
WebView *w = currentTab();
- HomePage p(w);
- w->setHtml( p.rekonqHomePage(url), url);
+ HomePage p;
+ QString html = p.rekonqHomePage(url);
+ w->setHtml(html, url);
return true;
}
return false;
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 50c3e7dc..02302aca 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -32,7 +32,7 @@
// Local Includes
#include "bookmarks.h"
-#include "mainview.h"
+// #include "mainview.h"
#include "webview.h"
// KDE Includes
@@ -49,6 +49,7 @@ class KPassivePopup;
class FindBar;
class SidePanel;
class WebView;
+class MainView;
/**
@@ -70,7 +71,7 @@ public:
virtual QSize sizeHint() const;
virtual KActionCollection *actionCollection () const;
- bool homePage(const KUrl &url = KUrl("rekonq:home"));
+ bool newTabPage(const KUrl &url = KUrl("rekonq:home"));
private:
void setupActions();
@@ -82,7 +83,7 @@ private:
public slots:
void slotUpdateBrowser();
- void slotHome();
+ void homePage();
/**
* Notifies a message in a popup
diff --git a/src/tabbar.h b/src/tabbar.h
index fcb04d28..e70c7914 100644
--- a/src/tabbar.h
+++ b/src/tabbar.h
@@ -59,7 +59,7 @@ class REKONQ_TESTS_EXPORT TabBar : public KTabBar
Q_OBJECT
public:
- TabBar(MainView *parent = 0);
+ TabBar(MainView *parent);
~TabBar();
void showTabPreview(int tab);