From 6cf7ab65f009f07cdc0ded9ec377665c124a84ac Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 8 Jan 2009 02:35:46 +0100 Subject: Created mainview! Other minor adjs.. --- src/mainview.cpp | 704 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 704 insertions(+) create mode 100644 src/mainview.cpp (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp new file mode 100644 index 00000000..79cb865d --- /dev/null +++ b/src/mainview.cpp @@ -0,0 +1,704 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +// Local Includes +#include "mainview.h" + +#include "tabbar.h" +#include "browserapplication.h" +#include "mainwindow.h" +#include "history.h" +#include "urlbar.h" +#include "webview.h" + +// KDE Includes +#include +#include +#include + +// Qt Includes +#include +#include + + + + +WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent) + : QObject(parent) + , m_currentParent(0) + , m_root(root) + , m_webAction(webAction) +{ + if ( !m_root ) + { + return; + } + connect(m_root, SIGNAL( triggered() ), this, SLOT( rootTriggered() ) ); + connect(root, SIGNAL( destroyed(QObject *) ), this, SLOT( rootDestroyed() ) ); + + root->setEnabled(false); +} + + +void WebActionMapper::rootDestroyed() +{ + m_root = 0; +} + + +void WebActionMapper::currentDestroyed() +{ + updateCurrent(0); +} + + +void WebActionMapper::addChild(KAction *action) +{ + if ( !action ) + { + return; + } + connect(action, SIGNAL( changed() ), this, SLOT( childChanged() ) ); +} + +QWebPage::WebAction WebActionMapper::webAction() const +{ + return m_webAction; +} + + +void WebActionMapper::rootTriggered() +{ + if (m_currentParent) + { + KAction *gotoAction = new KAction( m_currentParent->action(m_webAction) ); + gotoAction->trigger(); + } +} + + +void WebActionMapper::childChanged() +{ + if (KAction *source = qobject_cast(sender())) + { + if (m_root + && m_currentParent + && source->parent() == m_currentParent) + { + m_root->setChecked(source->isChecked()); + m_root->setEnabled(source->isEnabled()); + } + } +} + + +void WebActionMapper::updateCurrent(QWebPage *currentParent) +{ + if (m_currentParent) + disconnect(m_currentParent, SIGNAL(destroyed(QObject *)), + this, SLOT(currentDestroyed())); + + m_currentParent = currentParent; + if (!m_root) + { + return; + } + if (!m_currentParent) + { + m_root->setEnabled(false); + m_root->setChecked(false); + return; + } + KAction *source = new KAction( m_currentParent->action(m_webAction) ); + m_root->setChecked(source->isChecked()); + m_root->setEnabled(source->isEnabled()); + connect(m_currentParent, SIGNAL( destroyed(QObject *) ), this, SLOT( currentDestroyed() ) ); +} + + +// ---------------------------------------------------------------------------------------------------------- + + +MainView::MainView(QWidget *parent) + : KTabWidget(parent) + , m_recentlyClosedTabsAction(0) + , m_newTabAction(0) + , m_closeTabAction(0) + , m_nextTabAction(0) + , m_previousTabAction(0) + , m_recentlyClosedTabsMenu(0) + , m_lineEditCompleter(0) + , m_lineEdits(0) + , m_tabBar(new TabBar(this)) +{ + setElideMode(Qt::ElideRight); + + connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); + connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); + connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); + connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); + connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); + connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); + connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); + setTabBar(m_tabBar); + + // Actions + m_newTabAction = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); + m_newTabAction->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); + m_newTabAction->setIconVisibleInMenu(false); + connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); + + m_closeTabAction = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); + m_closeTabAction->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); + m_closeTabAction->setIconVisibleInMenu(false); + connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); + + m_nextTabAction = new KAction(i18n("Show Next Tab"), this); + m_nextTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); + connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); + + m_previousTabAction = new KAction(i18n("Show Previous Tab"), this); + m_previousTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); + connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); + + m_recentlyClosedTabsMenu = new KMenu(this); + connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); + connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); + m_recentlyClosedTabsAction = new KAction(i18n("Recently Closed Tabs"), this); + m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); + m_recentlyClosedTabsAction->setEnabled(false); + + // corner buttons + QToolButton *addTabButton = new QToolButton(this); + addTabButton->setDefaultAction(m_newTabAction); + addTabButton->setAutoRaise(true); + addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); + setCornerWidget(addTabButton, Qt::TopLeftCorner); + + QToolButton *closeTabButton = new QToolButton(this); + closeTabButton->setDefaultAction(m_closeTabAction); + closeTabButton->setAutoRaise(true); + closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); + setCornerWidget(closeTabButton, Qt::TopRightCorner); + + connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + + m_lineEdits = new QStackedWidget(this); +} + + +MainView::~MainView() +{ + delete m_lineEditCompleter; + delete m_recentlyClosedTabsMenu; +} + + +void MainView::clear() +{ + // clear the recently closed tabs + m_recentlyClosedTabs.clear(); + // clear the line edit history + for (int i = 0; i < m_lineEdits->count(); ++i) + { + QLineEdit *qLineEdit = lineEdit(i); + qLineEdit->setText(qLineEdit->text()); + } +} + + +void MainView::moveTab(int fromIndex, int toIndex) +{ + disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + + QWidget *tabWidget = widget(fromIndex); + QIcon icon = tabIcon(fromIndex); + QString text = tabText(fromIndex); + QVariant data = m_tabBar->tabData(fromIndex); + removeTab(fromIndex); + insertTab(toIndex, tabWidget, icon, text); + m_tabBar->setTabData(toIndex, data); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + setCurrentIndex(toIndex); +} + + +// When index is -1 index chooses the current tab +void MainView::reloadTab(int index) +{ + if (index < 0) + index = currentIndex(); + if (index < 0 || index >= count()) + return; + + QWidget *widget = this->widget(index); + if (WebView *tab = qobject_cast(widget)) + tab->reload(); +} + + +void MainView::addWebAction(KAction *action, QWebPage::WebAction webAction) +{ + if (!action) + return; + m_webActionList.append(new WebActionMapper(action, webAction, this)); +} + + +void MainView::currentChanged(int index) +{ + WebView *webView = this->webView(index); + if (!webView) + return; + + Q_ASSERT( m_lineEdits->count() == count() ); + + WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); + if (oldWebView) + { + disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); + disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); + 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(loadProgress(int)), this, SIGNAL(loadProgress(int))); + + for (int i = 0; i < m_webActionList.count(); ++i) + { + WebActionMapper *mapper = m_webActionList[i]; + mapper->updateCurrent(webView->page()); + } + emit setCurrentTitle(webView->title()); + m_lineEdits->setCurrentIndex(index); + emit loadProgress(webView->progress()); + emit showStatusBarMessage(webView->lastStatusBarText()); + + // set focus to the current webview + webView->setFocus(); +} + + +KAction *MainView::newTabAction() const +{ + return m_newTabAction; +} + + +KAction *MainView::closeTabAction() const +{ + return m_closeTabAction; +} + + +KAction *MainView::recentlyClosedTabsAction() const +{ + return m_recentlyClosedTabsAction; +} + + +KAction *MainView::nextTabAction() const +{ + return m_nextTabAction; +} + + +KAction *MainView::previousTabAction() const +{ + return m_previousTabAction; +} + + +QWidget *MainView::lineEditStack() const +{ + return m_lineEdits; +} + + +QLineEdit *MainView::currentLineEdit() const +{ + return lineEdit(m_lineEdits->currentIndex()); +} + + +WebView *MainView::currentWebView() const +{ + return webView(currentIndex()); +} + + +QLineEdit *MainView::lineEdit(int index) const +{ + UrlBar *urlLineEdit = qobject_cast(m_lineEdits->widget(index)); + if (urlLineEdit) + return urlLineEdit->lineEdit(); + return 0; +} + + +WebView *MainView::webView(int index) const +{ + QWidget *widget = this->widget(index); + if (WebView *webView = qobject_cast(widget)) + { + return webView; + } + else + { + // optimization to delay creating the first webview + if (count() == 1) + { + MainView *that = const_cast(this); + that->setUpdatesEnabled(false); + that->newTab(); + that->closeTab(0); + that->setUpdatesEnabled(true); + return currentWebView(); + } + } + return 0; +} + + +int MainView::webViewIndex(WebView *webView) const +{ + int index = indexOf(webView); + return index; +} + + +WebView *MainView::newTab(bool makeCurrent) +{ + // line edit + UrlBar *urlLineEdit = new UrlBar; + QLineEdit *lineEdit = urlLineEdit->lineEdit(); + if (!m_lineEditCompleter && count() > 0) + { + HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); + completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel()); + m_lineEditCompleter = new QCompleter(completionModel, this); + // Should this be in Qt by default? + QAbstractItemView *popup = m_lineEditCompleter->popup(); + QListView *listView = qobject_cast(popup); + if (listView) + { + listView->setUniformItemSizes(true); + } + } + lineEdit->setCompleter(m_lineEditCompleter); + connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed())); + m_lineEdits->addWidget(urlLineEdit); + m_lineEdits->setSizePolicy(lineEdit->sizePolicy()); + + // optimization to delay creating the more expensive WebView, history, etc + if (count() == 0) + { + QWidget *emptyWidget = new QWidget; + QPalette p = emptyWidget->palette(); + p.setColor(QPalette::Window, palette().color(QPalette::Base)); + emptyWidget->setPalette(p); + emptyWidget->setAutoFillBackground(true); + disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + addTab(emptyWidget, i18n("(Untitled)")); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + return 0; + } + + // webview + WebView *webView = new WebView; + urlLineEdit->setWebView(webView); + + connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted())); + connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &))); + connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &))); + connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); + 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)), this, SIGNAL(menuBarVisibilityChangeRequested(bool))); + connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); + connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); + + connect(webView, SIGNAL( ctrlTabPressed() ), this, SLOT( nextTab() ) ); + connect(webView, SIGNAL( shiftCtrlTabPressed() ), this, SLOT( previousTab() ) ); + + addTab(webView, i18n("(Untitled)") ); + if (makeCurrent) + setCurrentWidget(webView); + + // webview actions + for (int i = 0; i < m_webActionList.count(); ++i) + { + WebActionMapper *mapper = m_webActionList[i]; + mapper->addChild( new KAction( webView->page()->action( mapper->webAction() ) ) ); + } + + if (count() == 1) + currentChanged(currentIndex()); + emit tabsChanged(); + return webView; +} + + +void MainView::reloadAllTabs() +{ + for (int i = 0; i < count(); ++i) + { + QWidget *tabWidget = widget(i); + if (WebView *tab = qobject_cast(tabWidget)) + { + tab->reload(); + } + } +} + + +void MainView::lineEditReturnPressed() +{ + if (QLineEdit *lineEdit = qobject_cast(sender())) + { + emit loadPage(lineEdit->text()); + if (m_lineEdits->currentWidget() == lineEdit) + currentWebView()->setFocus(); + } +} + + +void MainView::windowCloseRequested() +{ + WebPage *webPage = qobject_cast(sender()); + WebView *webView = qobject_cast(webPage->view()); + int index = webViewIndex(webView); + if (index >= 0) + { + if (count() == 1) + webView->webPage()->mainWindow()->close(); + else + closeTab(index); + } +} + + +void MainView::closeOtherTabs(int index) +{ + if (-1 == index) + return; + for (int i = count() - 1; i > index; --i) + closeTab(i); + for (int i = index - 1; i >= 0; --i) + closeTab(i); +} + + +// When index is -1 index chooses the current tab +void MainView::cloneTab(int index) +{ + if (index < 0) + index = currentIndex(); + if (index < 0 || index >= count()) + return; + WebView *tab = newTab(false); + tab->setUrl( webView(index)->url() ); +} + + +// When index is -1 index chooses the current tab +void MainView::closeTab(int index) +{ + if (index < 0) + index = currentIndex(); + if (index < 0 || index >= count()) + return; + + bool hasFocus = false; + if (WebView *tab = webView(index)) + { + if (tab->isModified()) + { + int risp = KMessageBox::questionYesNo( this , + i18n("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n"), + i18n("Do you really want to close this page?"), + KStandardGuiItem::no() ); + if( risp == KMessageBox::No ) + return; + } + hasFocus = tab->hasFocus(); + + m_recentlyClosedTabsAction->setEnabled(true); + m_recentlyClosedTabs.prepend(tab->url()); + if (m_recentlyClosedTabs.size() >= MainView::m_recentlyClosedTabsSize) + m_recentlyClosedTabs.removeLast(); + } + QWidget *lineEdit = m_lineEdits->widget(index); + m_lineEdits->removeWidget(lineEdit); + lineEdit->deleteLater(); + QWidget *webView = widget(index); + removeTab(index); + webView->deleteLater(); + emit tabsChanged(); + if (hasFocus && count() > 0) + currentWebView()->setFocus(); + if (count() == 0) + emit lastTabClosed(); +} + + +void MainView::webViewLoadStarted() +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) + { + setTabIcon(index, KIcon("rekonq") ); + } +} + + +void MainView::webViewIconChanged() +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) + { + QIcon icon = BrowserApplication::instance()->icon(webView->url()); + setTabIcon(index, icon); + } +} + + +void MainView::webViewTitleChanged(const QString &title) +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) { + setTabText(index, title); + } + if (currentIndex() == index) + emit setCurrentTitle(title); + BrowserApplication::historyManager()->updateHistoryItem(webView->url(), title); +} + + +void MainView::webViewUrlChanged(const QUrl &url) +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) { + m_tabBar->setTabData(index, url); + } + emit tabsChanged(); +} + + +void MainView::aboutToShowRecentTabsMenu() +{ + m_recentlyClosedTabsMenu->clear(); + for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) + { + KAction *action = new KAction(m_recentlyClosedTabsMenu); + action->setData(m_recentlyClosedTabs.at(i)); + QIcon icon = BrowserApplication::instance()->icon(m_recentlyClosedTabs.at(i)); + action->setIcon(icon); + action->setText( m_recentlyClosedTabs.at(i).prettyUrl() ); + m_recentlyClosedTabsMenu->addAction(action); + } +} + + +void MainView::aboutToShowRecentTriggeredAction(QAction *action) +{ + KUrl url = action->data().toUrl(); + loadUrlInCurrentTab(url); +} + + +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())) + { + newTab(); + return; + } + QTabWidget::mouseDoubleClickEvent(event); +} + + +void MainView::contextMenuEvent(QContextMenuEvent *event) +{ + if (!childAt(event->pos())) { + m_tabBar->contextMenuRequested(event->pos()); + return; + } + QTabWidget::contextMenuEvent(event); +} + + +void MainView::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::MidButton && !childAt(event->pos()) + // Remove the line below when QTabWidget does not have a one pixel frame + && event->pos().y() < (tabBar()->y() + tabBar()->height())) + { + KUrl url( QApplication::clipboard()->text(QClipboard::Selection) ); + if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) + { + WebView *webView = newTab(); + webView->setUrl(url); + } + } +} + + +void MainView::loadUrlInCurrentTab(const KUrl &url) +{ + WebView *webView = currentWebView(); + if (webView) + { + webView->loadUrl(url); + webView->setFocus(); + } +} + + +void MainView::nextTab() +{ + int next = currentIndex() + 1; + if (next == count()) + next = 0; + setCurrentIndex(next); +} + + +void MainView::previousTab() +{ + int next = currentIndex() - 1; + if (next < 0) + next = count() - 1; + setCurrentIndex(next); +} + + +// ---------------------------------------------------------------------------------------------------------------------------- -- cgit v1.2.1 From a14af0874d4ceac743727af1665ea1d5f15839d9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 9 Jan 2009 02:44:50 +0100 Subject: removed LoadPage method to semplify API Now we have just loadUrl slot to run pages.. --- src/mainview.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 79cb865d..d4318cdf 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -477,9 +477,11 @@ void MainView::lineEditReturnPressed() { if (QLineEdit *lineEdit = qobject_cast(sender())) { - emit loadPage(lineEdit->text()); + emit loadUrlPage( KUrl( lineEdit->text() ) ); if (m_lineEdits->currentWidget() == lineEdit) + { currentWebView()->setFocus(); + } } } -- cgit v1.2.1 From 5391120be8cfd3a5d752ac8c7b66bf17b690f303 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 9 Jan 2009 12:10:19 +0100 Subject: BIG change!! Removed use of proxy webactionmapper to manage web actions.. --- src/mainview.cpp | 115 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 84 insertions(+), 31 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index d4318cdf..f61a7593 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -19,9 +19,11 @@  * ============================================================ */ -// Local Includes +// Self Includes #include "mainview.h" +#include "mainview.moc" +// Local Includes #include "tabbar.h" #include "browserapplication.h" #include "mainwindow.h" @@ -212,6 +214,87 @@ MainView::~MainView() } +// ======================================================================================================== + KAction *MainView::newTabAction() const {return m_newTabAction; } + KAction *MainView::closeTabAction() const {return m_closeTabAction; } + KAction *MainView::recentlyClosedTabsAction() const {return m_recentlyClosedTabsAction;} + KAction *MainView::nextTabAction() const{} + KAction *MainView::previousTabAction() const{} + + void MainView::slotWebReload() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Reload); + action->trigger(); + } + + void MainView::slotWebBack() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Back); + action->trigger(); + } + + void MainView::slotWebForward() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Forward); + action->trigger(); + } + + void MainView::slotWebUndo() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Undo); + action->trigger(); + } + + void MainView::slotWebRedo() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Redo); + action->trigger(); + } + + void MainView::slotWebCut() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Cut); + action->trigger(); + } + + void MainView::slotWebCopy() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Copy); + action->trigger(); + } + + void MainView::slotWebPaste() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Paste); + action->trigger(); + } + + void MainView::slotWebSelectAll() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + // FIXME + } + +// ======================================================================================================== + + void MainView::clear() { // clear the recently closed tabs @@ -298,36 +381,6 @@ void MainView::currentChanged(int index) } -KAction *MainView::newTabAction() const -{ - return m_newTabAction; -} - - -KAction *MainView::closeTabAction() const -{ - return m_closeTabAction; -} - - -KAction *MainView::recentlyClosedTabsAction() const -{ - return m_recentlyClosedTabsAction; -} - - -KAction *MainView::nextTabAction() const -{ - return m_nextTabAction; -} - - -KAction *MainView::previousTabAction() const -{ - return m_previousTabAction; -} - - QWidget *MainView::lineEditStack() const { return m_lineEdits; -- cgit v1.2.1 From 910f1cc073f95f2928cb29d87561f71a27513872 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 9 Jan 2009 12:26:38 +0100 Subject: Removed WebActionMapper class! Now we are really starting to have adjam web browser.. --- src/mainview.cpp | 125 ++----------------------------------------------------- 1 file changed, 4 insertions(+), 121 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index f61a7593..21c318ed 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -42,103 +42,6 @@ - -WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent) - : QObject(parent) - , m_currentParent(0) - , m_root(root) - , m_webAction(webAction) -{ - if ( !m_root ) - { - return; - } - connect(m_root, SIGNAL( triggered() ), this, SLOT( rootTriggered() ) ); - connect(root, SIGNAL( destroyed(QObject *) ), this, SLOT( rootDestroyed() ) ); - - root->setEnabled(false); -} - - -void WebActionMapper::rootDestroyed() -{ - m_root = 0; -} - - -void WebActionMapper::currentDestroyed() -{ - updateCurrent(0); -} - - -void WebActionMapper::addChild(KAction *action) -{ - if ( !action ) - { - return; - } - connect(action, SIGNAL( changed() ), this, SLOT( childChanged() ) ); -} - -QWebPage::WebAction WebActionMapper::webAction() const -{ - return m_webAction; -} - - -void WebActionMapper::rootTriggered() -{ - if (m_currentParent) - { - KAction *gotoAction = new KAction( m_currentParent->action(m_webAction) ); - gotoAction->trigger(); - } -} - - -void WebActionMapper::childChanged() -{ - if (KAction *source = qobject_cast(sender())) - { - if (m_root - && m_currentParent - && source->parent() == m_currentParent) - { - m_root->setChecked(source->isChecked()); - m_root->setEnabled(source->isEnabled()); - } - } -} - - -void WebActionMapper::updateCurrent(QWebPage *currentParent) -{ - if (m_currentParent) - disconnect(m_currentParent, SIGNAL(destroyed(QObject *)), - this, SLOT(currentDestroyed())); - - m_currentParent = currentParent; - if (!m_root) - { - return; - } - if (!m_currentParent) - { - m_root->setEnabled(false); - m_root->setChecked(false); - return; - } - KAction *source = new KAction( m_currentParent->action(m_webAction) ); - m_root->setChecked(source->isChecked()); - m_root->setEnabled(source->isEnabled()); - connect(m_currentParent, SIGNAL( destroyed(QObject *) ), this, SLOT( currentDestroyed() ) ); -} - - -// ---------------------------------------------------------------------------------------------------------- - - MainView::MainView(QWidget *parent) : KTabWidget(parent) , m_recentlyClosedTabsAction(0) @@ -338,14 +241,6 @@ void MainView::reloadTab(int index) } -void MainView::addWebAction(KAction *action, QWebPage::WebAction webAction) -{ - if (!action) - return; - m_webActionList.append(new WebActionMapper(action, webAction, this)); -} - - void MainView::currentChanged(int index) { WebView *webView = this->webView(index); @@ -366,11 +261,6 @@ void MainView::currentChanged(int index) 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))); - for (int i = 0; i < m_webActionList.count(); ++i) - { - WebActionMapper *mapper = m_webActionList[i]; - mapper->updateCurrent(webView->page()); - } emit setCurrentTitle(webView->title()); m_lineEdits->setCurrentIndex(index); emit loadProgress(webView->progress()); @@ -499,13 +389,6 @@ WebView *MainView::newTab(bool makeCurrent) if (makeCurrent) setCurrentWidget(webView); - // webview actions - for (int i = 0; i < m_webActionList.count(); ++i) - { - WebActionMapper *mapper = m_webActionList[i]; - mapper->addChild( new KAction( webView->page()->action( mapper->webAction() ) ) ); - } - if (count() == 1) currentChanged(currentIndex()); emit tabsChanged(); @@ -591,10 +474,10 @@ void MainView::closeTab(int index) if (tab->isModified()) { int risp = KMessageBox::questionYesNo( this , - i18n("You have modified this page and when closing it you would lose the modification.\n" - "Do you really want to close this page?\n"), - i18n("Do you really want to close this page?"), - KStandardGuiItem::no() ); + i18n("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n"), + i18n("Do you really want to close this page?"), + KStandardGuiItem::no() ); if( risp == KMessageBox::No ) return; } -- cgit v1.2.1 From 886bdb99cd998c045e111a2d7e6f77e29d30b784 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 9 Jan 2009 16:37:41 +0100 Subject: Every action is now in ActionCollection!! Fully adopted xmlgui && mainview concepts.. --- src/mainview.cpp | 182 +++++++++++++++++++++++-------------------------------- 1 file changed, 77 insertions(+), 105 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 21c318ed..d796035e 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -35,6 +35,7 @@ #include #include #include +#include // Qt Includes #include @@ -45,10 +46,6 @@ MainView::MainView(QWidget *parent) : KTabWidget(parent) , m_recentlyClosedTabsAction(0) - , m_newTabAction(0) - , m_closeTabAction(0) - , m_nextTabAction(0) - , m_previousTabAction(0) , m_recentlyClosedTabsMenu(0) , m_lineEditCompleter(0) , m_lineEdits(0) @@ -65,25 +62,7 @@ MainView::MainView(QWidget *parent) connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); setTabBar(m_tabBar); - // Actions - m_newTabAction = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); - m_newTabAction->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); - m_newTabAction->setIconVisibleInMenu(false); - connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); - - m_closeTabAction = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); - m_closeTabAction->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); - m_closeTabAction->setIconVisibleInMenu(false); - connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); - - m_nextTabAction = new KAction(i18n("Show Next Tab"), this); - m_nextTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); - connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); - - m_previousTabAction = new KAction(i18n("Show Previous Tab"), this); - m_previousTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); - connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); - + // Recently Closed Tab Action m_recentlyClosedTabsMenu = new KMenu(this); connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); @@ -91,19 +70,7 @@ MainView::MainView(QWidget *parent) m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); - // corner buttons - QToolButton *addTabButton = new QToolButton(this); - addTabButton->setDefaultAction(m_newTabAction); - addTabButton->setAutoRaise(true); - addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - setCornerWidget(addTabButton, Qt::TopLeftCorner); - - QToolButton *closeTabButton = new QToolButton(this); - closeTabButton->setDefaultAction(m_closeTabAction); - closeTabButton->setAutoRaise(true); - closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - setCornerWidget(closeTabButton, Qt::TopRightCorner); - + // -- connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); m_lineEdits = new QStackedWidget(this); @@ -117,85 +84,90 @@ MainView::~MainView() } -// ======================================================================================================== - KAction *MainView::newTabAction() const {return m_newTabAction; } - KAction *MainView::closeTabAction() const {return m_closeTabAction; } - KAction *MainView::recentlyClosedTabsAction() const {return m_recentlyClosedTabsAction;} - KAction *MainView::nextTabAction() const{} - KAction *MainView::previousTabAction() const{} +KAction *MainView::recentlyClosedTabsAction() const +{ + return m_recentlyClosedTabsAction; +} - void MainView::slotWebReload() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Reload); - action->trigger(); - } - void MainView::slotWebBack() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Back); - action->trigger(); - } +void MainView::slotWebReload() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Reload); + action->trigger(); +} - void MainView::slotWebForward() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Forward); - action->trigger(); - } - void MainView::slotWebUndo() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Undo); - action->trigger(); - } +void MainView::slotWebBack() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Back); + action->trigger(); +} - void MainView::slotWebRedo() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Redo); - action->trigger(); - } - void MainView::slotWebCut() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Cut); - action->trigger(); - } +void MainView::slotWebForward() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Forward); + action->trigger(); +} - void MainView::slotWebCopy() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Copy); - action->trigger(); - } - void MainView::slotWebPaste() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Paste); - action->trigger(); - } +void MainView::slotWebUndo() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Undo); + action->trigger(); +} - void MainView::slotWebSelectAll() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - // FIXME - } -// ======================================================================================================== +void MainView::slotWebRedo() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Redo); + action->trigger(); +} + + +void MainView::slotWebCut() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Cut); + action->trigger(); +} + + +void MainView::slotWebCopy() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Copy); + action->trigger(); +} + + +void MainView::slotWebPaste() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Paste); + action->trigger(); +} + + +void MainView::slotWebSelectAll() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + // FIXME +} void MainView::clear() -- cgit v1.2.1 From 8b0c34007ddf70de767b036a21d978befb9654d4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 12 Jan 2009 01:10:49 +0100 Subject: Fixed unconnected STOP web action --- src/mainview.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index d796035e..4236d5d0 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -99,6 +99,15 @@ void MainView::slotWebReload() } +void MainView::slotWebStop() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Stop); + action->trigger(); +} + + void MainView::slotWebBack() { WebView *webView = currentWebView(); -- cgit v1.2.1 From 195641eb0e7972b32756e95340ebd48c21a7feaf Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 18 Jan 2009 02:10:22 +0100 Subject: Partially ported rekonq to KConfigXT technology.. Perhaps ~50%..going on!! --- src/mainview.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 4236d5d0..328d3dd1 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -175,7 +175,7 @@ void MainView::slotWebSelectAll() { WebView *webView = currentWebView(); QWebPage *currentParent = webView->webPage(); - // FIXME + // TODO } @@ -618,6 +618,3 @@ void MainView::previousTab() next = count() - 1; setCurrentIndex(next); } - - -// ---------------------------------------------------------------------------------------------------------------------------- -- cgit v1.2.1 From 1024f77ad03ef3d30d8be6aa61542a057a100868 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 28 Jan 2009 00:59:08 +0100 Subject: Removed unuseful "Select All" action. If someone needs it, I can try to implement it one day.. --- src/mainview.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 328d3dd1..acef1998 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -171,14 +171,6 @@ void MainView::slotWebPaste() } -void MainView::slotWebSelectAll() -{ - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - // TODO -} - - void MainView::clear() { // clear the recently closed tabs -- cgit v1.2.1 From 39ff47469cdc4a7df148368ed60470dc042f677e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 15 Feb 2009 15:44:52 +0100 Subject: {Browser,}Application. Again.. --- src/mainview.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index acef1998..a3030748 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -25,7 +25,7 @@ // Local Includes #include "tabbar.h" -#include "browserapplication.h" +#include "application.h" #include "mainwindow.h" #include "history.h" #include "urlbar.h" @@ -310,7 +310,7 @@ WebView *MainView::newTab(bool makeCurrent) if (!m_lineEditCompleter && count() > 0) { HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); - completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel()); + completionModel->setSourceModel(Application::historyManager()->historyFilterModel()); m_lineEditCompleter = new QCompleter(completionModel, this); // Should this be in Qt by default? QAbstractItemView *popup = m_lineEditCompleter->popup(); @@ -492,7 +492,7 @@ void MainView::webViewIconChanged() int index = webViewIndex(webView); if (-1 != index) { - QIcon icon = BrowserApplication::instance()->icon(webView->url()); + QIcon icon = Application::instance()->icon(webView->url()); setTabIcon(index, icon); } } @@ -507,7 +507,7 @@ void MainView::webViewTitleChanged(const QString &title) } if (currentIndex() == index) emit setCurrentTitle(title); - BrowserApplication::historyManager()->updateHistoryItem(webView->url(), title); + Application::historyManager()->updateHistoryItem(webView->url(), title); } @@ -529,7 +529,7 @@ void MainView::aboutToShowRecentTabsMenu() { KAction *action = new KAction(m_recentlyClosedTabsMenu); action->setData(m_recentlyClosedTabs.at(i)); - QIcon icon = BrowserApplication::instance()->icon(m_recentlyClosedTabs.at(i)); + QIcon icon = Application::instance()->icon(m_recentlyClosedTabs.at(i)); action->setIcon(icon); action->setText( m_recentlyClosedTabs.at(i).prettyUrl() ); m_recentlyClosedTabsMenu->addAction(action); -- cgit v1.2.1 From 75310e79287a8bdffb86cc1dfda1a0f069383cd6 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 20 Feb 2009 19:06:41 +0100 Subject: Last commit before branching "di brutto".. --- src/mainview.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index a3030748..cb84f56b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -48,7 +48,7 @@ MainView::MainView(QWidget *parent) , m_recentlyClosedTabsAction(0) , m_recentlyClosedTabsMenu(0) , m_lineEditCompleter(0) - , m_lineEdits(0) + , m_lineEdits(new QStackedWidget(this)) , m_tabBar(new TabBar(this)) { setElideMode(Qt::ElideRight); @@ -72,8 +72,6 @@ MainView::MainView(QWidget *parent) // -- connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); - - m_lineEdits = new QStackedWidget(this); } -- cgit v1.2.1 From b5044060c9263d223c99055b9bd6b93c9fb966c7 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 11 Mar 2009 00:55:47 +0100 Subject: Forwarding class declarations to speed up compilation.. --- src/mainview.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index cb84f56b..9e23ae2d 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -32,14 +32,18 @@ #include "webview.h" // KDE Includes +#include +#include +#include #include #include #include #include // Qt Includes +#include #include -#include +#include -- cgit v1.2.1 From 84a93ab8a47c8e4546ae658b5400623cdccfe237 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 16 Mar 2009 15:45:45 +0100 Subject: updated rekonq site fixed tab actions.. really near rekonq 0.0.4! Perhaps this night!! --- src/mainview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 9e23ae2d..d7e07e14 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -39,6 +39,7 @@ #include #include #include +#include // Qt Includes #include @@ -55,7 +56,7 @@ MainView::MainView(QWidget *parent) , m_lineEdits(new QStackedWidget(this)) , m_tabBar(new TabBar(this)) { - setElideMode(Qt::ElideRight); + setTabBar(m_tabBar); connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); @@ -64,7 +65,6 @@ MainView::MainView(QWidget *parent) connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); - setTabBar(m_tabBar); // Recently Closed Tab Action m_recentlyClosedTabsMenu = new KMenu(this); -- cgit v1.2.1 From 5a8bb470bc30bf6a360661a87af783fd30588f5f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 21 Mar 2009 12:12:36 +0100 Subject: Always Show Tab Bar. Or not... --- src/mainview.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index d7e07e14..407db6fe 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -23,6 +23,9 @@ #include "mainview.h" #include "mainview.moc" +// Auto Includes +#include "rekonq.h" + // Local Includes #include "tabbar.h" #include "application.h" @@ -86,6 +89,26 @@ MainView::~MainView() } +void MainView::viewTabBar() +{ + bool always = ReKonfig::alwaysShowTabBar(); + if(always == true) + return; + + if( m_tabBar->count() == 1 ) + { + m_tabBar->hide(); + } + else + { + if( m_tabBar->isHidden() ) + { + m_tabBar->show(); + } + } +} + + KAction *MainView::recentlyClosedTabsAction() const { return m_recentlyClosedTabsAction; @@ -367,6 +390,9 @@ WebView *MainView::newTab(bool makeCurrent) if (count() == 1) currentChanged(currentIndex()); emit tabsChanged(); + + viewTabBar(); + return webView; } @@ -420,6 +446,8 @@ void MainView::closeOtherTabs(int index) closeTab(i); for (int i = index - 1; i >= 0; --i) closeTab(i); + + viewTabBar(); } @@ -432,6 +460,8 @@ void MainView::cloneTab(int index) return; WebView *tab = newTab(false); tab->setUrl( webView(index)->url() ); + + viewTabBar(); } @@ -474,6 +504,8 @@ void MainView::closeTab(int index) currentWebView()->setFocus(); if (count() == 0) emit lastTabClosed(); + + viewTabBar(); } -- cgit v1.2.1 From 39409ac6a2880ad815d6096231d0fcdcfd2547f6 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 22 Mar 2009 10:21:09 +0100 Subject: Fixed Copyright intro --- src/mainview.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 407db6fe..a39c40b1 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -1,22 +1,22 @@ /* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2008 by Andrea Diamantini +* +* +* This program is free software; you can redistribute it +* and/or modify it under the terms of the GNU General +* Public License as published by the Free Software Foundation; +* either version 2, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* ============================================================ */ + // Self Includes -- cgit v1.2.1 From 48b25611c94d380b40948a3de0bfab5678668e1d Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 25 Mar 2009 00:47:24 +0100 Subject: Huge update. Fixed quite all of the settings troubles.. From now on, we (mainly) go on WebView bugfixing.. --- src/mainview.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index a39c40b1..a1eed467 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -89,11 +89,17 @@ MainView::~MainView() } -void MainView::viewTabBar() +void MainView::showTabBar() { bool always = ReKonfig::alwaysShowTabBar(); if(always == true) + { + if( m_tabBar->isHidden() ) + { + m_tabBar->show(); + } return; + } if( m_tabBar->count() == 1 ) { @@ -391,7 +397,7 @@ WebView *MainView::newTab(bool makeCurrent) currentChanged(currentIndex()); emit tabsChanged(); - viewTabBar(); + showTabBar(); return webView; } @@ -447,7 +453,7 @@ void MainView::closeOtherTabs(int index) for (int i = index - 1; i >= 0; --i) closeTab(i); - viewTabBar(); + showTabBar(); } @@ -461,7 +467,7 @@ void MainView::cloneTab(int index) WebView *tab = newTab(false); tab->setUrl( webView(index)->url() ); - viewTabBar(); + showTabBar(); } @@ -505,7 +511,7 @@ void MainView::closeTab(int index) if (count() == 0) emit lastTabClosed(); - viewTabBar(); + showTabBar(); } -- cgit v1.2.1 From 3434cd81168e996b66ca6583d5b68cd19bf14c09 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 27 Mar 2009 03:14:47 +0100 Subject: Some fixes from avaddon-clone. Thank you --- src/mainview.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index a1eed467..7238b966 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -91,8 +91,9 @@ MainView::~MainView() void MainView::showTabBar() { - bool always = ReKonfig::alwaysShowTabBar(); - if(always == true) + bool astb = ReKonfig::alwaysShowTabBar(); + + if(astb == true) { if( m_tabBar->isHidden() ) { @@ -593,7 +594,7 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) newTab(); return; } - QTabWidget::mouseDoubleClickEvent(event); + KTabWidget::mouseDoubleClickEvent(event); } @@ -603,7 +604,7 @@ void MainView::contextMenuEvent(QContextMenuEvent *event) m_tabBar->contextMenuRequested(event->pos()); return; } - QTabWidget::contextMenuEvent(event); + KTabWidget::contextMenuEvent(event); } -- cgit v1.2.1 From a934072cf9695e46e793898102590322f43c0733 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 28 Mar 2009 15:53:26 +0100 Subject: astyle. First round.. --- src/mainview.cpp | 107 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 52 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 7238b966..4ab8dc8b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -52,12 +52,12 @@ MainView::MainView(QWidget *parent) - : KTabWidget(parent) - , m_recentlyClosedTabsAction(0) - , m_recentlyClosedTabsMenu(0) - , m_lineEditCompleter(0) - , m_lineEdits(new QStackedWidget(this)) - , m_tabBar(new TabBar(this)) + : KTabWidget(parent) + , m_recentlyClosedTabsAction(0) + , m_recentlyClosedTabsMenu(0) + , m_lineEditCompleter(0) + , m_lineEdits(new QStackedWidget(this)) + , m_tabBar(new TabBar(this)) { setTabBar(m_tabBar); @@ -86,29 +86,29 @@ MainView::~MainView() { delete m_lineEditCompleter; delete m_recentlyClosedTabsMenu; -} +} void MainView::showTabBar() { bool astb = ReKonfig::alwaysShowTabBar(); - if(astb == true) + if (astb == true) { - if( m_tabBar->isHidden() ) + if (m_tabBar->isHidden()) { m_tabBar->show(); } return; } - if( m_tabBar->count() == 1 ) + if (m_tabBar->count() == 1) { m_tabBar->hide(); } else { - if( m_tabBar->isHidden() ) + if (m_tabBar->isHidden()) { m_tabBar->show(); } @@ -208,7 +208,7 @@ void MainView::clear() // clear the recently closed tabs m_recentlyClosedTabs.clear(); // clear the line edit history - for (int i = 0; i < m_lineEdits->count(); ++i) + for (int i = 0; i < m_lineEdits->count(); ++i) { QLineEdit *qLineEdit = lineEdit(i); qLineEdit->setText(qLineEdit->text()); @@ -252,10 +252,10 @@ void MainView::currentChanged(int index) if (!webView) return; - Q_ASSERT( m_lineEdits->count() == count() ); + Q_ASSERT(m_lineEdits->count() == count()); WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); - if (oldWebView) + if (oldWebView) { disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); @@ -306,14 +306,14 @@ QLineEdit *MainView::lineEdit(int index) const WebView *MainView::webView(int index) const { QWidget *widget = this->widget(index); - if (WebView *webView = qobject_cast(widget)) + if (WebView *webView = qobject_cast(widget)) { return webView; - } - else + } + else { // optimization to delay creating the first webview - if (count() == 1) + if (count() == 1) { MainView *that = const_cast(this); that->setUpdatesEnabled(false); @@ -339,7 +339,7 @@ WebView *MainView::newTab(bool makeCurrent) // line edit UrlBar *urlLineEdit = new UrlBar; QLineEdit *lineEdit = urlLineEdit->lineEdit(); - if (!m_lineEditCompleter && count() > 0) + if (!m_lineEditCompleter && count() > 0) { HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); completionModel->setSourceModel(Application::historyManager()->historyFilterModel()); @@ -358,7 +358,7 @@ WebView *MainView::newTab(bool makeCurrent) m_lineEdits->setSizePolicy(lineEdit->sizePolicy()); // optimization to delay creating the more expensive WebView, history, etc - if (count() == 0) + if (count() == 0) { QWidget *emptyWidget = new QWidget; QPalette p = emptyWidget->palette(); @@ -370,7 +370,7 @@ WebView *MainView::newTab(bool makeCurrent) connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); return 0; } - + // webview WebView *webView = new WebView; urlLineEdit->setWebView(webView); @@ -387,10 +387,10 @@ WebView *MainView::newTab(bool makeCurrent) connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); - connect(webView, SIGNAL( ctrlTabPressed() ), this, SLOT( nextTab() ) ); - connect(webView, SIGNAL( shiftCtrlTabPressed() ), this, SLOT( previousTab() ) ); + connect(webView, SIGNAL(ctrlTabPressed()), this, SLOT(nextTab())); + connect(webView, SIGNAL(shiftCtrlTabPressed()), this, SLOT(previousTab())); - addTab(webView, i18n("(Untitled)") ); + addTab(webView, i18n("(Untitled)")); if (makeCurrent) setCurrentWidget(webView); @@ -406,10 +406,10 @@ WebView *MainView::newTab(bool makeCurrent) void MainView::reloadAllTabs() { - for (int i = 0; i < count(); ++i) + for (int i = 0; i < count(); ++i) { QWidget *tabWidget = widget(i); - if (WebView *tab = qobject_cast(tabWidget)) + if (WebView *tab = qobject_cast(tabWidget)) { tab->reload(); } @@ -419,9 +419,9 @@ void MainView::reloadAllTabs() void MainView::lineEditReturnPressed() { - if (QLineEdit *lineEdit = qobject_cast(sender())) + if (QLineEdit *lineEdit = qobject_cast(sender())) { - emit loadUrlPage( KUrl( lineEdit->text() ) ); + emit loadUrlPage(KUrl(lineEdit->text())); if (m_lineEdits->currentWidget() == lineEdit) { currentWebView()->setFocus(); @@ -435,7 +435,7 @@ void MainView::windowCloseRequested() WebPage *webPage = qobject_cast(sender()); WebView *webView = qobject_cast(webPage->view()); int index = webViewIndex(webView); - if (index >= 0) + if (index >= 0) { if (count() == 1) webView->webPage()->mainWindow()->close(); @@ -466,7 +466,7 @@ void MainView::cloneTab(int index) if (index < 0 || index >= count()) return; WebView *tab = newTab(false); - tab->setUrl( webView(index)->url() ); + tab->setUrl(webView(index)->url()); showTabBar(); } @@ -481,16 +481,16 @@ void MainView::closeTab(int index) return; bool hasFocus = false; - if (WebView *tab = webView(index)) + if (WebView *tab = webView(index)) { - if (tab->isModified()) + if (tab->isModified()) { - int risp = KMessageBox::questionYesNo( this , - i18n("You have modified this page and when closing it you would lose the modification.\n" - "Do you really want to close this page?\n"), - i18n("Do you really want to close this page?"), - KStandardGuiItem::no() ); - if( risp == KMessageBox::No ) + int risp = KMessageBox::questionYesNo(this , + i18n("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n"), + i18n("Do you really want to close this page?"), + KStandardGuiItem::no()); + if (risp == KMessageBox::No) return; } hasFocus = tab->hasFocus(); @@ -520,9 +520,9 @@ void MainView::webViewLoadStarted() { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) + if (-1 != index) { - setTabIcon(index, KIcon("rekonq") ); + setTabIcon(index, KIcon("rekonq")); } } @@ -531,7 +531,7 @@ void MainView::webViewIconChanged() { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) + if (-1 != index) { QIcon icon = Application::instance()->icon(webView->url()); setTabIcon(index, icon); @@ -543,7 +543,8 @@ void MainView::webViewTitleChanged(const QString &title) { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) { + if (-1 != index) + { setTabText(index, title); } if (currentIndex() == index) @@ -556,7 +557,8 @@ void MainView::webViewUrlChanged(const QUrl &url) { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) { + if (-1 != index) + { m_tabBar->setTabData(index, url); } emit tabsChanged(); @@ -566,13 +568,13 @@ void MainView::webViewUrlChanged(const QUrl &url) void MainView::aboutToShowRecentTabsMenu() { m_recentlyClosedTabsMenu->clear(); - for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) + for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) { KAction *action = new KAction(m_recentlyClosedTabsMenu); action->setData(m_recentlyClosedTabs.at(i)); QIcon icon = Application::instance()->icon(m_recentlyClosedTabs.at(i)); action->setIcon(icon); - action->setText( m_recentlyClosedTabs.at(i).prettyUrl() ); + action->setText(m_recentlyClosedTabs.at(i).prettyUrl()); m_recentlyClosedTabsMenu->addAction(action); } } @@ -587,9 +589,9 @@ void MainView::aboutToShowRecentTriggeredAction(QAction *action) 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())) + if (!childAt(event->pos()) + // Remove the line below when QTabWidget does not have a one pixel frame + && event->pos().y() < (tabBar()->y() + tabBar()->height())) { newTab(); return; @@ -600,7 +602,8 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) void MainView::contextMenuEvent(QContextMenuEvent *event) { - if (!childAt(event->pos())) { + if (!childAt(event->pos())) + { m_tabBar->contextMenuRequested(event->pos()); return; } @@ -612,10 +615,10 @@ void MainView::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::MidButton && !childAt(event->pos()) // Remove the line below when QTabWidget does not have a one pixel frame - && event->pos().y() < (tabBar()->y() + tabBar()->height())) + && event->pos().y() < (tabBar()->y() + tabBar()->height())) { - KUrl url( QApplication::clipboard()->text(QClipboard::Selection) ); - if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) + KUrl url(QApplication::clipboard()->text(QClipboard::Selection)); + if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { WebView *webView = newTab(); webView->setUrl(url); -- cgit v1.2.1 From 0b151ba388d46c4112b4e861d45f0d8229c8a599 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 29 Mar 2009 08:04:31 +0200 Subject: API change (rename). In MainView, newTab --> newWebView --- src/mainview.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 4ab8dc8b..3c563230 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -61,7 +61,7 @@ MainView::MainView(QWidget *parent) { setTabBar(m_tabBar); - connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); + connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newWebView())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); @@ -317,7 +317,7 @@ WebView *MainView::webView(int index) const { MainView *that = const_cast(this); that->setUpdatesEnabled(false); - that->newTab(); + that->newWebView(); that->closeTab(0); that->setUpdatesEnabled(true); return currentWebView(); @@ -334,7 +334,7 @@ int MainView::webViewIndex(WebView *webView) const } -WebView *MainView::newTab(bool makeCurrent) +WebView *MainView::newWebView(bool makeCurrent) { // line edit UrlBar *urlLineEdit = new UrlBar; @@ -465,7 +465,7 @@ void MainView::cloneTab(int index) index = currentIndex(); if (index < 0 || index >= count()) return; - WebView *tab = newTab(false); + WebView *tab = newWebView(false); tab->setUrl(webView(index)->url()); showTabBar(); @@ -593,7 +593,7 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) // Remove the line below when QTabWidget does not have a one pixel frame && event->pos().y() < (tabBar()->y() + tabBar()->height())) { - newTab(); + newWebView(); return; } KTabWidget::mouseDoubleClickEvent(event); @@ -620,7 +620,7 @@ void MainView::mouseReleaseEvent(QMouseEvent *event) KUrl url(QApplication::clipboard()->text(QClipboard::Selection)); if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { - WebView *webView = newTab(); + WebView *webView = newWebView(); webView->setUrl(url); } } -- cgit v1.2.1 From b2303b6eed202ab3685b37be0552ab2c30498b0e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 5 Apr 2009 16:49:57 +0200 Subject: Fixed no/no close tab confirm messagebox --- src/mainview.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 3c563230..0c39e418 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -488,8 +488,8 @@ void MainView::closeTab(int index) int risp = KMessageBox::questionYesNo(this , i18n("You have modified this page and when closing it you would lose the modification.\n" "Do you really want to close this page?\n"), - i18n("Do you really want to close this page?"), - KStandardGuiItem::no()); + i18n("Do you really want to close this page?") + ); if (risp == KMessageBox::No) return; } @@ -516,6 +516,7 @@ void MainView::closeTab(int index) } +// FIXME void MainView::webViewLoadStarted() { WebView *webView = qobject_cast(sender()); -- cgit v1.2.1 From 87e45bf866e51193b8dad830ade347e06b8d497c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 5 Apr 2009 16:59:46 +0200 Subject: Modified loading icon displaying, from KDE icon to loading one.. --- src/mainview.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 0c39e418..70ce39fc 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -43,6 +43,7 @@ #include #include #include +#include // Qt Includes #include @@ -61,6 +62,9 @@ MainView::MainView(QWidget *parent) { setTabBar(m_tabBar); + loadingGitPath = KStandardDirs::locate("appdata" , "pics/loading.gif"); + kWarning() << loadingGitPath; + connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newWebView())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); @@ -523,7 +527,8 @@ void MainView::webViewLoadStarted() int index = webViewIndex(webView); if (-1 != index) { - setTabIcon(index, KIcon("rekonq")); +// setTabIcon(index, KIcon("rekonq")); + setTabIcon(index, QIcon(loadingGitPath)); } } -- cgit v1.2.1 From e1781ecb6ce807cf4afd991d16c55b1d9b5f8e58 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 5 Apr 2009 17:16:28 +0200 Subject: Compiles just with 4.5.. --- src/mainview.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 70ce39fc..1c1ee678 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -59,11 +59,11 @@ MainView::MainView(QWidget *parent) , m_lineEditCompleter(0) , m_lineEdits(new QStackedWidget(this)) , m_tabBar(new TabBar(this)) + , m_parent(parent) { setTabBar(m_tabBar); loadingGitPath = KStandardDirs::locate("appdata" , "pics/loading.gif"); - kWarning() << loadingGitPath; connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newWebView())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); @@ -81,6 +81,20 @@ MainView::MainView(QWidget *parent) m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); +// if (oneCloseButton) +// { +// QToolButton *closeTabButton = new QToolButton(this); +// closeTabButton->setDefaultAction(m_closeTabAction); +// closeTabButton->setAutoRaise(true); +// closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); +// setCornerWidget(closeTabButton, Qt::TopRightCorner); +// } +// else +// { +// m_tabBar->setTabsClosable(true); +// connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); +// } + // -- connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); } -- cgit v1.2.1 From 51a5174d280aedf3508c7f4339345370545906d8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 5 Apr 2009 17:30:51 +0200 Subject: tab bar refactoring --- src/mainview.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 1c1ee678..ac2355ce 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -59,7 +59,6 @@ MainView::MainView(QWidget *parent) , m_lineEditCompleter(0) , m_lineEdits(new QStackedWidget(this)) , m_tabBar(new TabBar(this)) - , m_parent(parent) { setTabBar(m_tabBar); @@ -81,19 +80,9 @@ MainView::MainView(QWidget *parent) m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); -// if (oneCloseButton) -// { -// QToolButton *closeTabButton = new QToolButton(this); -// closeTabButton->setDefaultAction(m_closeTabAction); -// closeTabButton->setAutoRaise(true); -// closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); -// setCornerWidget(closeTabButton, Qt::TopRightCorner); -// } -// else -// { -// m_tabBar->setTabsClosable(true); -// connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); -// } + // add close button to tab bar.. + m_tabBar->setTabsClosable(true); + connect(m_tabBar, SIGNAL(tabCloseRequested(int)),this, SLOT(closeTab(int))); // -- connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); @@ -493,6 +482,10 @@ void MainView::cloneTab(int index) // When index is -1 index chooses the current tab void MainView::closeTab(int index) { + // do nothing if just one tab is opened + if( count() == 1 ) + return; + if (index < 0) index = currentIndex(); if (index < 0 || index >= count()) -- cgit v1.2.1 From e337fe554e7944a29534417b9a52abc1e1c8c9b7 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 8 Apr 2009 11:53:32 +0200 Subject: Fixing tab focus on new tab loading. Removed unuseful commented code.. --- src/mainview.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index ac2355ce..907a7fe5 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -399,7 +399,10 @@ WebView *MainView::newWebView(bool makeCurrent) addTab(webView, i18n("(Untitled)")); if (makeCurrent) + { setCurrentWidget(webView); + currentLineEdit()->setFocus(Qt::ActiveWindowFocusReason); + } if (count() == 1) currentChanged(currentIndex()); @@ -534,7 +537,6 @@ void MainView::webViewLoadStarted() int index = webViewIndex(webView); if (-1 != index) { -// setTabIcon(index, KIcon("rekonq")); setTabIcon(index, QIcon(loadingGitPath)); } } -- cgit v1.2.1 From 32c978f48bbeb6f64b53103fd2bc79ca308bf878 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 8 Apr 2009 11:54:42 +0200 Subject: pedantic --- src/mainview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 907a7fe5..80738cfd 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -530,7 +530,7 @@ void MainView::closeTab(int index) } -// FIXME +// FIXME: provide movie for loading sites void MainView::webViewLoadStarted() { WebView *webView = qobject_cast(sender()); -- cgit v1.2.1 From 4de5fd991b2a797e8644c581db6fe41cc4791735 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 9 Apr 2009 18:46:46 +0200 Subject: Removed unuseful lasttabclosed signal in mainview. This becamed unuseful because of choose to do nothing if just 1 tab opened. --- src/mainview.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 80738cfd..604cb7cd 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -523,8 +523,6 @@ void MainView::closeTab(int index) emit tabsChanged(); if (hasFocus && count() > 0) currentWebView()->setFocus(); - if (count() == 0) - emit lastTabClosed(); showTabBar(); } -- cgit v1.2.1 From 6d37e632d445b51f5321b4138dcd1fce0cae30f9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 10 Apr 2009 18:57:01 +0200 Subject: Fixed webview API Removed some unuseful comments --- src/mainview.cpp | 55 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 22 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 604cb7cd..2ada96e0 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -65,12 +65,12 @@ MainView::MainView(QWidget *parent) loadingGitPath = KStandardDirs::locate("appdata" , "pics/loading.gif"); connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newWebView())); - connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); - connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); - connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); - connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); - connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); - connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); + 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))); + connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(slotReloadTab(int))); + connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(slotReloadAllTabs())); + connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(slotMoveTab(int, int))); // Recently Closed Tab Action m_recentlyClosedTabsMenu = new KMenu(this); @@ -82,10 +82,10 @@ MainView::MainView(QWidget *parent) // add close button to tab bar.. m_tabBar->setTabsClosable(true); - connect(m_tabBar, SIGNAL(tabCloseRequested(int)),this, SLOT(closeTab(int))); + connect(m_tabBar, SIGNAL(tabCloseRequested(int)),this, SLOT(slotCloseTab(int))); // -- - connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); } @@ -223,9 +223,9 @@ void MainView::clear() } -void MainView::moveTab(int fromIndex, int toIndex) +void MainView::slotMoveTab(int fromIndex, int toIndex) { - disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); QWidget *tabWidget = widget(fromIndex); QIcon icon = tabIcon(fromIndex); @@ -234,13 +234,13 @@ void MainView::moveTab(int fromIndex, int toIndex) removeTab(fromIndex); insertTab(toIndex, tabWidget, icon, text); m_tabBar->setTabData(toIndex, data); - connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); setCurrentIndex(toIndex); } // When index is -1 index chooses the current tab -void MainView::reloadTab(int index) +void MainView::slotReloadTab(int index) { if (index < 0) index = currentIndex(); @@ -253,7 +253,7 @@ void MainView::reloadTab(int index) } -void MainView::currentChanged(int index) +void MainView::slotCurrentChanged(int index) { WebView *webView = this->webView(index); if (!webView) @@ -265,7 +265,8 @@ void MainView::currentChanged(int index) if (oldWebView) { disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); - disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); + disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), + this, SIGNAL(linkHovered(const QString&))); disconnect(oldWebView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); } @@ -325,7 +326,7 @@ WebView *MainView::webView(int index) const MainView *that = const_cast(this); that->setUpdatesEnabled(false); that->newWebView(); - that->closeTab(0); + that->slotCloseTab(0); that->setUpdatesEnabled(true); return currentWebView(); } @@ -414,7 +415,7 @@ WebView *MainView::newWebView(bool makeCurrent) } -void MainView::reloadAllTabs() +void MainView::slotReloadAllTabs() { for (int i = 0; i < count(); ++i) { @@ -448,28 +449,38 @@ void MainView::windowCloseRequested() if (index >= 0) { if (count() == 1) + { webView->webPage()->mainWindow()->close(); + } else - closeTab(index); + { + slotCloseTab(index); + } } } -void MainView::closeOtherTabs(int index) +void MainView::slotCloseOtherTabs(int index) { if (-1 == index) return; + for (int i = count() - 1; i > index; --i) - closeTab(i); + { + slotCloseTab(i); + } + for (int i = index - 1; i >= 0; --i) - closeTab(i); + { + slotCloseTab(i); + } showTabBar(); } // When index is -1 index chooses the current tab -void MainView::cloneTab(int index) +void MainView::slotCloneTab(int index) { if (index < 0) index = currentIndex(); @@ -483,7 +494,7 @@ void MainView::cloneTab(int index) // When index is -1 index chooses the current tab -void MainView::closeTab(int index) +void MainView::slotCloseTab(int index) { // do nothing if just one tab is opened if( count() == 1 ) -- cgit v1.2.1 From 7e0bc7dab417bd01acd50a9a95f324e5b8e1d79a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 10 Apr 2009 19:11:54 +0200 Subject: new tab has to have focusgit st --- src/mainview.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 2ada96e0..eb2ae732 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -342,7 +342,7 @@ int MainView::webViewIndex(WebView *webView) const } -WebView *MainView::newWebView(bool makeCurrent) +WebView *MainView::newWebView() { // line edit UrlBar *urlLineEdit = new UrlBar; @@ -399,14 +399,15 @@ WebView *MainView::newWebView(bool makeCurrent) connect(webView, SIGNAL(shiftCtrlTabPressed()), this, SLOT(previousTab())); addTab(webView, i18n("(Untitled)")); - if (makeCurrent) - { - setCurrentWidget(webView); - currentLineEdit()->setFocus(Qt::ActiveWindowFocusReason); - } + setCurrentWidget(webView); + + // FIXME: focus on currentLineEdit just for empty pages + currentLineEdit()->setFocus(Qt::ActiveWindowFocusReason); if (count() == 1) + { currentChanged(currentIndex()); + } emit tabsChanged(); showTabBar(); @@ -486,7 +487,7 @@ void MainView::slotCloneTab(int index) index = currentIndex(); if (index < 0 || index >= count()) return; - WebView *tab = newWebView(false); + WebView *tab = newWebView(); tab->setUrl(webView(index)->url()); showTabBar(); -- cgit v1.2.1 From db4dbacd0b073fe561bf9f4da9b093f4be907afc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 10 Apr 2009 19:20:15 +0200 Subject: Fixed some wrong changes --- src/mainview.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index eb2ae732..65400ace 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -373,9 +373,9 @@ WebView *MainView::newWebView() p.setColor(QPalette::Window, palette().color(QPalette::Base)); emptyWidget->setPalette(p); emptyWidget->setAutoFillBackground(true); - disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); addTab(emptyWidget, i18n("(Untitled)")); - connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); return 0; } @@ -401,12 +401,15 @@ WebView *MainView::newWebView() addTab(webView, i18n("(Untitled)")); setCurrentWidget(webView); - // FIXME: focus on currentLineEdit just for empty pages - currentLineEdit()->setFocus(Qt::ActiveWindowFocusReason); + // focus on currentLineEdit just for empty pages + if(webView->url().isEmpty()) + { + currentLineEdit()->setFocus(Qt::ActiveWindowFocusReason); + } if (count() == 1) { - currentChanged(currentIndex()); + slotCurrentChanged(currentIndex()); } emit tabsChanged(); -- cgit v1.2.1 From ebc27b8734167c9aad4900d9baffd426556d1376 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 10 Apr 2009 19:38:30 +0200 Subject: Fixed tab moving, thanks to Qt 4.5 magic.. --- src/mainview.cpp | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 65400ace..c67d70a6 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -70,7 +70,6 @@ MainView::MainView(QWidget *parent) connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(slotCloseOtherTabs(int))); connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(slotReloadTab(int))); connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(slotReloadAllTabs())); - connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(slotMoveTab(int, int))); // Recently Closed Tab Action m_recentlyClosedTabsMenu = new KMenu(this); @@ -223,22 +222,6 @@ void MainView::clear() } -void MainView::slotMoveTab(int fromIndex, int toIndex) -{ - disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); - - QWidget *tabWidget = widget(fromIndex); - QIcon icon = tabIcon(fromIndex); - QString text = tabText(fromIndex); - QVariant data = m_tabBar->tabData(fromIndex); - removeTab(fromIndex); - insertTab(toIndex, tabWidget, icon, text); - m_tabBar->setTabData(toIndex, data); - connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); - setCurrentIndex(toIndex); -} - - // When index is -1 index chooses the current tab void MainView::slotReloadTab(int index) { -- cgit v1.2.1 From 3f6b179bb3004ee6d5df4e5039e90b7e5c53a8de Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 11 Apr 2009 19:10:28 +0200 Subject: Fixed lineEdits tabs movements (each site, its url..) --- src/mainview.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index c67d70a6..3b5db52e 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -70,6 +70,7 @@ MainView::MainView(QWidget *parent) connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(slotCloseOtherTabs(int))); connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(slotReloadTab(int))); connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(slotReloadAllTabs())); + connect(m_tabBar, SIGNAL(tabMoved(int,int)), this, SLOT(moveTab(int,int))); // Recently Closed Tab Action m_recentlyClosedTabsMenu = new KMenu(this); @@ -665,3 +666,12 @@ void MainView::previousTab() next = count() - 1; setCurrentIndex(next); } + + +void MainView::moveTab(int fromIndex, int toIndex) +{ + QWidget *lineEdit = m_lineEdits->widget(fromIndex); + m_lineEdits->removeWidget(lineEdit); + m_lineEdits->insertWidget(toIndex, lineEdit); +} + -- cgit v1.2.1 From 08380e9276505735f618a2a48de8d5de4807997f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 11 Apr 2009 19:32:21 +0200 Subject: Removed MainView events.. --- src/mainview.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 3b5db52e..14adaeda 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -599,46 +599,6 @@ void MainView::aboutToShowRecentTriggeredAction(QAction *action) } -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(); - return; - } - KTabWidget::mouseDoubleClickEvent(event); -} - - -void MainView::contextMenuEvent(QContextMenuEvent *event) -{ - if (!childAt(event->pos())) - { - m_tabBar->contextMenuRequested(event->pos()); - return; - } - KTabWidget::contextMenuEvent(event); -} - - -void MainView::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() == Qt::MidButton && !childAt(event->pos()) - // Remove the line below when QTabWidget does not have a one pixel frame - && event->pos().y() < (tabBar()->y() + tabBar()->height())) - { - KUrl url(QApplication::clipboard()->text(QClipboard::Selection)); - if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) - { - WebView *webView = newWebView(); - webView->setUrl(url); - } - } -} - - void MainView::loadUrlInCurrentTab(const KUrl &url) { WebView *webView = currentWebView(); -- cgit v1.2.1 From 6e40be23ae449bf5f4f5dc3babf936e9efe07594 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 11 Apr 2009 20:02:50 +0200 Subject: animated loading. Imported following (a bit) Arora code.. --- src/mainview.cpp | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 3b5db52e..6a7ed495 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -62,7 +62,7 @@ MainView::MainView(QWidget *parent) { setTabBar(m_tabBar); - loadingGitPath = KStandardDirs::locate("appdata" , "pics/loading.gif"); + 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))); @@ -527,14 +527,17 @@ void MainView::slotCloseTab(int index) } -// FIXME: provide movie for loading sites void MainView::webViewLoadStarted() { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); if (-1 != index) { - setTabIcon(index, QIcon(loadingGitPath)); + QLabel *label = animatedLoading(index); + if (label->movie()) + { + label->movie()->start(); + } } } @@ -546,7 +549,11 @@ void MainView::webViewIconChanged() if (-1 != index) { QIcon icon = Application::instance()->icon(webView->url()); - setTabIcon(index, icon); + QLabel *label = animatedLoading(index); + QMovie *movie = label->movie(); + delete movie; + label->setMovie(0); + label->setPixmap(icon.pixmap(16, 16)); } } @@ -675,3 +682,25 @@ void MainView::moveTab(int fromIndex, int toIndex) m_lineEdits->insertWidget(toIndex, lineEdit); } + +QLabel *MainView::animatedLoading(int index) +{ + if (index == -1) + return 0; + + QLabel *label = qobject_cast(m_tabBar->tabButton(index, QTabBar::LeftSide)); + if (!label) + { + label = new QLabel(this); + if (!label->movie()) + { + QMovie *movie = new QMovie(m_loadingGitPath, QByteArray(), label); + movie->setSpeed(50); + label->setMovie(movie); + movie->start(); + } + m_tabBar->setTabButton(index, QTabBar::LeftSide, 0); + m_tabBar->setTabButton(index, QTabBar::LeftSide, label); + } + return label; +} -- cgit v1.2.1 From 969eb157c5343eae7efefb7e48a843c4ec2180b8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 17 Apr 2009 14:24:35 +0200 Subject: set (Untitled) to untitled pages.. --- src/mainview.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 185d0a41..49fa237b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -560,15 +560,22 @@ void MainView::webViewIconChanged() void MainView::webViewTitleChanged(const QString &title) { + QString tabTitle = title; + if(title.isEmpty()) + { + tabTitle = i18n("(Untitled)"); + } WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); if (-1 != index) { - setTabText(index, title); + setTabText(index, tabTitle); } if (currentIndex() == index) - emit setCurrentTitle(title); - Application::historyManager()->updateHistoryItem(webView->url(), title); + { + emit setCurrentTitle(tabTitle); + } + Application::historyManager()->updateHistoryItem(webView->url(), tabTitle); } -- cgit v1.2.1 From 8dc9b31c5036707d8f011636d46e5411d57fd3ea Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 21 Apr 2009 23:47:08 +0200 Subject: Fixing (and updating) MainView code --- src/mainview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 49fa237b..245a2ff7 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -438,7 +438,7 @@ void MainView::windowCloseRequested() { if (count() == 1) { - webView->webPage()->mainWindow()->close(); + Application::instance()->mainWindow()->close(); } else { @@ -575,7 +575,7 @@ void MainView::webViewTitleChanged(const QString &title) { emit setCurrentTitle(tabTitle); } - Application::historyManager()->updateHistoryItem(webView->url(), tabTitle); + Application::historyManager()->updateHistoryEntry(webView->url(), tabTitle); } -- cgit v1.2.1 From 7557af13f9f904cb9a6240d2101fb14e1ffdca99 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 22 Apr 2009 01:33:28 +0200 Subject: Fixing Copyrights --- src/mainview.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 245a2ff7..a4966e7b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -2,7 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008 by Andrea Diamantini +* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2009 rekonq team. Please, see AUTHORS file for details * * * This program is free software; you can redistribute it -- cgit v1.2.1 From 2399843ceb70b45b2c1a47b680e11ba1e623ef45 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 25 Apr 2009 23:55:14 +0200 Subject: Another importing step. Need to fix cookies' classes and then (I think) we are near the goal.. --- src/mainview.cpp | 318 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 160 insertions(+), 158 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index a4966e7b..95d3565a 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -32,6 +32,7 @@ #include "application.h" #include "mainwindow.h" #include "history.h" +#include "stackedurlbar.h" #include "urlbar.h" #include "webview.h" @@ -56,9 +57,8 @@ MainView::MainView(QWidget *parent) : KTabWidget(parent) , m_recentlyClosedTabsAction(0) - , m_recentlyClosedTabsMenu(0) - , m_lineEditCompleter(0) - , m_lineEdits(new QStackedWidget(this)) + , m_recentlyClosedTabsMenu(new KMenu(this)) + , m_urlBars(new StackedUrlBar(this)) , m_tabBar(new TabBar(this)) { setTabBar(m_tabBar); @@ -74,17 +74,24 @@ MainView::MainView(QWidget *parent) connect(m_tabBar, SIGNAL(tabMoved(int,int)), this, SLOT(moveTab(int,int))); // Recently Closed Tab Action - m_recentlyClosedTabsMenu = new KMenu(this); connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); m_recentlyClosedTabsAction = new KAction(i18n("Recently Closed Tabs"), this); m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); - // add close button to tab bar.. - m_tabBar->setTabsClosable(true); + #if KDE_IS_VERSION(4,2,60) + setTabsClosable(true); // this causes #23 on KDE 4.2 + #else + setCloseButtonEnabled(oneCloseButton); // this is deprecated, remove + #endif + connect(m_tabBar, SIGNAL(tabCloseRequested(int)),this, SLOT(slotCloseTab(int))); + // -- + connect(this, SIGNAL(loadUrlPage(const KUrl &)), + this, SLOT(loadUrlInCurrentTab(const KUrl &))); + // -- connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); } @@ -92,16 +99,12 @@ MainView::MainView(QWidget *parent) MainView::~MainView() { - delete m_lineEditCompleter; - delete m_recentlyClosedTabsMenu; } void MainView::showTabBar() { - bool astb = ReKonfig::alwaysShowTabBar(); - - if (astb == true) + if ( ReKonfig::alwaysShowTabBar() ) { if (m_tabBar->isHidden()) { @@ -124,12 +127,6 @@ void MainView::showTabBar() } -KAction *MainView::recentlyClosedTabsAction() const -{ - return m_recentlyClosedTabsAction; -} - - void MainView::slotWebReload() { WebView *webView = currentWebView(); @@ -216,10 +213,11 @@ void MainView::clear() // clear the recently closed tabs m_recentlyClosedTabs.clear(); // clear the line edit history - for (int i = 0; i < m_lineEdits->count(); ++i) + for (int i = 0; i < m_urlBars->count(); ++i) { - QLineEdit *qLineEdit = lineEdit(i); - qLineEdit->setText(qLineEdit->text()); + /// TODO What exacly do we need to clear here? + urlBar(i)->clearHistory(); + urlBar(i)->clear(); } } @@ -244,15 +242,17 @@ void MainView::slotCurrentChanged(int index) if (!webView) return; - Q_ASSERT(m_lineEdits->count() == count()); + Q_ASSERT(m_urlBars->count() == count()); - WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); + WebView *oldWebView = this->webView(m_urlBars->currentIndex()); if (oldWebView) { - disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); + disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), + this, SIGNAL(showStatusBarMessage(const QString&))); disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); - disconnect(oldWebView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); + disconnect(oldWebView, SIGNAL(loadProgress(int)), + this, SIGNAL(loadProgress(int))); } connect(webView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); @@ -260,7 +260,7 @@ void MainView::slotCurrentChanged(int index) connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); emit setCurrentTitle(webView->title()); - m_lineEdits->setCurrentIndex(index); + m_urlBars->setCurrentIndex(index); emit loadProgress(webView->progress()); emit showStatusBarMessage(webView->lastStatusBarText()); @@ -269,30 +269,19 @@ void MainView::slotCurrentChanged(int index) } -QWidget *MainView::lineEditStack() const -{ - return m_lineEdits; -} - - -QLineEdit *MainView::currentLineEdit() const +UrlBar *MainView::urlBar(int index) const { - return lineEdit(m_lineEdits->currentIndex()); -} - - -WebView *MainView::currentWebView() const -{ - return webView(currentIndex()); -} - - -QLineEdit *MainView::lineEdit(int index) const -{ - UrlBar *urlLineEdit = qobject_cast(m_lineEdits->widget(index)); - if (urlLineEdit) - return urlLineEdit->lineEdit(); - return 0; + if (index == -1) + { + index = m_urlBars->currentIndex(); + } + UrlBar *urlBar = m_urlBars->urlBar(index); + if (urlBar) + { + return urlBar; + } + kWarning() << "URL bar with index" << index << "not found. Returning NULL. (line:" << __LINE__ << ")"; + return NULL; } @@ -303,99 +292,59 @@ WebView *MainView::webView(int index) const { return webView; } - else - { - // optimization to delay creating the first webview - if (count() == 1) - { - MainView *that = const_cast(this); - that->setUpdatesEnabled(false); - that->newWebView(); - that->slotCloseTab(0); - that->setUpdatesEnabled(true); - return currentWebView(); - } - } - return 0; -} - -int MainView::webViewIndex(WebView *webView) const -{ - int index = indexOf(webView); - return index; + kWarning() << "WebView with index " << index << "not found. Returning NULL." ; + return 0; } -WebView *MainView::newWebView() +WebView *MainView::newWebView(bool makeCurrent) { // line edit - UrlBar *urlLineEdit = new UrlBar; - QLineEdit *lineEdit = urlLineEdit->lineEdit(); - if (!m_lineEditCompleter && count() > 0) - { - HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); - completionModel->setSourceModel(Application::historyManager()->historyFilterModel()); - m_lineEditCompleter = new QCompleter(completionModel, this); - // Should this be in Qt by default? - QAbstractItemView *popup = m_lineEditCompleter->popup(); - QListView *listView = qobject_cast(popup); - if (listView) - { - listView->setUniformItemSizes(true); - } - } - lineEdit->setCompleter(m_lineEditCompleter); - connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed())); - m_lineEdits->addWidget(urlLineEdit); - m_lineEdits->setSizePolicy(lineEdit->sizePolicy()); - - // optimization to delay creating the more expensive WebView, history, etc - if (count() == 0) - { - QWidget *emptyWidget = new QWidget; - QPalette p = emptyWidget->palette(); - p.setColor(QPalette::Window, palette().color(QPalette::Base)); - emptyWidget->setPalette(p); - emptyWidget->setAutoFillBackground(true); - disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); - addTab(emptyWidget, i18n("(Untitled)")); - connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); - return 0; - } - - // webview - WebView *webView = new WebView; - urlLineEdit->setWebView(webView); - + 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&))); + 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(loadFinished(bool)), this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(loadProgress(int)), this, SLOT(webViewLoadProgress(int))); + connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewLoadFinished(bool))); connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); connect(webView, SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &))); connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &))); - connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); - 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)), this, SIGNAL(menuBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); connect(webView, SIGNAL(ctrlTabPressed()), this, SLOT(nextTab())); connect(webView, SIGNAL(shiftCtrlTabPressed()), this, SLOT(previousTab())); + // connecting webPage signals with mainview + connect(webView->page(), SIGNAL(windowCloseRequested()), + this, SLOT(windowCloseRequested())); + 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)), + this, SIGNAL(menuBarVisibilityChangeRequested(bool))); + connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), + this, SIGNAL(statusBarVisibilityChangeRequested(bool))); + connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), + this, SIGNAL(toolBarVisibilityChangeRequested(bool))); + addTab(webView, i18n("(Untitled)")); - setCurrentWidget(webView); - // focus on currentLineEdit just for empty pages - if(webView->url().isEmpty()) + if (makeCurrent) { - currentLineEdit()->setFocus(Qt::ActiveWindowFocusReason); + setCurrentWidget(webView); // this method does NOT take owneship of webView } - if (count() == 1) - { - slotCurrentChanged(currentIndex()); - } emit tabsChanged(); showTabBar(); @@ -417,19 +366,6 @@ void MainView::slotReloadAllTabs() } -void MainView::lineEditReturnPressed() -{ - if (QLineEdit *lineEdit = qobject_cast(sender())) - { - emit loadUrlPage(KUrl(lineEdit->text())); - if (m_lineEdits->currentWidget() == lineEdit) - { - currentWebView()->setFocus(); - } - } -} - - void MainView::windowCloseRequested() { WebPage *webPage = qobject_cast(sender()); @@ -500,10 +436,10 @@ void MainView::slotCloseTab(int index) if (tab->isModified()) { int risp = KMessageBox::questionYesNo(this , - i18n("You have modified this page and when closing it you would lose the modification.\n" - "Do you really want to close this page?\n"), - i18n("Do you really want to close this page?") - ); + i18n("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n"), + i18n("Do you really want to close this page?") + ); if (risp == KMessageBox::No) return; } @@ -511,18 +447,33 @@ void MainView::slotCloseTab(int index) m_recentlyClosedTabsAction->setEnabled(true); m_recentlyClosedTabs.prepend(tab->url()); + + // don't add empty urls + if (tab->url().isValid()) + { + m_recentlyClosedTabs.prepend(tab->url()); + } + if (m_recentlyClosedTabs.size() >= MainView::m_recentlyClosedTabsSize) + { m_recentlyClosedTabs.removeLast(); + } } - QWidget *lineEdit = m_lineEdits->widget(index); - m_lineEdits->removeWidget(lineEdit); - lineEdit->deleteLater(); + + QWidget *urlBar = m_urlBars->urlBar(index); + m_urlBars->removeWidget(urlBar); + urlBar->deleteLater(); // urlBar is scheduled for deletion. + QWidget *webView = widget(index); removeTab(index); - webView->deleteLater(); + webView->deleteLater(); // webView is scheduled for deletion. + emit tabsChanged(); + if (hasFocus && count() > 0) + { currentWebView()->setFocus(); + } showTabBar(); } @@ -532,14 +483,64 @@ void MainView::webViewLoadStarted() { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); + kWarning() << "Here.. index = " << index; if (-1 != index) { - QLabel *label = animatedLoading(index); + QLabel *label = animatedLoading(index, true); if (label->movie()) { label->movie()->start(); } } + + if (index != currentIndex()) + return; + + emit showStatusBarMessage(i18n("Loading...")); +} + + +void MainView::webViewLoadProgress(int progress) +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (index != currentIndex() || index < 0) + { + return; + } + + double totalBytes = static_cast(webView->webPage()->totalBytes() / 1024); + + QString message = i18n("Loading %1% (%2 %3)...", progress, totalBytes, QLatin1String("kB") ); + emit showStatusBarMessage(message); +} + + +void MainView::webViewLoadFinished(bool ok) +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + + if (-1 != index) + { + QLabel *label = animatedLoading(index, true); + QMovie *movie = label->movie(); + if(movie) + movie->stop(); + } + + webViewIconChanged(); + + // don't display messages for background tabs + if (index != currentIndex()) + { + return; + } + + if (ok) + emit showStatusBarMessage(i18n("Done")); + else + emit showStatusBarMessage(i18n("Failed to load")); } @@ -550,7 +551,7 @@ void MainView::webViewIconChanged() if (-1 != index) { QIcon icon = Application::instance()->icon(webView->url()); - QLabel *label = animatedLoading(index); + QLabel *label = animatedLoading(index, false); QMovie *movie = label->movie(); delete movie; label->setMovie(0); @@ -645,13 +646,13 @@ void MainView::previousTab() void MainView::moveTab(int fromIndex, int toIndex) { - QWidget *lineEdit = m_lineEdits->widget(fromIndex); - m_lineEdits->removeWidget(lineEdit); - m_lineEdits->insertWidget(toIndex, lineEdit); + QWidget *lineEdit = m_urlBars->widget(fromIndex); + m_urlBars->removeWidget(lineEdit); + m_urlBars->insertWidget(toIndex, lineEdit); } -QLabel *MainView::animatedLoading(int index) +QLabel *MainView::animatedLoading(int index, bool addMovie) { if (index == -1) return 0; @@ -660,15 +661,16 @@ QLabel *MainView::animatedLoading(int index) if (!label) { label = new QLabel(this); - if (!label->movie()) - { - QMovie *movie = new QMovie(m_loadingGitPath, QByteArray(), label); - movie->setSpeed(50); - label->setMovie(movie); - movie->start(); - } - m_tabBar->setTabButton(index, QTabBar::LeftSide, 0); - m_tabBar->setTabButton(index, QTabBar::LeftSide, label); } + if (addMovie && !label->movie()) + { + QMovie *movie = new QMovie(m_loadingGitPath, QByteArray(), label); + movie->setSpeed(50); + label->setMovie(movie); + movie->start(); + } + m_tabBar->setTabButton(index, QTabBar::LeftSide, 0); + m_tabBar->setTabButton(index, QTabBar::LeftSide, label); return label; } + -- cgit v1.2.1 From 4089c665cb907c48dfd45c088313a08d9ac4e7fb Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 26 Apr 2009 00:00:32 +0200 Subject: Fixed 4.2 compiling --- src/mainview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 95d3565a..accc4d16 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -83,7 +83,7 @@ MainView::MainView(QWidget *parent) #if KDE_IS_VERSION(4,2,60) setTabsClosable(true); // this causes #23 on KDE 4.2 #else - setCloseButtonEnabled(oneCloseButton); // this is deprecated, remove + setCloseButtonEnabled(true); // this is deprecated, remove #endif connect(m_tabBar, SIGNAL(tabCloseRequested(int)),this, SLOT(slotCloseTab(int))); -- cgit v1.2.1 From e657ef44ef1eef1f998101ab3dcce1a251d729fc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 26 Apr 2009 01:45:38 +0200 Subject: Fixed copyright strings, per file, as decided --- src/mainview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index accc4d16..470a7e06 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -2,8 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 rekonq team. Please, see AUTHORS file for details +* Copyright (C) 2008 by Andrea Diamantini +* Copyright (C) 2009 by Paweł Prażak * * * This program is free software; you can redistribute it -- cgit v1.2.1 From 242ce9ca556de1aa5355a24bfd6855dfa9a39e4f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 26 Apr 2009 11:55:45 +0200 Subject: mainview fixes --- src/mainview.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 470a7e06..2e30aa58 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -80,19 +80,17 @@ MainView::MainView(QWidget *parent) m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); + #if QT_VERSION >= 0x040500 + connect(m_tabBar, SIGNAL(closeRequest(int)), this, SLOT(closeTab(int))); #if KDE_IS_VERSION(4,2,60) setTabsClosable(true); // this causes #23 on KDE 4.2 #else - setCloseButtonEnabled(true); // this is deprecated, remove + setCloseButtonEnabled(true); // this is deprecated, remove for KDE >=4.3 + #endif #endif - - connect(m_tabBar, SIGNAL(tabCloseRequested(int)),this, SLOT(slotCloseTab(int))); - - // -- - connect(this, SIGNAL(loadUrlPage(const KUrl &)), - this, SLOT(loadUrlInCurrentTab(const KUrl &))); // -- + connect(this, SIGNAL(loadUrlPage(const KUrl &)), this, SLOT(loadUrlInCurrentTab(const KUrl &))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); } -- cgit v1.2.1 From 3ebb8cca124d70c5565656b26060892de551a880 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 26 Apr 2009 12:31:32 +0200 Subject: Removed KDE VERSION check. tabbar needs some love.. --- src/mainview.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 2e30aa58..865ffab2 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -80,18 +80,12 @@ MainView::MainView(QWidget *parent) m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); - #if QT_VERSION >= 0x040500 - connect(m_tabBar, SIGNAL(closeRequest(int)), this, SLOT(closeTab(int))); - #if KDE_IS_VERSION(4,2,60) - setTabsClosable(true); // this causes #23 on KDE 4.2 - #else - setCloseButtonEnabled(true); // this is deprecated, remove for KDE >=4.3 - #endif - #endif - // -- connect(this, SIGNAL(loadUrlPage(const KUrl &)), this, SLOT(loadUrlInCurrentTab(const KUrl &))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); + + setTabsClosable(true); + connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(slotCloseTab(int))); } @@ -366,9 +360,11 @@ void MainView::slotReloadAllTabs() void MainView::windowCloseRequested() { + WebPage *webPage = qobject_cast(sender()); WebView *webView = qobject_cast(webPage->view()); int index = webViewIndex(webView); + if (index >= 0) { if (count() == 1) @@ -380,6 +376,10 @@ void MainView::windowCloseRequested() slotCloseTab(index); } } + else + { + kWarning() << "Invalid tab index" << "line:" << __LINE__; + } } @@ -419,6 +419,7 @@ void MainView::slotCloneTab(int index) // When index is -1 index chooses the current tab void MainView::slotCloseTab(int index) { + kWarning() << "Index: " << index; // do nothing if just one tab is opened if( count() == 1 ) return; -- cgit v1.2.1 From fdbd70a77a8c294e0a578073c738f3bc4dfa6ab5 Mon Sep 17 00:00:00 2001 From: Alexandr Domrachev Date: Mon, 27 Apr 2009 17:05:43 +0000 Subject: Some changes ported for merge to mainline (bookmarks & links handling related) Added author: me :) Bookmark owner: openFolderinTabs implemented Links handling ported from Pawel branch Issue #1 fixed --- src/mainview.cpp | 83 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 26 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 865ffab2..9449a9c5 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -81,9 +81,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))); } @@ -239,16 +244,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 +301,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 +324,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 +514,9 @@ void MainView::webViewLoadProgress(int progress) { return; } - + double totalBytes = static_cast(webView->webPage()->totalBytes() / 1024); - + QString message = i18n("Loading %1% (%2 %3)...", progress, totalBytes, QLatin1String("kB") ); emit showStatusBarMessage(message); } @@ -519,7 +526,7 @@ void MainView::webViewLoadFinished(bool ok) { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - + if (-1 != index) { QLabel *label = animatedLoading(index, true); @@ -527,7 +534,7 @@ void MainView::webViewLoadFinished(bool ok) if(movie) movie->stop(); } - + webViewIconChanged(); // don't display messages for background tabs @@ -535,7 +542,7 @@ void MainView::webViewLoadFinished(bool ok) { return; } - + if (ok) emit showStatusBarMessage(i18n("Done")); else @@ -610,21 +617,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 +688,7 @@ QLabel *MainView::animatedLoading(int index, bool addMovie) return 0; QLabel *label = qobject_cast(m_tabBar->tabButton(index, QTabBar::LeftSide)); - if (!label) + if (!label) { label = new QLabel(this); } -- cgit v1.2.1 From 78aef384a57bca278bdd4484e9b31bbd7b88c98e Mon Sep 17 00:00:00 2001 From: Alexandr Domrachev Date: Mon, 27 Apr 2009 18:01:41 +0000 Subject: TabBar code clean. Icons added to context menu --- src/mainview.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 9449a9c5..8cf09e2a 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))); -- cgit v1.2.1 From 61172b031c59d7f78447d224963b1333ce1d92bd Mon Sep 17 00:00:00 2001 From: Alexandr Domrachev Date: Mon, 27 Apr 2009 18:05:39 +0000 Subject: Open new tab on TabBar double click --- src/mainview.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 8cf09e2a..dc614f5c 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -218,6 +218,19 @@ 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); +} + + // When index is -1 index chooses the current tab void MainView::slotReloadTab(int index) { -- cgit v1.2.1 From 2382db2c27728214cb9645fee3ef49222ca8dcd5 Mon Sep 17 00:00:00 2001 From: Alexandr Domrachev Date: Mon, 27 Apr 2009 18:42:51 +0000 Subject: TabBar context menu fix ported --- src/mainview.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index dc614f5c..c3818b50 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -231,6 +231,16 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *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) { -- cgit v1.2.1 From 32da13f039241349c894f5c13cc1954c16c2e783 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 28 Apr 2009 03:19:14 +0200 Subject: Revert "Some changes ported for merge to mainline (bookmarks & links handling related)" links hadling problem This reverts commit fdbd70a77a8c294e0a578073c738f3bc4dfa6ab5. --- src/mainview.cpp | 83 ++++++++++++++++++-------------------------------------- 1 file changed, 26 insertions(+), 57 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index c3818b50..cbfd418b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -80,14 +80,9 @@ 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))); } @@ -266,18 +261,16 @@ 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()); @@ -323,17 +316,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(openUrl(const KUrl &))); + connect(urlBar, SIGNAL(activated(const KUrl&)), this, SLOT(loadUrlInCurrentTab(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))); @@ -346,17 +339,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)")); @@ -536,9 +529,9 @@ void MainView::webViewLoadProgress(int progress) { return; } - + double totalBytes = static_cast(webView->webPage()->totalBytes() / 1024); - + QString message = i18n("Loading %1% (%2 %3)...", progress, totalBytes, QLatin1String("kB") ); emit showStatusBarMessage(message); } @@ -548,7 +541,7 @@ void MainView::webViewLoadFinished(bool ok) { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - + if (-1 != index) { QLabel *label = animatedLoading(index, true); @@ -556,7 +549,7 @@ void MainView::webViewLoadFinished(bool ok) if(movie) movie->stop(); } - + webViewIconChanged(); // don't display messages for background tabs @@ -564,7 +557,7 @@ void MainView::webViewLoadFinished(bool ok) { return; } - + if (ok) emit showStatusBarMessage(i18n("Done")); else @@ -639,45 +632,21 @@ void MainView::aboutToShowRecentTabsMenu() void MainView::aboutToShowRecentTriggeredAction(QAction *action) { KUrl url = action->data().toUrl(); - openUrl(url, Rekonq::Current); + loadUrlInCurrentTab(url); } -void MainView::openUrl(const KUrl& url, Rekonq::OpenType type) +void MainView::loadUrlInCurrentTab(const KUrl &url) { - kDebug() << "sender:" << sender() << " line:" << __LINE__; - - if (url.isEmpty()) - { - 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) + WebView *webView = currentWebView(); + if (webView) { - kWarning() << "Can't find the view" << "line:" << __LINE__; - return; + webView->loadUrl(url); + webView->setFocus(); } - webView->loadUrl(url); - webView->setFocus(); - - currentUrlBar()->setUrl(url.prettyUrl()); } -void MainView::loadUrlInCurrentTab(const KUrl &url) -{ - openUrl(url); -} - void MainView::nextTab() { int next = currentIndex() + 1; @@ -710,7 +679,7 @@ QLabel *MainView::animatedLoading(int index, bool addMovie) return 0; QLabel *label = qobject_cast(m_tabBar->tabButton(index, QTabBar::LeftSide)); - if (!label) + if (!label) { label = new QLabel(this); } -- cgit v1.2.1 From b71a1e3f03808450ad9b4474b2098e637e99e14e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 28 Apr 2009 19:07:47 +0200 Subject: Faster Mainview load --- src/mainview.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index cbfd418b..e4958919 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -61,10 +61,13 @@ MainView::MainView(QWidget *parent) , m_urlBars(new StackedUrlBar(this)) , m_tabBar(new TabBar(this)) { + // setting tabbar setTabBar(m_tabBar); - + + // loading pixmap path m_loadingGitPath = KStandardDirs::locate("appdata" , "pics/loading.gif"); + // connecting tabbar signals 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))); @@ -72,19 +75,14 @@ MainView::MainView(QWidget *parent) connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(slotReloadAllTabs())); connect(m_tabBar, SIGNAL(tabMoved(int,int)), this, SLOT(moveTab(int,int))); - // Recently Closed Tab Action - connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); - connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); - m_recentlyClosedTabsAction = new KAction(i18n("Recently Closed Tabs"), this); - m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); - m_recentlyClosedTabsAction->setEnabled(false); - // -- connect(this, SIGNAL(loadUrlPage(const KUrl &)), this, SLOT(loadUrlInCurrentTab(const KUrl &))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); setTabsClosable(true); connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(slotCloseTab(int))); + + QTimer::singleShot(0, this, SLOT(postLaunch())); } @@ -93,6 +91,16 @@ MainView::~MainView() } +void MainView::postLaunch() +{ + // Recently Closed Tab Action + connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); + connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); + m_recentlyClosedTabsAction = new KAction(i18n("Recently Closed Tabs"), this); + m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); + m_recentlyClosedTabsAction->setEnabled(false); +} + void MainView::showTabBar() { if ( ReKonfig::alwaysShowTabBar() ) -- cgit v1.2.1 From 4c3f484e1f697d93877db5425fb6ac6e6cab40a2 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 28 Apr 2009 19:15:42 +0200 Subject: Removed Qt4.4 compatibility slots --- src/mainview.cpp | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index e4958919..8f96637d 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -221,29 +221,6 @@ 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) { -- cgit v1.2.1 From b60da9d6300097f31d163e86e2d689e9b2bc7cb6 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 29 Apr 2009 00:52:52 +0200 Subject: Removed unused MainView loadUrlPage signal --- src/mainview.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 8f96637d..7a7b36b3 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -75,8 +75,7 @@ MainView::MainView(QWidget *parent) connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(slotReloadAllTabs())); connect(m_tabBar, SIGNAL(tabMoved(int,int)), this, SLOT(moveTab(int,int))); - // -- - connect(this, SIGNAL(loadUrlPage(const KUrl &)), this, SLOT(loadUrlInCurrentTab(const KUrl &))); + // current page index changing connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); setTabsClosable(true); -- cgit v1.2.1 From 7a35bdc75a549a617bb3d8440a9a96f551bc26a2 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 29 Apr 2009 01:11:58 +0200 Subject: mainview loadurlinCurrentTab improvements --- src/mainview.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 7a7b36b3..ed09def9 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -623,9 +623,19 @@ void MainView::aboutToShowRecentTriggeredAction(QAction *action) void MainView::loadUrlInCurrentTab(const KUrl &url) { WebView *webView = currentWebView(); + + KUrl loadingUrl(url); + + if (loadingUrl.isRelative()) + { + QString fn = loadingUrl.url(KUrl::RemoveTrailingSlash); + loadingUrl.setUrl("//" + fn); + loadingUrl.setScheme("http"); + } + if (webView) { - webView->loadUrl(url); + webView->load(loadingUrl); webView->setFocus(); } } -- cgit v1.2.1 From 5fb7d909e87be4ea5a07b7a29271c96b7db4a9b3 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 29 Apr 2009 01:41:58 +0200 Subject: Fixed loading Url methods. Now in all rekonq code we have just a loadUrl method in mainview (doing the dirty job) and one in mainwindow, provided for convenience. Every class needing loading an url has a openUrl signal. Hope this should go well.. --- src/mainview.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index ed09def9..df42a340 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -300,7 +300,7 @@ 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(loadUrl(const KUrl&))); m_urlBars->addUrlBar(urlBar); WebView *webView = new WebView; // should be deleted on tab close @@ -616,12 +616,17 @@ void MainView::aboutToShowRecentTabsMenu() void MainView::aboutToShowRecentTriggeredAction(QAction *action) { KUrl url = action->data().toUrl(); - loadUrlInCurrentTab(url); + loadUrl(url); } -void MainView::loadUrlInCurrentTab(const KUrl &url) +void MainView::loadUrl(const KUrl &url) { + if (url.isEmpty()) + return; + + currentUrlBar()->setUrl(url.prettyUrl()); + WebView *webView = currentWebView(); KUrl loadingUrl(url); -- cgit v1.2.1 From 82862fbd150afae0101757d1d6081e0e6ddf7baa Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 29 Apr 2009 11:24:11 +0200 Subject: astyle --- src/mainview.cpp | 66 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index df42a340..274d15de 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -63,7 +63,7 @@ MainView::MainView(QWidget *parent) { // setting tabbar setTabBar(m_tabBar); - + // loading pixmap path m_loadingGitPath = KStandardDirs::locate("appdata" , "pics/loading.gif"); @@ -73,7 +73,7 @@ MainView::MainView(QWidget *parent) connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(slotCloseOtherTabs(int))); connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(slotReloadTab(int))); connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(slotReloadAllTabs())); - connect(m_tabBar, SIGNAL(tabMoved(int,int)), this, SLOT(moveTab(int,int))); + connect(m_tabBar, SIGNAL(tabMoved(int, int)), this, SLOT(moveTab(int, int))); // current page index changing connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); @@ -102,7 +102,7 @@ void MainView::postLaunch() void MainView::showTabBar() { - if ( ReKonfig::alwaysShowTabBar() ) + if (ReKonfig::alwaysShowTabBar()) { if (m_tabBar->isHidden()) { @@ -245,12 +245,12 @@ void MainView::slotCurrentChanged(int index) WebView *oldWebView = this->webView(m_urlBars->currentIndex()); if (oldWebView) { - disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), - this, SIGNAL(showStatusBarMessage(const QString&))); - disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), - this, SIGNAL(linkHovered(const QString&))); - disconnect(oldWebView, SIGNAL(loadProgress(int)), - this, SIGNAL(loadProgress(int))); + disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), + this, SIGNAL(showStatusBarMessage(const QString&))); + disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), + this, SIGNAL(linkHovered(const QString&))); + disconnect(oldWebView, SIGNAL(loadProgress(int)), + this, SIGNAL(loadProgress(int))); } connect(webView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); @@ -304,13 +304,13 @@ WebView *MainView::newWebView(bool makeCurrent) 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))); @@ -323,17 +323,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)")); @@ -427,7 +427,7 @@ void MainView::slotCloseTab(int index) { kWarning() << "Index: " << index; // do nothing if just one tab is opened - if( count() == 1 ) + if (count() == 1) return; if (index < 0) @@ -441,10 +441,10 @@ void MainView::slotCloseTab(int index) if (tab->isModified()) { int risp = KMessageBox::questionYesNo(this , - i18n("You have modified this page and when closing it you would lose the modification.\n" - "Do you really want to close this page?\n"), - i18n("Do you really want to close this page?") - ); + i18n("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n"), + i18n("Do you really want to close this page?") + ); if (risp == KMessageBox::No) return; } @@ -499,7 +499,7 @@ void MainView::webViewLoadStarted() } if (index != currentIndex()) - return; + return; emit showStatusBarMessage(i18n("Loading...")); } @@ -513,10 +513,10 @@ void MainView::webViewLoadProgress(int progress) { return; } - + double totalBytes = static_cast(webView->webPage()->totalBytes() / 1024); - - QString message = i18n("Loading %1% (%2 %3)...", progress, totalBytes, QLatin1String("kB") ); + + QString message = i18n("Loading %1% (%2 %3)...", progress, totalBytes, QLatin1String("kB")); emit showStatusBarMessage(message); } @@ -525,15 +525,15 @@ void MainView::webViewLoadFinished(bool ok) { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - - if (-1 != index) + + if (-1 != index) { QLabel *label = animatedLoading(index, true); QMovie *movie = label->movie(); - if(movie) + if (movie) movie->stop(); } - + webViewIconChanged(); // don't display messages for background tabs @@ -541,7 +541,7 @@ void MainView::webViewLoadFinished(bool ok) { return; } - + if (ok) emit showStatusBarMessage(i18n("Done")); else @@ -568,7 +568,7 @@ void MainView::webViewIconChanged() void MainView::webViewTitleChanged(const QString &title) { QString tabTitle = title; - if(title.isEmpty()) + if (title.isEmpty()) { tabTitle = i18n("(Untitled)"); } @@ -622,7 +622,7 @@ void MainView::aboutToShowRecentTriggeredAction(QAction *action) void MainView::loadUrl(const KUrl &url) { - if (url.isEmpty()) + if (url.isEmpty()) return; currentUrlBar()->setUrl(url.prettyUrl()); @@ -678,7 +678,7 @@ QLabel *MainView::animatedLoading(int index, bool addMovie) return 0; QLabel *label = qobject_cast(m_tabBar->tabButton(index, QTabBar::LeftSide)); - if (!label) + if (!label) { label = new QLabel(this); } -- cgit v1.2.1 From 2c9ea8dd8a766c1518d2d09e711bde3d7e52270e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 1 May 2009 01:44:22 +0200 Subject: i18n plural bugs. Courtesy patch of Kristol Baf --- src/mainview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 274d15de..bb016872 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -340,7 +340,7 @@ WebView *MainView::newWebView(bool makeCurrent) if (makeCurrent) { - setCurrentWidget(webView); // this method does NOT take owneship of webView + setCurrentWidget(webView); // this method does NOT take ownership of webView } emit tabsChanged(); -- cgit v1.2.1 From 070aabd69a693acefb8fbd152c467bace3600a67 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 1 May 2009 01:58:29 +0200 Subject: mouseDoubleClickEvent return, as decided with Avaddon --- src/mainview.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index bb016872..d6b86452 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -694,3 +694,13 @@ QLabel *MainView::animatedLoading(int index, bool addMovie) return label; } + +void MainView::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (!childAt(event->pos())) + { + newWebView(true); + return; + } + KTabWidget::mouseDoubleClickEvent(event); +} \ No newline at end of file -- cgit v1.2.1 From 3ec7985aaa24d522c27f41b5bcc6063c02da66ff Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 1 May 2009 02:13:27 +0200 Subject: setting focus to urlbar on empty tab opened. Some kwarning removal --- src/mainview.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index d6b86452..d8375ab8 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -341,6 +341,7 @@ WebView *MainView::newWebView(bool makeCurrent) if (makeCurrent) { setCurrentWidget(webView); // this method does NOT take ownership of webView + urlBar->setFocus(); } emit tabsChanged(); @@ -425,7 +426,6 @@ void MainView::slotCloneTab(int index) // When index is -1 index chooses the current tab void MainView::slotCloseTab(int index) { - kWarning() << "Index: " << index; // do nothing if just one tab is opened if (count() == 1) return; @@ -488,7 +488,6 @@ void MainView::webViewLoadStarted() { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - kWarning() << "Here.. index = " << index; if (-1 != index) { QLabel *label = animatedLoading(index, true); -- cgit v1.2.1 From 55816b45e681f10c9b45675dba65575d01d9efe3 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 1 May 2009 03:20:42 +0200 Subject: Managing user tab open settings. Step 2 --- src/mainview.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index d8375ab8..9dbf800b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -296,7 +296,7 @@ WebView *MainView::webView(int index) const } -WebView *MainView::newWebView(bool makeCurrent) +WebView *MainView::newWebView(Rekonq::OpenType type) { // line edit UrlBar *urlBar = new UrlBar; // Ownership of widget is passed on to the QStackedWidget (addWidget method). @@ -338,11 +338,22 @@ WebView *MainView::newWebView(bool makeCurrent) addTab(webView, i18n("(Untitled)")); - if (makeCurrent) + switch(type) { + case Rekonq::Default: + if (makeTabCurrent) + { + setCurrentWidget(webView); // this method does NOT take ownership of webView + urlBar->setFocus(); + } + break; + case Rekonq::New: setCurrentWidget(webView); // this method does NOT take ownership of webView urlBar->setFocus(); - } + break; + case Rekonq::Background: + break; + }; emit tabsChanged(); @@ -698,7 +709,7 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) { if (!childAt(event->pos())) { - newWebView(true); + newWebView(Rekonq::New); return; } KTabWidget::mouseDoubleClickEvent(event); -- cgit v1.2.1 From 0d324ed688eda0e1f172353d33ca33731b8f6764 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 2 May 2009 02:32:34 +0200 Subject: Open Back/Forward tabs fixed --- src/mainview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 9dbf800b..d4edeb19 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -341,7 +341,7 @@ WebView *MainView::newWebView(Rekonq::OpenType type) switch(type) { case Rekonq::Default: - if (makeTabCurrent) + if (!m_makeBackTab) { setCurrentWidget(webView); // this method does NOT take ownership of webView urlBar->setFocus(); -- cgit v1.2.1 From 06b2dc0ce6ec6dd4cb090c22e2f9f8521138146b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 6 May 2009 03:09:23 +0200 Subject: EBN Krazy fixes. 1st round.. --- src/mainview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index d4edeb19..5432fa51 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -213,7 +213,7 @@ void MainView::clear() // clear the line edit history for (int i = 0; i < m_urlBars->count(); ++i) { - /// TODO What exacly do we need to clear here? + /// TODO What exactly do we need to clear here? urlBar(i)->clearHistory(); urlBar(i)->clear(); } @@ -713,4 +713,4 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) return; } KTabWidget::mouseDoubleClickEvent(event); -} \ No newline at end of file +} -- cgit v1.2.1