diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/application.cpp | 20 | ||||
-rw-r--r-- | src/application.h | 20 | ||||
-rw-r--r-- | src/bookmarks.cpp | 44 | ||||
-rw-r--r-- | src/bookmarks.h | 49 | ||||
-rw-r--r-- | src/main.cpp | 18 | ||||
-rw-r--r-- | src/mainview.cpp | 107 | ||||
-rw-r--r-- | src/mainview.h | 27 | ||||
-rw-r--r-- | src/mainwindow.cpp | 43 | ||||
-rw-r--r-- | src/mainwindow.h | 1 | ||||
-rw-r--r-- | src/panelhistory.cpp | 6 | ||||
-rw-r--r-- | src/panelhistory.h | 4 | ||||
-rw-r--r-- | src/sidepanel.cpp | 9 | ||||
-rw-r--r-- | src/sidepanel.h | 10 | ||||
-rw-r--r-- | src/tabbar.cpp | 25 | ||||
-rw-r--r-- | src/tabbar.h | 6 | ||||
-rw-r--r-- | src/webview.cpp | 24 |
16 files changed, 240 insertions, 173 deletions
diff --git a/src/application.cpp b/src/application.cpp index eee803bc..25b328e6 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -79,12 +79,12 @@ int Application::newInstance() if (!m_mainWindow) { m_mainWindow = new MainWindow(); - + m_mainWindow->setObjectName("MainWindow"); setWindowIcon(KIcon("rekonq")); - + m_mainWindow->show(); - + QTimer::singleShot(0, this, SLOT(postLaunch())); } @@ -94,7 +94,7 @@ int Application::newInstance() { KUrl url = MainWindow::guessUrlFromString(args->arg(i)); newWebView(); - mainWindow()->loadUrl(url); + emit openUrl(url); } args->clear(); } @@ -135,21 +135,15 @@ void Application::slotSaveConfiguration() const } -void Application::openUrl(const KUrl &url) -{ - mainWindow()->loadUrl(url); -} - - MainWindow *Application::mainWindow() { return m_mainWindow; } -WebView *Application::newWebView() +WebView *Application::newWebView(bool makeCurrent) { - return m_mainWindow->mainView()->newWebView(); + return m_mainWindow->mainView()->newWebView(makeCurrent); } @@ -183,7 +177,7 @@ HistoryManager *Application::historyManager() DownloadManager *Application::downloadManager() { - if (!s_downloadManager) + if (!s_downloadManager) { s_downloadManager = new DownloadManager(); } diff --git a/src/application.h b/src/application.h index 98b213a3..dfcfab62 100644 --- a/src/application.h +++ b/src/application.h @@ -47,6 +47,18 @@ class MainWindow; class NetworkAccessManager; class WebView; +namespace Rekonq { + /** + * @short Open link options + * Defferent modes of opening new tab + */ + enum OpenType { + Default, ///< open url according to users settings + Current, ///< open url in current tab + New, ///< open url in new tab and make it current + Background ///< open url in new tab in background + }; +} /** * @@ -62,7 +74,7 @@ public: static Application *instance(); MainWindow *mainWindow(); - WebView* newWebView(); + WebView* newWebView(bool makeCurrent = true); KIcon icon(const KUrl &url) const; @@ -72,13 +84,16 @@ public: static DownloadManager *downloadManager(); static BookmarkProvider *bookmarkProvider(); +signals: + void openUrl(const KUrl &url, Rekonq::OpenType type=Rekonq::Current); + public slots: /** * Save application's configuration * @see ReKonfig::self()->writeConfig(); */ void slotSaveConfiguration() const; - + private slots: @@ -86,7 +101,6 @@ private slots: * Any actions that can be delayed until the window is visible */ void postLaunch(); - void openUrl(const KUrl &url); private: static QPointer<HistoryManager> s_historyManager; diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 568759a8..70afc29e 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -27,7 +27,6 @@ // Local Includes #include "mainwindow.h" #include "webview.h" -#include "application.h" // KDE Includes #include <KActionCollection> @@ -55,14 +54,14 @@ BookmarkOwner::BookmarkOwner(QObject *parent) } -void BookmarkOwner::openBookmark(const KBookmark & bookmark, - Qt::MouseButtons mouseButtons, +void BookmarkOwner::openBookmark(const KBookmark &bookmark, + Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers) { - Q_UNUSED(mouseButtons) + Q_UNUSED(mouseButtons) Q_UNUSED(keyboardModifiers) - emit openUrl(bookmark.url()); + emit openUrl(bookmark.url(), Rekonq::Current); } @@ -78,6 +77,15 @@ QString BookmarkOwner::currentTitle() const } +void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bm) +{ + QList<KUrl> urlList = bm.groupUrlList(); + //kDebug() << urlList; + QList<KUrl>::iterator url; + for(url = urlList.begin(); url != urlList.end(); ++url) + emit openUrl(*url, Rekonq::Background); +} + // ------------------------------------------------------------------------------------------------------ @@ -85,11 +93,10 @@ BookmarkMenu::BookmarkMenu(KBookmarkManager *manager, KBookmarkOwner *owner, KMenu *menu, KActionCollection* actionCollection) - : KBookmarkMenu(manager, owner, menu, actionCollection) - + : KBookmarkMenu(manager, owner, menu, actionCollection) { actionCollection->addAction(KStandardAction::AddBookmark, - QLatin1String("add_bookmark_payload"), + QLatin1String("add_bookmark_payload"), this, SLOT(slotAddBookmark())); } @@ -98,7 +105,7 @@ BookmarkMenu::~BookmarkMenu() { } - + KMenu *BookmarkMenu::viewContextMenu(QAction *action) { return contextMenu(action); @@ -116,7 +123,7 @@ void BookmarkMenu::slotAddBookmark() manager()->emitChanged(); return; } - + KBookmarkMenu::slotAddBookmark(); } @@ -151,12 +158,13 @@ BookmarkProvider::BookmarkProvider(QWidget *parent) } } m_manager = KBookmarkManager::managerForExternalFile(bookfile.path()); - connect(m_manager, SIGNAL(changed(const QString &, const QString &)), + connect(m_manager, SIGNAL(changed(const QString &, const QString &)), this, SLOT(slotBookmarksChanged(const QString &, const QString &))); // setup menu m_owner = new BookmarkOwner(this); - connect(m_owner, SIGNAL(openUrl(const KUrl& )), this, SIGNAL(openUrl(const KUrl& ))); + connect(m_owner, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType)), + this, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType))); m_bookmarkMenu = new BookmarkMenu(m_manager, m_owner, m_menu, m_actionCollection); // setup toolbar @@ -184,9 +192,9 @@ void BookmarkProvider::setupToolBar() m_bookmarkToolBar->setContentsMargins(0, 0, 0, 0); m_bookmarkToolBar->setMinimumHeight(16); m_bookmarkToolBar->setContextMenuPolicy(Qt::CustomContextMenu); - connect(m_bookmarkToolBar, SIGNAL(customContextMenuRequested(const QPoint &)), + connect(m_bookmarkToolBar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); - + slotBookmarksChanged("", ""); } @@ -201,13 +209,13 @@ void BookmarkProvider::slotBookmarksChanged(const QString &group, const QString kWarning() << "There is no bookmark toolbar"; return; } - + KActionCollection bookmarkCollection(this); - + KBookmarkGroup toolBarGroup = m_manager->toolbar(); if (toolBarGroup.isNull()) return; - + KBookmark bookmark = toolBarGroup.first(); while (!bookmark.isNull()) { if (!bookmark.isGroup()) @@ -224,7 +232,7 @@ void BookmarkProvider::slotBookmarksChanged(const QString &group, const QString QAction *BookmarkProvider::actionByName(const QString &name) -{ +{ QAction *action = m_actionCollection->action(name); if (action) return action; diff --git a/src/bookmarks.h b/src/bookmarks.h index 5ac1270d..32982c8a 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -23,6 +23,9 @@ #ifndef BOOKMARKS_H #define BOOKMARKS_H +// Local includes +#include "application.h" + // Qt Includes #include <QWidget> @@ -69,8 +72,8 @@ public: * @param mouseButtons the mouse buttons clicked to select the bookmark * @param keyboardModifiers the keyboard modifiers pushed when the bookmark was selected */ - virtual void openBookmark(const KBookmark &bookmark, - Qt::MouseButtons mouseButtons, + virtual void openBookmark(const KBookmark &bookmark, + Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers); @@ -95,14 +98,23 @@ public: */ virtual bool supportsTabs() const { return true; } + /** + * Called if the user wants to open every bookmark in this folder in a new tab. + * The default implementation does nothing. + * This is only called if supportsTabs() returns true + */ + virtual void openFolderinTabs(const KBookmarkGroup &bm); + signals: /** * This signal is emitted when an url has to be loaded * * @param url the URL to load + * @param type type of load + * @see Application::OpenType * */ - void openUrl(const KUrl &); + void openUrl(const KUrl &url, Rekonq::OpenType type); private: @@ -124,17 +136,17 @@ class BookmarkMenu : public KBookmarkMenu Q_OBJECT public: - BookmarkMenu(KBookmarkManager* manager, - KBookmarkOwner* owner, - KMenu* menu, + BookmarkMenu(KBookmarkManager* manager, + KBookmarkOwner* owner, + KMenu* menu, KActionCollection* actionCollection); ~BookmarkMenu(); - + virtual KMenu *viewContextMenu(QAction* action); - + protected slots: void slotAddBookmark(); - + }; @@ -163,7 +175,7 @@ public: */ BookmarkProvider(QWidget* parent=0); ~BookmarkProvider(); - + /** * @short Get the Bookmarks Menu Action * @return the Bookmarks Menu @@ -189,11 +201,14 @@ public: signals: /** - * @short This signal is emitted when an url has to be loaded - * - * @param url the URL to load - */ - void openUrl(const KUrl &url); + * This signal is emitted when an url has to be loaded + * + * @param url the URL to load + * @param type type of load + * @see Application::OpenType + * + */ + void openUrl(const KUrl &url, Rekonq::OpenType type); public slots: @@ -202,12 +217,12 @@ public slots: * @param point Point on whitch you want to open this menu */ void contextMenu(const QPoint &point); - + /** * @short Waits for signal that the group with the address has been modified by the caller. * Waits for signal that the group (or any of its children) with the address * @p groupAddress (e.g. "/4/5") has been modified by the caller @p caller. - * + * * @param group bookmark group adress * @param caller caller that modified the bookmarks * @see KBookmarkManager::changed diff --git a/src/main.cpp b/src/main.cpp index d5e7c33b..ea7ab8a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,14 +47,18 @@ int main(int argc, char **argv) ); // about authors - about.addAuthor(ki18n("Andrea Diamantini"), - ki18n("Project Lead, Developer, Italian translations"), - "adjam7@gmail.com", + about.addAuthor(ki18n("Andrea Diamantini"), + ki18n("Project Lead, Developer, Italian translations"), + "adjam7@gmail.com", "http://www.adjam.org"); - -// about.addAuthor(ki18n("your name"), -// ki18n("your role"), -// "your mail", + about.addAuthor(ki18n("Domrachev Alexandr"), + ki18n("Developer, Russian translations"), + "alexandr.domrachev@gmail.com", + ""); + +// about.addAuthor(ki18n("your name"), +// ki18n("your role"), +// "your mail", // "your site"); // Initialize command line args diff --git a/src/mainview.cpp b/src/mainview.cpp index 865ffab2..c3818b50 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -65,7 +65,6 @@ MainView::MainView(QWidget *parent) m_loadingGitPath = KStandardDirs::locate("appdata" , "pics/loading.gif"); - connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newWebView())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(slotCloseTab(int))); connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(slotCloneTab(int))); connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(slotCloseOtherTabs(int))); @@ -81,9 +80,14 @@ MainView::MainView(QWidget *parent) m_recentlyClosedTabsAction->setEnabled(false); // -- - connect(this, SIGNAL(loadUrlPage(const KUrl &)), this, SLOT(loadUrlInCurrentTab(const KUrl &))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); + connect(Application::instance(), SIGNAL(openUrl(const KUrl &, Rekonq::OpenType)), + this, SLOT(openUrl(const KUrl &, Rekonq::OpenType))); + // bookmarks loading + connect(Application::bookmarkProvider(), SIGNAL(openUrl(const KUrl &, Rekonq::OpenType)), + this, SLOT(openUrl(const KUrl &, Rekonq::OpenType))); + setTabsClosable(true); connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(slotCloseTab(int))); } @@ -214,6 +218,29 @@ void MainView::clear() } +void MainView::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (!childAt(event->pos()) + // Remove the line below when QTabWidget does not have a one pixel frame + && event->pos().y() < (tabBar()->y() + tabBar()->height())) + { + newWebView(true); + return; + } + KTabWidget::mouseDoubleClickEvent(event); +} + + +void MainView::contextMenuEvent(QContextMenuEvent *event) +{ + if (!childAt(event->pos())) + { + m_tabBar->contextMenuRequested(event->pos()); + return; + } + KTabWidget::contextMenuEvent(event); +} + // When index is -1 index chooses the current tab void MainView::slotReloadTab(int index) { @@ -239,16 +266,18 @@ void MainView::slotCurrentChanged(int index) WebView *oldWebView = this->webView(m_urlBars->currentIndex()); if (oldWebView) { - disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), + disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); - disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), + disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); - disconnect(oldWebView, SIGNAL(loadProgress(int)), + disconnect(oldWebView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); } - connect(webView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); - connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); + connect(webView, SIGNAL(statusBarMessage(const QString &)), + this, SIGNAL(showStatusBarMessage(const QString &))); + connect(webView->page(), SIGNAL(linkHovered(const QString &, const QString &, const QString &)), + this, SIGNAL(linkHovered(const QString &))); connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); emit setCurrentTitle(webView->title()); @@ -294,17 +323,17 @@ WebView *MainView::newWebView(bool makeCurrent) { // line edit UrlBar *urlBar = new UrlBar; // Ownership of widget is passed on to the QStackedWidget (addWidget method). - connect(urlBar, SIGNAL(activated(const KUrl&)), this, SLOT(loadUrlInCurrentTab(const KUrl&))); + connect(urlBar, SIGNAL(activated(const KUrl &)), this, SLOT(openUrl(const KUrl &))); m_urlBars->addUrlBar(urlBar); WebView *webView = new WebView; // should be deleted on tab close - + // connecting webview with urlbar connect(webView, SIGNAL(loadProgress(int)), urlBar, SLOT(slotUpdateProgress(int))); connect(webView, SIGNAL(loadFinished(bool)), urlBar, SLOT(slotLoadFinished(bool))); connect(webView, SIGNAL(urlChanged(const QUrl &)), urlBar, SLOT(setUrl(const QUrl &))); connect(webView, SIGNAL(iconChanged()), urlBar, SLOT(slotUpdateUrl())); - + // connecting webview with mainview connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted())); connect(webView, SIGNAL(loadProgress(int)), this, SLOT(webViewLoadProgress(int))); @@ -317,17 +346,17 @@ WebView *MainView::newWebView(bool makeCurrent) connect(webView, SIGNAL(shiftCtrlTabPressed()), this, SLOT(previousTab())); // connecting webPage signals with mainview - connect(webView->page(), SIGNAL(windowCloseRequested()), + connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); - connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), + connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), this, SIGNAL(geometryChangeRequested(const QRect &))); connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *))); - connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), + connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SIGNAL(menuBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), + connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), + connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); addTab(webView, i18n("(Untitled)")); @@ -507,9 +536,9 @@ void MainView::webViewLoadProgress(int progress) { return; } - + double totalBytes = static_cast<double>(webView->webPage()->totalBytes() / 1024); - + QString message = i18n("Loading %1% (%2 %3)...", progress, totalBytes, QLatin1String("kB") ); emit showStatusBarMessage(message); } @@ -519,7 +548,7 @@ void MainView::webViewLoadFinished(bool ok) { WebView *webView = qobject_cast<WebView*>(sender()); int index = webViewIndex(webView); - + if (-1 != index) { QLabel *label = animatedLoading(index, true); @@ -527,7 +556,7 @@ void MainView::webViewLoadFinished(bool ok) if(movie) movie->stop(); } - + webViewIconChanged(); // don't display messages for background tabs @@ -535,7 +564,7 @@ void MainView::webViewLoadFinished(bool ok) { return; } - + if (ok) emit showStatusBarMessage(i18n("Done")); else @@ -610,21 +639,45 @@ void MainView::aboutToShowRecentTabsMenu() void MainView::aboutToShowRecentTriggeredAction(QAction *action) { KUrl url = action->data().toUrl(); - loadUrlInCurrentTab(url); + openUrl(url, Rekonq::Current); } -void MainView::loadUrlInCurrentTab(const KUrl &url) +void MainView::openUrl(const KUrl& url, Rekonq::OpenType type) { - WebView *webView = currentWebView(); - if (webView) + kDebug() << "sender:" << sender() << " line:" << __LINE__; + + if (url.isEmpty()) { - webView->loadUrl(url); - webView->setFocus(); + kWarning() << "Can't load an empty url; sender:" << sender() << "line: " << __LINE__; + return; } + + WebView *webView = NULL; + if (type == Rekonq::New) + webView = newWebView(true); + else if (type == Rekonq::Background) + webView = newWebView(false); + else + webView = currentWebView(); + + if (!webView) + { + kWarning() << "Can't find the view" << "line:" << __LINE__; + return; + } + webView->loadUrl(url); + webView->setFocus(); + + currentUrlBar()->setUrl(url.prettyUrl()); } +void MainView::loadUrlInCurrentTab(const KUrl &url) +{ + openUrl(url); +} + void MainView::nextTab() { int next = currentIndex() + 1; @@ -657,7 +710,7 @@ QLabel *MainView::animatedLoading(int index, bool addMovie) return 0; QLabel *label = qobject_cast<QLabel*>(m_tabBar->tabButton(index, QTabBar::LeftSide)); - if (!label) + if (!label) { label = new QLabel(this); } diff --git a/src/mainview.h b/src/mainview.h index facd865f..97b9fbad 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -26,6 +26,7 @@ // Local Includes #include "webview.h" +#include "application.h" // KDE Includes #include <KTabWidget> @@ -48,7 +49,7 @@ class UrlBar; /** - * This class represent rekonq Main View. It contains all WebViews and a stack widget + * This class represent rekonq Main View. It contains all WebViews and a stack widget * of associated line edits. * */ @@ -64,7 +65,6 @@ public: signals: // tab widget signals - void loadUrlPage(const KUrl &url); void tabsChanged(); void lastTabClosed(); @@ -73,7 +73,7 @@ signals: void showStatusBarMessage(const QString &message); void linkHovered(const QString &link); void loadProgress(int progress); - + void geometryChangeRequested(const QRect &geometry); void menuBarVisibilityChangeRequested(bool visible); void statusBarVisibilityChangeRequested(bool visible); @@ -82,19 +82,19 @@ signals: public: // void setupTabButtons(); - + UrlBar *urlBar(int index) const; UrlBar *currentUrlBar() const { return urlBar(-1); } WebView *webView(int index) const; QList<WebView *> tabs(); // ? - + // inlines TabBar *tabBar() const { return m_tabBar; } StackedUrlBar *urlBarStack() const { return m_urlBars; } WebView *currentWebView() const { return webView(currentIndex()); } int webViewIndex(WebView *webView) const { return indexOf(webView); } KAction *recentlyClosedTabsAction() const { return m_recentlyClosedTabsAction; } - + /** * show and hide TabBar if user doesn't choose * "Always Show TabBar" option @@ -103,6 +103,10 @@ public: void showTabBar(); void clear(); +protected: + virtual void mouseDoubleClickEvent(QMouseEvent *event); + virtual void contextMenuEvent(QContextMenuEvent *event); + public slots: /** * Core browser slot. This create a new tab with a WebView inside @@ -111,7 +115,6 @@ public slots: * @return a pointer to the new WebView */ WebView *newWebView(bool makeCurrent = true); - void loadUrlInCurrentTab(const KUrl &url); void slotCloneTab(int index = -1); void slotCloseTab(int index = -1); void slotCloseOtherTabs(int index); @@ -119,6 +122,7 @@ public slots: void slotReloadAllTabs(); void nextTab(); void previousTab(); + void openUrl(const KUrl& url, Rekonq::OpenType type=Rekonq::Current); // WEB slot actions void slotWebReload(); @@ -132,6 +136,7 @@ public slots: void slotWebPaste(); private slots: + KDE_DEPRECATED void loadUrlInCurrentTab(const KUrl &url); void slotCurrentChanged(int index); void aboutToShowRecentTabsMenu(); void aboutToShowRecentTriggeredAction(QAction *action); // need QAction! @@ -146,7 +151,7 @@ private slots: void windowCloseRequested(); /** - * This functions move tab informations "from index to index" + * This functions move tab informations "from index to index" * * @param fromIndex the index from which we move * @@ -157,12 +162,12 @@ private slots: private: /** - * This function creates (if not exists) and returns a QLabel + * This function creates (if not exists) and returns a QLabel * with a loading QMovie. - * Imported from Arora's code. + * Imported from Arora's code. * * @param index the tab index where inserting the animated label - * @param addMovie creates or not a loading movie + * @param addMovie creates or not a loading movie * * @return animated label's pointer */ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a9364ef1..5f112abd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -103,7 +103,6 @@ MainWindow::MainWindow() setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // --------- connect signals and slots - connect(m_view, SIGNAL(loadUrlPage(const KUrl &)), this, SLOT(loadUrl(const KUrl &))); connect(m_view, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); connect(m_view, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(geometryChangeRequested(const QRect &))); @@ -118,9 +117,6 @@ MainWindow::MainWindow() // update toolbar actions connect(m_view, SIGNAL(tabsChanged()), this, SLOT(slotUpdateActions())); connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(slotUpdateActions())); - - // bookmarks loading - connect(Application::bookmarkProvider(), SIGNAL(openUrl(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); slotUpdateWindowTitle(); @@ -184,7 +180,7 @@ void MainWindow::setupToolBars() a = new KAction(i18n("Search Bar"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_K)); a->setDefaultWidget(m_searchBar); - connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); + connect(m_searchBar, SIGNAL(search(const KUrl&)), m_view, SLOT(openUrl(const KUrl &))); actionCollection()->addAction(QLatin1String("search_bar"), a); // bookmarks bar @@ -311,11 +307,12 @@ void MainWindow::setupSidePanel() { // Setup history side panel m_sidePanel = new SidePanel(i18n("History"), this); - connect(m_sidePanel, SIGNAL(openUrl(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); + connect(m_sidePanel, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType)), + m_view, SLOT(openUrl(const KUrl &, Rekonq::OpenType))); connect(m_sidePanel, SIGNAL(destroyed()), Application::instance(), SLOT(slotSaveConfiguration())); - + addDockWidget(Qt::LeftDockWidgetArea, m_sidePanel); - + // setup side panel actions KAction* a = new KAction(this); a->setText(i18n("History")); @@ -323,7 +320,7 @@ void MainWindow::setupSidePanel() a->setChecked(ReKonfig::showSideBar()); a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_H)); actionCollection()->addAction(QLatin1String("show_history_panel"), a); - + // connect to toogle action connect(a, SIGNAL(triggered(bool)), m_sidePanel->toggleViewAction(), SLOT(trigger())); } @@ -332,7 +329,7 @@ void MainWindow::setupSidePanel() void MainWindow::setupHistoryMenu() { HistoryMenu *historyMenu = new HistoryMenu(this); - connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_view, SLOT(loadUrlInCurrentTab(const KUrl&))); + connect(historyMenu, SIGNAL(openUrl(const KUrl &)), m_view, SLOT(openUrl(const KUrl &))); connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); historyMenu->setTitle(i18n("&History")); @@ -454,16 +451,6 @@ KUrl MainWindow::guessUrlFromString(const QString &string) } -void MainWindow::loadUrl(const KUrl &url) -{ - if (!currentTab() || url.isEmpty()) - return; - - m_view->currentUrlBar()->setUrl(url.prettyUrl()); - m_view->loadUrlInCurrentTab(url); -} - - void MainWindow::slotOpenLocation() { m_view->currentUrlBar()->selectAll(); @@ -532,7 +519,7 @@ void MainWindow::slotFileOpen() if (filePath.isEmpty()) return; - loadUrl(guessUrlFromString(filePath)); + mainView()->openUrl(guessUrlFromString(filePath)); } @@ -693,7 +680,7 @@ void MainWindow::slotViewFullScreen(bool makeFullScreen) static bool bookmarksToolBarFlag; static bool statusBarFlag; static bool sidePanelFlag; - + if (makeFullScreen == true) { // save current state @@ -703,7 +690,7 @@ void MainWindow::slotViewFullScreen(bool makeFullScreen) bookmarksToolBarFlag = toolBar("bookmarksToolBar")->isHidden(); statusBarFlag = statusBar()->isHidden(); sidePanelFlag = sidePanel()->isHidden(); - + menuBar()->hide(); toolBar("mainToolBar")->hide(); toolBar("locationToolBar")->hide(); @@ -745,12 +732,12 @@ void MainWindow::slotViewPageSource() /// TODO: autochoose tempfile suffix sourceFile.setSuffix(QString(".html")); sourceFile.setAutoRemove(false); - + if (sourceFile.open()) { QDataStream stream(&sourceFile); stream << currentTab()->page()->mainFrame()->toHtml().toUtf8(); - + url = KUrl(); url.setPath(sourceFile.fileName()); isTempFile = true; @@ -762,7 +749,7 @@ void MainWindow::slotViewPageSource() void MainWindow::slotHome() { - loadUrl(KUrl(m_homePage)); + mainView()->openUrl(KUrl(m_homePage)); } @@ -896,7 +883,7 @@ bool MainWindow::queryClose() if (m_view->count() > 1) { - int answer = KMessageBox::questionYesNoCancel( + int answer = KMessageBox::questionYesNoCancel( this, i18n("Are you sure you want to close the window?\n" "You have %1 tab(s) open" , m_view->count()), i18n("Are you sure you want to close the window?"), @@ -906,7 +893,7 @@ bool MainWindow::queryClose() "confirmClosingMultipleTabs" ); - switch (answer) + switch (answer) { case KMessageBox::Yes: // Quit diff --git a/src/mainwindow.h b/src/mainwindow.h index aedf049d..6a162005 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -77,7 +77,6 @@ private: public slots: void slotHome(); - void loadUrl(const KUrl &url); void slotUpdateBrowser(); protected: diff --git a/src/panelhistory.cpp b/src/panelhistory.cpp index 57aa9281..9e04a88c 100644 --- a/src/panelhistory.cpp +++ b/src/panelhistory.cpp @@ -64,7 +64,7 @@ PanelHistory::PanelHistory(QWidget *parent) //- HistoryManager *historyManager = Application::historyManager(); QAbstractItemModel *model = historyManager->historyTreeModel(); - + m_treeProxyModel->setSourceModel(model); m_historyTreeView->setModel(m_treeProxyModel); m_historyTreeView->setExpanded(m_treeProxyModel->index(0, 0), true); @@ -72,7 +72,7 @@ PanelHistory::PanelHistory(QWidget *parent) QFontMetrics fm(font()); int header = fm.width(QLatin1Char('m')) * 40; m_historyTreeView->header()->resizeSection(0, header); - + connect(search, SIGNAL(textChanged(QString)), m_treeProxyModel, SLOT(setFilterFixedString(QString))); connect(m_historyTreeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(open())); } @@ -90,6 +90,6 @@ void PanelHistory::open() QModelIndex index = m_historyTreeView->currentIndex(); if (!index.parent().isValid()) return; - emit openUrl(index.data(HistoryModel::UrlRole).toUrl()); + emit openUrl(index.data(HistoryModel::UrlRole).toUrl(), Rekonq::Current); } diff --git a/src/panelhistory.h b/src/panelhistory.h index 45847565..dfc3810d 100644 --- a/src/panelhistory.h +++ b/src/panelhistory.h @@ -41,7 +41,7 @@ public: virtual ~PanelHistory(); signals: - void openUrl(const KUrl&); + void openUrl(const KUrl &url, Rekonq::OpenType type=Rekonq::Current); private slots: void open(); @@ -49,7 +49,7 @@ private slots: private: QTreeView *m_historyTreeView; TreeProxyModel *m_treeProxyModel; - + }; #endif // PANELHISTORY_H diff --git a/src/sidepanel.cpp b/src/sidepanel.cpp index c4ba6c2a..7156c3d5 100644 --- a/src/sidepanel.cpp +++ b/src/sidepanel.cpp @@ -36,9 +36,10 @@ SidePanel::SidePanel(const QString &title, QWidget *parent, Qt::WindowFlags flag setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); setShown(ReKonfig::showSideBar()); - - connect(m_panelHistory, SIGNAL(openUrl(const KUrl&)), this, SIGNAL(openUrl(const KUrl&))); - + + connect(m_panelHistory, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType)), + this, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType))); + setWidget(m_panelHistory); } @@ -47,7 +48,7 @@ SidePanel::~SidePanel() { // Save side panel's state ReKonfig::setShowSideBar(!isHidden()); - + delete m_panelHistory; } diff --git a/src/sidepanel.h b/src/sidepanel.h index ae1a76f1..7efb919b 100644 --- a/src/sidepanel.h +++ b/src/sidepanel.h @@ -34,17 +34,17 @@ class SidePanel : public QDockWidget { Q_OBJECT Q_DISABLE_COPY(SidePanel) - + public: explicit SidePanel(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0); ~SidePanel(); - + signals: - void openUrl(const KUrl&); - + void openUrl(const KUrl&, Rekonq::OpenType type=Rekonq::Current); + private: PanelHistory *m_panelHistory; - + }; #endif // SIDEPANEL_H diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 75a06e23..f11ea688 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -49,7 +49,8 @@ TabBar::TabBar(QWidget *parent) setElideMode(Qt::ElideRight); setContextMenuPolicy(Qt::CustomContextMenu); setMovable(true); - connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); + connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, + SLOT(contextMenuRequested(const QPoint &))); // tabbar font QFont standardFont = KGlobalSettings::generalFont(); @@ -96,18 +97,20 @@ QSize TabBar::tabSizeHint(int index) const void TabBar::contextMenuRequested(const QPoint &position) { KMenu menu; - menu.addAction(i18n("New &Tab"), this, SIGNAL(newTab())); + MainWindow *mainWindow = Application::instance()->mainWindow(); + + menu.addAction(mainWindow->actionByName(QLatin1String("new_tab"))); int index = tabAt(position); if (-1 != index) { m_actualIndex = index; - KAction *action = (KAction *) menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); + menu.addAction(KIcon("tab-duplicate"), i18n("Clone Tab"), this, SLOT(cloneTab())); menu.addSeparator(); - action = (KAction *) menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab())); - action = (KAction *) menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); + menu.addAction(KIcon("tab-close"), i18n("&Close Tab"), this, SLOT(closeTab())); + menu.addAction(KIcon("tab-close-other"), i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); menu.addSeparator(); - action = (KAction *) menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab())); + menu.addAction(KIcon("view-refresh"), i18n("Reload Tab"), this, SLOT(reloadTab())); } else { @@ -136,16 +139,6 @@ void TabBar::closeOtherTabs() } -void TabBar::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - m_dragStartPos = event->pos(); - } - KTabBar::mousePressEvent(event); -} - - void TabBar::reloadTab() { emit reloadTab(m_actualIndex); diff --git a/src/tabbar.h b/src/tabbar.h index 2281f997..8563793f 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -45,7 +45,6 @@ public: ~TabBar(); signals: - void newTab(); void cloneTab(int index); void closeTab(int index); void closeOtherTabs(int index); @@ -53,8 +52,6 @@ signals: void reloadAllTabs(); protected: - void mousePressEvent(QMouseEvent* event); - /** * Added to fix tab dimension */ @@ -68,12 +65,9 @@ private slots: void contextMenuRequested(const QPoint &position); private: - friend class MainView; QWidget *m_parent; - QPoint m_dragStartPos; - int m_dragCurrentIndex; /** * the index in which we are seeing a Context menu diff --git a/src/webview.cpp b/src/webview.cpp index 78f0e734..53802b9c 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -89,7 +89,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r if(m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) { - webView = Application::instance()->newWebView(); + webView = Application::instance()->newWebView(false); webView->setFocus(); webView->load(request); m_keyboardModifiers = Qt::NoModifier; @@ -131,7 +131,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r // A short term hack until QtWebKit can get a reload without cache QAction // *FYI* currently type is never NavigationTypeReload // See: https://bugs.webkit.org/show_bug.cgi?id=24283 - if (qApp->keyboardModifiers() & Qt::ShiftModifier) + if (qApp->keyboardModifiers() & Qt::ShiftModifier) { QNetworkRequest newRequest(request); newRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, @@ -217,7 +217,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) } QUrl url(path); - Application::instance()->mainWindow()->loadUrl(url); + Application::instance()->mainWindow()->mainView()->openUrl(url); return; } @@ -308,27 +308,27 @@ KActionCollection* WebView::webActions() a = new KAction(KIcon("tab-new"), i18n("Open Link in New &Tab"), this); connect(a, SIGNAL(triggered()), this, SLOT(openLinkInNewTab()) ); s_webActionCollection->addAction( QLatin1String("open_link_in_new_tab"), a); - + a = pageAction(QWebPage::Cut); a->setIcon(KIcon("edit-cut")); a->setText(i18n("Cu&t")); s_webActionCollection->addAction( QLatin1String("edit_cut"), a); - + a = pageAction(QWebPage::Copy); a->setIcon(KIcon("edit-copy")); a->setText(i18n("&Copy")); s_webActionCollection->addAction( QLatin1String("edit_copy"), a ); - + a = pageAction(QWebPage::Paste); a->setIcon(KIcon("edit-paste")); a->setText(i18n("&Paste")); s_webActionCollection->addAction( QLatin1String("edit_paste"), a ); - + a = pageAction(QWebPage::DownloadImageToDisk); a->setIcon(KIcon("folder-image")); a->setText(i18n("&Save Image As...")); s_webActionCollection->addAction( QLatin1String("save_image_as"), a ); - + a = pageAction(QWebPage::CopyImageToClipboard); a->setIcon(KIcon("insert-image")); a->setText(i18n("&Copy This Image")); @@ -338,7 +338,7 @@ KActionCollection* WebView::webActions() a->setIcon(KIcon("folder-downloads")); a->setText(i18n("&Save Link As...")); s_webActionCollection->addAction( QLatin1String("save_link_as"), a); - + a = pageAction(QWebPage::CopyLinkToClipboard); a->setIcon(KIcon("insert-link")); a->setText(i18n("&Copy Link Location")); @@ -358,12 +358,12 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) { QWebHitTestResult result = page()->mainFrame()->hitTestContent(event->pos()); MainWindow *mainwindow = Application::instance()->mainWindow(); - + QAction *addBookmarkAction = Application::bookmarkProvider()->actionByName("add_bookmark_payload"); addBookmarkAction->setText(i18n("Bookmark This Page")); addBookmarkAction->setData(QVariant()); KMenu menu(this); - + bool linkIsEmpty = result.linkUrl().isEmpty(); if (!linkIsEmpty) { @@ -416,7 +416,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) addBookmarkAction->setText(i18n("&Bookmark This Link")); } menu.addSeparator(); - + menu.addAction(addBookmarkAction); menu.exec(mapToGlobal(event->pos())); } |