From c328e203e0d84177a0028d8ba5b0af4b82c16eeb Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Feb 2010 00:29:13 +0100 Subject: QPointers --> QWeakPointers --- src/application.cpp | 53 +++++++++++++++++++++++++---------------- src/application.h | 12 +++++----- src/history/historymanager.cpp | 3 +-- src/mainwindow.cpp | 19 ++++++++------- src/sessionmanager.cpp | 4 ++-- src/settings/settingsdialog.cpp | 1 - src/tabbar.cpp | 29 ++++++++++------------ src/tabbar.h | 4 ++-- 8 files changed, 66 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index 05004f30..cfd4d060 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -64,10 +64,10 @@ #include -QPointer Application::s_historyManager; -QPointer Application::s_bookmarkProvider; -QPointer Application::s_sessionManager; -QPointer Application::s_adblockManager; +QWeakPointer Application::s_historyManager; +QWeakPointer Application::s_bookmarkProvider; +QWeakPointer Application::s_sessionManager; +QWeakPointer Application::s_adblockManager; Application::Application() @@ -80,12 +80,23 @@ Application::Application() Application::~Application() { - qDeleteAll(m_mainWindows); + foreach( QWeakPointer window, m_mainWindows) + { + delete window.data(); + window.clear(); + } - delete s_bookmarkProvider; - delete s_historyManager; - delete s_sessionManager; - delete s_adblockManager; + delete s_bookmarkProvider.data(); + s_bookmarkProvider.clear(); + + delete s_historyManager.data(); + s_historyManager.clear(); + + delete s_sessionManager.data(); + s_sessionManager.clear(); + + delete s_adblockManager.data(); + s_adblockManager.clear(); } @@ -145,7 +156,7 @@ int Application::newInstance() // is there a window open on the current desktop ? use it! for (int i = 0; i < m_mainWindows.size(); ++i) { - MainWindow *m = m_mainWindows.at(i); + MainWindow *m = m_mainWindows.at(i).data(); KWindowInfo w = KWindowInfo(m->winId(), NET::WMDesktop); if(w.isOnCurrentDesktop()) { @@ -210,7 +221,7 @@ MainWindow *Application::mainWindow() if(!active) { - return m_mainWindows.at(0); + return m_mainWindows.at(0).data(); } return active; } @@ -218,38 +229,38 @@ MainWindow *Application::mainWindow() HistoryManager *Application::historyManager() { - if (!s_historyManager) + if ( s_historyManager.isNull() ) { s_historyManager = new HistoryManager(); - QWebHistoryInterface::setDefaultInterface(s_historyManager); + QWebHistoryInterface::setDefaultInterface( s_historyManager.data() ); } - return s_historyManager; + return s_historyManager.data(); } BookmarkProvider *Application::bookmarkProvider() { - if (!s_bookmarkProvider) + if ( s_bookmarkProvider.isNull() ) { s_bookmarkProvider = new BookmarkProvider(instance()); } - return s_bookmarkProvider; + return s_bookmarkProvider.data(); } SessionManager *Application::sessionManager() { - if(!s_sessionManager) + if( s_sessionManager.isNull() ) { s_sessionManager = new SessionManager(instance()); } - return s_sessionManager; + return s_sessionManager.data(); } KIcon Application::icon(const KUrl &url) { - if(!Application::instance()->mainWindowList().isEmpty()) // avoid infinite loop at startup + if( !Application::instance()->mainWindowList().isEmpty() ) // avoid infinite loop at startup { if(url == KUrl("about:closedTabs")) @@ -355,11 +366,11 @@ MainWindowList Application::mainWindowList() AdBlockManager *Application::adblockManager() { - if(!s_adblockManager) + if( s_adblockManager.isNull() ) { s_adblockManager = new AdBlockManager(instance()); } - return s_adblockManager; + return s_adblockManager.data(); } diff --git a/src/application.h b/src/application.h index 4b951ded..0c3bd3f5 100644 --- a/src/application.h +++ b/src/application.h @@ -38,7 +38,7 @@ #include // Qt Includes -#include +#include #include // Forward Declarations @@ -52,7 +52,7 @@ class AdBlockManager; class WebView; -typedef QList< QPointer > MainWindowList; +typedef QList< QWeakPointer > MainWindowList; namespace Rekonq @@ -139,10 +139,10 @@ private slots: void loadResolvedUrl(ThreadWeaver::Job *); private: - static QPointer s_historyManager; - static QPointer s_bookmarkProvider; - static QPointer s_sessionManager; - static QPointer s_adblockManager; + static QWeakPointer s_historyManager; + static QWeakPointer s_bookmarkProvider; + static QWeakPointer s_sessionManager; + static QWeakPointer s_adblockManager; MainWindowList m_mainWindows; }; diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp index 29bdb45b..db19a6b4 100644 --- a/src/history/historymanager.cpp +++ b/src/history/historymanager.cpp @@ -69,10 +69,9 @@ HistoryManager::HistoryManager(QObject *parent) , m_historyModel(0) , m_historyFilterModel(0) , m_historyTreeModel(0) - , m_completion(0) + , m_completion(new KCompletion) { // take care of the completion object - m_completion = new KCompletion; m_completion->setOrder( KCompletion::Weighted ); m_expiredTimer.setSingleShot(true); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index df600c05..ffc9f508 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -76,7 +76,7 @@ #include #include #include -#include +#include #include #include @@ -599,13 +599,14 @@ void MainWindow::preferences() return; // we didn't find an instance of this dialog, so lets create it - QPointer s = new SettingsDialog(this); + QWeakPointer s = new SettingsDialog(this); // keep us informed when the user changes settings - connect(s, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateBrowser())); + connect(s.data(), SIGNAL(settingsChanged(const QString&)), this, SLOT(updateBrowser())); - s->exec(); - delete s; + s.data()->exec(); + delete s.data(); + s.clear(); } @@ -1041,16 +1042,16 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) void MainWindow::clearPrivateData() { - QPointer dialog = new KDialog(this, Qt::Sheet); - dialog->setButtons(KDialog::Ok | KDialog::Cancel); + QWeakPointer dialog = new KDialog(this, Qt::Sheet); + dialog.data()->setButtons(KDialog::Ok | KDialog::Cancel); Ui::ClearDataWidget clearWidget; QWidget widget; clearWidget.setupUi(&widget); - dialog->setMainWidget(&widget); + dialog.data()->setMainWidget(&widget); - if (dialog->exec() == KDialog::Accepted) + if (dialog.data()->exec() == KDialog::Accepted) { if(clearWidget.clearHistory->isChecked()) { diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp index f4e7cd3e..f512e943 100644 --- a/src/sessionmanager.cpp +++ b/src/sessionmanager.cpp @@ -71,10 +71,10 @@ void SessionManager::saveSession() } QTextStream out(&sessionFile); MainWindowList wl = Application::instance()->mainWindowList(); - Q_FOREACH(QPointer w, wl) + Q_FOREACH(QWeakPointer w, wl) { out << "window\n"; - MainView *mv = w->mainView(); + MainView *mv = w.data()->mainView(); for (int i = 0 ; i < mv->count() ; i++) { out << mv->webTab(i)->url().toEncoded() << "\n"; diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index e37481aa..6fab5dcf 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -53,7 +53,6 @@ #include // Qt Includes -#include #include diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 460a2464..5e1feb56 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -161,24 +161,21 @@ void TabBar::showTabPreview(int tab) int h = w*((0.0 + currentView->height())/currentView->width()); //delete previous tab preview - if (m_previewPopup) - { - delete m_previewPopup; - } - + m_previewPopup.clear(); + m_previewPopup = new KPassivePopup(this); - m_previewPopup->setFrameShape(QFrame::StyledPanel); - m_previewPopup->setFrameShadow(QFrame::Plain); - m_previewPopup->setFixedSize(w, h); + m_previewPopup.data()->setFrameShape(QFrame::StyledPanel); + m_previewPopup.data()->setFrameShadow(QFrame::Plain); + m_previewPopup.data()->setFixedSize(w, h); QLabel *l = new QLabel(); view->page()->setViewportSize(currentView->page()->viewportSize()); l->setPixmap(WebSnap::renderPreview(*(view->page()), w, h)); - m_previewPopup->setView(l); - m_previewPopup->layout()->setAlignment(Qt::AlignTop); - m_previewPopup->layout()->setMargin(0); + m_previewPopup.data()->setView(l); + m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop); + m_previewPopup.data()->layout()->setMargin(0); QPoint pos( tabRect(tab).x() , tabRect(tab).y() + tabRect(tab).height() ); - m_previewPopup->show(mapToGlobal(pos)); + m_previewPopup.data()->show(mapToGlobal(pos)); } @@ -208,9 +205,9 @@ void TabBar::mouseMoveEvent(QMouseEvent *event) //if current tab or not found then hide previous tab preview if (tab==currentIndex() || tab==-1) { - if ( m_previewPopup) + if ( !m_previewPopup.isNull() ) { - m_previewPopup->hide(); + m_previewPopup.data()->hide(); } m_currentTabPreview = -1; } @@ -225,9 +222,9 @@ void TabBar::leaveEvent(QEvent *event) if (ReKonfig::alwaysShowTabPreviews()) { //if leave tabwidget then hide previous tab preview - if ( m_previewPopup) + if ( !m_previewPopup.isNull() ) { - m_previewPopup->hide(); + m_previewPopup.data()->hide(); } m_currentTabPreview = -1; } diff --git a/src/tabbar.h b/src/tabbar.h index f0476cbd..b57106dc 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -35,7 +35,7 @@ #include "rekonqprivate_export.h" // Qt Includes -#include +#include // KDE Includes #include @@ -99,7 +99,7 @@ private: */ int m_actualIndex; - QPointer m_previewPopup; + QWeakPointer m_previewPopup; int m_currentTabPreview; }; -- cgit v1.2.1 From 2c11a95da6772a63d85905d4712a1a2d016a9e1e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Feb 2010 01:49:54 +0100 Subject: FIx focus on browsing (FIRST STEP) and on findbar hiding --- src/application.cpp | 2 +- src/findbar.cpp | 15 +++++++++------ src/findbar.h | 2 +- src/mainview.cpp | 6 +++--- src/mainwindow.cpp | 1 + src/webtab.cpp | 3 +++ 6 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index cfd4d060..14fd5ce0 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -382,8 +382,8 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job) if (view) { - view->setFocus(); view->load(url); + view->setFocus(); // we are sure of the url now, let's add it to history // anyway we store here just http sites because local and ftp ones are diff --git a/src/findbar.cpp b/src/findbar.cpp index bd1a5137..9efb9c6a 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -143,12 +143,6 @@ void FindBar::show() void FindBar::keyPressEvent(QKeyEvent* event) { - if (event->key() == Qt::Key_Escape) - { - hide(); - m_hideTimer->stop(); - return; - } if (event->key() == Qt::Key_Return && !m_lineEdit->text().isEmpty()) { emit searchString(m_lineEdit->text()); @@ -158,6 +152,7 @@ void FindBar::keyPressEvent(QKeyEvent* event) QWidget::keyPressEvent(event); } + void FindBar::notifyMatch(bool match) { QPalette p = m_lineEdit->palette(); @@ -180,3 +175,11 @@ void FindBar::notifyMatch(bool match) m_lineEdit->setPalette(p); m_hideTimer->start(60000); } + + + +void FindBar::hide() +{ + m_hideTimer->stop(); + QWidget::hide(); +} diff --git a/src/findbar.h b/src/findbar.h index fa369f66..5a41c0bc 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -56,6 +56,7 @@ public: public slots: void clear(); void show(); + void hide(); void notifyMatch(bool match); protected Q_SLOTS: @@ -68,7 +69,6 @@ private: KLineEdit *m_lineEdit; QCheckBox *m_matchCase; QTimer *m_hideTimer; - }; #endif diff --git a/src/mainview.cpp b/src/mainview.cpp index b26e7466..bc9d0bda 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -308,7 +308,7 @@ void MainView::currentChanged(int index) emit browserTabLoading(false); // set focus to the current webview - tab->setFocus(); + tab->view()->setFocus(); } @@ -507,8 +507,8 @@ void MainView::closeTab(int index) } removeTab(index); - updateTabBar(); // UI operation: do it ASAP!! - tab->deleteLater(); // webView is scheduled for deletion. + updateTabBar(); // UI operation: do it ASAP!! + tab->deleteLater(); // webView is scheduled for deletion. emit tabsChanged(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ffc9f508..9df24692 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -925,6 +925,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) if (event->key() == Qt::Key_Escape) { m_findBar->hide(); + currentTab()->setFocus(); // give focus to web pages return; } diff --git a/src/webtab.cpp b/src/webtab.cpp index b1f2cdfc..b3eb71f0 100644 --- a/src/webtab.cpp +++ b/src/webtab.cpp @@ -64,6 +64,9 @@ WebTab::WebTab(QWidget* parent) , m_view( new WebView(this) ) , m_progress(0) { + // fix focus handling + setFocusProxy( m_view ); + QVBoxLayout* l = new QVBoxLayout(this); l->setMargin(0); l->setSpacing(0); -- cgit v1.2.1 From 8343d45f3dfd631a3f5ac4213918f285930eb446 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Thu, 17 Dec 2009 18:22:23 +0100 Subject: Re-implemented previews in homepage without using plugins. Not finished yet : Little things that change: -nice buttons appearing on hover -transitions on hover TODO: -when a preview is empty or when loading, it is very ugly -for now there's no way to choose the page you want to preview -port "closed Tabs" to this new architecture -totally remove PreviewImage classes -eventually, specific contextmenu for previews --- src/data/home.html | 76 +++++++++++++++++---- src/rekonqpage/newtabpage.cpp | 155 ++++++++++++++++++++++++++++++++++-------- src/rekonqpage/newtabpage.h | 19 ++++-- src/webpage.cpp | 10 +++ src/webpage.h | 3 + src/websnap.cpp | 52 +++++++++++++- src/websnap.h | 14 +++- 7 files changed, 277 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/data/home.html b/src/data/home.html index 9d8f390f..8db3d894 100644 --- a/src/data/home.html +++ b/src/data/home.html @@ -54,6 +54,10 @@ margin-top: 0.5em; a{ color: #3F7AB7; text-decoration: none; +-webkit-transition-property: color; +-webkit-transition-duration: 0.5s; +-webkit-transition-timing-function: ease; + } a:hover{ color: black; @@ -118,18 +122,61 @@ margin-top: -5%; /* Thumbnail class */ .thumbnail { -text-align: center; display: inline-block; -width:25%; -margin-top: 7%; -min-width:250px; -min-height:192px; +width:25%; margin-top: 7%; +min-width:250px; min-height:192px; +} + +.preview { +display: block; +width: 200px; +height: 150px; +padding: 14px 16px; +background: url(%2/bg.png) no-repeat; +-webkit-background-size: 100% 100%; +-webkit-background-clip: padding; +} +.thumbnail:hover .preview , .thumbnail:hover .button img { +opacity: 0.8; +} + +.button img, .preview { +-webkit-transition-property: opacity; +-webkit-transition-duration: 0.8s; +-webkit-transition-timing-function: ease-in-out; +} + +.button img { +display: inline-block; +width: 16px; +height: 16px; +opacity: 0; } -.thumbnail object{ +.remove { + float: right; +} +.modify { + float: left; +} + +.title { +display: block; +width: 200px; +height: 15px; +padding: 0 14px; text-align: center; -width:228px; -height:192px; +} + +.thumbnail a { +text-align:center; +} +.thumbnail a:hover { +color:#3F7AB7; +} + +.thumbnail span { + } /* -------------------------------------------------------- */ @@ -162,11 +209,14 @@ margin-bottom: 0.5em;
- - - - - + + +
+ + + +
+

diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 66f74b86..4299c8bb 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -46,6 +46,7 @@ // Qt Includes #include +#include NewTabPage::NewTabPage(QWebFrame *frame) @@ -72,6 +73,16 @@ NewTabPage::~NewTabPage() void NewTabPage::generate(const KUrl &url) { + if(KUrl("about:preview").isParentOf(url)) + { + if(url.directory() == QString("preview/remove")) + { + removePreview(url.fileName().toInt()); + return; + } + } + + QWebPage *page = m_root.webFrame()->page(); page->mainFrame()->setHtml(m_html); @@ -80,26 +91,26 @@ void NewTabPage::generate(const KUrl &url) browsingMenu(url); QString title; - if(url == KUrl("about:closedTabs")) + if(url == KUrl("about:home") || url == KUrl("about:favorites")) + { + favoritesPage(); + title = i18n("Favorites"); + } + else if(url == KUrl("about:closedTabs")) { closedTabsPage(); title = i18n("Closed Tabs"); } - if(url == KUrl("about:history")) + else if(url == KUrl("about:history")) { historyPage(); title = i18n("History"); } - if(url == KUrl("about:bookmarks")) + else if(url == KUrl("about:bookmarks")) { bookmarksPage(); title = i18n("Bookmarks"); } - if(url == KUrl("about:home") || url == KUrl("about:favorites")) - { - favoritesPage(); - title = i18n("Favorites"); - } m_root.document().findFirst("title").setPlainText(title); } @@ -114,34 +125,111 @@ void NewTabPage::favoritesPage() for(int i=0; i<8; ++i) { - QWebElement speed = markup(".thumbnail"); - speed.findFirst("object").setAttribute("data" , urls.at(i)); - speed.findFirst("param[name=title]").setAttribute("value", names.at(i)); - speed.findFirst("param[name=index]").setAttribute("value", QString::number(i)); - speed.findFirst("param[name=isFavorite]").setAttribute("value", "true"); + QWebElement speed; + + if(urls.at(i).isEmpty()) + speed = emptyPreview(); + else if(!QFile::exists(WebSnap::fileForUrl(urls.at(i)).toLocalFile())) + speed = loadingPreview(i, urls.at(i)); + else + speed = validPreview(i, urls.at(i), names.at(i)); + + speed.setAttribute("id", "preview" + QVariant(i).toString()); m_root.appendInside(speed); } } -// FIXME : port to new PreviewImage API to use... -/*QString NewTabPage::lastVisitedPage() +QWebElement NewTabPage::emptyPreview() { - QString last; - QList history = Application::historyManager()->history(); - for (int i = 0; i < 8 && i < history.size(); ++i) - { - HistoryItem it = history.at(i); - last += "
"; - last += ""; - last += ""; - last += "
"; - last += "" + it.title + "
"; - } + QWebElement prev = markup(".thumbnail"); + + prev.findFirst("img").setAttribute("src" , QString("file:///") + + KIconLoader::global()->iconPath("insert-image", KIconLoader::Desktop)); + prev.findFirst("span").appendInside(i18n("Set a Preview...")); + + return prev; +} + + +QWebElement NewTabPage::loadingPreview(int index, KUrl url) +{ + QWebElement prev = markup(".thumbnail"); + + prev.findFirst("img").setAttribute("src" , + QString("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif")); + prev.findFirst("span").appendInside(i18n("Loading Preview...")); + WebSnap *snap = new WebSnap(url); + snap->SetData(QVariant(index)); + connect(snap, SIGNAL(finished()), SLOT(snapFinished())); + + return prev; +} + +QWebElement NewTabPage::validPreview(int index, KUrl url, QString title) +{ + QWebElement prev = markup(".thumbnail"); + KUrl previewPath = WebSnap::fileForUrl(url); + QString iString = QVariant(index).toString(); + + prev.findFirst(".preview").setAttribute("src" , previewPath.toMimeDataString()); + prev.findFirst("a").setAttribute("href", url.toMimeDataString()); + prev.findFirst("span > a").setAttribute("href", url.toMimeDataString()); + prev.findFirst("span").appendInside(checkTitle(title)); + + prev.findFirst(".modify img").setAttribute("src", QString("file:///") + + KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState)); + prev.findFirst(".modify").setAttribute("href", QString("about:preview/modify/" + iString )); + + prev.findFirst(".remove img").setAttribute("src", QString("file:///") + + KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState)); + prev.findFirst(".remove").setAttribute("href", QString("about:preview/remove/" + iString )); + + return prev; +} - return last; -}*/ +void NewTabPage::snapFinished() +{ + WebSnap *snap = qobject_cast(sender()); + QWebElement thumb = m_root.findFirst("#preview" + snap->data().toString()); + thumb.findFirst("img").setAttribute("src", WebSnap::fileForUrl(snap->snapUrl()).toMimeDataString()); + thumb.findFirst("p").setPlainText(snap->snapTitle()); + + // Save the new config + QStringList names = ReKonfig::previewNames(); + QStringList urls = ReKonfig::previewUrls(); + + // stripTrailingSlash to be sure to get the same string for same address + urls.replace(snap->data().toInt(), snap->snapUrl().toString(QUrl::StripTrailingSlash)); + names.replace(snap->data().toInt() , snap->snapTitle()); + + ReKonfig::setPreviewNames(names); + ReKonfig::setPreviewUrls(urls); + + ReKonfig::self()->writeConfig(); +} + + +void NewTabPage::removePreview(int index) +{ + QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); + + + QStringList names = ReKonfig::previewNames(); + QStringList urls = ReKonfig::previewUrls(); + + urls.replace(index, QString("")); + names.replace(index, QString("")); + + ReKonfig::setPreviewNames(names); + ReKonfig::setPreviewUrls(urls); + + // sync file data + ReKonfig::self()->writeConfig(); + + prev.replace(emptyPreview()); +} void NewTabPage::browsingMenu(const KUrl ¤tUrl) @@ -278,3 +366,14 @@ void NewTabPage::closedTabsPage() m_root.appendInside(closed); } } + + +QString NewTabPage::checkTitle(QString title) +{ + if(title.length() > 23) + { + title.truncate(20); + title += "..."; + } + return title; +} diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index 003aa84e..84880a10 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -28,9 +28,6 @@ #define REKONQ_NEW_TAB_PAGE -// rekonq Includes -#include - // KDE Includes #include @@ -41,11 +38,12 @@ // Forward Includes class KBookmark; +class WebPage; -class NewTabPage +class NewTabPage : public QObject { - +Q_OBJECT public: NewTabPage(QWebFrame *frame); ~NewTabPage(); @@ -56,12 +54,19 @@ public: * new tab page */ void generate(const KUrl &url = KUrl("about:home")); + +protected slots: + void snapFinished(); + void removePreview(int index); protected: // these are the function to build the new tab page void browsingMenu(const KUrl ¤tUrl); void favoritesPage(); - //QString lastVisitedPage(); + QWebElement emptyPreview(); + QWebElement loadingPreview(int index, KUrl url); + QWebElement validPreview(int index, KUrl url, QString title); + void historyPage(); void bookmarksPage(); void closedTabsPage(); @@ -77,6 +82,8 @@ private: { return m_root.document().findFirst("#models > " + selector).clone(); } + + QString checkTitle(QString title); QString m_html; diff --git a/src/webpage.cpp b/src/webpage.cpp index b2bedffc..59df13e7 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -72,6 +72,7 @@ WebPage::WebPage(QObject *parent) : KWebPage(parent, KWalletIntegration) + , m_newTabPage(0) { setForwardUnsupportedContent(true); @@ -114,10 +115,19 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r if(risp == KMessageBox::Cancel) return false; } + + if (request.url().scheme() == QLatin1String("about")) + { + if(m_newTabPage == 0) + m_newTabPage = new NewTabPage(frame); + m_newTabPage->generate(request.url()); + return false; + } if (frame && m_protHandler.preHandling( request, frame )) { return false; + } m_requestedUrl = request.url(); diff --git a/src/webpage.h b/src/webpage.h index 9169ad60..5671b5d9 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -32,8 +32,10 @@ #define WEBPAGE_H + // Local Includes #include "protocolhandler.h" +#include "newtabpage.h" // KDE Includes #include @@ -76,6 +78,7 @@ private: QUrl m_requestedUrl; ProtocolHandler m_protHandler; + NewTabPage *m_newTabPage; }; #endif diff --git a/src/websnap.cpp b/src/websnap.cpp index 7dcbb836..e5db7c4e 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -115,16 +115,62 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h) } +KUrl WebSnap::fileForUrl(KUrl url) +{ + QString filePath = + KStandardDirs::locateLocal("cache", QString("thumbs/") + WebSnap::guessNameFromUrl(url) + ".png", true); + return KUrl(filePath); +} + + +void WebSnap::SetData(QVariant data) +{ + m_data = data; +} + +QVariant& WebSnap::data() +{ + return m_data; +} + + + +QString WebSnap::guessNameFromUrl(QUrl url) +{ + QString name = url.toString( QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash ); + + // TODO learn Regular Expressions :) + // and implement something better here.. + name.remove('/'); + name.remove('&'); + name.remove('.'); + name.remove('-'); + name.remove('_'); + name.remove('?'); + name.remove('='); + name.remove('+'); + + return name; +} + + void WebSnap::saveResult(bool ok) { // crude error-checking if (!ok) { kDebug() << "Error loading site.."; - return; + m_snapTitle = "Error..."; + m_image = QPixmap(); } - - m_image = renderPreview(m_page, WIDTH, HEIGHT); + else + { + m_image = renderPreview(m_page, WIDTH, HEIGHT); + } + + m_image.save(fileForUrl(m_url).toLocalFile()); + kDebug() << "finished"; + emit finished(); } diff --git a/src/websnap.h b/src/websnap.h index 6c5b4af9..04fded57 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -51,18 +51,26 @@ public: WebSnap(const QUrl &url); ~WebSnap(); - QPixmap previewImage(); + QPixmap previewImage(); // TODO : remove + static QPixmap renderPreview(const QWebPage &page, int w, int h); + static KUrl fileForUrl(KUrl url); + + static QString guessNameFromUrl(QUrl url); + QString snapTitle(); QUrl snapUrl(); + + void SetData(QVariant data); + QVariant& data(); signals: void finished(); private slots: void load(); - void saveResult(bool ok); + void saveResult(bool ok = true); private: QWebPage m_page; @@ -70,6 +78,8 @@ private: QUrl m_url; QString m_snapTitle; + + QVariant m_data; }; #endif // WEB_SNAP_H -- cgit v1.2.1 From f1f7e2011c3f245cd1987b0f09b72c2f7dea283f Mon Sep 17 00:00:00 2001 From: matgic78 Date: Fri, 18 Dec 2009 15:58:48 +0100 Subject: Various changes: - improve appearance of empty/loading previews - port closedTabs to new system - remove PreviewImage files TODO : dialog to choose preview --- src/CMakeLists.txt | 1 - src/data/home.html | 22 +-- src/previewimage.cpp | 430 ------------------------------------------ src/previewimage.h | 101 ---------- src/rekonqpage/newtabpage.cpp | 84 ++++++--- src/rekonqpage/newtabpage.h | 9 +- src/webpluginfactory.cpp | 28 +-- 7 files changed, 79 insertions(+), 596 deletions(-) delete mode 100644 src/previewimage.cpp delete mode 100644 src/previewimage.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0a3fbd8..2295e9e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,7 +11,6 @@ SET( rekonq_KDEINIT_SRCS findbar.cpp mainview.cpp mainwindow.cpp - previewimage.cpp sessionmanager.cpp tabbar.cpp webpage.cpp diff --git a/src/data/home.html b/src/data/home.html index 8db3d894..103c559d 100644 --- a/src/data/home.html +++ b/src/data/home.html @@ -127,10 +127,12 @@ width:25%; margin-top: 7%; min-width:250px; min-height:192px; } +.preview img { +} .preview { -display: block; -width: 200px; -height: 150px; +display: table-cell; +vertical-align: middle; +width: 200px; height: 150px; padding: 14px 16px; background: url(%2/bg.png) no-repeat; -webkit-background-size: 100% 100%; @@ -154,10 +156,10 @@ opacity: 0; } .remove { - float: right; +float: right; } .modify { - float: left; +float: left; } .title { @@ -171,14 +173,10 @@ text-align: center; .thumbnail a { text-align:center; } -.thumbnail a:hover { +.thumbnail a:hover, span { color:#3F7AB7; } -.thumbnail span { - -} - /* -------------------------------------------------------- */ /* Bookmarks page*/ @@ -210,7 +208,9 @@ margin-bottom: 0.5em;
- +
+ +
diff --git a/src/previewimage.cpp b/src/previewimage.cpp deleted file mode 100644 index 9c8bb194..00000000 --- a/src/previewimage.cpp +++ /dev/null @@ -1,430 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 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 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* 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. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* ============================================================ */ - - -// Self Includes -#include "previewimage.h" -#include "previewimage.moc" - -// Local Includes -#include "historymanager.h" -#include "rekonq.h" -#include "mainwindow.h" -#include "mainview.h" - -// KDE Includes -#include -#include -#include -#include -#include -#include - -// Qt Includes -#include -#include -#include -#include -#include -#include - - -PreviewImage::PreviewImage(const QUrl &url, const QString &title, int index, bool isFavorite) - : QWidget() - , ws(0) - , loadingSnapshot(false) - , m_url(url) - , m_title(title) - , m_isFavorite(isFavorite) - , m_index(index) - , m_button(0) - , m_imageLabel(new QLabel) - , m_textLabel(new QLabel) - , m_backgroundLabel(new QLabel) - , m_previewLabel(new QLabel) -{ - - int borderTop = 14; - int borderRight = 16; - int borderBottom = 14; - int borderLeft = 16; - - int previewWidth = 200; - int previewHeight = 150; - - int urlHeight = 18; - - m_size = QSize(borderLeft+previewWidth+borderRight, borderTop+previewHeight+borderBottom+urlHeight); - - setFixedSize(m_size); - m_previewLabel->setFixedSize(m_size); - - m_backgroundLabel->setPixmap(renderBackground(previewWidth,previewHeight, borderTop, borderBottom, borderLeft, borderRight)); - - m_previewLabel->setAlignment(Qt::AlignCenter); - m_backgroundLabel->setAlignment(Qt::AlignCenter); - m_imageLabel->setAlignment(Qt::AlignCenter); - m_textLabel->setAlignment(Qt::AlignCenter); - - m_previewLabel->setLayout(new QVBoxLayout); - m_previewLabel->layout()->setMargin(0); - m_previewLabel->layout()->addWidget(m_backgroundLabel); - m_previewLabel->layout()->addWidget(m_textLabel); - m_previewLabel->setCursor(Qt::PointingHandCursor); - - m_backgroundLabel->setLayout(new QVBoxLayout); - m_backgroundLabel->layout()->addWidget(m_imageLabel); - - setLayout(new QHBoxLayout); - layout()->setMargin(0); - layout()->setAlignment(Qt::AlignCenter); - layout()->addWidget(m_previewLabel); - - connect(this, SIGNAL(loadUrl(const KUrl &, const Rekonq::OpenType &)), - Application::instance(), SLOT(loadUrl(const KUrl &, const Rekonq::OpenType &))); - - loadUrlPreview(url); -} - - -PreviewImage::~PreviewImage() -{ - delete ws; - delete m_textLabel; - delete m_imageLabel; - delete m_backgroundLabel; - delete m_previewLabel; -} - - -QPixmap PreviewImage::renderBackground(int w, int h, int t, int b, int l, int r) -{ - QImage backImage(KStandardDirs::locate("appdata", "pics/bg.png")); - QImage resultImage(QSize(w + l + r, h + t + b), QImage::Format_ARGB32_Premultiplied); - - if (!backImage.isNull()) - { - int sw = backImage.width() - l - r; - int sh = backImage.height() - t - b; - QPainter pt(&resultImage); - pt.setCompositionMode(QPainter::CompositionMode_Source); - pt.fillRect(resultImage.rect(), Qt::transparent); - pt.drawImage(QRect(0, 0, l, t), backImage, QRect(0, 0, l, t)); - pt.drawImage(QRect(l, 0, w, t), backImage, QRect(l, 0, sw, t)); - pt.drawImage(QRect(l + w, 0, r, t), backImage, QRect(l + sw, 0, r, t)); - pt.drawImage(QRect(0, t, l, h), backImage, QRect(0, t, l, sh)); - pt.drawImage(QRect(l, t, w, h), backImage, QRect(l, t, sw, sh)); - pt.drawImage(QRect(l + w, t, r, h), backImage, QRect(l + sw, t, r, sh)); - pt.drawImage(QRect(0, t + h, l , b), backImage, QRect(0, t + sh, l , b)); - pt.drawImage(QRect(l, t + h, w, b), backImage, QRect(l, t + sh, sw, b)); - pt.drawImage(QRect(l + w, t + h, w, b), backImage, QRect(l + sw, t + sh, sw, b)); - pt.end(); - } - - return QPixmap::fromImage(resultImage); -} - - -void PreviewImage::loadUrlPreview(const QUrl& url) -{ - m_url = url; - - if(url.isEmpty()) - { - showEmptyPreview(); - return; - } - - m_previewLabel->setFixedSize(m_size); //unhide - - m_savePath = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl(m_url) + ".png", true); - - if(QFile::exists(m_savePath)) - { - m_pixmap.load(m_savePath); - m_imageLabel->setPixmap(m_pixmap); - checkTitle(); - m_textLabel->setText(m_title); - } - else - { - loadingSnapshot = true; - ws = new WebSnap( url ); - connect(ws, SIGNAL(finished()), this, SLOT(snapFinished())); - - QString path = KStandardDirs::locate("appdata", "pics/busywidget.gif"); - - // load an animation waiting for site preview - QMovie *movie = new QMovie(path, QByteArray(), this); - movie->setSpeed(50); - m_imageLabel->setMovie(movie); - movie->start(); - m_textLabel->setText( i18n("Loading preview...") ); - setCursor(Qt::BusyCursor); - } -} - - -void PreviewImage::snapFinished() -{ - loadingSnapshot = false; - QMovie *m = m_imageLabel->movie(); - delete m; - m_imageLabel->setMovie(0); - - m_pixmap = ws->previewImage(); - m_imageLabel->setPixmap(m_pixmap); - checkTitle(); - m_textLabel->setText(m_title); - - setCursor(Qt::PointingHandCursor); - - m_pixmap.save(m_savePath); - - if(m_index > -1) - { - // Update title - QStringList names = ReKonfig::previewNames(); - // update url (for added thumbs) - QStringList urls = ReKonfig::previewUrls(); - - // stripTrailingSlash to be sure to get the same string for same address - urls.replace(m_index, ws->snapUrl().toString(QUrl::StripTrailingSlash)); - names.replace(m_index, ws->snapTitle()); - - ReKonfig::setPreviewNames(names); - ReKonfig::setPreviewUrls(urls); - - ReKonfig::self()->writeConfig(); - } -} - - -void PreviewImage::showEmptyPreview() -{ - if(!m_isFavorite) - return; - - m_imageLabel->clear(); - m_textLabel->clear(); - - m_previewLabel->setFixedSize(0,0); //hide - - - m_button = new QToolButton(); - m_button->setDefaultAction(historyMenu()); - m_button->setPopupMode(QToolButton::InstantPopup); - m_button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - m_button->setText(i18n("Add Preview")); - m_button->setAutoRaise(true); - m_button->setIconSize(QSize(48, 48)); - layout()->addWidget(m_button); -} - - -void PreviewImage::mouseDoubleClickEvent(QMouseEvent *event) -{ - kDebug() << "no double click over here, thanks :D"; - Q_UNUSED(event); -} - - -void PreviewImage::mouseMoveEvent(QMouseEvent *event) -{ - kDebug() << "moving mouse over preview image"; - Q_UNUSED(event) -} - - -void PreviewImage::mousePressEvent(QMouseEvent *event) -{ - if(event->button() == Qt::LeftButton) - { - emit loadUrl(m_url, Rekonq::CurrentTab); - return; - } - else if(event->button() == Qt::MidButton) - { - emit loadUrl(m_url, Rekonq::SettingOpenTab); - return; - } - - QWidget::mousePressEvent(event); -} - - -void PreviewImage::mouseReleaseEvent(QMouseEvent *event) -{ - kDebug() << "NO000... don't leave your finger from the button!!"; - Q_UNUSED(event) -} - - -void PreviewImage::contextMenuEvent(QContextMenuEvent* event) -{ - if(!m_isFavorite) - return; - - if(loadingSnapshot) - return; - - KMenu menu(this); - KAction *a; - - if(!m_url.isEmpty()) - { - a = new KAction(KIcon("edit-delete"), i18n("Remove Thumbnail"), this); - connect(a, SIGNAL(triggered(bool)), this, SLOT(removeMe())); - menu.addAction(a); - - a = new KAction(KIcon("view-refresh"), i18n("Refresh Thumbnail"), &menu); - connect(a, SIGNAL(triggered(bool)), this, SLOT(refreshPreview())); - menu.addAction(a); - } - menu.addAction(historyMenu()); - - menu.exec(mapToGlobal(event->pos())); -} - - -KActionMenu* PreviewImage::historyMenu() -{ - KActionMenu *histMenu = new KActionMenu(KIcon("insert-image"), i18n("Set Page to Preview"), this); - QList history = Application::historyManager()->history(); - - if(history.isEmpty()) - { - KAction *a = new KAction(i18n("History is Empty"), this); - a->setEnabled(false); - histMenu->addAction(a); - return histMenu; - } - - int maxItems = 15; - for (int i = 0; i < maxItems && i < history.size() ; ++i) - { - HistoryItem it = history.at(i); - KAction *a = new KAction(Application::icon(it.url), it.title, this); - QStringList urlData; - urlData << it.url << it.title; - a->setData(urlData); - connect(a, SIGNAL(triggered(bool)), this, SLOT(setUrlFromAction())); - histMenu->addAction(a); - } - - return histMenu; -} - - -void PreviewImage::removeMe() -{ - QStringList names = ReKonfig::previewNames(); - QStringList urls = ReKonfig::previewUrls(); - - int index = urls.indexOf(QRegExp(m_url.toString(QUrl::StripTrailingSlash), Qt::CaseSensitive, QRegExp::FixedString)); - - urls.replace(index, QString("")); - names.replace(index, QString("")); - - ReKonfig::setPreviewNames(names); - ReKonfig::setPreviewUrls(urls); - - // sync file data - ReKonfig::self()->writeConfig(); - - showEmptyPreview(); - - m_url = ""; -} - - -void PreviewImage::setUrlFromAction() -{ - KAction *a = qobject_cast(sender()); - QStringList urlData = a->data().toStringList(); - - m_url = KUrl(urlData.at(0)); - m_title = urlData.at(1); - checkTitle(); - - if(m_button) - { - m_imageLabel->layout()->deleteLater(); - m_button->menu()->deleteLater(); - m_button->deleteLater(); - } - loadUrlPreview(m_url); - - // Update title - QStringList names = ReKonfig::previewNames(); - // update url (for added thumbs) - QStringList urls = ReKonfig::previewUrls(); - - // stripTrailingSlash to be sure to get the same string for same address - urls.replace(m_index, m_url.toString(QUrl::StripTrailingSlash)); - names.replace(m_index, m_title); - - ReKonfig::setPreviewNames(names); - ReKonfig::setPreviewUrls(urls); - - ReKonfig::self()->writeConfig(); -} - - -void PreviewImage::refreshPreview() -{ - QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl(m_url) + ".png", true); - QFile::remove(path); - loadUrlPreview(m_url); -} - - -QString PreviewImage::guessNameFromUrl(QUrl url) -{ - QString name = url.toString( QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash ); - - // TODO learn Regular Expressions :) - // and implement something better here.. - name.remove('/'); - name.remove('&'); - name.remove('.'); - name.remove('-'); - name.remove('_'); - name.remove('?'); - name.remove('='); - name.remove('+'); - - return name; -} - - -void PreviewImage::checkTitle() -{ - if(m_title.length() > 23) - { - m_title.truncate(20); - m_title += "..."; - } -} diff --git a/src/previewimage.h b/src/previewimage.h deleted file mode 100644 index 4dd8df3b..00000000 --- a/src/previewimage.h +++ /dev/null @@ -1,101 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 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 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* 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. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* ============================================================ */ - - -#ifndef PREVIEW_IMAGE_H -#define PREVIEW_IMAGE_H - -// Local Includes -#include "websnap.h" -#include "application.h" - -// KDE Includes -#include - -// Qt Includes -#include -#include -#include -#include -#include -#include - - -class PreviewImage : public QWidget -{ - Q_OBJECT - -public: - PreviewImage(const QUrl &url, const QString &title, int index, bool isFavorite); - ~PreviewImage(); - - QString guessNameFromUrl(QUrl url); - -public slots: - void snapFinished(); - void removeMe(); - void setUrlFromAction(); - void refreshPreview(); - -signals: - void loadUrl(const KUrl &, const Rekonq::OpenType &); - -protected: - void contextMenuEvent(QContextMenuEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - - void loadUrlPreview(const QUrl &url); - KActionMenu *historyMenu(); - void showEmptyPreview(); - -private: - void checkTitle(); - QPixmap renderBackground(int w, int h, int t, int b, int l, int r); - - QPixmap m_pixmap; - WebSnap *ws; - - QString m_savePath; - bool loadingSnapshot; - - QUrl m_url; - QString m_title; - bool m_isFavorite; - int m_index; - - QToolButton *m_button; - - QLabel *m_imageLabel; - QLabel *m_textLabel; - QLabel *m_backgroundLabel; - QLabel *m_previewLabel; - - QSize m_size; -}; - -#endif // PREVIEW_IMAGE_H diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 4299c8bb..a587502c 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -80,6 +80,10 @@ void NewTabPage::generate(const KUrl &url) removePreview(url.fileName().toInt()); return; } + if(url.directory() == QString("preview/modify")) + { + return; + } } @@ -125,28 +129,31 @@ void NewTabPage::favoritesPage() for(int i=0; i<8; ++i) { - QWebElement speed; + KUrl url = urls.at(i); + QWebElement prev; - if(urls.at(i).isEmpty()) - speed = emptyPreview(); - else if(!QFile::exists(WebSnap::fileForUrl(urls.at(i)).toLocalFile())) - speed = loadingPreview(i, urls.at(i)); + if(url.isEmpty()) + prev = emptyPreview(i); + else if(!QFile::exists(WebSnap::fileForUrl(url).toLocalFile())) + prev = loadingPreview(i, url); else - speed = validPreview(i, urls.at(i), names.at(i)); + prev = validPreview(i, url, names.at(i)); - speed.setAttribute("id", "preview" + QVariant(i).toString()); - m_root.appendInside(speed); + prev.setAttribute("id", "preview" + QVariant(i).toString()); + m_root.appendInside(prev); } } -QWebElement NewTabPage::emptyPreview() +QWebElement NewTabPage::emptyPreview(int index) { QWebElement prev = markup(".thumbnail"); - prev.findFirst("img").setAttribute("src" , QString("file:///") + + prev.findFirst(".preview img").setAttribute("src" , QString("file:///") + KIconLoader::global()->iconPath("insert-image", KIconLoader::Desktop)); prev.findFirst("span").appendInside(i18n("Set a Preview...")); + prev.findFirst("a").setAttribute("href", QString("about:/preview/modify/" + QVariant(index).toString())); + hideControls(prev); return prev; } @@ -156,9 +163,11 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url) { QWebElement prev = markup(".thumbnail"); - prev.findFirst("img").setAttribute("src" , - QString("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif")); + prev.findFirst(".preview img").setAttribute("src" , + QString("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif")); prev.findFirst("span").appendInside(i18n("Loading Preview...")); + showControls(prev); + WebSnap *snap = new WebSnap(url); snap->SetData(QVariant(index)); connect(snap, SIGNAL(finished()), SLOT(snapFinished())); @@ -172,29 +181,43 @@ QWebElement NewTabPage::validPreview(int index, KUrl url, QString title) KUrl previewPath = WebSnap::fileForUrl(url); QString iString = QVariant(index).toString(); - prev.findFirst(".preview").setAttribute("src" , previewPath.toMimeDataString()); + prev.findFirst(".preview img").setAttribute("src" , previewPath.toMimeDataString()); prev.findFirst("a").setAttribute("href", url.toMimeDataString()); - prev.findFirst("span > a").setAttribute("href", url.toMimeDataString()); + prev.findFirst("span a").setAttribute("href", url.toMimeDataString()); prev.findFirst("span").appendInside(checkTitle(title)); prev.findFirst(".modify img").setAttribute("src", QString("file:///") + - KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState)); + KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState)); prev.findFirst(".modify").setAttribute("href", QString("about:preview/modify/" + iString )); prev.findFirst(".remove img").setAttribute("src", QString("file:///") + - KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState)); + KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState)); prev.findFirst(".remove").setAttribute("href", QString("about:preview/remove/" + iString )); + showControls(prev); + + return prev; } +void NewTabPage::hideControls(QWebElement e) +{ + e.findFirst(".remove").setStyleProperty("visibility", "hidden"); + e.findFirst(".modify").setStyleProperty("visibility", "hidden"); +} +void NewTabPage::showControls(QWebElement e) +{ + e.findFirst(".remove").setStyleProperty("visibility", "visible"); + e.findFirst(".modify").setStyleProperty("visibility", "visible"); +} + + void NewTabPage::snapFinished() { WebSnap *snap = qobject_cast(sender()); - QWebElement thumb = m_root.findFirst("#preview" + snap->data().toString()); - thumb.findFirst("img").setAttribute("src", WebSnap::fileForUrl(snap->snapUrl()).toMimeDataString()); - thumb.findFirst("p").setPlainText(snap->snapTitle()); + QWebElement prev = m_root.findFirst("#preview" + snap->data().toString()); + prev.replace(validPreview(snap->data().toInt(), snap->snapUrl(), snap->snapTitle())); // Save the new config QStringList names = ReKonfig::previewNames(); @@ -228,7 +251,7 @@ void NewTabPage::removePreview(int index) // sync file data ReKonfig::self()->writeConfig(); - prev.replace(emptyPreview()); + prev.replace(emptyPreview(index)); } @@ -357,13 +380,22 @@ void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent) void NewTabPage::closedTabsPage() { QList links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs(); - - foreach(const HistoryItem &item, links) + + for(int i=0; i < links.count(); ++i) { - QWebElement closed = markup(".thumbnail"); - closed.findFirst("object").setAttribute("data" , item.url); - closed.findFirst("param[name=title]").setAttribute("value", item.title); - m_root.appendInside(closed); + HistoryItem item = links.at(i); + QWebElement prev; + + if(item.url.isEmpty()) + continue; + else if(!QFile::exists(WebSnap::fileForUrl(item.url).toLocalFile())) + prev = loadingPreview(i, item.url); + else + prev = validPreview(i, item.url, item.title); + + prev.setAttribute("id", "preview" + QVariant(i).toString()); + hideControls(prev); + m_root.appendInside(prev); } } diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index 84880a10..9ac743ea 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -63,10 +63,17 @@ protected: // these are the function to build the new tab page void browsingMenu(const KUrl ¤tUrl); void favoritesPage(); - QWebElement emptyPreview(); + QWebElement emptyPreview(int index); QWebElement loadingPreview(int index, KUrl url); QWebElement validPreview(int index, KUrl url, QString title); + /** This function takes a QwebElement with the .thumbnail structure. + It hides the "remove" and "modify" buttons-> + */ + void hideControls(QWebElement e); + void showControls(QWebElement e); + + void historyPage(); void bookmarksPage(); void closedTabsPage(); diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index aec4e18d..ac18fece 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -32,7 +32,6 @@ #include "rekonq.h" #include "application.h" #include "mainwindow.h" -#include "previewimage.h" #include "clicktoflash.h" // KDE Includes @@ -65,27 +64,7 @@ QObject *WebPluginFactory::create(const QString &mimeType, const QStringList &argumentValues) const { kDebug() << "loading mimeType: " << mimeType; - - if(mimeType == QString("application/image-preview") ) - { - QString title; - int number = -1; - bool isFavorite = false; - - int i; - i = argumentNames.indexOf( QString("title") ); - if(i > -1) - title = argumentValues.at(i); - i = argumentNames.indexOf( QString("isFavorite") ); - if(i > -1) - isFavorite = true; - i = argumentNames.indexOf( QString("index") ); - if(i > -1) - number = argumentValues.at(i).toInt(); - - return new PreviewImage(url, title, number, isFavorite); - } - + if(ReKonfig::pluginsEnabled() == 0) // plugins are enabled { kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones..."; @@ -112,10 +91,7 @@ QList WebPluginFactory::plugins() const { QList plugins = KWebPluginFactory::plugins(); - QWebPluginFactory::Plugin p; - p.name = "application/image-preview"; - p.description = "plugin for embedding Web snapped images"; - plugins.append(p); + KWebPluginFactory::Plugin p; p.name = "application/x-shockwave-flash"; p.description = "Plugin for flash animations"; -- cgit v1.2.1 From 18b87086d1a0e472662f3883962b60dbe57e215f Mon Sep 17 00:00:00 2001 From: matgic78 Date: Sat, 26 Dec 2009 13:00:53 +0100 Subject: First expermimental implementation of a new way of choosing a preview --- src/CMakeLists.txt | 1 + src/rekonqpage/newtabpage.cpp | 57 +++++++++++---- src/rekonqpage/newtabpage.h | 2 + src/rekonqpage/previewchooser.cpp | 143 ++++++++++++++++++++++++++++++++++++++ src/rekonqpage/previewchooser.h | 70 +++++++++++++++++++ src/websnap.cpp | 2 +- 6 files changed, 262 insertions(+), 13 deletions(-) create mode 100644 src/rekonqpage/previewchooser.cpp create mode 100644 src/rekonqpage/previewchooser.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2295e9e0..2ad18a02 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,6 +31,7 @@ SET( rekonq_KDEINIT_SRCS history/historypanel.cpp #---------------------------------------- rekonqpage/newtabpage.cpp + rekonqpage/previewchooser.cpp #---------------------------------------- settings/settingsdialog.cpp #---------------------------------------- diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index a587502c..c91af2dc 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -36,6 +36,7 @@ #include "application.h" #include "mainwindow.h" #include "mainview.h" +#include "previewchooser.h" // KDE Includes #include @@ -43,6 +44,7 @@ #include #include #include +#include // Qt Includes #include @@ -82,6 +84,9 @@ void NewTabPage::generate(const KUrl &url) } if(url.directory() == QString("preview/modify")) { + PreviewChooser *pc = new PreviewChooser(url.fileName().toInt()); + connect(pc, SIGNAL(urlChoosed(int,KUrl)), SLOT(setPreview(int,KUrl))); + pc->show(); return; } } @@ -139,7 +144,8 @@ void NewTabPage::favoritesPage() else prev = validPreview(i, url, names.at(i)); - prev.setAttribute("id", "preview" + QVariant(i).toString()); + setupPreview(prev, i); + m_root.appendInside(prev); } } @@ -152,7 +158,9 @@ QWebElement NewTabPage::emptyPreview(int index) prev.findFirst(".preview img").setAttribute("src" , QString("file:///") + KIconLoader::global()->iconPath("insert-image", KIconLoader::Desktop)); prev.findFirst("span").appendInside(i18n("Set a Preview...")); - prev.findFirst("a").setAttribute("href", QString("about:/preview/modify/" + QVariant(index).toString())); + prev.findFirst("a").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString())); + + setupPreview(prev, index); hideControls(prev); return prev; @@ -166,6 +174,8 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url) prev.findFirst(".preview img").setAttribute("src" , QString("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif")); prev.findFirst("span").appendInside(i18n("Loading Preview...")); + + setupPreview(prev, index); showControls(prev); WebSnap *snap = new WebSnap(url); @@ -184,19 +194,11 @@ QWebElement NewTabPage::validPreview(int index, KUrl url, QString title) prev.findFirst(".preview img").setAttribute("src" , previewPath.toMimeDataString()); prev.findFirst("a").setAttribute("href", url.toMimeDataString()); prev.findFirst("span a").setAttribute("href", url.toMimeDataString()); - prev.findFirst("span").appendInside(checkTitle(title)); - - prev.findFirst(".modify img").setAttribute("src", QString("file:///") + - KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState)); - prev.findFirst(".modify").setAttribute("href", QString("about:preview/modify/" + iString )); - - prev.findFirst(".remove img").setAttribute("src", QString("file:///") + - KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState)); - prev.findFirst(".remove").setAttribute("href", QString("about:preview/remove/" + iString )); + prev.findFirst("span").setPlainText(checkTitle(title)); + setupPreview(prev, index); showControls(prev); - return prev; } @@ -212,6 +214,19 @@ void NewTabPage::showControls(QWebElement e) e.findFirst(".modify").setStyleProperty("visibility", "visible"); } +void NewTabPage::setupPreview(QWebElement e, int index) +{ + e.findFirst(".remove img").setAttribute("src", QString("file:///") + + KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState)); + e.findFirst(".modify img").setAttribute("src", QString("file:///") + + KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState)); + + e.findFirst(".modify").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString())); + e.findFirst(".remove").setAttribute("href", QString("about:preview/remove/" + QVariant(index).toString())); + + e.setAttribute("id", "preview" + QVariant(index).toString()); +} + void NewTabPage::snapFinished() { @@ -255,6 +270,24 @@ void NewTabPage::removePreview(int index) } +void NewTabPage::setPreview(int index, KUrl url) +{ + if(url.isEmpty()) + return; + + QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); + + QStringList urls = ReKonfig::previewUrls(); + urls.replace(index, url.toMimeDataString()); + ReKonfig::setPreviewUrls(urls); + ReKonfig::self()->writeConfig(); + + prev.replace(loadingPreview(index, url)); + + +} + + void NewTabPage::browsingMenu(const KUrl ¤tUrl) { QList navItems; diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index 9ac743ea..973028b3 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -58,6 +58,7 @@ public: protected slots: void snapFinished(); void removePreview(int index); + void setPreview(int index, KUrl url); protected: // these are the function to build the new tab page void browsingMenu(const KUrl ¤tUrl); @@ -72,6 +73,7 @@ protected: // these are the function to build the new tab page */ void hideControls(QWebElement e); void showControls(QWebElement e); + void setupPreview(QWebElement e, int index); void historyPage(); diff --git a/src/rekonqpage/previewchooser.cpp b/src/rekonqpage/previewchooser.cpp new file mode 100644 index 00000000..a7c86d12 --- /dev/null +++ b/src/rekonqpage/previewchooser.cpp @@ -0,0 +1,143 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +// Self Includes +#include "previewchooser.h" + +// Local Includes +#include "rekonq.h" +#include +#include +#include + +// Qt Includes +#include +#include + +// KDE Includes +#include +#include + + +PreviewChooser::PreviewChooser(int previewIndex) + : KDialog(0) + , m_treeView(new QTreeView) + , m_model(new QStandardItemModel) + , m_previewIndex(previewIndex) +{ + setMinimumSize(350, 100); + setWindowTitle(i18n("Set Page to preview")); + setModal(true); + + setButtons(KDialog::Cancel | KDialog::Apply | KDialog::Ok); + setDefaultButton(KDialog::Ok); + connect(this, SIGNAL(buttonClicked(KDialog::ButtonCode)), this, SLOT(buttonClicked(KDialog::ButtonCode))); + + m_treeView->setUniformRowHeights(true); + m_treeView->setSelectionBehavior(QAbstractItemView::SelectRows); + m_treeView->setTextElideMode(Qt::ElideRight); + m_treeView->setHeaderHidden(true); + m_treeView->setIndentation(0); + + QWidget *mainWidget = new QWidget(this); + + // add url bar + QHBoxLayout *urlLayout = new QHBoxLayout; + urlLayout->setContentsMargins(5, 0, 0, 0); + QLabel *searchLabel = new QLabel(i18n("adress:")); + urlLayout->addWidget(searchLabel); + m_line = new KLineEdit; + connect(m_line, SIGNAL(textChanged(QString)), SLOT(urlChanged())); + urlLayout->addWidget(m_line); + + // setup view + QVBoxLayout *vBoxLayout = new QVBoxLayout; + vBoxLayout->setContentsMargins(0, 0, 0, 0); + vBoxLayout->addLayout(urlLayout); + vBoxLayout->addWidget(m_treeView); + mainWidget->setLayout(vBoxLayout); + setMainWidget(mainWidget); + + refreshModel(); + connect(Application::instance()->mainWindow()->mainView(), SIGNAL(tabsChanged()), SLOT(refreshModel())); + + m_treeView->setModel(m_model); + + connect(m_treeView, SIGNAL(activated(QModelIndex)), SLOT(setUrl(QModelIndex))); +} + + +PreviewChooser::~PreviewChooser() +{ + delete m_model; +} + + + +void PreviewChooser::refreshModel() +{ + m_model->clear(); + MainView *mv = Application::instance()->mainWindow()->mainView(); + for(int i=0; i < mv->count(); ++i) + { + WebView *view = qobject_cast(mv->webView(i)); + + if(view->url().scheme() == "about:") + continue; + + QStandardItem *it = new QStandardItem(view->icon(), view->title()); + it->setData(QVariant(view->url()), Qt::ToolTipRole); + m_model->insertRow(i, it); + } +} + +void PreviewChooser::setUrl(QModelIndex i) +{ + if(!i.data().canConvert(QVariant::String)) + return; + + m_line->setText(i.data(Qt::ToolTipRole).toString()); +} + + +void PreviewChooser::buttonClicked(KDialog::ButtonCode code) +{ + if(code == KDialog::Apply || code == KDialog::Ok) + { + emit urlChoosed(m_previewIndex, KUrl(m_line->text())); + enableButtonApply(false); + } + + if(code == KDialog::Cancel || code == KDialog::Ok) + { + close(); + deleteLater(); + } +} + + +void PreviewChooser::urlChanged() +{ + enableButtonApply(true); +} + diff --git a/src/rekonqpage/previewchooser.h b/src/rekonqpage/previewchooser.h new file mode 100644 index 00000000..79766fdc --- /dev/null +++ b/src/rekonqpage/previewchooser.h @@ -0,0 +1,70 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +#ifndef PREVIEWCHOOSER_H +#define PREVIEWCHOOSER_H + + +// Local Includes +#include "application.h" + +// KDE Includes +#include +#include + +// Qt Includes +#include +#include +#include + +// Forward Declarations +class KUrl; + + +class PreviewChooser : public KDialog +{ +Q_OBJECT + +public: + explicit PreviewChooser(int previewIndex); + virtual ~PreviewChooser(); + +signals: + void urlChoosed(int, const KUrl &); + +public slots: + void refreshModel(); + void setUrl(QModelIndex i); + void buttonClicked(KDialog::ButtonCode code); + void urlChanged(); + +private: + QTreeView *m_treeView; + QStandardItemModel *m_model; + + KLineEdit *m_line; + + int m_previewIndex; +}; + +#endif // PREVIEWCHOOSER_H diff --git a/src/websnap.cpp b/src/websnap.cpp index e5db7c4e..0d72ef3a 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -167,7 +167,7 @@ void WebSnap::saveResult(bool ok) { m_image = renderPreview(m_page, WIDTH, HEIGHT); } - + QFile::remove(fileForUrl(m_url).toLocalFile()); m_image.save(fileForUrl(m_url).toLocalFile()); kDebug() << "finished"; -- cgit v1.2.1 From e5d1f43e3c58bef6da3ea5a725a57872ddb74f27 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Mon, 28 Dec 2009 14:26:20 +0100 Subject: Fix compilation after rebasing --- src/rekonqpage/previewchooser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/rekonqpage/previewchooser.cpp b/src/rekonqpage/previewchooser.cpp index a7c86d12..fde36563 100644 --- a/src/rekonqpage/previewchooser.cpp +++ b/src/rekonqpage/previewchooser.cpp @@ -29,6 +29,7 @@ #include #include #include +#include // Qt Includes #include @@ -100,7 +101,7 @@ void PreviewChooser::refreshModel() MainView *mv = Application::instance()->mainWindow()->mainView(); for(int i=0; i < mv->count(); ++i) { - WebView *view = qobject_cast(mv->webView(i)); + WebView *view = qobject_cast(mv->webTab(i)->view()); if(view->url().scheme() == "about:") continue; -- cgit v1.2.1 From e3215b1316fa0459d4238bf5cb3c60b0bff90f73 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Thu, 31 Dec 2009 10:53:51 +0100 Subject: little changes --- src/rekonqpage/newtabpage.cpp | 4 +++- src/rekonqpage/previewchooser.cpp | 17 +++++++++++++---- src/rekonqpage/previewchooser.h | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index c91af2dc..c8b2e916 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -84,7 +84,9 @@ void NewTabPage::generate(const KUrl &url) } if(url.directory() == QString("preview/modify")) { - PreviewChooser *pc = new PreviewChooser(url.fileName().toInt()); + int index = url.fileName().toInt(); + QString url = m_root.findFirst("#preview" + QVariant(index).toString() + " > a").attribute("href"); + PreviewChooser *pc = new PreviewChooser(index, url); connect(pc, SIGNAL(urlChoosed(int,KUrl)), SLOT(setPreview(int,KUrl))); pc->show(); return; diff --git a/src/rekonqpage/previewchooser.cpp b/src/rekonqpage/previewchooser.cpp index fde36563..eeea9f99 100644 --- a/src/rekonqpage/previewchooser.cpp +++ b/src/rekonqpage/previewchooser.cpp @@ -40,7 +40,7 @@ #include -PreviewChooser::PreviewChooser(int previewIndex) +PreviewChooser::PreviewChooser(int previewIndex, QString url) : KDialog(0) , m_treeView(new QTreeView) , m_model(new QStandardItemModel) @@ -70,6 +70,15 @@ PreviewChooser::PreviewChooser(int previewIndex) m_line = new KLineEdit; connect(m_line, SIGNAL(textChanged(QString)), SLOT(urlChanged())); urlLayout->addWidget(m_line); + + if(url.isEmpty() || url.startsWith("about:")) + m_line->setText(QString("http://")); + else + { + m_line->setText(url); + m_line->setSelection(8, m_line->text().size()); + } + // setup view QVBoxLayout *vBoxLayout = new QVBoxLayout; @@ -103,10 +112,10 @@ void PreviewChooser::refreshModel() { WebView *view = qobject_cast(mv->webTab(i)->view()); - if(view->url().scheme() == "about:") + if(view->url().scheme() == "about") continue; - QStandardItem *it = new QStandardItem(view->icon(), view->title()); + QStandardItem *it = new QStandardItem(Application::icon(view->url()), view->title()); it->setData(QVariant(view->url()), Qt::ToolTipRole); m_model->insertRow(i, it); } @@ -123,7 +132,7 @@ void PreviewChooser::setUrl(QModelIndex i) void PreviewChooser::buttonClicked(KDialog::ButtonCode code) { - if(code == KDialog::Apply || code == KDialog::Ok) + if(code == KDialog::Apply || (code == KDialog::Ok && isButtonEnabled(KDialog::Apply))) { emit urlChoosed(m_previewIndex, KUrl(m_line->text())); enableButtonApply(false); diff --git a/src/rekonqpage/previewchooser.h b/src/rekonqpage/previewchooser.h index 79766fdc..3eae71db 100644 --- a/src/rekonqpage/previewchooser.h +++ b/src/rekonqpage/previewchooser.h @@ -46,7 +46,7 @@ class PreviewChooser : public KDialog Q_OBJECT public: - explicit PreviewChooser(int previewIndex); + explicit PreviewChooser(int previewIndex, QString url); virtual ~PreviewChooser(); signals: -- cgit v1.2.1 From 8b26d07972db5a2953e64f61bf86e2e31959a32f Mon Sep 17 00:00:00 2001 From: matgic78 Date: Thu, 31 Dec 2009 11:07:24 +0100 Subject: fix bug : closed Tabs replaced favorites when loaded --- src/rekonqpage/newtabpage.cpp | 9 ++++++++- src/rekonqpage/newtabpage.h | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index c8b2e916..78928bca 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -53,6 +53,7 @@ NewTabPage::NewTabPage(QWebFrame *frame) : m_root(frame->documentElement()) + , m_url(KUrl()) { QString htmlFilePath = KStandardDirs::locate("data", "rekonq/htmls/home.html"); @@ -73,7 +74,7 @@ NewTabPage::~NewTabPage() } -void NewTabPage::generate(const KUrl &url) +void NewTabPage::generate(KUrl url) { if(KUrl("about:preview").isParentOf(url)) { @@ -106,6 +107,7 @@ void NewTabPage::generate(const KUrl &url) { favoritesPage(); title = i18n("Favorites"); + url = KUrl("about:favorites"); } else if(url == KUrl("about:closedTabs")) { @@ -123,6 +125,8 @@ void NewTabPage::generate(const KUrl &url) title = i18n("Bookmarks"); } + m_url = url; + m_root.document().findFirst("title").setPlainText(title); } @@ -236,6 +240,9 @@ void NewTabPage::snapFinished() QWebElement prev = m_root.findFirst("#preview" + snap->data().toString()); prev.replace(validPreview(snap->data().toInt(), snap->snapUrl(), snap->snapTitle())); + if(m_url != KUrl("about:favorites")) + return; + // Save the new config QStringList names = ReKonfig::previewNames(); QStringList urls = ReKonfig::previewUrls(); diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index 973028b3..cdc3cb31 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -53,7 +53,7 @@ public: * about: url and loads the corresponding part of the * new tab page */ - void generate(const KUrl &url = KUrl("about:home")); + void generate(KUrl url = KUrl("about:home")); protected slots: void snapFinished(); @@ -97,6 +97,8 @@ private: QString m_html; QWebElement m_root; + + KUrl m_url; }; #endif // REKONQ_NEW_TAB_PAGE -- cgit v1.2.1 From 0c98fe6a475ec8003590db31eb6c9ab471a4b388 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Mon, 4 Jan 2010 18:22:50 +0100 Subject: tmp commit --- src/rekonqpage/previewchooser.cpp | 40 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/rekonqpage/previewchooser.cpp b/src/rekonqpage/previewchooser.cpp index eeea9f99..79bdb068 100644 --- a/src/rekonqpage/previewchooser.cpp +++ b/src/rekonqpage/previewchooser.cpp @@ -51,7 +51,7 @@ PreviewChooser::PreviewChooser(int previewIndex, QString url) setModal(true); setButtons(KDialog::Cancel | KDialog::Apply | KDialog::Ok); - setDefaultButton(KDialog::Ok); + //setDefaultButton(KDialog::Ok); connect(this, SIGNAL(buttonClicked(KDialog::ButtonCode)), this, SLOT(buttonClicked(KDialog::ButtonCode))); m_treeView->setUniformRowHeights(true); @@ -68,18 +68,7 @@ PreviewChooser::PreviewChooser(int previewIndex, QString url) QLabel *searchLabel = new QLabel(i18n("adress:")); urlLayout->addWidget(searchLabel); m_line = new KLineEdit; - connect(m_line, SIGNAL(textChanged(QString)), SLOT(urlChanged())); - urlLayout->addWidget(m_line); - if(url.isEmpty() || url.startsWith("about:")) - m_line->setText(QString("http://")); - else - { - m_line->setText(url); - m_line->setSelection(8, m_line->text().size()); - } - - // setup view QVBoxLayout *vBoxLayout = new QVBoxLayout; vBoxLayout->setContentsMargins(0, 0, 0, 0); @@ -94,6 +83,21 @@ PreviewChooser::PreviewChooser(int previewIndex, QString url) m_treeView->setModel(m_model); connect(m_treeView, SIGNAL(activated(QModelIndex)), SLOT(setUrl(QModelIndex))); + + connect(m_line, SIGNAL(textChanged(QString)), SLOT(urlChanged())); + urlLayout->addWidget(m_line); + + if(url.isEmpty() || url.startsWith("about:")) + m_line->setText(QString("http://")); + else + { + m_line->setText(url); + m_line->setSelection(8, m_line->text().size()); + } + + enableButtonApply(false); + setFocusProxy(mainWidget); + mainWidget->setFocusProxy(m_line); } @@ -112,12 +116,12 @@ void PreviewChooser::refreshModel() { WebView *view = qobject_cast(mv->webTab(i)->view()); - if(view->url().scheme() == "about") - continue; - - QStandardItem *it = new QStandardItem(Application::icon(view->url()), view->title()); - it->setData(QVariant(view->url()), Qt::ToolTipRole); - m_model->insertRow(i, it); + if(view->url().scheme() != "about") + { + QStandardItem *it = new QStandardItem(Application::icon(view->url()), view->title()); + it->setData(QVariant(view->url()), Qt::ToolTipRole); + m_model->appendRow(it); + } } } -- cgit v1.2.1 From 544094302a51b919b1eea86b313ec10d47533a08 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Fri, 15 Jan 2010 17:20:51 +0100 Subject: A new approach for choosing previews : a bar appears, then you browse to the page you want to preview, and then you click a button --- src/CMakeLists.txt | 2 +- src/mainwindow.cpp | 5 ++ src/mainwindow.h | 8 +- src/protocolhandler.cpp | 33 +------ src/rekonqpage/newtabpage.cpp | 36 +++++--- src/rekonqpage/newtabpage.h | 11 ++- src/rekonqpage/previewchooser.cpp | 157 ---------------------------------- src/rekonqpage/previewchooser.h | 70 --------------- src/rekonqpage/previewselectorbar.cpp | 138 ++++++++++++++++++++++++++++++ src/rekonqpage/previewselectorbar.h | 60 +++++++++++++ src/webpage.cpp | 16 ++-- src/webpage.h | 2 + src/websnap.cpp | 11 ++- src/websnap.h | 7 +- 14 files changed, 268 insertions(+), 288 deletions(-) delete mode 100644 src/rekonqpage/previewchooser.cpp delete mode 100644 src/rekonqpage/previewchooser.h create mode 100644 src/rekonqpage/previewselectorbar.cpp create mode 100644 src/rekonqpage/previewselectorbar.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ad18a02..00cfbf77 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,7 +31,7 @@ SET( rekonq_KDEINIT_SRCS history/historypanel.cpp #---------------------------------------- rekonqpage/newtabpage.cpp - rekonqpage/previewchooser.cpp + rekonqpage/previewselectorbar.cpp #---------------------------------------- settings/settingsdialog.cpp #---------------------------------------- diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ffc9f508..e11f6d19 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -98,6 +98,7 @@ MainWindow::MainWindow() : KMainWindow() , m_view( new MainView(this) ) , m_findBar( new FindBar(this) ) + , m_previewSelectorBar( new PreviewSelectorBar(this) ) , m_historyPanel(0) , m_bookmarksPanel(0) , m_webInspectorPanel(0) @@ -122,6 +123,7 @@ MainWindow::MainWindow() QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_view); + layout->addWidget(m_previewSelectorBar); layout->addWidget(m_findBar); centralWidget->setLayout(layout); @@ -617,6 +619,9 @@ void MainWindow::updateActions() QAction *historyForwardAction = actionByName(KStandardAction::name(KStandardAction::Forward)); historyForwardAction->setEnabled(currentTab()->view()->history()->canGoForward()); + + if(m_previewSelectorBar->isVisible()) + m_previewSelectorBar->setPage(currentTab()->page()); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 7083591d..3a828afe 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -1,4 +1,5 @@ -/* ============================================================ + +class PreviewSelectorBar;/* ============================================================ * * This file is a part of the rekonq project * @@ -32,6 +33,7 @@ // Local Includes #include "application.h" +#include "previewselectorbar.h" // KDE Includes #include @@ -152,7 +154,9 @@ private slots: private: MainView *m_view; FindBar *m_findBar; - + + PreviewSelectorBar *m_previewSelectorBar; + HistoryPanel *m_historyPanel; BookmarksPanel *m_bookmarksPanel; WebInspectorPanel *m_webInspectorPanel; diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index c90afd19..a9339cfa 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -108,36 +108,9 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra // "about" handling if ( _url.protocol() == QLatin1String("about") ) { - if( _url == KUrl("about:home") ) - { - switch(ReKonfig::newTabStartPage()) - { - case 0: // favorites - _url = KUrl("about:favorites"); - break; - case 1: // closed tabs - _url = KUrl("about:closedTabs"); - break; - case 2: // history - _url = KUrl("about:history"); - break; - case 3: // bookmarks - _url = KUrl("about:bookmarks"); - break; - default: // unuseful - break; - } - } - if( _url == KUrl("about:closedTabs") - || _url == KUrl("about:history") - || _url == KUrl("about:bookmarks") - || _url == KUrl("about:favorites") - ) - { - NewTabPage p(frame); - p.generate(_url); - return true; - } + NewTabPage p(frame); + p.generate(_url); + return true; } return false; diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 78928bca..b075c186 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -36,7 +36,8 @@ #include "application.h" #include "mainwindow.h" #include "mainview.h" -#include "previewchooser.h" +#include "websnap.h" +#include "previewselectorbar.h" // KDE Includes #include @@ -48,7 +49,6 @@ // Qt Includes #include -#include NewTabPage::NewTabPage(QWebFrame *frame) @@ -86,10 +86,8 @@ void NewTabPage::generate(KUrl url) if(url.directory() == QString("preview/modify")) { int index = url.fileName().toInt(); - QString url = m_root.findFirst("#preview" + QVariant(index).toString() + " > a").attribute("href"); - PreviewChooser *pc = new PreviewChooser(index, url); - connect(pc, SIGNAL(urlChoosed(int,KUrl)), SLOT(setPreview(int,KUrl))); - pc->show(); + Application::instance()->mainWindow()->findChild() + ->enable(index, qobject_cast< WebPage* >(m_root.webFrame()->page())); return; } } @@ -260,9 +258,6 @@ void NewTabPage::snapFinished() void NewTabPage::removePreview(int index) { - QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); - - QStringList names = ReKonfig::previewNames(); QStringList urls = ReKonfig::previewUrls(); @@ -272,9 +267,9 @@ void NewTabPage::removePreview(int index) ReKonfig::setPreviewNames(names); ReKonfig::setPreviewUrls(urls); - // sync file data ReKonfig::self()->writeConfig(); + QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); prev.replace(emptyPreview(index)); } @@ -285,18 +280,33 @@ void NewTabPage::setPreview(int index, KUrl url) return; QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); + prev.replace(loadingPreview(index, url)); + +} + + +void NewTabPage::setPreview(int index, WebPage* page) +{ + KUrl url = page->mainFrame()->url(); + WebSnap::savePreview(WebSnap::renderPreview(*page), url); + + QStringList names = ReKonfig::previewNames(); QStringList urls = ReKonfig::previewUrls(); + urls.replace(index, url.toMimeDataString()); + names.replace(index, page->mainFrame()->title()); + + ReKonfig::setPreviewNames(names); ReKonfig::setPreviewUrls(urls); + ReKonfig::self()->writeConfig(); - - prev.replace(loadingPreview(index, url)); - + setPreview(index, url); } + void NewTabPage::browsingMenu(const KUrl ¤tUrl) { QList navItems; diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index cdc3cb31..742d9209 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -55,10 +55,19 @@ public: */ void generate(KUrl url = KUrl("about:home")); -protected slots: +public slots: void snapFinished(); void removePreview(int index); + + /** + Used for recently closed tabs + */ void setPreview(int index, KUrl url); + + /** + Used for favorites + */ + void setPreview(int index, WebPage *page); protected: // these are the function to build the new tab page void browsingMenu(const KUrl ¤tUrl); diff --git a/src/rekonqpage/previewchooser.cpp b/src/rekonqpage/previewchooser.cpp deleted file mode 100644 index 79bdb068..00000000 --- a/src/rekonqpage/previewchooser.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* 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 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* 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. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* ============================================================ */ - - -// Self Includes -#include "previewchooser.h" - -// Local Includes -#include "rekonq.h" -#include -#include -#include -#include - -// Qt Includes -#include -#include - -// KDE Includes -#include -#include - - -PreviewChooser::PreviewChooser(int previewIndex, QString url) - : KDialog(0) - , m_treeView(new QTreeView) - , m_model(new QStandardItemModel) - , m_previewIndex(previewIndex) -{ - setMinimumSize(350, 100); - setWindowTitle(i18n("Set Page to preview")); - setModal(true); - - setButtons(KDialog::Cancel | KDialog::Apply | KDialog::Ok); - //setDefaultButton(KDialog::Ok); - connect(this, SIGNAL(buttonClicked(KDialog::ButtonCode)), this, SLOT(buttonClicked(KDialog::ButtonCode))); - - m_treeView->setUniformRowHeights(true); - m_treeView->setSelectionBehavior(QAbstractItemView::SelectRows); - m_treeView->setTextElideMode(Qt::ElideRight); - m_treeView->setHeaderHidden(true); - m_treeView->setIndentation(0); - - QWidget *mainWidget = new QWidget(this); - - // add url bar - QHBoxLayout *urlLayout = new QHBoxLayout; - urlLayout->setContentsMargins(5, 0, 0, 0); - QLabel *searchLabel = new QLabel(i18n("adress:")); - urlLayout->addWidget(searchLabel); - m_line = new KLineEdit; - - // setup view - QVBoxLayout *vBoxLayout = new QVBoxLayout; - vBoxLayout->setContentsMargins(0, 0, 0, 0); - vBoxLayout->addLayout(urlLayout); - vBoxLayout->addWidget(m_treeView); - mainWidget->setLayout(vBoxLayout); - setMainWidget(mainWidget); - - refreshModel(); - connect(Application::instance()->mainWindow()->mainView(), SIGNAL(tabsChanged()), SLOT(refreshModel())); - - m_treeView->setModel(m_model); - - connect(m_treeView, SIGNAL(activated(QModelIndex)), SLOT(setUrl(QModelIndex))); - - connect(m_line, SIGNAL(textChanged(QString)), SLOT(urlChanged())); - urlLayout->addWidget(m_line); - - if(url.isEmpty() || url.startsWith("about:")) - m_line->setText(QString("http://")); - else - { - m_line->setText(url); - m_line->setSelection(8, m_line->text().size()); - } - - enableButtonApply(false); - setFocusProxy(mainWidget); - mainWidget->setFocusProxy(m_line); -} - - -PreviewChooser::~PreviewChooser() -{ - delete m_model; -} - - - -void PreviewChooser::refreshModel() -{ - m_model->clear(); - MainView *mv = Application::instance()->mainWindow()->mainView(); - for(int i=0; i < mv->count(); ++i) - { - WebView *view = qobject_cast(mv->webTab(i)->view()); - - if(view->url().scheme() != "about") - { - QStandardItem *it = new QStandardItem(Application::icon(view->url()), view->title()); - it->setData(QVariant(view->url()), Qt::ToolTipRole); - m_model->appendRow(it); - } - } -} - -void PreviewChooser::setUrl(QModelIndex i) -{ - if(!i.data().canConvert(QVariant::String)) - return; - - m_line->setText(i.data(Qt::ToolTipRole).toString()); -} - - -void PreviewChooser::buttonClicked(KDialog::ButtonCode code) -{ - if(code == KDialog::Apply || (code == KDialog::Ok && isButtonEnabled(KDialog::Apply))) - { - emit urlChoosed(m_previewIndex, KUrl(m_line->text())); - enableButtonApply(false); - } - - if(code == KDialog::Cancel || code == KDialog::Ok) - { - close(); - deleteLater(); - } -} - - -void PreviewChooser::urlChanged() -{ - enableButtonApply(true); -} - diff --git a/src/rekonqpage/previewchooser.h b/src/rekonqpage/previewchooser.h deleted file mode 100644 index 3eae71db..00000000 --- a/src/rekonqpage/previewchooser.h +++ /dev/null @@ -1,70 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* 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 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* 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. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* ============================================================ */ - - -#ifndef PREVIEWCHOOSER_H -#define PREVIEWCHOOSER_H - - -// Local Includes -#include "application.h" - -// KDE Includes -#include -#include - -// Qt Includes -#include -#include -#include - -// Forward Declarations -class KUrl; - - -class PreviewChooser : public KDialog -{ -Q_OBJECT - -public: - explicit PreviewChooser(int previewIndex, QString url); - virtual ~PreviewChooser(); - -signals: - void urlChoosed(int, const KUrl &); - -public slots: - void refreshModel(); - void setUrl(QModelIndex i); - void buttonClicked(KDialog::ButtonCode code); - void urlChanged(); - -private: - QTreeView *m_treeView; - QStandardItemModel *m_model; - - KLineEdit *m_line; - - int m_previewIndex; -}; - -#endif // PREVIEWCHOOSER_H diff --git a/src/rekonqpage/previewselectorbar.cpp b/src/rekonqpage/previewselectorbar.cpp new file mode 100644 index 00000000..04e7f0ac --- /dev/null +++ b/src/rekonqpage/previewselectorbar.cpp @@ -0,0 +1,138 @@ +/* + + Copyright (C) + + 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 3 of the License, 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. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + + +// Auto Includes +#include "previewselectorbar.h" + +// KDE Includes +#include +#include + +// Qt Includes +#include +#include +#include + + +PreviewSelectorBar::PreviewSelectorBar(QWidget* parent) + : QWidget(parent) + , m_button(0) + , m_label(0) + , m_page(0) +{ + hide(); +} + + +void PreviewSelectorBar::setup() +{ + if(m_button != 0) + return; + + m_label = new QLabel(i18n("Please go to the page you want to preview"), this); + m_label->setWordWrap(true); + + QToolButton *closeButton = new QToolButton(this); + closeButton->setAutoRaise(true); + closeButton->setIcon(KIcon("dialog-close")); + connect(closeButton, SIGNAL(clicked(bool)), SLOT(hide())); + + m_button = new QPushButton(KIcon("insert-image"), i18n("Set to this page"), this); + connect(m_button, SIGNAL(clicked(bool)), SLOT(clicked())); + + // layout + QHBoxLayout *layout = new QHBoxLayout(this); + layout->addWidget(closeButton); + layout->addStretch(); + layout->addWidget(m_label); + layout->addWidget(m_button); + + setLayout(layout); +} + + +void PreviewSelectorBar::setPage(WebPage* page) +{ + m_page = page; + verifyUrl(); +} + + +void PreviewSelectorBar::verifyUrl() +{ + if(m_page->mainFrame()->url().scheme() != "about") + { + m_button->setEnabled(true); + m_button->setToolTip(""); + } + else + { + m_button->setEnabled(false); + m_button->setToolTip(i18n("You can't set this page as preview")); + } +} + + +void PreviewSelectorBar::enable(int previewIndex, WebPage* page) +{ + if(m_page != 0) + disconnect(m_page, 0, this, 0); + + + setup(); + m_previewIndex = previewIndex; + m_page = page; + + verifyUrl(); + + show(); + + connect(page, SIGNAL(loadStarted()), SLOT(loadProgress())); + connect(page, SIGNAL(loadProgress(int)), SLOT(loadProgress())); + connect(page, SIGNAL(loadFinished(bool)), SLOT(loadFinished())); + connect(page->mainFrame(), SIGNAL(urlChanged(QUrl)), SLOT(verifyUrl())); +} + + +void PreviewSelectorBar::loadProgress() +{ + m_button->setEnabled(false); + m_button->setToolTip(i18n("Page is loading...")); +} + + + +void PreviewSelectorBar::loadFinished() +{ + m_button->setEnabled(true); + m_button->setToolTip(""); + + verifyUrl(); +} + + +void PreviewSelectorBar::clicked() +{ + m_page->newTabPage()->setPreview(m_previewIndex, m_page); + m_page->mainFrame()->load(KUrl("about:favorites")); + hide(); +} + + diff --git a/src/rekonqpage/previewselectorbar.h b/src/rekonqpage/previewselectorbar.h new file mode 100644 index 00000000..aa011fe4 --- /dev/null +++ b/src/rekonqpage/previewselectorbar.h @@ -0,0 +1,60 @@ +/* + + Copyright (C) + + 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 3 of the License, 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. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#ifndef PREVIEWSELECTORBAR_H +#define PREVIEWSELECTORBAR_H + +// Local Includes +#include "webpage.h" + +// Qt Includes +#include +#include +#include + +class PreviewSelectorBar : public QWidget +{ + Q_OBJECT + + public: + PreviewSelectorBar(QWidget *parent = 0); + + void setPage(WebPage *page); + + public slots: + void enable(int previewIndex, WebPage *page); + void clicked(); + + void loadProgress(); + void loadFinished(); + + void verifyUrl(); + + private: + void setup(); + + QPushButton *m_button; + QLabel *m_label; + + int m_previewIndex; + WebPage *m_page; + +}; + +#endif // PREVIEWSELECTORBAR_H diff --git a/src/webpage.cpp b/src/webpage.cpp index 59df13e7..340e9805 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -72,7 +72,7 @@ WebPage::WebPage(QObject *parent) : KWebPage(parent, KWalletIntegration) - , m_newTabPage(0) + , m_newTabPage(new NewTabPage(mainFrame() )) { setForwardUnsupportedContent(true); @@ -104,6 +104,12 @@ WebPage::~WebPage() } +NewTabPage* WebPage::newTabPage() +{ + return m_newTabPage; +} + + bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { // advise users on resubmitting data @@ -115,14 +121,6 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r if(risp == KMessageBox::Cancel) return false; } - - if (request.url().scheme() == QLatin1String("about")) - { - if(m_newTabPage == 0) - m_newTabPage = new NewTabPage(frame); - m_newTabPage->generate(request.url()); - return false; - } if (frame && m_protHandler.preHandling( request, frame )) { diff --git a/src/webpage.h b/src/webpage.h index 5671b5d9..da91ea5c 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -55,6 +55,8 @@ class WebPage : public KWebPage public: explicit WebPage(QObject *parent = 0); ~WebPage(); + + NewTabPage *newTabPage(); public slots: void manageNetworkErrors(QNetworkReply *reply); diff --git a/src/websnap.cpp b/src/websnap.cpp index 0d72ef3a..ff4746ca 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -42,10 +42,6 @@ #include -#define WIDTH 200 -#define HEIGHT 150 - - WebSnap::WebSnap(const QUrl &url) : QObject() { @@ -115,6 +111,13 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h) } +void WebSnap::savePreview(QPixmap pm, KUrl url) +{ + QFile::remove(fileForUrl(url).toLocalFile()); + pm.save(fileForUrl(url).toLocalFile()); +} + + KUrl WebSnap::fileForUrl(KUrl url) { QString filePath = diff --git a/src/websnap.h b/src/websnap.h index 04fded57..b8ada30f 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -37,6 +37,9 @@ #include #include +#define WIDTH 200 +#define HEIGHT 150 + /** * This class renders a site producing an image based @@ -53,12 +56,14 @@ public: QPixmap previewImage(); // TODO : remove - static QPixmap renderPreview(const QWebPage &page, int w, int h); + static QPixmap renderPreview(const QWebPage &page, int w = WIDTH, int h = HEIGHT); static KUrl fileForUrl(KUrl url); static QString guessNameFromUrl(QUrl url); + static void savePreview(QPixmap pm, KUrl url); + QString snapTitle(); QUrl snapUrl(); -- cgit v1.2.1 From 50d6ee1e340c35261b0445c1a2c793fb07da4854 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Sun, 17 Jan 2010 19:06:27 +0100 Subject: bugfixing... --- src/rekonqpage/newtabpage.cpp | 56 ++++------------------------------- src/rekonqpage/newtabpage.h | 14 ++------- src/rekonqpage/previewselectorbar.cpp | 22 +++++++++++++- src/websnap.cpp | 4 ++- 4 files changed, 31 insertions(+), 65 deletions(-) (limited to 'src') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index b075c186..f2609c19 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -26,6 +26,7 @@ // Self Includes #include "newtabpage.h" +#include "newtabpage.moc" // Auto Includes #include "rekonq.h" @@ -183,8 +184,9 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url) showControls(prev); WebSnap *snap = new WebSnap(url); + bool test = connect(snap, SIGNAL(finished()), this, SLOT(snapFinished())); + kDebug() << test; snap->SetData(QVariant(index)); - connect(snap, SIGNAL(finished()), SLOT(snapFinished())); return prev; } @@ -233,26 +235,11 @@ void NewTabPage::setupPreview(QWebElement e, int index) void NewTabPage::snapFinished() -{ +{ + kDebug() << "called"; WebSnap *snap = qobject_cast(sender()); QWebElement prev = m_root.findFirst("#preview" + snap->data().toString()); prev.replace(validPreview(snap->data().toInt(), snap->snapUrl(), snap->snapTitle())); - - if(m_url != KUrl("about:favorites")) - return; - - // Save the new config - QStringList names = ReKonfig::previewNames(); - QStringList urls = ReKonfig::previewUrls(); - - // stripTrailingSlash to be sure to get the same string for same address - urls.replace(snap->data().toInt(), snap->snapUrl().toString(QUrl::StripTrailingSlash)); - names.replace(snap->data().toInt() , snap->snapTitle()); - - ReKonfig::setPreviewNames(names); - ReKonfig::setPreviewUrls(urls); - - ReKonfig::self()->writeConfig(); } @@ -274,39 +261,6 @@ void NewTabPage::removePreview(int index) } -void NewTabPage::setPreview(int index, KUrl url) -{ - if(url.isEmpty()) - return; - - QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); - prev.replace(loadingPreview(index, url)); - -} - - -void NewTabPage::setPreview(int index, WebPage* page) -{ - KUrl url = page->mainFrame()->url(); - - WebSnap::savePreview(WebSnap::renderPreview(*page), url); - - QStringList names = ReKonfig::previewNames(); - QStringList urls = ReKonfig::previewUrls(); - - urls.replace(index, url.toMimeDataString()); - names.replace(index, page->mainFrame()->title()); - - ReKonfig::setPreviewNames(names); - ReKonfig::setPreviewUrls(urls); - - ReKonfig::self()->writeConfig(); - - setPreview(index, url); -} - - - void NewTabPage::browsingMenu(const KUrl ¤tUrl) { QList navItems; diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index 742d9209..1057c7cc 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -32,8 +32,8 @@ #include // Qt Includes -#include -#include +#include +#include #include // Forward Includes @@ -58,16 +58,6 @@ public: public slots: void snapFinished(); void removePreview(int index); - - /** - Used for recently closed tabs - */ - void setPreview(int index, KUrl url); - - /** - Used for favorites - */ - void setPreview(int index, WebPage *page); protected: // these are the function to build the new tab page void browsingMenu(const KUrl ¤tUrl); diff --git a/src/rekonqpage/previewselectorbar.cpp b/src/rekonqpage/previewselectorbar.cpp index 04e7f0ac..bbdce9d4 100644 --- a/src/rekonqpage/previewselectorbar.cpp +++ b/src/rekonqpage/previewselectorbar.cpp @@ -21,6 +21,10 @@ // Auto Includes #include "previewselectorbar.h" +// Local Include +#include "rekonq.h" +#include "websnap.h" + // KDE Includes #include #include @@ -130,8 +134,24 @@ void PreviewSelectorBar::loadFinished() void PreviewSelectorBar::clicked() { - m_page->newTabPage()->setPreview(m_previewIndex, m_page); + KUrl url = m_page->mainFrame()->url(); + + WebSnap::savePreview(WebSnap::renderPreview(*m_page), url); + + QStringList names = ReKonfig::previewNames(); + QStringList urls = ReKonfig::previewUrls(); + + urls.replace(m_previewIndex, url.toMimeDataString()); + names.replace(m_previewIndex, m_page->mainFrame()->title()); + + ReKonfig::setPreviewNames(names); + ReKonfig::setPreviewUrls(urls); + + ReKonfig::self()->writeConfig(); + + m_page->mainFrame()->load(KUrl("about:favorites")); + hide(); } diff --git a/src/websnap.cpp b/src/websnap.cpp index ff4746ca..fde7bd94 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -108,6 +108,8 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h) page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); return QPixmap::fromImage(pageImage); + + kDebug() << w << h; } @@ -172,8 +174,8 @@ void WebSnap::saveResult(bool ok) } QFile::remove(fileForUrl(m_url).toLocalFile()); m_image.save(fileForUrl(m_url).toLocalFile()); - kDebug() << "finished"; + kDebug() << "finished"; emit finished(); } -- cgit v1.2.1 From d7b37b950bb9ac396914d937df44891e02a64811 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Fri, 29 Jan 2010 19:55:08 +0100 Subject: bugfix : previews were sometimes saved using the good size --- src/rekonqpage/previewselectorbar.cpp | 2 +- src/websnap.cpp | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/rekonqpage/previewselectorbar.cpp b/src/rekonqpage/previewselectorbar.cpp index bbdce9d4..00950526 100644 --- a/src/rekonqpage/previewselectorbar.cpp +++ b/src/rekonqpage/previewselectorbar.cpp @@ -135,7 +135,7 @@ void PreviewSelectorBar::loadFinished() void PreviewSelectorBar::clicked() { KUrl url = m_page->mainFrame()->url(); - + WebSnap::savePreview(WebSnap::renderPreview(*m_page), url); QStringList names = ReKonfig::previewNames(); diff --git a/src/websnap.cpp b/src/websnap.cpp index fde7bd94..983da716 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -80,17 +80,10 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h) // find the best size QSize size; - if (page.viewportSize().width() && page.viewportSize().height()) - { - size = page.viewportSize(); - } - else - { - int width = page.mainFrame()->contentsSize().width(); - if (width < 640) width = 640; - size = QSize(width,width*((0.0+h)/w)); - page.setViewportSize(size); - } + int width = page.mainFrame()->contentsSize().width(); + if (width < 640) width = 640; + size = QSize(width,width*((0.0+h)/w)); + page.setViewportSize(size); // create the page image QImage pageImage = QImage(size, QImage::Format_ARGB32_Premultiplied); @@ -108,13 +101,12 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h) page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); return QPixmap::fromImage(pageImage); - - kDebug() << w << h; } void WebSnap::savePreview(QPixmap pm, KUrl url) { + kDebug() << "saving preview"; QFile::remove(fileForUrl(url).toLocalFile()); pm.save(fileForUrl(url).toLocalFile()); } -- cgit v1.2.1 From 40a13302af46792cb139d59d7f66e12b46644392 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Sun, 31 Jan 2010 11:28:31 +0100 Subject: Last bugs : layout fixes and empty urlbar when going back to homepage --- src/rekonqpage/previewselectorbar.cpp | 4 +++- src/urlbar/urlbar.cpp | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rekonqpage/previewselectorbar.cpp b/src/rekonqpage/previewselectorbar.cpp index 00950526..e7800f09 100644 --- a/src/rekonqpage/previewselectorbar.cpp +++ b/src/rekonqpage/previewselectorbar.cpp @@ -59,15 +59,17 @@ void PreviewSelectorBar::setup() connect(closeButton, SIGNAL(clicked(bool)), SLOT(hide())); m_button = new QPushButton(KIcon("insert-image"), i18n("Set to this page"), this); + m_button->setMaximumWidth(250); connect(m_button, SIGNAL(clicked(bool)), SLOT(clicked())); // layout QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(closeButton); - layout->addStretch(); layout->addWidget(m_label); layout->addWidget(m_button); + layout->setContentsMargins(2, 0, 2, 0); + setLayout(layout); } diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index adeba6ae..4d9765a2 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -148,7 +148,6 @@ void UrlBar::setUrl(const QUrl& url) m_currentUrl = KUrl(url); updateUrl(); } - } -- cgit v1.2.1 From dd2b45b7592bdefd14665c13cec2b7db6728d800 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Sun, 31 Jan 2010 15:53:29 +0100 Subject: Add tooltips to buttons --- src/rekonqpage/newtabpage.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index f2609c19..8a1ca89f 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -224,8 +224,10 @@ void NewTabPage::setupPreview(QWebElement e, int index) { e.findFirst(".remove img").setAttribute("src", QString("file:///") + KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState)); + e.findFirst(".remove").setAttribute("title", "Remove favorite"); e.findFirst(".modify img").setAttribute("src", QString("file:///") + KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState)); + e.findFirst(".modify").setAttribute("title", "Set new favorite"); e.findFirst(".modify").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString())); e.findFirst(".remove").setAttribute("href", QString("about:preview/remove/" + QVariant(index).toString())); -- cgit v1.2.1 From b9b292845f2953396fc088c551b31f79eddd3caa Mon Sep 17 00:00:00 2001 From: matgic78 Date: Sun, 31 Jan 2010 15:57:24 +0100 Subject: Changed strings following pano's recommandations --- src/rekonqpage/previewselectorbar.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/rekonqpage/previewselectorbar.cpp b/src/rekonqpage/previewselectorbar.cpp index e7800f09..5f3956d7 100644 --- a/src/rekonqpage/previewselectorbar.cpp +++ b/src/rekonqpage/previewselectorbar.cpp @@ -50,7 +50,7 @@ void PreviewSelectorBar::setup() if(m_button != 0) return; - m_label = new QLabel(i18n("Please go to the page you want to preview"), this); + m_label = new QLabel(i18n("Please open up the webpage you want to add as favorite"), this); m_label->setWordWrap(true); QToolButton *closeButton = new QToolButton(this); @@ -58,7 +58,7 @@ void PreviewSelectorBar::setup() closeButton->setIcon(KIcon("dialog-close")); connect(closeButton, SIGNAL(clicked(bool)), SLOT(hide())); - m_button = new QPushButton(KIcon("insert-image"), i18n("Set to this page"), this); + m_button = new QPushButton(KIcon("insert-image"), i18n("Set to This Page"), this); m_button->setMaximumWidth(250); connect(m_button, SIGNAL(clicked(bool)), SLOT(clicked())); @@ -91,7 +91,7 @@ void PreviewSelectorBar::verifyUrl() else { m_button->setEnabled(false); - m_button->setToolTip(i18n("You can't set this page as preview")); + m_button->setToolTip(i18n("You can not add this webpage as favorite")); } } -- cgit v1.2.1 From 1c1f1edd697aca0bf96d8d61c40e45166b5f1d02 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Wed, 3 Feb 2010 14:51:38 +0100 Subject: Remove m_newtabPage. That was not used anywhere ! --- src/webpage.cpp | 7 ------- src/webpage.h | 3 --- 2 files changed, 10 deletions(-) (limited to 'src') diff --git a/src/webpage.cpp b/src/webpage.cpp index 340e9805..f2ea412d 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -72,7 +72,6 @@ WebPage::WebPage(QObject *parent) : KWebPage(parent, KWalletIntegration) - , m_newTabPage(new NewTabPage(mainFrame() )) { setForwardUnsupportedContent(true); @@ -104,12 +103,6 @@ WebPage::~WebPage() } -NewTabPage* WebPage::newTabPage() -{ - return m_newTabPage; -} - - bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { // advise users on resubmitting data diff --git a/src/webpage.h b/src/webpage.h index da91ea5c..c8ecc89a 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -55,8 +55,6 @@ class WebPage : public KWebPage public: explicit WebPage(QObject *parent = 0); ~WebPage(); - - NewTabPage *newTabPage(); public slots: void manageNetworkErrors(QNetworkReply *reply); @@ -80,7 +78,6 @@ private: QUrl m_requestedUrl; ProtocolHandler m_protHandler; - NewTabPage *m_newTabPage; }; #endif -- cgit v1.2.1 From 697d05328acd76de7a73145056ef22c8083f3ca4 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Thu, 4 Feb 2010 17:29:13 +0100 Subject: Do not try to load homepage if url is not valid --- src/rekonqpage/newtabpage.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 8a1ca89f..49f4e837 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -93,6 +93,14 @@ void NewTabPage::generate(KUrl url) } } + if( url != KUrl("about:home") + && url != KUrl("about:favorites") + && url != KUrl("about:closedTabs") + && url != KUrl("about:history") + && url != KUrl("about:bookmarks") + ) + return; + QWebPage *page = m_root.webFrame()->page(); page->mainFrame()->setHtml(m_html); -- cgit v1.2.1 From 6f3b61c0462b08d3c2a34ac1923470a3690233ee Mon Sep 17 00:00:00 2001 From: matgic78 Date: Sat, 6 Feb 2010 11:19:18 +0100 Subject: Fix loading previews : when load finished, result wasn't shown --- src/data/home.html | 4 ++-- src/rekonqpage/newtabpage.cpp | 47 +++++++++++++++++++++++++++++++------------ src/rekonqpage/newtabpage.h | 2 +- src/websnap.cpp | 27 +++++++++++-------------- src/websnap.h | 11 +++------- 5 files changed, 52 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/data/home.html b/src/data/home.html index 103c559d..51b9ceec 100644 --- a/src/data/home.html +++ b/src/data/home.html @@ -66,7 +66,7 @@ color: black; /* ------------------------------------------------------- */ /* page sections */ -#container { +#rekonq-newtabpage { width: 100%; } @@ -191,7 +191,7 @@ margin-bottom: 0.5em; -
+
diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 49f4e837..19f1686f 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -76,7 +76,7 @@ NewTabPage::~NewTabPage() void NewTabPage::generate(KUrl url) -{ +{ if(KUrl("about:preview").isParentOf(url)) { if(url.directory() == QString("preview/remove")) @@ -140,10 +140,10 @@ void NewTabPage::generate(KUrl url) void NewTabPage::favoritesPage() { + m_root.addClass("favorites"); + QStringList names = ReKonfig::previewNames(); QStringList urls = ReKonfig::previewUrls(); - - m_root.addClass("favorites"); for(int i=0; i<8; ++i) { @@ -187,14 +187,12 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url) prev.findFirst(".preview img").setAttribute("src" , QString("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif")); prev.findFirst("span").appendInside(i18n("Loading Preview...")); + prev.findFirst("a").setAttribute("href", url.toMimeDataString()); setupPreview(prev, index); showControls(prev); - WebSnap *snap = new WebSnap(url); - bool test = connect(snap, SIGNAL(finished()), this, SLOT(snapFinished())); - kDebug() << test; - snap->SetData(QVariant(index)); + new WebSnap(url, m_root.webFrame()->page(), index); return prev; } @@ -244,12 +242,29 @@ void NewTabPage::setupPreview(QWebElement e, int index) } -void NewTabPage::snapFinished() -{ - kDebug() << "called"; - WebSnap *snap = qobject_cast(sender()); - QWebElement prev = m_root.findFirst("#preview" + snap->data().toString()); - prev.replace(validPreview(snap->data().toInt(), snap->snapUrl(), snap->snapTitle())); +void NewTabPage::snapFinished(int index, KUrl url, QString title) +{ + // do not try to modify the page if it isn't the newTabPage + if(m_root.document().findAll("#rekonq-newtabpage").count() == 0) + return; + + QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); + QWebElement newPrev = validPreview(index, url, title); + + if(m_root.findAll(".closedTabs").count() != 0) + hideControls(newPrev); + + prev.replace(newPrev); + + // update title + if(m_root.findAll(".favorites").count() != 0) + { + QStringList names = ReKonfig::previewNames(); + names.replace(index, title); + ReKonfig::setPreviewNames(names); + + ReKonfig::self()->writeConfig(); + } } @@ -319,6 +334,8 @@ void NewTabPage::browsingMenu(const KUrl ¤tUrl) void NewTabPage::historyPage() { + m_root.addClass("history"); + HistoryTreeModel *model = Application::historyManager()->historyTreeModel(); int i = 0; @@ -349,6 +366,8 @@ void NewTabPage::historyPage() void NewTabPage::bookmarksPage() { + m_root.addClass("bookmarks"); + KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup(); if (bookGroup.isNull()) { @@ -395,6 +414,8 @@ void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent) void NewTabPage::closedTabsPage() { + m_root.addClass("closedTabs"); + QList links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs(); for(int i=0; i < links.count(); ++i) diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index 1057c7cc..9d41946e 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -56,7 +56,7 @@ public: void generate(KUrl url = KUrl("about:home")); public slots: - void snapFinished(); + void snapFinished(int index, KUrl url, QString title); void removePreview(int index); protected: // these are the function to build the new tab page diff --git a/src/websnap.cpp b/src/websnap.cpp index 983da716..11b70e9e 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -29,6 +29,9 @@ #include "websnap.h" #include "websnap.moc" +// Local Includes +#include "newtabpage.h" + // KDE Includes #include #include @@ -42,10 +45,12 @@ #include -WebSnap::WebSnap(const QUrl &url) +WebSnap::WebSnap(const QUrl& url, QWebPage* originatingPage, int previewIndex) : QObject() { m_url = url; + m_originatingPage = originatingPage; + m_previewIndex = previewIndex; // this to not register websnap history m_page.settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); @@ -120,18 +125,6 @@ KUrl WebSnap::fileForUrl(KUrl url) } -void WebSnap::SetData(QVariant data) -{ - m_data = data; -} - -QVariant& WebSnap::data() -{ - return m_data; -} - - - QString WebSnap::guessNameFromUrl(QUrl url) { QString name = url.toString( QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash ); @@ -163,12 +156,16 @@ void WebSnap::saveResult(bool ok) else { m_image = renderPreview(m_page, WIDTH, HEIGHT); + m_snapTitle = m_page.mainFrame()->title(); } QFile::remove(fileForUrl(m_url).toLocalFile()); m_image.save(fileForUrl(m_url).toLocalFile()); - kDebug() << "finished"; - emit finished(); + //m_originatingPage->mainFrame()->load(KUrl("about:preview/replace/" + QVariant(m_previewIndex).toString())); + NewTabPage p(m_originatingPage->mainFrame()); + p.snapFinished(m_previewIndex, m_url, m_snapTitle); + + deleteLater(); } diff --git a/src/websnap.h b/src/websnap.h index b8ada30f..e15c2dcf 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -51,7 +51,7 @@ class WebSnap : public QObject Q_OBJECT public: - WebSnap(const QUrl &url); + WebSnap(const QUrl &url, QWebPage *originatingPage, int previewIndex); ~WebSnap(); QPixmap previewImage(); // TODO : remove @@ -66,12 +66,6 @@ public: QString snapTitle(); QUrl snapUrl(); - - void SetData(QVariant data); - QVariant& data(); - -signals: - void finished(); private slots: void load(); @@ -84,7 +78,8 @@ private: QUrl m_url; QString m_snapTitle; - QVariant m_data; + QWebPage *m_originatingPage; + int m_previewIndex; }; #endif // WEB_SNAP_H -- cgit v1.2.1 From 79ce24b2d2d50c5dd594c25200122d07bb0e232c Mon Sep 17 00:00:00 2001 From: matgic78 Date: Tue, 2 Feb 2010 18:42:19 +0100 Subject: Replace zoom setting submenu by a widget with a slider --- src/mainview.cpp | 4 +++ src/mainwindow.cpp | 91 +++++++++++++++++++++++++++++++++++++----------------- src/mainwindow.h | 14 ++++++--- 3 files changed, 77 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/mainview.cpp b/src/mainview.cpp index b26e7466..02823d3b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -306,6 +306,10 @@ void MainView::currentChanged(int index) emit browserTabLoading(true); else emit browserTabLoading(false); + + // update zoom slider + if(!Application::instance()->mainWindowList().isEmpty()) + Application::instance()->mainWindow()->setZoomSliderFactor(tab->view()->zoomFactor()); // set focus to the current webview tab->setFocus(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ffc9f508..30e5a061 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -298,20 +298,20 @@ void MainWindow::setupActions() // ============================= Zoom Actions =================================== - a = new KAction(KIcon("zoom-in"), i18n("&Enlarge Font"), this); + a = new KAction(KIcon("zoom-in"), i18n("&Zoom In"), this); a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Plus)); - actionCollection()->addAction(QLatin1String("bigger_font"), a); - connect(a, SIGNAL(triggered(bool)), this, SLOT(viewTextBigger())); - - a = new KAction(KIcon("zoom-original"), i18n("&Normal Font"), this); + actionCollection()->addAction(QLatin1String("zoom_in"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(zoomIn())); + + a = new KAction(KIcon("zoom-original"), i18n("&Normal Zoom"), this); a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_0)); - actionCollection()->addAction(QLatin1String("normal_font"), a); - connect(a, SIGNAL(triggered(bool)), this, SLOT(viewTextNormal())); + actionCollection()->addAction(QLatin1String("zoom_normal"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(zoomNormal())); - a = new KAction(KIcon("zoom-out"), i18n("&Shrink Font"), this); + a = new KAction(KIcon("zoom-out"), i18n("&Zoom Out"), this); a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Minus)); - actionCollection()->addAction(QLatin1String("smaller_font"), a); - connect(a, SIGNAL(triggered(bool)), this, SLOT(viewTextSmaller())); + actionCollection()->addAction(QLatin1String("zoom_out"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(zoomOut())); // =============================== Tools Actions ================================= a = new KAction(i18n("Page S&ource"), this); @@ -409,12 +409,43 @@ void MainWindow::setupTools() toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs))); toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Print))); toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Find))); - - KActionMenu *fontMenu = new KActionMenu(KIcon("page-zoom"), i18n("Zoom"), this); - fontMenu->addAction(actionByName(QLatin1String("smaller_font"))); - fontMenu->addAction(actionByName(QLatin1String("normal_font"))); - fontMenu->addAction(actionByName(QLatin1String("bigger_font"))); - toolsMenu->addAction(fontMenu); + + + + // setup zoom widget + QWidget *zoomWidget = new QWidget(this); + + QToolButton *zoomOut = new QToolButton(zoomWidget); + zoomOut->setDefaultAction(actionByName(QLatin1String("zoom_out"))); + zoomOut->setAutoRaise(true); + + m_zoomSlider = new QSlider(Qt::Horizontal, zoomWidget); + m_zoomSlider->setTracking(true); + m_zoomSlider->setRange(1, 19); // divide by 10 to obtain a qreal for zoomFactor() + m_zoomSlider->setValue(10); + m_zoomSlider->setPageStep(3); + connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setZoomFactor(int))); + + QToolButton *zoomIn = new QToolButton(zoomWidget); + zoomIn->setDefaultAction(actionByName(QLatin1String("zoom_in"))); + zoomIn->setAutoRaise(true); + + QToolButton *zoomNormal = new QToolButton(zoomWidget); + zoomNormal->setDefaultAction(actionByName(QLatin1String("zoom_normal"))); + zoomNormal->setAutoRaise(true); + + QHBoxLayout* zoomWidgetLayout = new QHBoxLayout(zoomWidget); + zoomWidgetLayout->setSpacing(0); + zoomWidgetLayout->setMargin(0); + zoomWidgetLayout->addWidget(zoomOut); + zoomWidgetLayout->addWidget(m_zoomSlider); + zoomWidgetLayout->addWidget(zoomIn); + zoomWidgetLayout->addWidget(zoomNormal); + + QWidgetAction *zoomAction = new QWidgetAction(this); + zoomAction->setDefaultWidget(zoomWidget); + toolsMenu->addAction(zoomAction); + toolsMenu->addSeparator(); @@ -759,27 +790,31 @@ void MainWindow::findPrevious() } -void MainWindow::viewTextBigger() +void MainWindow::zoomIn() { - if (!currentTab()) - return; - currentTab()->view()->setTextSizeMultiplier(currentTab()->view()->textSizeMultiplier() + 0.1); + m_zoomSlider->setValue(m_zoomSlider->value() + 1); } - -void MainWindow::viewTextNormal() +void MainWindow::zoomNormal() { - if (!currentTab()) - return; - currentTab()->view()->setTextSizeMultiplier(1.0); + m_zoomSlider->setValue(10); } +void MainWindow::zoomOut() +{ + m_zoomSlider->setValue(m_zoomSlider->value() - 1); +} -void MainWindow::viewTextSmaller() +void MainWindow::setZoomFactor(int factor) { - if (!currentTab()) + if(!currentTab()) return; - currentTab()->view()->setTextSizeMultiplier(currentTab()->view()->textSizeMultiplier() - 0.1); + currentTab()->view()->setZoomFactor(QVariant(factor).toReal() / 10); +} + +void MainWindow::setZoomSliderFactor(qreal factor) +{ + m_zoomSlider->setValue(factor*10); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 7083591d..35632c64 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -41,6 +41,7 @@ // Forward Declarations class QWebFrame; +class QSlider; class KAction; class KPassivePopup; @@ -72,7 +73,9 @@ public: virtual QSize sizeHint() const; virtual KActionCollection *actionCollection () const; void setWidgetsVisible(bool makeFullScreen); - + + void setZoomSliderFactor(qreal factor); + private: void setupActions(); void setupTools(); @@ -125,9 +128,10 @@ private slots: void findPrevious(); // Zoom slots - void viewTextBigger(); - void viewTextNormal(); - void viewTextSmaller(); + void zoomIn(); + void zoomNormal(); + void zoomOut(); + void setZoomFactor(int factor); // File Menu slots void openLocation(); @@ -163,6 +167,8 @@ private: KToolBar *m_mainBar; KToolBar *m_bmBar; + QSlider *m_zoomSlider; + QString m_lastSearch; KPassivePopup *m_popup; -- cgit v1.2.1 From 595760ddc38f35c8307eac5eb797975b6482461b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 8 Feb 2010 10:35:54 +0100 Subject: Fix tab preview. WeakPointer misconcept --- src/tabbar.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 5e1feb56..58216991 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -161,6 +161,7 @@ void TabBar::showTabPreview(int tab) int h = w*((0.0 + currentView->height())/currentView->width()); //delete previous tab preview + delete m_previewPopup.data(); m_previewPopup.clear(); m_previewPopup = new KPassivePopup(this); -- cgit v1.2.1 From 73721c2a057fc5b346d127dbab826859e796e454 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 9 Feb 2010 10:44:04 +0100 Subject: FIX Delete ASAP the threaded job fix focus navigation while opening new tabs back/fore ground.. --- src/application.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index 14fd5ce0..6989eee7 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -380,10 +380,12 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job) KUrl url = threadedJob->url(); WebView *view = threadedJob->view(); + // Bye and thanks :) + delete threadedJob; + if (view) { view->load(url); - view->setFocus(); // we are sure of the url now, let's add it to history // anyway we store here just http sites because local and ftp ones are @@ -391,7 +393,4 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job) if( url.protocol() == QLatin1String("http") || url.protocol() == QLatin1String("https") ) historyManager()->addHistoryEntry( url.prettyUrl() ); } - - // Bye and thanks :) - delete threadedJob; } -- cgit v1.2.1 From 57bc503662183f0d2b89ddc419548e0938c17e8f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 9 Feb 2010 11:15:10 +0100 Subject: Fix NewTabPage API && comments --- src/rekonqpage/newtabpage.cpp | 4 ++++ src/rekonqpage/newtabpage.h | 18 ++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 19f1686f..95b15ed9 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -197,6 +197,7 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url) return prev; } + QWebElement NewTabPage::validPreview(int index, KUrl url, QString title) { QWebElement prev = markup(".thumbnail"); @@ -220,12 +221,15 @@ void NewTabPage::hideControls(QWebElement e) e.findFirst(".remove").setStyleProperty("visibility", "hidden"); e.findFirst(".modify").setStyleProperty("visibility", "hidden"); } + + void NewTabPage::showControls(QWebElement e) { e.findFirst(".remove").setStyleProperty("visibility", "visible"); e.findFirst(".modify").setStyleProperty("visibility", "visible"); } + void NewTabPage::setupPreview(QWebElement e, int index) { e.findFirst(".remove img").setAttribute("src", QString("file:///") + diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index 9d41946e..38d82684 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -44,18 +44,17 @@ class WebPage; class NewTabPage : public QObject { Q_OBJECT + public: NewTabPage(QWebFrame *frame); ~NewTabPage(); /** - * This is the unique NewTabPage public method. It takes an - * about: url and loads the corresponding part of the - * new tab page + * This method takes an about: url and loads + * the corresponding part of the new tab page */ void generate(KUrl url = KUrl("about:home")); -public slots: void snapFinished(int index, KUrl url, QString title); void removePreview(int index); @@ -63,6 +62,10 @@ protected: // these are the function to build the new tab page void browsingMenu(const KUrl ¤tUrl); void favoritesPage(); + void historyPage(); + void bookmarksPage(); + void closedTabsPage(); + QWebElement emptyPreview(int index); QWebElement loadingPreview(int index, KUrl url); QWebElement validPreview(int index, KUrl url, QString title); @@ -73,12 +76,7 @@ protected: // these are the function to build the new tab page void hideControls(QWebElement e); void showControls(QWebElement e); void setupPreview(QWebElement e, int index); - - - void historyPage(); - void bookmarksPage(); - void closedTabsPage(); - + private: void createBookItem(const KBookmark &bookmark, QWebElement parent); -- cgit v1.2.1 From 7628a51f8afe0518c05ab41348560852ed313a34 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 9 Feb 2010 11:56:16 +0100 Subject: Free MainWindow from PreviewSelectorBar WARNING: it doesn't compile --- src/mainwindow.cpp | 5 ----- src/mainwindow.h | 4 +--- 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9e6bfb03..e4890b72 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -98,7 +98,6 @@ MainWindow::MainWindow() : KMainWindow() , m_view( new MainView(this) ) , m_findBar( new FindBar(this) ) - , m_previewSelectorBar( new PreviewSelectorBar(this) ) , m_historyPanel(0) , m_bookmarksPanel(0) , m_webInspectorPanel(0) @@ -123,7 +122,6 @@ MainWindow::MainWindow() QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_view); - layout->addWidget(m_previewSelectorBar); layout->addWidget(m_findBar); centralWidget->setLayout(layout); @@ -650,9 +648,6 @@ void MainWindow::updateActions() QAction *historyForwardAction = actionByName(KStandardAction::name(KStandardAction::Forward)); historyForwardAction->setEnabled(currentTab()->view()->history()->canGoForward()); - - if(m_previewSelectorBar->isVisible()) - m_previewSelectorBar->setPage(currentTab()->page()); } diff --git a/src/mainwindow.h b/src/mainwindow.h index f7746893..7a51cc10 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -1,5 +1,5 @@ -class PreviewSelectorBar;/* ============================================================ +/* ============================================================ * * This file is a part of the rekonq project * @@ -159,8 +159,6 @@ private: MainView *m_view; FindBar *m_findBar; - PreviewSelectorBar *m_previewSelectorBar; - HistoryPanel *m_historyPanel; BookmarksPanel *m_bookmarksPanel; WebInspectorPanel *m_webInspectorPanel; -- cgit v1.2.1 From e8e00372f5e1a881b1ce83a3623208dae7833f4c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 9 Feb 2010 12:32:58 +0100 Subject: HUGE CHANGE on Preview Page Choosing The idea here is to free rekonq from unuseful weight while browsing and better maintain code. - Moved PreviewSelectorBar to be one of the WebTab bar - (this way position moved to up rather then down) - creation on use && deletion on close (SAVE MEMORY) - free others page for browsing - fix copyright - CLEAN API (is private/public a misconception?) && comments --- src/rekonqpage/newtabpage.cpp | 4 +- src/rekonqpage/previewselectorbar.cpp | 140 ++++++++++++++++------------------ src/rekonqpage/previewselectorbar.h | 85 +++++++++++---------- src/webinspectorpanel.cpp | 6 +- src/webinspectorpanel.h | 2 +- src/webtab.cpp | 14 ++++ src/webtab.h | 5 +- 7 files changed, 134 insertions(+), 122 deletions(-) (limited to 'src') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 95b15ed9..7a373f62 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -39,6 +39,7 @@ #include "mainview.h" #include "websnap.h" #include "previewselectorbar.h" +#include "webtab.h" // KDE Includes #include @@ -87,8 +88,7 @@ void NewTabPage::generate(KUrl url) if(url.directory() == QString("preview/modify")) { int index = url.fileName().toInt(); - Application::instance()->mainWindow()->findChild() - ->enable(index, qobject_cast< WebPage* >(m_root.webFrame()->page())); + Application::instance()->mainWindow()->currentTab()->createPreviewSelectorBar(index); return; } } diff --git a/src/rekonqpage/previewselectorbar.cpp b/src/rekonqpage/previewselectorbar.cpp index 5f3956d7..564d286c 100644 --- a/src/rekonqpage/previewselectorbar.cpp +++ b/src/rekonqpage/previewselectorbar.cpp @@ -1,29 +1,40 @@ -/* - - Copyright (C) - - 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 3 of the License, 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. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 by Matthieu Gicquel +* Copyright (C) 2010 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ // Auto Includes #include "previewselectorbar.h" +#include "previewselectorbar.moc" // Local Include #include "rekonq.h" #include "websnap.h" +#include "application.h" +#include "mainwindow.h" +#include "webtab.h" // KDE Includes #include @@ -35,32 +46,23 @@ #include -PreviewSelectorBar::PreviewSelectorBar(QWidget* parent) +PreviewSelectorBar::PreviewSelectorBar(int index, QWidget* parent) : QWidget(parent) , m_button(0) , m_label(0) - , m_page(0) + , m_previewIndex(index) { - hide(); -} - - -void PreviewSelectorBar::setup() -{ - if(m_button != 0) - return; - m_label = new QLabel(i18n("Please open up the webpage you want to add as favorite"), this); m_label->setWordWrap(true); QToolButton *closeButton = new QToolButton(this); closeButton->setAutoRaise(true); closeButton->setIcon(KIcon("dialog-close")); - connect(closeButton, SIGNAL(clicked(bool)), SLOT(hide())); + connect(closeButton, SIGNAL(clicked(bool)), this, SLOT(destroy())); m_button = new QPushButton(KIcon("insert-image"), i18n("Set to This Page"), this); m_button->setMaximumWidth(250); - connect(m_button, SIGNAL(clicked(bool)), SLOT(clicked())); + connect(m_button, SIGNAL(clicked(bool)), this, SLOT(clicked())); // layout QHBoxLayout *layout = new QHBoxLayout(this); @@ -74,16 +76,15 @@ void PreviewSelectorBar::setup() } -void PreviewSelectorBar::setPage(WebPage* page) +PreviewSelectorBar::~PreviewSelectorBar() { - m_page = page; - verifyUrl(); } void PreviewSelectorBar::verifyUrl() { - if(m_page->mainFrame()->url().scheme() != "about") + + if(Application::instance()->mainWindow()->currentTab()->page()->mainFrame()->url().scheme() != "about") { m_button->setEnabled(true); m_button->setToolTip(""); @@ -96,27 +97,6 @@ void PreviewSelectorBar::verifyUrl() } -void PreviewSelectorBar::enable(int previewIndex, WebPage* page) -{ - if(m_page != 0) - disconnect(m_page, 0, this, 0); - - - setup(); - m_previewIndex = previewIndex; - m_page = page; - - verifyUrl(); - - show(); - - connect(page, SIGNAL(loadStarted()), SLOT(loadProgress())); - connect(page, SIGNAL(loadProgress(int)), SLOT(loadProgress())); - connect(page, SIGNAL(loadFinished(bool)), SLOT(loadFinished())); - connect(page->mainFrame(), SIGNAL(urlChanged(QUrl)), SLOT(verifyUrl())); -} - - void PreviewSelectorBar::loadProgress() { m_button->setEnabled(false); @@ -124,7 +104,6 @@ void PreviewSelectorBar::loadProgress() } - void PreviewSelectorBar::loadFinished() { m_button->setEnabled(true); @@ -136,25 +115,38 @@ void PreviewSelectorBar::loadFinished() void PreviewSelectorBar::clicked() { - KUrl url = m_page->mainFrame()->url(); - - WebSnap::savePreview(WebSnap::renderPreview(*m_page), url); - - QStringList names = ReKonfig::previewNames(); - QStringList urls = ReKonfig::previewUrls(); - - urls.replace(m_previewIndex, url.toMimeDataString()); - names.replace(m_previewIndex, m_page->mainFrame()->title()); - - ReKonfig::setPreviewNames(names); - ReKonfig::setPreviewUrls(urls); + WebPage *page = Application::instance()->mainWindow()->currentTab()->page(); - ReKonfig::self()->writeConfig(); - - - m_page->mainFrame()->load(KUrl("about:favorites")); + if(page) + { + KUrl url = page->mainFrame()->url(); + + WebSnap::savePreview(WebSnap::renderPreview(*page), url); + + QStringList names = ReKonfig::previewNames(); + QStringList urls = ReKonfig::previewUrls(); + + urls.replace(m_previewIndex, url.toMimeDataString()); + names.replace(m_previewIndex, page->mainFrame()->title()); + + ReKonfig::setPreviewNames(names); + ReKonfig::setPreviewUrls(urls); + + ReKonfig::self()->writeConfig(); + + + page->mainFrame()->load(KUrl("about:favorites")); + } - hide(); + destroy(); } +void PreviewSelectorBar::destroy() +{ + if (parentWidget() && parentWidget()->layout()) + { + parentWidget()->layout()->removeWidget(this); + } + this->deleteLater(); +} diff --git a/src/rekonqpage/previewselectorbar.h b/src/rekonqpage/previewselectorbar.h index aa011fe4..4f7fc21b 100644 --- a/src/rekonqpage/previewselectorbar.h +++ b/src/rekonqpage/previewselectorbar.h @@ -1,21 +1,29 @@ -/* - - Copyright (C) +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 by Matthieu Gicquel +* Copyright (C) 2010 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ - 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 3 of the License, 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. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ #ifndef PREVIEWSELECTORBAR_H #define PREVIEWSELECTORBAR_H @@ -28,33 +36,30 @@ #include #include + class PreviewSelectorBar : public QWidget { - Q_OBJECT +Q_OBJECT + +public: + PreviewSelectorBar(int index, QWidget *parent); + ~PreviewSelectorBar(); + +private slots: + void clicked(); + + void loadProgress(); + void loadFinished(); + + void verifyUrl(); + + void destroy(); - public: - PreviewSelectorBar(QWidget *parent = 0); - - void setPage(WebPage *page); - - public slots: - void enable(int previewIndex, WebPage *page); - void clicked(); - - void loadProgress(); - void loadFinished(); - - void verifyUrl(); - - private: - void setup(); - - QPushButton *m_button; - QLabel *m_label; - - int m_previewIndex; - WebPage *m_page; +private: + QPushButton *m_button; + QLabel *m_label; + int m_previewIndex; }; #endif // PREVIEWSELECTORBAR_H diff --git a/src/webinspectorpanel.cpp b/src/webinspectorpanel.cpp index a038d280..4f86f5e4 100644 --- a/src/webinspectorpanel.cpp +++ b/src/webinspectorpanel.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Matthieu Gicquel +* Copyright (C) 2009 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or @@ -10,9 +10,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * 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 diff --git a/src/webinspectorpanel.h b/src/webinspectorpanel.h index 8f65b48a..2d6dd8eb 100644 --- a/src/webinspectorpanel.h +++ b/src/webinspectorpanel.h @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Matthieu Gicquel +* Copyright (C) 2009 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/webtab.cpp b/src/webtab.cpp index b3eb71f0..fb925d6e 100644 --- a/src/webtab.cpp +++ b/src/webtab.cpp @@ -39,6 +39,7 @@ #include "webpage.h" #include "bookmarksmanager.h" #include "walletbar.h" +#include "previewselectorbar.h" // KDE Includes #include @@ -165,3 +166,16 @@ void WebTab::createWalletBar(const QString &key, const QUrl &url) connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)), wallet, SLOT(rejectSaveFormDataRequest(const QString &))); } + + +void WebTab::createPreviewSelectorBar(int index) +{ + QWidget *messageBar = layout()->itemAt(0)->widget(); + PreviewSelectorBar *bar = new PreviewSelectorBar(index, messageBar); + messageBar->layout()->addWidget(bar); + + connect(page(), SIGNAL(loadStarted()), bar, SLOT(loadProgress())); + connect(page(), SIGNAL(loadProgress(int)), bar, SLOT(loadProgress())); + connect(page(), SIGNAL(loadFinished(bool)), bar, SLOT(loadFinished())); + connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), bar, SLOT(verifyUrl())); +} diff --git a/src/webtab.h b/src/webtab.h index ecf8e5b3..7ab5114e 100644 --- a/src/webtab.h +++ b/src/webtab.h @@ -51,14 +51,15 @@ public: KUrl url() const; QString lastStatusBarText() const; int progress(); - + void createPreviewSelectorBar(int index); + private slots: void setStatusBarText(const QString &string); void updateProgress(int progress); void loadFinished(bool); void createWalletBar(const QString &, const QUrl &); - + private: WebView *const m_view; int m_progress; -- cgit v1.2.1 From 65af58d17b5de8369aa74533f5fee31add9d2a31 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 10 Feb 2010 09:56:22 +0100 Subject: margin-top in favorites from 7% to 4%. This to let previews fit in my screen (1280x800, quite common..) --- src/data/home.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/data/home.html b/src/data/home.html index 51b9ceec..f9106642 100644 --- a/src/data/home.html +++ b/src/data/home.html @@ -123,7 +123,7 @@ margin-top: -5%; .thumbnail { display: inline-block; -width:25%; margin-top: 7%; +width:25%; margin-top: 4%; min-width:250px; min-height:192px; } @@ -224,6 +224,5 @@ margin-bottom: 0.5em;

- -- cgit v1.2.1 From e6bc31b0263c97cef99769c722b958ba788d0aa5 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 10 Feb 2010 10:01:36 +0100 Subject: Fix popup position --- src/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e4890b72..55a08916 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1058,7 +1058,7 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) //TODO: detect QStyle size scrollbarSize = 17; } - QPoint webViewOrigin = m_view->currentWebTab()->mapToGlobal(QPoint(0,0)); + QPoint webViewOrigin = m_view->currentWebTab()->view()->mapToGlobal(QPoint(0,0)); int bottomLeftY=webViewOrigin.y() + m_view->currentWebTab()->page()->viewportSize().height() - labelSize.height() - scrollbarSize; // setting popup in bottom-left position -- cgit v1.2.1 From 067b99a053b6f8b1ccab507be8e828b2f72a1e43 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 10 Feb 2010 10:57:57 +0100 Subject: Fix copyright for 0.4 beta release --- src/adblock/adblockmanager.cpp | 2 +- src/adblock/adblockmanager.h | 2 +- src/adblock/adblocknetworkreply.cpp | 2 +- src/adblock/adblocknetworkreply.h | 2 +- src/adblock/adblockrule.cpp | 2 +- src/adblock/adblockrule.h | 2 +- src/application.cpp | 6 +++--- src/application.h | 4 ++-- src/bookmarks/bookmarksmanager.cpp | 4 ++-- src/bookmarks/bookmarksmanager.h | 4 ++-- src/bookmarks/bookmarkspanel.cpp | 2 +- src/bookmarks/bookmarkspanel.h | 1 + src/bookmarks/bookmarksproxy.cpp | 1 + src/bookmarks/bookmarksproxy.h | 1 + src/bookmarks/bookmarkstreemodel.cpp | 1 + src/bookmarks/bookmarkstreemodel.h | 1 + src/clicktoflash.cpp | 2 +- src/clicktoflash.h | 2 +- src/findbar.cpp | 4 ++-- src/findbar.h | 4 ++-- src/history/autosaver.cpp | 2 +- src/history/autosaver.h | 2 +- src/history/historymanager.cpp | 2 +- src/history/historymanager.h | 2 +- src/history/historymodels.cpp | 2 +- src/history/historymodels.h | 2 +- src/history/historypanel.cpp | 2 +- src/history/historypanel.h | 2 +- src/main.cpp | 14 +++++++------- src/mainview.cpp | 5 +++-- src/mainview.h | 5 +++-- src/mainwindow.cpp | 5 +++-- src/mainwindow.h | 5 +++-- src/networkaccessmanager.cpp | 3 ++- src/networkaccessmanager.h | 3 ++- src/protocolhandler.cpp | 2 +- src/protocolhandler.h | 2 +- src/rekonqpage/newtabpage.cpp | 3 ++- src/rekonqpage/newtabpage.h | 3 ++- src/rekonqpage/previewselectorbar.cpp | 2 +- src/rekonqpage/previewselectorbar.h | 2 +- src/sessionmanager.cpp | 4 ++-- src/sessionmanager.h | 4 ++-- src/settings/settingsdialog.cpp | 5 ++--- src/settings/settingsdialog.h | 5 ++--- src/tabbar.cpp | 4 ++-- src/tabbar.h | 4 ++-- src/urlbar/lineedit.cpp | 4 ++-- src/urlbar/lineedit.h | 4 ++-- src/urlbar/urlbar.cpp | 4 ++-- src/urlbar/urlbar.h | 4 ++-- src/webinspectorpanel.cpp | 2 +- src/webinspectorpanel.h | 2 +- src/webpage.cpp | 3 ++- src/webpage.h | 3 ++- src/webpluginfactory.cpp | 3 ++- src/webpluginfactory.h | 3 ++- src/websnap.cpp | 3 ++- src/websnap.h | 3 ++- src/webtab.cpp | 4 ++-- src/webtab.h | 4 ++-- src/webview.cpp | 4 ++-- src/webview.h | 4 ++-- 63 files changed, 108 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp index c2a42f0b..bcb5b556 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/adblock/adblockmanager.h b/src/adblock/adblockmanager.h index f01aaca0..754c81c2 100644 --- a/src/adblock/adblockmanager.h +++ b/src/adblock/adblockmanager.h @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/adblock/adblocknetworkreply.cpp b/src/adblock/adblocknetworkreply.cpp index 1ccca96d..804524b3 100644 --- a/src/adblock/adblocknetworkreply.cpp +++ b/src/adblock/adblocknetworkreply.cpp @@ -28,7 +28,7 @@ * * This file is a part of the rekonq project * - * Copyright (C) 2009 by Andrea Diamantini + * Copyright (C) 2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/adblock/adblocknetworkreply.h b/src/adblock/adblocknetworkreply.h index b5bb8300..36dd7fdb 100644 --- a/src/adblock/adblocknetworkreply.h +++ b/src/adblock/adblocknetworkreply.h @@ -28,7 +28,7 @@ * * This file is a part of the rekonq project * - * Copyright (C) 2009 by Andrea Diamantini + * Copyright (C) 2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/adblock/adblockrule.cpp b/src/adblock/adblockrule.cpp index 9f86ffee..25ca3678 100644 --- a/src/adblock/adblockrule.cpp +++ b/src/adblock/adblockrule.cpp @@ -30,7 +30,7 @@ * * This file is a part of the rekonq project * - * Copyright (C) 2009 by Andrea Diamantini + * Copyright (C) 2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/adblock/adblockrule.h b/src/adblock/adblockrule.h index 35715051..1cb97dc4 100644 --- a/src/adblock/adblockrule.h +++ b/src/adblock/adblockrule.h @@ -29,7 +29,7 @@ * * This file is a part of the rekonq project * - * Copyright (C) 2009 by Andrea Diamantini + * Copyright (C) 2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/application.cpp b/src/application.cpp index 6989eee7..f3db4c7b 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -2,9 +2,9 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or @@ -102,7 +102,7 @@ Application::~Application() int Application::newInstance() { - KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); + KCmdLineArgs::setCwd( QDir::currentPath().toUtf8() ); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); // we share one process for several mainwindows, diff --git a/src/application.h b/src/application.h index 0c3bd3f5..f20f537b 100644 --- a/src/application.h +++ b/src/application.h @@ -2,9 +2,9 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp index 6442192a..3aab08ae 100644 --- a/src/bookmarks/bookmarksmanager.cpp +++ b/src/bookmarks/bookmarksmanager.cpp @@ -2,9 +2,9 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/bookmarks/bookmarksmanager.h b/src/bookmarks/bookmarksmanager.h index febac234..200bfb4b 100644 --- a/src/bookmarks/bookmarksmanager.h +++ b/src/bookmarks/bookmarksmanager.h @@ -2,9 +2,9 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index 9164dbb6..48ca6537 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -3,7 +3,7 @@ * This file is a part of the rekonq project * * Copyright (C) 2009 by Nils Weigel -* +* Copyright (C) 2010 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 diff --git a/src/bookmarks/bookmarkspanel.h b/src/bookmarks/bookmarkspanel.h index 6c0e153f..64d68f70 100644 --- a/src/bookmarks/bookmarkspanel.h +++ b/src/bookmarks/bookmarkspanel.h @@ -3,6 +3,7 @@ * This file is a part of the rekonq project * * Copyright (C) 2009 by Nils Weigel +* Copyright (C) 2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/bookmarks/bookmarksproxy.cpp b/src/bookmarks/bookmarksproxy.cpp index e94fbeff..7fa34b3f 100644 --- a/src/bookmarks/bookmarksproxy.cpp +++ b/src/bookmarks/bookmarksproxy.cpp @@ -3,6 +3,7 @@ * This file is a part of the rekonq project * * Copyright (C) 2009 by Nils Weigel +* Copyright (C) 2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/bookmarks/bookmarksproxy.h b/src/bookmarks/bookmarksproxy.h index 99483331..fcd49673 100644 --- a/src/bookmarks/bookmarksproxy.h +++ b/src/bookmarks/bookmarksproxy.h @@ -3,6 +3,7 @@ * This file is a part of the rekonq project * * Copyright (C) 2009 by Nils Weigel +* Copyright (C) 2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp index 140fa9c8..f80fdc74 100644 --- a/src/bookmarks/bookmarkstreemodel.cpp +++ b/src/bookmarks/bookmarkstreemodel.cpp @@ -3,6 +3,7 @@ * This file is a part of the rekonq project * * Copyright (C) 2009 by Nils Weigel +* Copyright (C) 2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/bookmarks/bookmarkstreemodel.h b/src/bookmarks/bookmarkstreemodel.h index 9753999c..9b65d923 100644 --- a/src/bookmarks/bookmarkstreemodel.h +++ b/src/bookmarks/bookmarkstreemodel.h @@ -3,6 +3,7 @@ * This file is a part of the rekonq project * * Copyright (C) 2009 by Nils Weigel +* Copyright (C) 2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/clicktoflash.cpp b/src/clicktoflash.cpp index b6e1df34..509202fb 100644 --- a/src/clicktoflash.cpp +++ b/src/clicktoflash.cpp @@ -28,7 +28,7 @@ * * This file is a part of the rekonq project * - * Copyright (C) 2009 by Matthieu Gicquel + * Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/clicktoflash.h b/src/clicktoflash.h index 01bba257..d519e047 100644 --- a/src/clicktoflash.h +++ b/src/clicktoflash.h @@ -28,7 +28,7 @@ * * This file is a part of the rekonq project * - * Copyright (C) 2009 by Matthieu Gicquel + * Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/findbar.cpp b/src/findbar.cpp index 9efb9c6a..1cb16e3f 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -2,8 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/findbar.h b/src/findbar.h index 5a41c0bc..d56b8d25 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -2,8 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/history/autosaver.cpp b/src/history/autosaver.cpp index 236922b5..41f19098 100644 --- a/src/history/autosaver.cpp +++ b/src/history/autosaver.cpp @@ -3,7 +3,7 @@ * This file is a part of the rekonq project * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/history/autosaver.h b/src/history/autosaver.h index 80583f9c..4a307a16 100644 --- a/src/history/autosaver.h +++ b/src/history/autosaver.h @@ -3,7 +3,7 @@ * This file is a part of the rekonq project * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp index db19a6b4..e75adbdc 100644 --- a/src/history/historymanager.cpp +++ b/src/history/historymanager.cpp @@ -4,7 +4,7 @@ * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 Benjamin C. Meyer -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/history/historymanager.h b/src/history/historymanager.h index ff3b4381..0df1467f 100644 --- a/src/history/historymanager.h +++ b/src/history/historymanager.h @@ -4,7 +4,7 @@ * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 Benjamin C. Meyer -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/history/historymodels.cpp b/src/history/historymodels.cpp index cf8d1aed..709d0523 100644 --- a/src/history/historymodels.cpp +++ b/src/history/historymodels.cpp @@ -4,7 +4,7 @@ * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 Benjamin C. Meyer -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/history/historymodels.h b/src/history/historymodels.h index 08f3f63e..a8cd7a8c 100644 --- a/src/history/historymodels.h +++ b/src/history/historymodels.h @@ -4,7 +4,7 @@ * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 Benjamin C. Meyer -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index 08dc3800..8c8eae75 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -2,8 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini * * Copyright (C) 2009 by Domrachev Alexandr +* Copyright (C) 2009-2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/history/historypanel.h b/src/history/historypanel.h index e07e2190..67284c0e 100644 --- a/src/history/historypanel.h +++ b/src/history/historypanel.h @@ -2,8 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini * * Copyright (C) 2009 by Domrachev Alexandr +* Copyright (C) 2009-2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/main.cpp b/src/main.cpp index 030b8476..0b12fba1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or @@ -56,15 +56,10 @@ extern "C" KDE_EXPORT int kdemain( int argc, char **argv ) // --------------- about authors ----------------------------- about.addAuthor(ki18n("Andrea Diamantini"), - ki18n("Project Lead, Developer"), + ki18n("Project Lead, Developer, Maintainer"), "adjam7@gmail.com", "http://www.adjam.org"); - about.addAuthor(ki18n("Domrachev Alexandr"), - ki18n("Developer"), - "alexandr.domrachev@gmail.com", - ""); - about.addAuthor(ki18n("Panagiotis Papadopoulos"), ki18n("Quite everything but code"), "pano_90@gmx.net", @@ -91,6 +86,11 @@ extern "C" KDE_EXPORT int kdemain( int argc, char **argv ) ""); // --------------- about credits ----------------------------- + about.addCredit(ki18n("Domrachev Alexandr"), + ki18n("Developer"), + "alexandr.domrachev@gmail.com", + ""); + about.addCredit(ki18n("Henry de Valence"), ki18n("Promised help on multitask rekonq"), "hdevalence@gmail.com", diff --git a/src/mainview.cpp b/src/mainview.cpp index 57185fd2..8034563b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -2,9 +2,10 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/mainview.h b/src/mainview.h index 908389b1..ace9d941 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -2,9 +2,10 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 55a08916..8ce6afe0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2,9 +2,10 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/mainwindow.h b/src/mainwindow.h index 7a51cc10..c104ad4d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -3,9 +3,10 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index eadbfab3..e6dd6d85 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -3,7 +3,8 @@ * This file is a part of the rekonq project * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved -* Copyright (C) 2008-2009 by Andrea Diamantini * +* Copyright (C) 2008-2010 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 diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h index 5c34ebd7..171a5337 100644 --- a/src/networkaccessmanager.h +++ b/src/networkaccessmanager.h @@ -3,7 +3,8 @@ * This file is a part of the rekonq project * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved -* Copyright (C) 2008-2009 by Andrea Diamantini * +* Copyright (C) 2008-2010 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 diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index a9339cfa..995c1448 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2010 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 diff --git a/src/protocolhandler.h b/src/protocolhandler.h index 6ae47b74..140faa7d 100644 --- a/src/protocolhandler.h +++ b/src/protocolhandler.h @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2010 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 diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 7a373f62..3fd9fcc6 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -2,7 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2009-2010 by Andrea Diamantini +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index 38d82684..d659362f 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -2,7 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2009-2010 by Andrea Diamantini +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/rekonqpage/previewselectorbar.cpp b/src/rekonqpage/previewselectorbar.cpp index 564d286c..d7676e3c 100644 --- a/src/rekonqpage/previewselectorbar.cpp +++ b/src/rekonqpage/previewselectorbar.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2010 by Matthieu Gicquel +* Copyright (C) 2010 by Matthieu Gicquel * Copyright (C) 2010 by Andrea Diamantini * * diff --git a/src/rekonqpage/previewselectorbar.h b/src/rekonqpage/previewselectorbar.h index 4f7fc21b..fa71bdfa 100644 --- a/src/rekonqpage/previewselectorbar.h +++ b/src/rekonqpage/previewselectorbar.h @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2010 by Matthieu Gicquel +* Copyright (C) 2010 by Matthieu Gicquel * Copyright (C) 2010 by Andrea Diamantini * * diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp index f512e943..72e1cc77 100644 --- a/src/sessionmanager.cpp +++ b/src/sessionmanager.cpp @@ -2,9 +2,9 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2009-2010 by Andrea Diamantini * Copyright (C) 2009 by Yoram Bar-Haim < -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/sessionmanager.h b/src/sessionmanager.h index f1b7a71f..baa6ac22 100644 --- a/src/sessionmanager.h +++ b/src/sessionmanager.h @@ -2,9 +2,9 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2009-2010 by Andrea Diamantini * Copyright (C) 2009 by Yoram Bar-Haim < -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index 6fab5dcf..2c04fac0 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -2,9 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/settings/settingsdialog.h b/src/settings/settingsdialog.h index 360fe246..da1415c4 100644 --- a/src/settings/settingsdialog.h +++ b/src/settings/settingsdialog.h @@ -2,9 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 58216991..f77d4694 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -3,9 +3,9 @@ * This file is a part of the rekonq project * * Copyright (C) 2008 Benjamin C. Meyer -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/tabbar.h b/src/tabbar.h index b57106dc..9d1fd7a9 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -3,9 +3,9 @@ * This file is a part of the rekonq project * * Copyright (C) 2008 Benjamin C. Meyer -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/urlbar/lineedit.cpp b/src/urlbar/lineedit.cpp index f3c93e8e..db36bd0c 100644 --- a/src/urlbar/lineedit.cpp +++ b/src/urlbar/lineedit.cpp @@ -2,9 +2,9 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2009-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/urlbar/lineedit.h b/src/urlbar/lineedit.h index 67ded052..0fca21d4 100644 --- a/src/urlbar/lineedit.h +++ b/src/urlbar/lineedit.h @@ -2,9 +2,9 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2009-2010 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 4d9765a2..1b6ebca8 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -2,10 +2,10 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Domrachev Alexandr * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h index 8d267b2c..6d24e599 100644 --- a/src/urlbar/urlbar.h +++ b/src/urlbar/urlbar.h @@ -2,10 +2,10 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini * Copyright (C) 2009 by Domrachev Alexandr * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/webinspectorpanel.cpp b/src/webinspectorpanel.cpp index 4f86f5e4..6f8e48a0 100644 --- a/src/webinspectorpanel.cpp +++ b/src/webinspectorpanel.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Matthieu Gicquel +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/webinspectorpanel.h b/src/webinspectorpanel.h index 2d6dd8eb..dac54648 100644 --- a/src/webinspectorpanel.h +++ b/src/webinspectorpanel.h @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Matthieu Gicquel +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/webpage.cpp b/src/webpage.cpp index f2ea412d..a6e103bd 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -6,7 +6,8 @@ * Copyright (C) 2008 Dirk Mueller * Copyright (C) 2008 Urs Wolfer * Copyright (C) 2008 Michael Howell -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/webpage.h b/src/webpage.h index c8ecc89a..2a1cf826 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -6,7 +6,8 @@ * Copyright (C) 2008 Dirk Mueller * Copyright (C) 2008 Urs Wolfer * Copyright (C) 2008 Michael Howell -* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index ac18fece..6265aeb3 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -2,7 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2009-2010 by Andrea Diamantini +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/webpluginfactory.h b/src/webpluginfactory.h index c1e4c28f..384f0653 100644 --- a/src/webpluginfactory.h +++ b/src/webpluginfactory.h @@ -2,7 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2009-2010 by Andrea Diamantini +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/websnap.cpp b/src/websnap.cpp index 11b70e9e..6310c868 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -3,7 +3,8 @@ * This file is a part of the rekonq project * * Copyright (C) 2009 Nokia Corporation -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2009-2010 by Andrea Diamantini +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/websnap.h b/src/websnap.h index e15c2dcf..30441e02 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -3,7 +3,8 @@ * This file is a part of the rekonq project * * Copyright (C) 2009 Nokia Corporation -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2009-2010 by Andrea Diamantini +* Copyright (C) 2010 by Matthieu Gicquel * * * This program is free software; you can redistribute it and/or diff --git a/src/webtab.cpp b/src/webtab.cpp index fb925d6e..9dea9a72 100644 --- a/src/webtab.cpp +++ b/src/webtab.cpp @@ -2,8 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/webtab.h b/src/webtab.h index 7ab5114e..d54ae5f8 100644 --- a/src/webtab.h +++ b/src/webtab.h @@ -2,8 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/webview.cpp b/src/webview.cpp index 232a2633..e1ba2a46 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -2,8 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/webview.h b/src/webview.h index 263b2ec4..1598b19c 100644 --- a/src/webview.h +++ b/src/webview.h @@ -2,8 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or -- cgit v1.2.1 From e9c6614a7986367e29721ace8341c830f5d5a78d Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 10 Feb 2010 12:33:09 +0100 Subject: fix tab preview position --- src/tabbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index f77d4694..2fa4cf8e 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -158,7 +158,7 @@ void TabBar::showTabPreview(int tab) return; int w = tabSizeHint(tab).width(); - int h = w*((0.0 + currentView->height())/currentView->width()); + int h = w * ( (0.0 + currentView->height()) / currentView->width() ); //delete previous tab preview delete m_previewPopup.data(); @@ -175,7 +175,7 @@ void TabBar::showTabPreview(int tab) m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop); m_previewPopup.data()->layout()->setMargin(0); - QPoint pos( tabRect(tab).x() , tabRect(tab).y() + tabRect(tab).height() ); + QPoint pos( tabRect(tab).x() , tabRect(tab).y() + tabRect(tab).height() - 3); m_previewPopup.data()->show(mapToGlobal(pos)); } -- cgit v1.2.1 From 315700ae94d0307b0bceb0e78329620e61a4ba0e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 10 Feb 2010 12:47:57 +0100 Subject: DISCLAIMER: I'm sorry for this This commit reverts the ability to change main toolbar settings (change icon/text). In the context rekonq is developed (KMainWindow + simple toolbars) this is quite impossible. We'll see in the next version a proper fix for this (back to XMLGUI? QML??) This commit fixes also the problem with the disappearing toolbar backing from a fullscreen close BUG:222826 --- src/mainwindow.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8ce6afe0..b0007ed4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -103,7 +103,7 @@ MainWindow::MainWindow() , m_bookmarksPanel(0) , m_webInspectorPanel(0) , m_historyBackMenu(0) - , m_mainBar( new KToolBar( QString("MainToolBar"), this, Qt::TopToolBarArea, true, false, false) ) + , m_mainBar( new KToolBar( QString("MainToolBar"), this, Qt::TopToolBarArea, true, true, false) ) , m_bmBar( new KToolBar( QString("BookmarkToolBar"), this, Qt::TopToolBarArea, true, false, false) ) , m_popup( new KPassivePopup(this) ) , m_hidePopup( new QTimer(this) ) @@ -184,12 +184,19 @@ void MainWindow::setupToolbars() m_mainBar->addAction( actionByName("bookmarksActionMenu") ); m_mainBar->addAction( actionByName("rekonq_tools") ); + m_mainBar->setContextMenuPolicy(Qt::PreventContextMenu); + + m_mainBar->show(); // this just to fix reopening rekonq after fullscreen close + // =========== Bookmarks ToolBar ================================ m_bmBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); m_bmBar->setAcceptDrops(true); m_bmBar->setContextMenuPolicy(Qt::CustomContextMenu); m_bmBar->setIconDimensions(16); Application::bookmarkProvider()->setupBookmarkBar(m_bmBar); + + KToolBar::setToolBarsEditable(false); + KToolBar::setToolBarsLocked(true); } -- cgit v1.2.1 From 95e0972db84722d462e7e63f7250a88f285df2e3 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Wed, 10 Feb 2010 16:38:48 +0100 Subject: Improve newtabpage css: -previews are centered -favorites fit in 1280*800 -removed unuseful lines --- src/data/home.html | 162 +++++++++++++++--------------------------- src/rekonqpage/newtabpage.cpp | 6 +- 2 files changed, 62 insertions(+), 106 deletions(-) (limited to 'src') diff --git a/src/data/home.html b/src/data/home.html index f9106642..22d0a007 100644 --- a/src/data/home.html +++ b/src/data/home.html @@ -6,142 +6,111 @@ + + + + + +

Test Cases for HTTP Content-Disposition header and RFC 2231/2047 Encoding

+ + +

Test Cases

Content-Disposition: Disposition-Type Inline

+

+ Various tests relating to the "inline" disposition type, see + Section 2.1 of RFC 2183. +

+

inlonly + [TEST] +

Content-Disposition: inline
+ Test Results +
FF3pass
MSIE8pass
Op10pass
Saf4pass
Konqpass
Chromepass

'inline' only

This should be equivalent to not including the header at all.

inlwithasciifilename + [TEST] +

Content-Disposition: inline; filename="foo.html"
+ Test Results +
FF3pass + (uses the filename in subsequent 'save' operation) +
MSIE8pass + (filename information not used) +
Op10pass + (filename information not used) +
Saf4pass + (filename information not used) +
Konqpass + (filename information not used) +
Chromepass + (filename information not used) +

+ 'inline', specifying a filename of foo.html +

+ Some UAs use this filename in a subsequent "save" operation. +

inlwithasciifilenamepdf + [TEST] +

Content-Disposition: inline; filename="foo.pdf"
+ Test Results +
FF3pass + (filename information not used) +
MSIE8pass + (filename information not used) +
Op10pass + (filename information not used) +
Saf4pass + (filename information not used) +
Konqpass + (filename information not used) +
Chromepass + (filename information not used) +

+ 'inline', specifying a filename of foo.pdf +

+ Some UAs use this filename in a subsequent "save" operation. + This variation of the test checks whether whatever handles PDF display + receives the filename information, and acts upon it + (this was tested with the latest Acrobat Reader plugin). +

Content-Disposition: Disposition-Type Attachment

+

+ Various tests relating to the "attchment" disposition type, see + Section 2.2 of RFC 2183. +

+

attonly + [TEST] +

Content-Disposition: attachment
+ Test Results +
FF3pass
MSIE8pass
Op10pass
Saf4pass
Konqpass
Chromepass

'attachment' only

UA should offer to download the resource.

attonlyucase + [TEST] +

Content-Disposition: ATTACHMENT
+ Test Results +
FF3pass
MSIE8pass
Op10pass
Saf4pass
Konqfail
Chromepass

'ATTACHMENT' only

UA should offer to download the resource.

attwithasciifilename + [TEST] +

Content-Disposition: attachment; filename="foo.html"
+ Test Results +
FF3pass
MSIE8pass
Op10pass
Saf4pass
Konqpass
Chromepass

+ 'attachment', specifying a filename of foo.html +

UA should offer to download the resource as "foo.html".

attwithasciifnescapedchar + [TEST] +

Content-Disposition: attachment; filename="f\oo.html"
+ Test Results +
FF3fail + (apparently does not treat the backslash as escape character, replaces it with '_') +
MSIE8fail + (apparently does not treat the backslash as escape character, replaces it with '_') +
Op10pass
Saf4fail + (apparently does not treat the backslash as escape character, replaces it with '-') +
Konqpass
Chromefail + (saves "oo.html" (what's going on here?)) +

+ 'attachment', specifying a filename of f\oo.html (the first 'o' being escaped) +

UA should offer to download the resource as "foo.html".

attwithfilenameandextparam + [TEST] +

Content-Disposition: attachment; foo="bar"; filename="foo.html"
+ Test Results +
FF3pass
MSIE8pass
Op10pass
Saf4pass
Konqpass
Chromepass

+ 'attachment', specifying a filename of foo.html + and an extension parameter "foo" which should be ignored + (see Section 2.8 of RFC 2183.). +

UA should offer to download the resource as "foo.html".

attwithasciifilenameucase + [TEST] +

Content-Disposition: attachment; FILENAME="foo.html"
+ Test Results +
FF3pass
MSIE8pass
Op10pass
Saf4pass
Konqfail + (filename parameter is ignored) +
Chromepass

+ 'attachment', specifying a filename of foo.html +

UA should offer to download the resource as "foo.html".

attwithasciifilenamenq + [TEST] +

Content-Disposition: attachment; filename=foo.html
+ Test Results +
FF3warn + (accepts the unquoted value) +
MSIE8warn + (accepts the unquoted value) +
Op10warn + (accepts the unquoted value) +
Saf4warn + (accepts the unquoted value) +
Konqwarn + (accepts the unquoted value) +
Chromewarn + (accepts the unquoted value) +

+ 'attachment', specifying a filename of foo.html, but missing + the quotes. +

This is invalid according to Section 19.5.1 of RFC2616, so UAs should + ignore it.

attwithisofnplain + [TEST] +

Content-Disposition: attachment; filename="foo-ä.html"
+ Test Results +
FF3pass
MSIE8pass
Op10pass
Saf4pass
Konqpass
Chromepass

+ 'attachment', specifying a filename of foo-ä.html, using plain ISO-8859-1 +

UA should offer to download the resource as "foo-ä.html".

attwithutf8fnplain + [TEST] +

Content-Disposition: attachment; filename="foo-ä.html"
+ Test Results +
FF3fail + (decodes as UTF-8) +
MSIE8pass
Op10pass
Saf4pass
Konqpass
Chromefail + (decodes as UTF-8) +

+ 'attachment', specifying a filename of foo-ä.html, + which happens to be foo-ä.html using UTF-8 encoding. +

UA should offer to download the resource as "foo-ä.html". + Displaying "foo-ä.html" instead indicates that the UA tried to be smart by detecting + something that happens to look like UTF-8.

attwithfnrawpctenca + [TEST] +

Content-Disposition: attachment; filename="foo-%41.html"
+ Test Results +
FF3pass
MSIE8fail + (displays "foo-A.html") +
Op10pass
Saf4pass
Konqpass
Chromefail + (displays "foo-A.html" (see Chrome Issue 118)) +

+ 'attachment', specifying a filename of foo-%41.html +

UA should offer to download the resource as "foo-%41.html". + Displaying "foo-A.html" instead would indicate that the UA has attempted + to percent-decode the parameter. +

attwithfnrawpctenclong + [TEST] +

Content-Disposition: attachment; filename="foo-%c3%a4-%e2%82%ac.html"
+ Test Results +
FF3pass
MSIE8fail + (displays "foo-ä-€.html") +
Op10pass
Saf4pass
Konqpass
Chromefail + (displays "foo-ä-€.html" (see Chrome Issue 118)) +

+ 'attachment', specifying a filename of foo-%c3%a4-%e2%82%ac.html, using raw percent encoded UTF-8 + to represent foo-ä-€.html +

UA should offer to download the resource as "foo-%c3%a4-%e2%82%ac.html". + Displaying "foo-ä-€.html" instead would indicate that the UA has attempted + to percent-decode the parameter (using UTF-8). Displaying something else + would indicate that the UA tried to percent-decode, but used a different encoding. +

attwithasciifilenamews1 + [TEST] +

Content-Disposition: attachment; filename ="foo.html"
+ Test Results +
FF3pass
MSIE8pass
Op10pass
Saf4pass
Konqpass
Chromepass

+ 'attachment', specifying a filename of foo.html, with one + blank space before the equals character. +

UA should offer to download the resource as "foo.html".

attwithasciifilenamews2 + [TEST] +

Content-Disposition: attachment; filename= "foo.html"
+ Test Results +
FF3pass
MSIE8pass
Op10pass
Saf4pass
Konqpass
Chromepass

+ 'attachment', specifying a filename of foo.html, with one + blank space after the equals character. +

UA should offer to download the resource as "foo.html".

attfnbrokentoken + [TEST] +

Content-Disposition: attachment; filename=foo[1](2).html
+ Test Results +
FF3warn + (accepts the unquoted value) +
MSIE8warn + (accepts the unquoted value) +
Op10warn + (accepts the unquoted value) +
Saf4warn + (accepts the unquoted value) +
Konqwarn + (accepts the unquoted value) +
Chromewarn + (accepts the unquoted value) +

+ 'attachment', specifying a filename of foo[1](2).html, but missing + the quotes. Also, "[", "]", "(" and ")" are not allowed in the HTTP token + production. +

This is invalid according to Section 19.5.1 of RFC2616, + so UAs should ignore it.

Content-Disposition: Additional Parameters

+

+ Various tests relating to the additional parameters defined in + Section 2 of RFC 2183. +

+

attcdate + [TEST] +

Content-Disposition: attachment; creation-date="Wed, 12 Feb 1997 16:29:51 -0500"
+ Test Results +
FF3unsupported + (seems to ignore the parameter) +
MSIE8unsupported + (seems to ignore the parameter) +
Op10unsupported + (seems to ignore the parameter) +
Saf4unsupported + (seems to ignore the parameter) +
Konqunsupported + (seems to ignore the parameter) +
Chromeunsupported + (seems to ignore the parameter) +

'attachment', plus creation-date (see Section 2.4 of RFC 2183)

UA should offer to download the resource. When doing so, + the creation date should be set to 12 Feb 1997.

attmdate + [TEST] +

Content-Disposition: attachment; modification-date="Wed, 12 Feb 1997 16:29:51 -0500"
+ Test Results +
FF3unsupported + (seems to ignore the parameter) +
MSIE8unsupported + (seems to ignore the parameter) +
Op10unsupported + (seems to ignore the parameter) +
Saf4unsupported + (seems to ignore the parameter) +
Konqunsupported + (seems to ignore the parameter) +
Chromeunsupported + (seems to ignore the parameter) +

'attachment', plus modification-date (see Section 2.5 of RFC 2183)

UA should offer to download the resource. When doing so, + the modification date should be set to 12 Feb 1997.

Content-Disposition: Disposition-Type Extension

+

+ A test checking behavior for disposition type extensions, + which should be treated as "attachment", see + Section 2.8 of RFC 2183. +

+

dispext + [TEST] +

Content-Disposition: foobar
+ Test Results +
FF3pass
MSIE8fail (does not treat it as 'attachment')
Op10fail (does not treat it as 'attachment')
Saf4fail (does not treat it as 'attachment')
Konqfail (does not treat it as 'attachment')
Chromepass

'foobar' only

This should be equivalent to using "attachment".

RFC2231 Encoding: Character Sets

+

+ Various tests using the parameter value encoding defined + in Section 4 of RFC 2231. +

+

attwithisofn2231iso + [TEST] +

Content-Disposition: attachment; filename*=iso-8859-1''foo-%E4.html
+ Test Results +
FF3pass
MSIE8unsupported
Op10pass
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo-ä.html, using RFC2231 encoded ISO-8859-1 +

UA should offer to download the resource as "foo-ä.html". +

attwithfn2231utf8 + [TEST] +

Content-Disposition: attachment; filename*=UTF-8''foo-%c3%a4-%e2%82%ac.html
+ Test Results +
FF3pass
MSIE8unsupported
Op10pass
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo-ä-€.html, using RFC2231 encoded UTF-8 +

UA should offer to download the resource as "foo-ä-€.html". +

attwithfn2231noc + [TEST] +

Content-Disposition: attachment; filename*=''foo-%c3%a4-%e2%82%ac.html
+ Test Results +
FF3warn + (decodes as UTF-8) +
MSIE8unsupported
Op10warn + (decodes as 8bit encoding (ISO-8859-1?)) +
Saf4unsupported
Konqunsupported
Chromeunsupported

+ Behavior is undefined in RFC 2231, the charset part is missing, although UTF-8 was used. +

attwithfn2231utf8comp + [TEST] +

Content-Disposition: attachment; filename*=UTF-8''foo-a%cc%88.html
+ Test Results +
FF3pass
MSIE8unsupported
Op10warn + (displays "foo-ä.html") +
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo-ä.html, using RFC2231 encoded UTF-8, but + choosing the decomposed form (lowercase a plus COMBINING DIAERESIS) -- + on a Windows target system, this should be translated to the preferred + Unicode normal form (composed). +

UA should offer to download the resource as "foo-ä.html". +

attwithfn2231utf8-bad + [TEST] +

Content-Disposition: attachment; filename*=iso-8859-1''foo-%c3%a4-%e2%82%ac.html
+ Test Results +
FF3fail + (falls back to UTF-8) +
MSIE8unsupported
Op10warn + (displays the raw octet sequence as if it was ISO-8859-1 (which is internally + treated as windows-1252, which does allow %82)) +
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo-ä-€.html, using RFC2231 encoded UTF-8, but declaring ISO-8859-1 +

+ The octet %82 does not represent a valid ISO-8859-1 code point, so + the UA should really ignore the parameter. +

attwithfn2231ws1 + [TEST] +

Content-Disposition: attachment; filename *=UTF-8''foo-%c3%a4.html
+ Test Results +
FF3fail + (displays garbage) +
MSIE8unsupported
Op10pass
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo-ä.html, using RFC2231 encoded UTF-8, with whitespace before "*=" +

+ The parameter is invalid, thus should be ignored. +

attwithfn2231ws2 + [TEST] +

Content-Disposition: attachment; filename*= UTF-8''foo-%c3%a4.html
+ Test Results +
FF3pass
MSIE8unsupported
Op10pass
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo-ä.html, using RFC2231 encoded UTF-8, with whitespace after "*=" +

+ UA should offer to download the resource as "foo-ä.html". +

attwithfn2231ws3 + [TEST] +

Content-Disposition: attachment; filename* =UTF-8''foo-%c3%a4.html
+ Test Results +
FF3pass
MSIE8unsupported
Op10pass
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo-ä.html, using RFC2231 encoded UTF-8, with whitespace inside "* =" +

+ UA should offer to download the resource as "foo-ä.html". +

attwithfn2231quot + [TEST] +

Content-Disposition: attachment; filename*="UTF-8''foo-%c3%a4.html"
+ Test Results +
FF3fail + (tries to be helpful by removing the quotes) +
MSIE8unsupported
Op10pass
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo-ä.html, using RFC2231 encoded UTF-8, with double quotes + around the parameter value. +

+ The parameter is invalid, thus should be ignored. +

attwithfn2231encmissing + [TEST] +

Content-Disposition: attachment; filename*=''foo-%c3%a4.html
+ Test Results +
FF3fail + (sniffs the encoding as UTF-8) +
MSIE8unsupported
Op10fail + (assumes a default of ISO-8859-1) +
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo-ä.html, using RFC2231 encoded UTF-8, but + leaving out the charset field. +

+ The parameter is invalid, thus should be ignored. +

RFC2231 Encoding: Continuations

+

+ Various tests using the parameter value continuation efined + in Section 3 of RFC 2231. +

+

attfncont + [TEST] +

Content-Disposition: attachment; filename*0="foo."; filename*1="html"
+ Test Results +
FF3pass
MSIE8unsupported
Op10pass
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo.html, using RFC2231-style parameter continuations. +

+ UA should offer to download the resource as "foo.html". +

attfncontenc + [TEST] +

Content-Disposition: attachment; filename*0*=UTF-8''foo-%c3%a4; filename*1=".html"
+ Test Results +
FF3pass
MSIE8unsupported
Op10pass
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo-ä.html, using both RFC2231-style parameter continuations + and UTF-8 encoding. +

+ UA should offer to download the resource as "foo-ä.html". +

attfncontlz + [TEST] +

Content-Disposition: attachment; filename*0="foo"; filename*01="bar"
+ Test Results +
FF3warn + (accepts leading zeros) +
MSIE8unsupported
Op10warn + (accepts leading zeros) +
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo (the parameter filename*01 should be ignored because of the leading zero) +

+ UA should offer to download the resource as "foo". +

attfncontnc + [TEST] +

Content-Disposition: attachment; filename*0="foo"; filename*2="bar"
+ Test Results +
FF3warn + (accepts gaps) +
MSIE8unsupported
Op10pass
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foo (the parameter filename*2 because there's no filename*1 parameter) +

+ UA should offer to download the resource as "foo". +

attfnconts1 + [TEST] +

Content-Disposition: attachment; filename*1="foo."; filename*2="html"
+ Test Results +
FF3pass
MSIE8unsupported
Op10pass
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment' (the filename* parameters should be ignored because filename*0 is missing) +

+ UA should offer to download, not getting the filename from the header. +

attfncontord + [TEST] +

Content-Disposition: attachment; filename*1="bar"; filename*0="foo"
+ Test Results +
FF3fail + (parameters are expected to be ordered) +
MSIE8unsupported
Op10pass
Saf4unsupported
Konqunsupported
Chromeunsupported

+ 'attachment', specifying a filename of foobar +

+ UA should offer to download the resource as "foobar". +

RFC2231 Encoding: Fallback Behaviour

+

+ This tests how the UA behaves when the same parameter name appear + both in traditional and RFC 2231 extended format. +

+

attfnboth + [TEST] +

Content-Disposition: attachment; filename="foo-ae.html"; filename*=UTF-8''foo-%c3%a4.html
+ Test Results +
FF3pass + (picks the traditionally encoded value -- the first of both) +
MSIE8pass + (picks the traditionally encoded value -- the first of both) +
Op10pass + (picks the traditionally encoded value -- the first of both) +
Saf4pass + (picks the traditionally encoded value -- the first of both) +
Konqpass + (picks the traditionally encoded value -- the first of both) +
Chromepass + (picks the traditionally encoded value -- the first of both) +

+ 'attachment', specifying a filename of foo-ae.html in + the traditional format, and foo-ä.html in RFC2231 format. +

+ The behaviour of this undefined. Thus UAs should one of the two values. +

attfnboth2 + [TEST] +

Content-Disposition: attachment; filename*=UTF-8''foo-%c3%a4.html; filename="foo-ae.html"
+ Test Results +
FF3pass + (picks the RFC2231 encoded value -- the first of both) +
MSIE8fail + (ignores the parameter (this indicates a parsing bug)) +
Op10pass + (picks the RFC2231 encoded value -- the first of both) +
Saf4pass + (picks the traditionally encoded value -- the one it understands) +
Konqpass + (picks the traditionally encoded value -- the one it understands) +
Chromefail + (ignores the parameter (this indicates a parsing bug)) +

+ 'attachment', specifying a filename of foo-ae.html in + the traditional format, and foo-ä.html in RFC2231 format. +

+ The behaviour of this undefined. Thus UAs should one of the two values. +

RFC2047 Encoding

+

+ These tests RFC 2047 style encoding. +

+

+ Note that according to Section 5 of RFC 2047, + this encoding does not apply here: An 'encoded-word' MUST NOT appear within a 'quoted-string'., and + An 'encoded-word' MUST NOT be used in parameter of a MIME + Content-Type or Content-Disposition field, or in any structured + field body except within a 'comment' or 'phrase'. +

+

+ Therefore, these tests are only be present in order to check + whether the UA by mistake tries to implement RFC2047. +

+

attrfc2047token + [TEST] +

Content-Disposition: attachment; filename==?ISO-8859-1?Q?foo-=E4.html?=
+ Test Results +
FF3fail + (decodes it anyway to "foo-ä.html") +
MSIE8pass + (takes the whole value as filename, but does not decode it (replacing question marks by underscores)) +
Op10fail + (displays garbage ("=.htm")) +
Saf4pass + (takes the whole value as filename, but does not decode it (replacing question marks by underscores)) +
Konqfail + (decodes it anyway to "foo-ä.html") +
Chromefail + (decodes it anyway to "foo-ä.html") +

+ Uses RFC 2047 style encoded word. "=" is invalid inside the token + production, so this is invalid. +

attrfc2047quoted + [TEST] +

Content-Disposition: attachment; filename="=?ISO-8859-1?Q?foo-=E4.html?="
+ Test Results +
FF3fail + (decodes it anyway to "foo-ä.html") +
MSIE8pass + (takes the whole value as filename, but does not decode it) +
Op10fail + (displays garbage ("=.htm")) +
Saf4pass + (takes the whole value as filename, but does not decode it) +
Konqfail + (decodes it anyway to "foo-ä.html") +
Chromefail + (decodes it anyway to "foo-ä.html") +

+ Uses RFC 2047 style encoded word, using the quoted-string production. +

+ \ No newline at end of file -- cgit v1.2.1 From f959cfb603baea26f6e7c7d9414d0d06ee4acd0a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 2 Mar 2010 01:20:04 +0100 Subject: This will fix rekonq behaviour on opening external links. It's a bit "less functional" than before, but it always works :) --- src/application.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index e5b76745..270cd87f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -53,7 +53,6 @@ #include #include #include -#include #include #include @@ -153,21 +152,17 @@ int Application::newInstance() // are there args? load them.. if (args->count() > 0) { - // is there a window open on the current desktop ? use it! - for (int i = 0; i < m_mainWindows.size(); ++i) + // are there any windows there? use it + int index = m_mainWindows.size(); + if(index > 0) { - MainWindow *m = m_mainWindows.at(i).data(); - KWindowInfo w = KWindowInfo(m->winId(), NET::WMDesktop); - if(w.isOnCurrentDesktop()) - { - m->activateWindow(); - m->raise(); + MainWindow *m = m_mainWindows.at(index - 1).data(); + m->activateWindow(); - for (int i = 0; i < args->count(); ++i) - loadUrl(args->arg(i), Rekonq::NewCurrentTab); + for (int i = 0; i < args->count(); ++i) + loadUrl(args->arg(i), Rekonq::NewCurrentTab); - return 2; - } + return 2; } // No windows in the current desktop? No windows at all? -- cgit v1.2.1 From 51bc713428c8c23f9b3f614c756a1bc3e239c586 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 2 Mar 2010 01:22:13 +0100 Subject: Reenabled urlbar hack BUG:228606 --- src/urlbar/urlbar.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 3ddadf6b..718d9f67 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -161,13 +161,13 @@ void UrlBar::setProgress(int progress) void UrlBar::updateUrl() { -// // Don't change my typed url... -// // FIXME this is not a proper solution (also if it works...) -// if(hasFocus()) -// { -// kDebug() << "Don't change my typed url..."; -// return; -// } + // Don't change my typed url... + // FIXME this is not a proper solution (also if it works...) + if(hasFocus()) + { + kDebug() << "Don't change my typed url..."; + return; + } KIcon icon; if(m_currentUrl.isEmpty()) -- cgit v1.2.1 From f24d3182f08480502cbf7bcfd1a0775e57722197 Mon Sep 17 00:00:00 2001 From: Darjus Loktevic Date: Tue, 2 Mar 2010 21:27:03 -0800 Subject: * Added continue search by key (similar to Firefox, enter the search term and press for next result). * Removed focusNextPrevChild if the search fails as it does not seem to make sense. It's the same as you would press to focus the next item on the page. Why "Search" should do that? Some context: found that when searching some websites, when the match is not found, the page would suddenly scroll to some location and focus a link or search edit. Hope this makes sense. --- src/findbar.cpp | 1 + src/mainwindow.cpp | 9 +-------- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/findbar.cpp b/src/findbar.cpp index bb693ab0..03fe2180 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -82,6 +82,7 @@ FindBar::FindBar(QWidget *parent) setFocusProxy(m_lineEdit); m_lineEdit->setMaximumWidth(250); connect(m_lineEdit, SIGNAL(textChanged(const QString &)), window, SLOT(find(const QString &))); + connect(m_lineEdit, SIGNAL(returnPressed()), mainwindow, SLOT(findNext())); layout->addWidget(m_lineEdit); // buttons diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 39dd9a40..a09c25e8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -794,10 +794,7 @@ void MainWindow::findNext() return; if(m_findBar->isHidden()) - { - currentTab()->view()->page()->focusNextPrevChild(true); - return; - } + return; QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; if (m_findBar->matchCase()) @@ -805,8 +802,6 @@ void MainWindow::findNext() bool found = currentTab()->view()->findText(m_lastSearch, options); m_findBar->notifyMatch(found); - if(!found) - currentTab()->view()->page()->focusNextPrevChild(true); } @@ -821,8 +816,6 @@ void MainWindow::findPrevious() bool found = currentTab()->view()->findText(m_lastSearch, options); m_findBar->notifyMatch(found); - if(!found) - currentTab()->view()->page()->focusNextPrevChild(true); } -- cgit v1.2.1 From a9c75882d7ba333baf54befcd64fe0bd51e6b220 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 3 Mar 2010 10:04:15 +0100 Subject: Removing call to non-extant slot.. --- src/webtab.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/webtab.cpp b/src/webtab.cpp index b4759995..b4e59d84 100644 --- a/src/webtab.cpp +++ b/src/webtab.cpp @@ -91,8 +91,6 @@ WebTab::WebTab(QWidget *parent) this, SLOT(createWalletBar(const QString &, const QUrl &))); } - connect(view->page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); - connect(view, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int))); connect(view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); } -- cgit v1.2.1 From 1255296a1bdf0a2f4e3baa1992bb80d224f33941 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Wed, 3 Mar 2010 11:46:07 +0100 Subject: Fix the scroll problem with the workaround of findText() (spotted by Darjus Loktevic) --- src/mainwindow.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 39dd9a40..5df226df 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -795,8 +795,10 @@ void MainWindow::findNext() if(m_findBar->isHidden()) { - currentTab()->view()->page()->focusNextPrevChild(true); - return; + QPoint test = currentTab()->view()->page()->currentFrame()->scrollPosition(); + currentTab()->view()->page()->focusNextPrevChild(true); + currentTab()->view()->page()->currentFrame()->setScrollPosition(test); + return; } QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; @@ -806,7 +808,11 @@ void MainWindow::findNext() bool found = currentTab()->view()->findText(m_lastSearch, options); m_findBar->notifyMatch(found); if(!found) - currentTab()->view()->page()->focusNextPrevChild(true); + { + QPoint test = currentTab()->view()->page()->currentFrame()->scrollPosition(); + currentTab()->view()->page()->focusNextPrevChild(true); + currentTab()->view()->page()->currentFrame()->setScrollPosition(test); + } } @@ -821,8 +827,6 @@ void MainWindow::findPrevious() bool found = currentTab()->view()->findText(m_lastSearch, options); m_findBar->notifyMatch(found); - if(!found) - currentTab()->view()->page()->focusNextPrevChild(true); } -- cgit v1.2.1 From 92baa8b9ff6171e391fdbc0f70b4ece24be4843f Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Wed, 3 Mar 2010 12:04:54 +0100 Subject: Fix the move of the page whith case sensitive --- src/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5df226df..7c30198f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -783,7 +783,7 @@ void MainWindow::matchCaseUpdate() if (!currentTab()) return; - currentTab()->view()->findText(m_lastSearch, QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument); + currentTab()->view()->findText(m_lastSearch, QWebPage::FindBackward); findNext(); } -- cgit v1.2.1 From 479afef6b760849df654226861e264ddd735632d Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Wed, 3 Mar 2010 12:41:43 +0100 Subject: variable names ... --- src/mainwindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7c30198f..a6f1428f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -795,9 +795,9 @@ void MainWindow::findNext() if(m_findBar->isHidden()) { - QPoint test = currentTab()->view()->page()->currentFrame()->scrollPosition(); + QPoint previous_position = currentTab()->view()->page()->currentFrame()->scrollPosition(); currentTab()->view()->page()->focusNextPrevChild(true); - currentTab()->view()->page()->currentFrame()->setScrollPosition(test); + currentTab()->view()->page()->currentFrame()->setScrollPosition(previous_position); return; } @@ -809,9 +809,9 @@ void MainWindow::findNext() m_findBar->notifyMatch(found); if(!found) { - QPoint test = currentTab()->view()->page()->currentFrame()->scrollPosition(); + QPoint previous_position = currentTab()->view()->page()->currentFrame()->scrollPosition(); currentTab()->view()->page()->focusNextPrevChild(true); - currentTab()->view()->page()->currentFrame()->setScrollPosition(test); + currentTab()->view()->page()->currentFrame()->setScrollPosition(previous_position); } } -- cgit v1.2.1 From b6d1cf90688c74c98b12e86618fc142e1d432379 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 3 Mar 2010 14:15:34 +0100 Subject: Fix compile :/ --- src/findbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/findbar.cpp b/src/findbar.cpp index 03fe2180..4c780aca 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -82,7 +82,7 @@ FindBar::FindBar(QWidget *parent) setFocusProxy(m_lineEdit); m_lineEdit->setMaximumWidth(250); connect(m_lineEdit, SIGNAL(textChanged(const QString &)), window, SLOT(find(const QString &))); - connect(m_lineEdit, SIGNAL(returnPressed()), mainwindow, SLOT(findNext())); + connect(m_lineEdit, SIGNAL(returnPressed()), window, SLOT(findNext())); layout->addWidget(m_lineEdit); // buttons -- cgit v1.2.1 From e26472693aac7fe5ef277889fd0136dd66159e94 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 4 Mar 2010 13:59:25 +0100 Subject: WebPluginFactory. Cleaning code.. --- src/webpluginfactory.cpp | 60 +++++++++++++++++++++++------------------------- src/webpluginfactory.h | 5 +--- 2 files changed, 30 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index 6265aeb3..c8060969 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -41,8 +41,8 @@ WebPluginFactory::WebPluginFactory(QObject *parent) : KWebPluginFactory(parent) + , _loadClickToFlash(false) { - loadClickToFlash = false; connect(this, SIGNAL(signalLoadClickToFlash(bool)), SLOT(setLoadClickToFlash(bool))); } @@ -55,7 +55,7 @@ WebPluginFactory::~WebPluginFactory() void WebPluginFactory::setLoadClickToFlash(bool load) { - loadClickToFlash = load; + _loadClickToFlash = load; } @@ -65,39 +65,37 @@ QObject *WebPluginFactory::create(const QString &mimeType, const QStringList &argumentValues) const { kDebug() << "loading mimeType: " << mimeType; - - if(ReKonfig::pluginsEnabled() == 0) // plugins are enabled + + switch( ReKonfig::pluginsEnabled() ) { + case 0: kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones..."; + return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); + + case 1: + if( mimeType != QString("application/x-shockwave-flash") ) + break; + + if( _loadClickToFlash ) + { + emit signalLoadClickToFlash(false); + return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); + } + else + { + ClickToFlash* ctf = new ClickToFlash(url); + connect(ctf, SIGNAL(signalLoadClickToFlash(bool)), this, SLOT(setLoadClickToFlash(bool))); + return ctf; + } + break; + + case 2: return 0; + + default: + kDebug() << "oh oh.. this should NEVER happen.."; + break; } - if(mimeType == QString("application/x-shockwave-flash") - && !loadClickToFlash) - { - ClickToFlash* ctf = new ClickToFlash(url); - connect(ctf, SIGNAL(signalLoadClickToFlash(bool)), this, SLOT(setLoadClickToFlash(bool))); - return ctf; - } - - // this let QtWebKit using builtin plugins - // to load in example flash contents and so on.. - kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones..."; - emit signalLoadClickToFlash(false); return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); } - - -QList WebPluginFactory::plugins() const -{ - QList plugins = KWebPluginFactory::plugins(); - - KWebPluginFactory::Plugin p; - - p.name = "application/x-shockwave-flash"; - p.description = "Plugin for flash animations"; - plugins.append(p); - - - return plugins; -} diff --git a/src/webpluginfactory.h b/src/webpluginfactory.h index 74bca043..9e5028b2 100644 --- a/src/webpluginfactory.h +++ b/src/webpluginfactory.h @@ -53,10 +53,7 @@ public: const QStringList &argumentNames, const QStringList &argumentValues) const; - virtual QList plugins() const; - signals: - void signalLoadClickToFlash(bool) const; public slots: @@ -67,7 +64,7 @@ private: When true, force loading of next flash animation (don't show clicktoflash) We use signals/slots to set this property because QWebPluginFactory::create is const */ - bool loadClickToFlash; + bool _loadClickToFlash; }; #endif // WEB_PLUGIN_FACTORY_H -- cgit v1.2.1 From 3d9eeaedd2124cd4548c3f718986f41d0172fe9a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 4 Mar 2010 14:01:40 +0100 Subject: delete clicktoflash object just when detection doesn't fail. This will save rekonq from crashes :) --- src/clicktoflash.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/clicktoflash.cpp b/src/clicktoflash.cpp index 64dff19d..24f8740e 100644 --- a/src/clicktoflash.cpp +++ b/src/clicktoflash.cpp @@ -114,14 +114,13 @@ void ClickToFlash::load() QWebElement substitute = element.clone(); emit signalLoadClickToFlash(true); element.replace(substitute); + deleteLater(); return; } } frames += frame->childFrames(); } - - deleteLater(); } -- cgit v1.2.1 From c9813c11a0c8a928d8fac4eb63efd29eec50047d Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 4 Mar 2010 15:37:18 +0100 Subject: Fix Click to Flash. In my tests it doesn't crash anymore and works ever well :) (Please, don't wake up me if this is just aa dream..) --- src/clicktoflash.cpp | 54 ++++++++++++++++++++++++++++++------------------ src/clicktoflash.h | 3 +++ src/webpluginfactory.cpp | 2 +- 3 files changed, 38 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/clicktoflash.cpp b/src/clicktoflash.cpp index 24f8740e..3c284b3f 100644 --- a/src/clicktoflash.cpp +++ b/src/clicktoflash.cpp @@ -31,6 +31,7 @@ // KDE Includes #include +#include // Qt Includes #include @@ -89,28 +90,11 @@ void ClickToFlash::load() elements.append(docElement.findAll(selector.arg(QLatin1String("object")))); elements.append(docElement.findAll(selector.arg(QLatin1String("embed")))); - bool isRightElement = false; foreach (QWebElement element, elements) { - // TODO : find a proper solution to compare a QWebElement with a plugin - // With this "manual" test, it's probably not working everywhere - if(QUrl(element.attribute("data")) == m_url - || QUrl(element.attribute("src")) == m_url) - isRightElement = true; - else - { - QWebElementCollection collec = element.findAll("param"); - int i = 0; - while(i < collec.count() && isRightElement == false) - { - if(QUrl(collec.at(i).attribute("value")) == m_url) - isRightElement = true; - i++; - } - } - - if(isRightElement) + if( checkElement(element) ) { + kDebug() << "RETURNED TRUE ..........................."; QWebElement substitute = element.clone(); emit signalLoadClickToFlash(true); element.replace(substitute); @@ -118,9 +102,39 @@ void ClickToFlash::load() return; } } - frames += frame->childFrames(); } } +bool ClickToFlash::checkElement(QWebElement el) +{ + kDebug() << "src: " << QUrl(el.attribute("src")); + kDebug() << "url: " << m_url; + + QString checkString; + QString urlString; + + checkString = QUrl(el.attribute("src")).toString( QUrl::RemoveQuery ); + urlString = m_url.toString( QUrl::RemoveQuery ); + + if( urlString.contains( checkString ) ) + return true; + + QWebElementCollection collec = el.findAll("*"); + int i = 0; + while( i < collec.count() ) + { + QWebElement el = collec.at(i); + + checkString = QUrl(el.attribute("src")).toString( QUrl::RemoveQuery ); + urlString = m_url.toString( QUrl::RemoveQuery ); + + if( urlString.contains( checkString ) ) + return true; + + i++; + } + + return false; +} diff --git a/src/clicktoflash.h b/src/clicktoflash.h index 2284ec7e..7d6c4e05 100644 --- a/src/clicktoflash.h +++ b/src/clicktoflash.h @@ -35,6 +35,7 @@ // Qt Includes #include #include +#include // Forward Declarations class WebPluginFactory; @@ -54,6 +55,8 @@ private slots: void load(); private: + bool checkElement(QWebElement el); + /** used to find the right QWebElement between the ones of the different plugins */ diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index c8060969..9e4b8ba3 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -79,7 +79,7 @@ QObject *WebPluginFactory::create(const QString &mimeType, if( _loadClickToFlash ) { emit signalLoadClickToFlash(false); - return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); + return 0; //KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); } else { -- cgit v1.2.1 From 09ba3b9c585ad397c3168d1fb44f7f4dc75f0447 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Mar 2010 00:52:07 +0100 Subject: Fix choice between history & bookmarks in the new tab first page. No more reloading pages on accepting configuration --- src/mainwindow.cpp | 9 +-------- src/mainwindow.h | 1 - src/protocolhandler.cpp | 8 ++++---- 3 files changed, 5 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a02910fd..eebebc09 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -603,13 +603,6 @@ void MainWindow::updateConfiguration() } -void MainWindow::updateBrowser() -{ - updateConfiguration(); - mainView()->reloadAllTabs(); -} - - void MainWindow::openLocation() { m_view->urlBar()->selectAll(); @@ -646,7 +639,7 @@ void MainWindow::preferences() QWeakPointer s = new SettingsDialog(this); // keep us informed when the user changes settings - connect(s.data(), SIGNAL(settingsChanged(const QString&)), this, SLOT(updateBrowser())); + connect(s.data(), SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration())); s.data()->exec(); delete s.data(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 66c796cc..57b88dfd 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -87,7 +87,6 @@ private: void setupPanels(); public slots: - void updateBrowser(); void homePage(); /** diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index ffeea562..70d69107 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -124,12 +124,12 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra case 1: // closed tabs _url = KUrl("about:closedTabs"); break; - case 2: // history - _url = KUrl("about:history"); - break; - case 3: // bookmarks + case 2: // bookmarks _url = KUrl("about:bookmarks"); break; + case 3: // history + _url = KUrl("about:history"); + break; default: // unuseful break; } -- cgit v1.2.1 From fba2312780dd712fff036c3926320d1ceba2adbc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Mar 2010 01:04:28 +0100 Subject: Fixing recover on crash hackish fix :( --- src/application.cpp | 11 ++++++++++- src/rekonq.kcfg | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index 270cd87f..499c7a37 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -79,6 +79,11 @@ Application::Application() Application::~Application() { + // ok, we are closing well. + // Don't recover on next load.. + ReKonfig::setRecoverOnCrash(false); + saveConfiguration(); + foreach( QWeakPointer window, m_mainWindows) { delete window.data(); @@ -143,7 +148,7 @@ int Application::newInstance() // is your app session restored? restore session... // this mechanism also falls back to load usual plain rekonq // if something goes wrong... - if (isSessionRestored() && sessionManager()->restoreSession()) + if (ReKonfig::recoverOnCrash() && sessionManager()->restoreSession()) { kDebug() << "session restored"; return 1; @@ -198,6 +203,10 @@ void Application::postLaunch() // bookmarks loading connect(Application::bookmarkProvider(), SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&)), Application::instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType&))); + + // crash recovering + ReKonfig::setRecoverOnCrash(true); + saveConfiguration(); } diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 0675720c..f68dc7e8 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -25,6 +25,9 @@ + + false + -- cgit v1.2.1 From 984526692fa8d8b77f4cc026a2f527a974e403c0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Mar 2010 01:21:58 +0100 Subject: Cleaning websnaps code.. --- src/rekonqpage/newtabpage.cpp | 2 +- src/websnap.cpp | 26 +++++++++----------------- src/websnap.h | 4 ++-- 3 files changed, 12 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index cc8aa1fb..3cd79326 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -183,7 +183,7 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url) setupPreview(prev, index); showControls(prev); - new WebSnap(url, m_root.webFrame()->page(), index); + new WebSnap(url, m_root.webFrame(), index); return prev; } diff --git a/src/websnap.cpp b/src/websnap.cpp index 6310c868..2916418b 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -46,13 +46,12 @@ #include -WebSnap::WebSnap(const QUrl& url, QWebPage* originatingPage, int previewIndex) +WebSnap::WebSnap(const QUrl& url, QWebFrame *frame, int index) : QObject() + , m_url(url) + , m_frame(frame) + , m_previewIndex(index) { - m_url = url; - m_originatingPage = originatingPage; - m_previewIndex = previewIndex; - // this to not register websnap history m_page.settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); @@ -76,14 +75,12 @@ void WebSnap::load() } -QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h) +QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h) { // prepare page - page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); // Why it doesn't work with one setScrollBarPolicy? - page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); // bug in qtwebkit ? - page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); - + // find the best size QSize size; int width = page.mainFrame()->contentsSize().width(); @@ -102,8 +99,6 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h) // restore page settings page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); - page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); - page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); return QPixmap::fromImage(pageImage); @@ -120,8 +115,7 @@ void WebSnap::savePreview(QPixmap pm, KUrl url) KUrl WebSnap::fileForUrl(KUrl url) { - QString filePath = - KStandardDirs::locateLocal("cache", QString("thumbs/") + WebSnap::guessNameFromUrl(url) + ".png", true); + QString filePath = KStandardDirs::locateLocal("cache", QString("thumbs/") + WebSnap::guessNameFromUrl(url) + ".png", true); return KUrl(filePath); } @@ -162,15 +156,13 @@ void WebSnap::saveResult(bool ok) QFile::remove(fileForUrl(m_url).toLocalFile()); m_image.save(fileForUrl(m_url).toLocalFile()); - //m_originatingPage->mainFrame()->load(KUrl("about:preview/replace/" + QVariant(m_previewIndex).toString())); - NewTabPage p(m_originatingPage->mainFrame()); + NewTabPage p( m_frame ); p.snapFinished(m_previewIndex, m_url, m_snapTitle); deleteLater(); } - QString WebSnap::snapTitle() { return m_page.mainFrame()->title(); diff --git a/src/websnap.h b/src/websnap.h index 54f63503..49b60769 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -55,7 +55,7 @@ class REKONQ_TESTS_EXPORT WebSnap : public QObject Q_OBJECT public: - WebSnap(const QUrl &url, QWebPage *originatingPage, int previewIndex); + WebSnap(const QUrl &url, QWebFrame *frame, int index); ~WebSnap(); QPixmap previewImage(); // TODO : remove @@ -82,7 +82,7 @@ private: QUrl m_url; QString m_snapTitle; - QWebPage *m_originatingPage; + QWebFrame *m_frame; int m_previewIndex; }; -- cgit v1.2.1 From 01bf832717d4910183f7e55715065044361a4108 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Mar 2010 01:34:06 +0100 Subject: Bug about page viewportsize seems fixed here, creating a copy of the page fro the tab preview. Some days of testing needed.. --- src/tabbar.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 49ed230b..43432ec4 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -168,9 +168,12 @@ void TabBar::showTabPreview(int tab) m_previewPopup.data()->setFrameShape(QFrame::StyledPanel); m_previewPopup.data()->setFrameShadow(QFrame::Plain); m_previewPopup.data()->setFixedSize(w, h); + QLabel *l = new QLabel(); - view->page()->setViewportSize(currentView->page()->viewportSize()); - l->setPixmap(WebSnap::renderPreview(*(view->page()), w, h)); + QWebPage copyPage(view->page()); + copyPage.setViewportSize(currentView->page()->viewportSize()); + l->setPixmap(WebSnap::renderPreview(copyPage, w, h)); + m_previewPopup.data()->setView(l); m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop); m_previewPopup.data()->layout()->setMargin(0); -- cgit v1.2.1 From b43e6d9f1784cb95977a2cfd0a21f7caeed8d6d9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Mar 2010 02:17:51 +0100 Subject: Stupid me, committed wrong change. Sorry :) --- src/application.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index 499c7a37..31f0ab2e 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -143,17 +143,17 @@ int Application::newInstance() { QTimer::singleShot(0, this, SLOT(postLaunch())); first = false; + + // is your app session restored? restore session... + // this mechanism also falls back to load usual plain rekonq + // if something goes wrong... + if (ReKonfig::recoverOnCrash() && sessionManager()->restoreSession()) + { + kDebug() << "session restored"; + return 1; + } } - // is your app session restored? restore session... - // this mechanism also falls back to load usual plain rekonq - // if something goes wrong... - if (ReKonfig::recoverOnCrash() && sessionManager()->restoreSession()) - { - kDebug() << "session restored"; - return 1; - } - // are there args? load them.. if (args->count() > 0) { -- cgit v1.2.1 From 384b3f1d066443b67b9d3d6389846a44e976876f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Mar 2010 12:41:28 +0100 Subject: Ok, things seem working well now. Anyway, it needs some days of testing.. --- src/tabbar.cpp | 12 +++++------- src/websnap.cpp | 9 +++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 43432ec4..25351ac0 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -150,15 +150,15 @@ void TabBar::showTabPreview(int tab) { MainView *mv = qobject_cast(parent()); - WebTab *view = mv->webTab(tab); - WebTab *currentView = mv->webTab(currentIndex()); + WebTab *indexedTab = mv->webTab(tab); + WebTab *currentTab = mv->webTab(currentIndex()); // check if view && currentView exist before using them :) - if(!currentView || !view) + if(!currentTab || !indexedTab) return; int w = tabSizeHint(tab).width(); - int h = w * ( (0.0 + currentView->height()) / currentView->width() ); + int h = w * ( (0.0 + currentTab->height()) / currentTab->width() ); //delete previous tab preview delete m_previewPopup.data(); @@ -170,9 +170,7 @@ void TabBar::showTabPreview(int tab) m_previewPopup.data()->setFixedSize(w, h); QLabel *l = new QLabel(); - QWebPage copyPage(view->page()); - copyPage.setViewportSize(currentView->page()->viewportSize()); - l->setPixmap(WebSnap::renderPreview(copyPage, w, h)); + l->setPixmap( WebSnap::renderPreview( *indexedTab->page() , w, h) ); m_previewPopup.data()->setView(l); m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop); diff --git a/src/websnap.cpp b/src/websnap.cpp index 2916418b..ceb24b4f 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -75,11 +75,14 @@ void WebSnap::load() } +// NOTE please, be careful modifying this. +// You are playing with fire.. QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h) { // prepare page page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + QSize oldSize = page.viewportSize(); // find the best size QSize size; @@ -90,7 +93,8 @@ QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h) // create the page image QImage pageImage = QImage(size, QImage::Format_ARGB32_Premultiplied); - pageImage.fill(Qt::transparent); + pageImage.fill(Qt::transparent); + // render it QPainter p(&pageImage); page.mainFrame()->render(&p); @@ -100,7 +104,8 @@ QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h) // restore page settings page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); - + page.setViewportSize(oldSize); + return QPixmap::fromImage(pageImage); } -- cgit v1.2.1 From 215274abfcbe43e5d64ae8104481dc46cd618952 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Mar 2010 00:20:52 +0100 Subject: Just another crash recovery fix. Now rekonq tries just 1 time to recover from crash. In Italy we say "Perseverare e' diabolico"... --- src/application.cpp | 7 ++++--- src/rekonq.kcfg | 4 ++-- src/sessionmanager.cpp | 11 ++++++----- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index 31f0ab2e..efa7bc22 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -81,7 +81,7 @@ Application::~Application() { // ok, we are closing well. // Don't recover on next load.. - ReKonfig::setRecoverOnCrash(false); + ReKonfig::setRecoverOnCrash(0); saveConfiguration(); foreach( QWeakPointer window, m_mainWindows) @@ -147,7 +147,7 @@ int Application::newInstance() // is your app session restored? restore session... // this mechanism also falls back to load usual plain rekonq // if something goes wrong... - if (ReKonfig::recoverOnCrash() && sessionManager()->restoreSession()) + if (ReKonfig::recoverOnCrash() == 1 && sessionManager()->restoreSession()) { kDebug() << "session restored"; return 1; @@ -205,7 +205,8 @@ void Application::postLaunch() Application::instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType&))); // crash recovering - ReKonfig::setRecoverOnCrash(true); + int n = ReKonfig::recoverOnCrash(); + ReKonfig::setRecoverOnCrash(++n); saveConfiguration(); } diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index f68dc7e8..bbf20ac1 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -25,8 +25,8 @@ - - false + + 0 diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp index 72e1cc77..9e1f7baf 100644 --- a/src/sessionmanager.cpp +++ b/src/sessionmanager.cpp @@ -66,7 +66,7 @@ void SessionManager::saveSession() QFile sessionFile(m_sessionFilePath); if (!sessionFile.open(QFile::WriteOnly | QFile::Truncate)) { - kWarning() << "Unable to open session file" << sessionFile.fileName(); + kDebug() << "Unable to open session file" << sessionFile.fileName(); return; } QTextStream out(&sessionFile); @@ -93,7 +93,7 @@ bool SessionManager::restoreSession() return false; if (!sessionFile.open(QFile::ReadOnly)) { - kWarning() << "Unable to open session file" << sessionFile.fileName(); + kDebug() << "Unable to open session file" << sessionFile.fileName(); return false; } @@ -104,16 +104,17 @@ bool SessionManager::restoreSession() line = in.readLine(); if(line == QString("window")) { - Application::instance()->newMainWindow(); line = in.readLine(); - Application::instance()->loadUrl(line); + kDebug() << "New Window line: " << line; + Application::instance()->loadUrl(line, Rekonq::NewWindow); } else { + kDebug() << "New Current Tab line: " << line; Application::instance()->loadUrl(line, Rekonq::NewCurrentTab); } } - while(!line.isNull()); + while(!line.isEmpty()); return true; } -- cgit v1.2.1 From 6aeb9406dd77ad066d7904a6f453aff019bb5838 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Mar 2010 00:26:02 +0100 Subject: kWarning --> kDebug --- src/history/autosaver.cpp | 4 ++-- src/history/historymanager.cpp | 8 ++++---- src/mainwindow.cpp | 2 +- src/rekonqpage/newtabpage.cpp | 15 +++++++++------ 4 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/history/autosaver.cpp b/src/history/autosaver.cpp index 41f19098..1bfd5c9e 100644 --- a/src/history/autosaver.cpp +++ b/src/history/autosaver.cpp @@ -52,7 +52,7 @@ AutoSaver::~AutoSaver() { if (m_timer.isActive()) { - kWarning() << "AutoSaver: still active when destroyed, changes not saved."; + kDebug() << "AutoSaver: still active when destroyed, changes not saved."; } } @@ -94,7 +94,7 @@ void AutoSaver::saveIfNeccessary() m_firstChange = QTime(); if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) { - kWarning() << "AutoSaver: error invoking slot save() on parent"; + kDebug() << "AutoSaver: error invoking slot save() on parent"; } } diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp index e75adbdc..362fe340 100644 --- a/src/history/historymanager.cpp +++ b/src/history/historymanager.cpp @@ -316,7 +316,7 @@ void HistoryManager::load() return; if (!historyFile.open(QFile::ReadOnly)) { - kWarning() << "Unable to open history file" << historyFile.fileName(); + kDebug() << "Unable to open history file" << historyFile.fileName(); return; } @@ -416,7 +416,7 @@ void HistoryManager::save() if (!open) { - kWarning() << "Unable to open history file for saving" + kDebug() << "Unable to open history file for saving" << (saveAll ? tempFile.fileName() : historyFile.fileName()); return; } @@ -436,11 +436,11 @@ void HistoryManager::save() { if (historyFile.exists() && !historyFile.remove()) { - kWarning() << "History: error removing old history." << historyFile.errorString(); + kDebug() << "History: error removing old history." << historyFile.errorString(); } if (!tempFile.rename(historyFile.fileName())) { - kWarning() << "History: error moving new history over old." << tempFile.errorString() << historyFile.fileName(); + kDebug() << "History: error moving new history over old." << tempFile.errorString() << historyFile.fileName(); } } m_lastSavedUrl = m_history.value(0).url; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index eebebc09..60784af0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1031,7 +1031,7 @@ QAction *MainWindow::actionByName(const QString name) return ret; /* else */ - kWarning() << "Action named: " << name << " not found, returning empty action."; + kDebug() << "Action named: " << name << " not found, returning empty action."; return new QAction(this); // return empty object instead of NULL pointer } diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 3cd79326..845dcf51 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -59,16 +59,19 @@ NewTabPage::NewTabPage(QWebFrame *frame) , m_url(KUrl()) { QString htmlFilePath = KStandardDirs::locate("data", "rekonq/htmls/home.html"); + QString imagesPath = QString("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QString("rekonq/pics"); QFile file(htmlFilePath); bool isOpened = file.open(QIODevice::ReadOnly); if (!isOpened) - kWarning() << "Couldn't open the home.html file"; - - QString imagesPath = QString("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QString("rekonq/pics"); - - m_html = file.readAll(); - m_html.replace(QString("%2"), imagesPath); + { + kDebug() << "Couldn't open the home.html file"; + } + else + { + m_html = file.readAll(); + m_html.replace(QString("%2"), imagesPath); + } } -- cgit v1.2.1 From e846f0e8cc58036a6fc6455f8a40f621c636cbc5 Mon Sep 17 00:00:00 2001 From: pano Date: Sat, 6 Mar 2010 16:37:47 +0100 Subject: Replace "Yes/No" dialog code copied and pasted from Konqueror (konqmainwindow.cpp) and adapted to rekonq code by me --- src/mainview.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mainview.cpp b/src/mainview.cpp index e2f9094f..fc4ddc6c 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -495,12 +495,12 @@ void MainView::closeTab(int index) { if (tab->view()->isModified()) { - int risp = KMessageBox::questionYesNo(this, + int risp = KMessageBox::warningContinueCancel(this, i18n("This tab contains changes that have not been submitted.\n" "Closing the tab will discard these changes.\n" "Do you really want to close this tab?\n"), - i18n("Closing Modified Tab")); - if (risp == KMessageBox::No) + i18n("Closing Modified Tab"), KGuiItem(i18n("&Discard Changes"),"view-refresh"), KStandardGuiItem::cancel()); + if (risp != KMessageBox::Continue) return; } hasFocus = tab->hasFocus(); -- cgit v1.2.1 From 87fabef6340c83c7c8746f37aa70b9d7a54b7d5e Mon Sep 17 00:00:00 2001 From: pano Date: Sat, 6 Mar 2010 16:46:55 +0100 Subject: Further changes to my last commit Change string and icon of the button --- src/mainview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mainview.cpp b/src/mainview.cpp index fc4ddc6c..f2152364 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -499,7 +499,7 @@ void MainView::closeTab(int index) i18n("This tab contains changes that have not been submitted.\n" "Closing the tab will discard these changes.\n" "Do you really want to close this tab?\n"), - i18n("Closing Modified Tab"), KGuiItem(i18n("&Discard Changes"),"view-refresh"), KStandardGuiItem::cancel()); + i18n("Closing Modified Tab"), KGuiItem(i18n("Close &Tab"),"tab-close"), KStandardGuiItem::cancel()); if (risp != KMessageBox::Continue) return; } -- cgit v1.2.1 From ab05c308dbe8a78445a785ed3873f38eec981120 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 11 Mar 2010 00:37:06 +0100 Subject: clean NewInstance slot and fix crashRecovery. Two days of testing before stable release. :) --- src/application.cpp | 72 ++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index efa7bc22..96254e07 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -108,14 +108,22 @@ int Application::newInstance() { KCmdLineArgs::setCwd( QDir::currentPath().toUtf8() ); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); - - // we share one process for several mainwindows, - // so initialize only once - static bool first = true; + + bool isFirstLoad = m_mainWindows.isEmpty(); + + // is your app session restored? restore session... + // this mechanism also falls back to load usual plain rekonq + // if something goes wrong... + if (isFirstLoad && ReKonfig::recoverOnCrash() == 1 && sessionManager()->restoreSession()) + { + QTimer::singleShot(0, this, SLOT(postLaunch())); + kDebug() << "session restored"; + return 1; + } if(args->count() == 0) { - if(first) // we are starting rekonq, for the first time with no args: use startup behaviour + if(isFirstLoad) // we are starting rekonq, for the first time with no args: use startup behaviour { switch(ReKonfig::startupBehaviour()) { @@ -138,47 +146,31 @@ int Application::newInstance() loadUrl( KUrl("about:home") , Rekonq::NewWindow ); } } - - if (first) + else { - QTimer::singleShot(0, this, SLOT(postLaunch())); - first = false; - - // is your app session restored? restore session... - // this mechanism also falls back to load usual plain rekonq - // if something goes wrong... - if (ReKonfig::recoverOnCrash() == 1 && sessionManager()->restoreSession()) + if(isFirstLoad) { - kDebug() << "session restored"; - return 1; + // No windows in the current desktop? No windows at all? + // Create a new one and load there sites... + loadUrl(args->arg(0), Rekonq::CurrentTab); + for (int i = 1; i < args->count(); ++i) + loadUrl(args->arg(i), Rekonq::SettingOpenTab); } - } - - // are there args? load them.. - if (args->count() > 0) - { - // are there any windows there? use it - int index = m_mainWindows.size(); - if(index > 0) + else { - MainWindow *m = m_mainWindows.at(index - 1).data(); - m->activateWindow(); - - for (int i = 0; i < args->count(); ++i) - loadUrl(args->arg(i), Rekonq::NewCurrentTab); - - return 2; + // are there any windows there? use it + int index = m_mainWindows.size(); + if(index > 0) + { + MainWindow *m = m_mainWindows.at(index - 1).data(); + m->activateWindow(); + for (int i = 0; i < args->count(); ++i) + loadUrl(args->arg(i), Rekonq::NewCurrentTab); + } } - - // No windows in the current desktop? No windows at all? - // Create a new one and load there sites... - loadUrl(args->arg(0), Rekonq::CurrentTab); - for (int i = 1; i < args->count(); ++i) - loadUrl(args->arg(i), Rekonq::SettingOpenTab); - - return 3; } - + + QTimer::singleShot(0, this, SLOT(postLaunch())); return 0; } -- cgit v1.2.1 From 25c5df38ada4523c7c76de55bf736656cf2bb5dc Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Thu, 11 Mar 2010 12:40:15 +0100 Subject: Close the tab preview when the close button is clicked --- src/tabbar.cpp | 14 ++++++++++++++ src/tabbar.h | 1 + 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 25351ac0..80782116 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -293,3 +293,17 @@ void TabBar::mouseReleaseEvent(QMouseEvent *event) KTabBar::mouseReleaseEvent(event); } + + +void TabBar::tabRemoved(int index) +{ + Q_UNUSED(index) + if (ReKonfig::alwaysShowTabPreviews()) + { + if ( !m_previewPopup.isNull() ) + { + m_previewPopup.data()->hide(); + } + m_currentTabPreview = -1; + } +} diff --git a/src/tabbar.h b/src/tabbar.h index 5d297e4c..97c320fc 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -81,6 +81,7 @@ protected: virtual void leaveEvent(QEvent *event); virtual void mousePressEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event); + virtual void tabRemoved(int); private slots: void cloneTab(); -- cgit v1.2.1 From 6faa12680a0d7d2f13c2862628325ab65521004b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 13 Mar 2010 23:24:45 +0100 Subject: Implemented automatic adblock update. This (squashed) commit adds this new feature in rekonq, letting people to simply "forgot" adblock and let rekonq do everything for it I added: - a new (rekonq) adblock widget - an asyncronous method to update rules from the net every TOT days - a better AdBlockManager management. What it is actually missing is the adp protocol support to add new subscriptions to adblock. This will come the next week. For now this part seems stable and needs just testing :) --- src/CMakeLists.txt | 2 + src/adblock/adblockmanager.cpp | 198 ++++++++++++++++++++++++++++++--------- src/adblock/adblockmanager.h | 18 +++- src/adblock/adblockrule.cpp | 6 ++ src/adblock/adblockrule.h | 4 +- src/rekonq.kcfg | 24 +++++ src/settings/adblockwidget.cpp | 158 +++++++++++++++++++++++++++++++ src/settings/adblockwidget.h | 56 +++++++++++ src/settings/settings_adblock.ui | 167 +++++++++++++++++++++++++++++++++ src/settings/settingsdialog.cpp | 22 +++-- src/webpage.cpp | 8 +- 11 files changed, 605 insertions(+), 58 deletions(-) create mode 100644 src/settings/adblockwidget.cpp create mode 100644 src/settings/adblockwidget.h create mode 100644 src/settings/settings_adblock.ui (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 00cfbf77..f05bbbdb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,6 +34,7 @@ SET( rekonq_KDEINIT_SRCS rekonqpage/previewselectorbar.cpp #---------------------------------------- settings/settingsdialog.cpp + settings/adblockwidget.cpp #---------------------------------------- bookmarks/bookmarksmanager.cpp bookmarks/bookmarkspanel.cpp @@ -54,6 +55,7 @@ KDE4_ADD_UI_FILES( rekonq_KDEINIT_SRCS settings/settings_tabs.ui settings/settings_fonts.ui settings/settings_webkit.ui + settings/settings_adblock.ui cleardata.ui ) diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp index 06f0d164..d2c2b013 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -28,6 +28,9 @@ #include "adblockmanager.h" #include "adblockmanager.moc" +// Auto Includes +#include "rekonq.h" + // Local Includes #include "adblocknetworkreply.h" #include "webpage.h" @@ -36,6 +39,7 @@ #include #include #include +#include // Qt Includes #include @@ -46,8 +50,8 @@ AdBlockManager::AdBlockManager(QObject *parent) : QObject(parent) , _isAdblockEnabled(false) , _isHideAdsEnabled(false) + , _index(0) { - loadSettings(); } @@ -58,52 +62,78 @@ AdBlockManager::~AdBlockManager() void AdBlockManager::loadSettings() { - KSharedConfig::Ptr config = KSharedConfig::openConfig("khtmlrc", KConfig::NoGlobals); - KConfigGroup cg( config, "Filter Settings" ); + _index = 0; + _buffer.clear(); + + _whiteList.clear(); + _blackList.clear(); + _hideList.clear(); + + _isAdblockEnabled = ReKonfig::adBlockEnabled(); + kDebug() << "ADBLOCK ENABLED = " << _isAdblockEnabled; + + // no need to load filters if adblock is not enabled :) + if(!_isAdblockEnabled) + return; + + // just to be sure.. + _isHideAdsEnabled = ReKonfig::hideAdsEnabled(); + + // local settings + KSharedConfig::Ptr config = KGlobal::config(); + KConfigGroup rulesGroup( config, "rules" ); + QStringList rules; + rules = rulesGroup.readEntry( "local-rules" , QStringList() ); + loadRules( rules ); - if ( cg.exists() ) + // ---------------------------------------------------------- + + QDateTime today = QDateTime::currentDateTime(); + QDateTime lastUpdate = ReKonfig::lastUpdate(); // the day of the implementation.. :) + int days = ReKonfig::updateInterval(); + + if( today > lastUpdate.addDays( days ) ) { - _isAdblockEnabled = cg.readEntry("Enabled", false); - _isHideAdsEnabled = cg.readEntry("Shrink", false); + ReKonfig::setLastUpdate( today ); + + updateNextSubscription(); + return; + } - // no need to load filters if adblock is not enabled :) - if(!_isAdblockEnabled) - return; + // else + QStringList names = ReKonfig::subscriptionNames(); + foreach(const QString &name, names) + { + rules = rulesGroup.readEntry( name + "-rules" , QStringList() ); + loadRules(rules); + } +} - _whiteList.clear(); - _blackList.clear(); - _hideList.clear(); - - QMap entryMap = cg.entryMap(); - QMap::ConstIterator it; - for( it = entryMap.constBegin(); it != entryMap.constEnd(); ++it ) - { - QString name = it.key(); - QString url = it.value(); - if (name.startsWith(QLatin1String("Filter"))) +void AdBlockManager::loadRules(const QStringList &rules) +{ + foreach(const QString &stringRule, rules) + { + // ! rules are comments + if( !stringRule.startsWith('!') && !stringRule.startsWith('[') && !stringRule.isEmpty() ) + { + // white rules + if( stringRule.startsWith( QLatin1String("@@") ) ) { - if(!url.startsWith('!')) - { - // white rules - if( url.startsWith( QLatin1String("@@") ) ) - { - AdBlockRule rule( url.mid(2) ); - _whiteList << rule; - continue; - } - - // hide (CSS) rules - if( url.startsWith( QLatin1String("##") ) ) - { - _hideList << url.mid(2); - continue; - } - - AdBlockRule rule( url ); - _blackList << rule; - } + AdBlockRule rule( stringRule.mid(2) ); + _whiteList << rule; + continue; } + + // hide (CSS) rules + if( stringRule.startsWith( QLatin1String("##") ) ) + { + _hideList << stringRule.mid(2); + continue; + } + + AdBlockRule rule( stringRule ); + _blackList << rule; } } } @@ -125,7 +155,9 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request) { if(filter.match(urlString)) { - kDebug() << "****ADBLOCK: WHITE RULE (@@) Matched: ***********" << urlString; + kDebug() << "****ADBLOCK: WHITE RULE (@@) Matched: ***********"; + kDebug() << "Filter exp: " << filter.pattern(); + kDebug() << "UrlString: " << urlString; return 0; } } @@ -135,7 +167,9 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request) { if(filter.match(urlString)) { - kDebug() << "****ADBLOCK: BLACK RULE Matched: ***********" << urlString; + kDebug() << "****ADBLOCK: BLACK RULE Matched: ***********"; + kDebug() << "Filter exp: " << filter.pattern(); + kDebug() << "UrlString: " << urlString; AdBlockNetworkReply *reply = new AdBlockNetworkReply(request, urlString, this); return reply; } @@ -164,8 +198,88 @@ void AdBlockManager::applyHidingRules(WebPage *page) foreach (QWebElement element, elements) { + kDebug() << "Hide element: " << element.localName(); element.setStyleProperty(QLatin1String("visibility"), QLatin1String("hidden")); element.removeFromDocument(); } } } + + +void AdBlockManager::updateNextSubscription() +{ + kDebug() << "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"; + + QStringList subUrlStrings = ReKonfig::subscriptionUrls(); + + if( _index < subUrlStrings.size() ) + { + QString urlString = subUrlStrings.at(_index); + kDebug() << "DOWNLOADING FROM " << urlString; + KUrl subUrl = KUrl( urlString ); + + KIO::TransferJob* job = KIO::get( subUrl , KIO::Reload , KIO::HideProgressInfo ); + connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)), this, SLOT(subscriptionData(KIO::Job*, const QByteArray&))); + connect(job, SIGNAL(result(KJob*)), this, SLOT(slotResult(KJob*))); + + return; + } + + _index = 0; + _buffer.clear(); +} + + +void AdBlockManager::slotResult(KJob *job) +{ + kDebug() << "SLOTRESULT"; + if(job->error()) + return; + + QList list = _buffer.split('\n'); + QStringList ruleList; + foreach(const QByteArray &ba, list) + { + kDebug() << ba; + ruleList << QString(ba); + } + loadRules(ruleList); + saveRules(ruleList); + + _index++; + + // last.. + updateNextSubscription(); +} + + +void AdBlockManager::subscriptionData(KIO::Job* job, const QByteArray& data) +{ + kDebug() << "subscriptionData"; + Q_UNUSED(job) + + if (data.isEmpty()) + return; + + int oldSize = _buffer.size(); + _buffer.resize( _buffer.size() + data.size() ); + memcpy( _buffer.data() + oldSize, data.data(), data.size() ); +} + + +void AdBlockManager::saveRules(const QStringList &rules) +{ + QStringList cleanedRules; + foreach(const QString &r, rules) + { + if( !r.startsWith('!') && !r.startsWith('[') && !r.isEmpty() ) + cleanedRules << r; + } + + QStringList names = ReKonfig::subscriptionNames(); + QString name = names.at(_index) + "-rules"; + + KSharedConfig::Ptr config = KGlobal::config(); + KConfigGroup cg( config , "rules" ); + cg.writeEntry( name, cleanedRules ); +} diff --git a/src/adblock/adblockmanager.h b/src/adblock/adblockmanager.h index d1bbe7ba..aac78e3b 100644 --- a/src/adblock/adblockmanager.h +++ b/src/adblock/adblockmanager.h @@ -112,6 +112,8 @@ #include #include #include +#include +#include // Forward Includes class QNetworkRequest; @@ -129,9 +131,20 @@ public: AdBlockManager(QObject *parent = 0); ~AdBlockManager(); - void loadSettings(); QNetworkReply *block(const QNetworkRequest &request); void applyHidingRules(WebPage *page); + +public slots: + void loadSettings(); + +private: + void updateNextSubscription(); + void saveRules(const QStringList &); + void loadRules(const QStringList &); + +private slots: + void slotResult(KJob *); + void subscriptionData(KIO::Job*, const QByteArray&); private: bool _isAdblockEnabled; @@ -140,6 +153,9 @@ private: AdBlockRuleList _blackList; AdBlockRuleList _whiteList; QStringList _hideList; + + int _index; + QByteArray _buffer; }; #endif diff --git a/src/adblock/adblockrule.cpp b/src/adblock/adblockrule.cpp index 25ca3678..c0c3fd5b 100644 --- a/src/adblock/adblockrule.cpp +++ b/src/adblock/adblockrule.cpp @@ -181,3 +181,9 @@ QString AdBlockRule::convertPatternToRegExp(const QString &wildcardPattern) // Finally, return... return pattern; } + + +QString AdBlockRule::pattern() const +{ + return m_regExp.pattern(); +} diff --git a/src/adblock/adblockrule.h b/src/adblock/adblockrule.h index 8f79d16e..ee4825d1 100644 --- a/src/adblock/adblockrule.h +++ b/src/adblock/adblockrule.h @@ -69,7 +69,9 @@ public: AdBlockRule(const QString &filter); bool match(const QString &encodedUrl) const; - + + QString pattern() const; + private: QString convertPatternToRegExp(const QString &wildcardPattern); diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index bbf20ac1..42ace3d3 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -7,6 +7,7 @@ QtWebKit +QDateTime KUrl @@ -151,4 +152,27 @@ + + + + + true + + + true + + + easylist + + + https://easylist-downloads.adblockplus.org/easylist.txt + + + QDateTime(QDate(2009,03,13)) + + + 7 + + + diff --git a/src/settings/adblockwidget.cpp b/src/settings/adblockwidget.cpp new file mode 100644 index 00000000..45e5fd5c --- /dev/null +++ b/src/settings/adblockwidget.cpp @@ -0,0 +1,158 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +#include "adblockwidget.h" +#include "adblockwidget.moc" + +#include "rekonq.h" + +#include +#include +#include + +#include +#include +#include + + +AdBlockWidget::AdBlockWidget(QWidget *parent) + : QWidget(parent) +{ + setupUi(this); + + hintLabel->setText( i18n("Filter expression (e.g. http://www.example.com/ad/*, more information):") ); + connect( hintLabel, SIGNAL(linkActivated(const QString &)), this, SLOT(slotInfoLinkActivated(const QString &)) ); + + listWidget->setSortingEnabled(true); + listWidget->setSelectionMode(QAbstractItemView::SingleSelection); + + searchLine->setListWidget(listWidget); + + insertButton->setIcon( KIcon("list-add") ); + connect( insertButton, SIGNAL( clicked() ), this, SLOT( insertRule() ) ); + + removeButton->setIcon( KIcon("list-remove") ); + connect( removeButton, SIGNAL( clicked() ), this, SLOT( removeRule() ) ); + + load(); +} + + +void AdBlockWidget::slotInfoLinkActivated(const QString &url) +{ + Q_UNUSED(url) + + QString hintHelpString = i18n("

Enter an expression to filter. Filters can be defined as either:" + "

  • a shell-style wildcard, e.g. http://www.example.com/ads*, the wildcards *?[] may be used
  • " + "
  • a full regular expression by surrounding the string with '/', e.g. /\\/(ad|banner)\\./
" + "

Any filter string can be preceded by '@@' to whitelist (allow) any matching URL, " + "which takes priority over any blacklist (blocking) filter."); + + QWhatsThis::showText( QCursor::pos(), hintHelpString ); +} + + +void AdBlockWidget::insertRule() +{ + QString rule = addFilterLineEdit->text(); + if(rule.isEmpty()) + return; + + listWidget->addItem( rule ); + addFilterLineEdit->clear(); +} + + +void AdBlockWidget::removeRule() +{ + listWidget->takeItem( listWidget->currentRow() ); +} + + +void AdBlockWidget::load() +{ + bool isAdBlockEnabled = ReKonfig::adBlockEnabled(); + checkEnableAdblock->setChecked(isAdBlockEnabled); + + bool areImageFiltered = ReKonfig::hideAdsEnabled(); + checkHideImages->setChecked(areImageFiltered); + + QStringList subscriptions = ReKonfig::subscriptionNames(); + + // load automatic rules + foreach(QString sub, subscriptions) + { + QTreeWidgetItem *subItem = new QTreeWidgetItem(treeWidget); + subItem->setText(0, sub); + loadRules(subItem); + } + + // load local rules + KSharedConfig::Ptr config = KGlobal::config(); + KConfigGroup localGroup( config, "rules" ); + QStringList rules = localGroup.readEntry( "local-rules" , QStringList() ); + foreach(const QString &rule, rules) + { + listWidget->addItem( rule ); + } +} + + +void AdBlockWidget::loadRules(QTreeWidgetItem *item) +{ + KSharedConfig::Ptr config = KGlobal::config(); + KConfigGroup localGroup( config, "rules" ); + + QString str = item->text(0) + "-rules"; + kDebug() << str; + QStringList rules = localGroup.readEntry( str , QStringList() ); + + foreach(const QString &rule, rules) + { + QTreeWidgetItem *subItem = new QTreeWidgetItem(item); + subItem->setText(0, rule); + } +} + + +void AdBlockWidget::save() +{ + int n; + + // local rules + KSharedConfig::Ptr config = KGlobal::config(); + KConfigGroup localGroup( config , "rules" ); + + QStringList localRules; + + n = listWidget->count(); + for(int i = 0; i < n; ++i) + { + QListWidgetItem *item = listWidget->takeItem(i); + localRules << item->text(); + } + localGroup.writeEntry( "local-rules" , localRules ); +} diff --git a/src/settings/adblockwidget.h b/src/settings/adblockwidget.h new file mode 100644 index 00000000..67061800 --- /dev/null +++ b/src/settings/adblockwidget.h @@ -0,0 +1,56 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +#ifndef ADBLOCK_WIDGET_H +#define ADBLOCK_WIDGET_H + + +#include "ui_settings_adblock.h" + +#include +#include + + +class AdBlockWidget : public QWidget, private Ui::adblock +{ +Q_OBJECT + +public: + AdBlockWidget(QWidget *parent = 0); + + void save(); + +private slots: + void slotInfoLinkActivated(const QString &); + void insertRule(); + void removeRule(); + +private: + void load(); + void loadRules(QTreeWidgetItem *item); +}; + +#endif // ADBLOCK_WIDGET_H diff --git a/src/settings/settings_adblock.ui b/src/settings/settings_adblock.ui new file mode 100644 index 00000000..28e1f973 --- /dev/null +++ b/src/settings/settings_adblock.ui @@ -0,0 +1,167 @@ + + + adblock + + + + 0 + 0 + 601 + 507 + + + + Form + + + + + + &Enable AdBlock + + + + + + + &Hide filtered Elements + + + + + + + + + + 0 + + + + Automatic Filters + + + + + + + 1 + + + + + + + + + + Automatic update interval: + + + + + + + 7 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Manual Filters + + + + + + + + Search: + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + ... + + + + + + + ... + + + + + + + + + + + + + + KListWidget + QListWidget +

klistwidget.h
+ + + KLineEdit + QLineEdit +
klineedit.h
+
+ + KTabWidget + QTabWidget +
ktabwidget.h
+ 1 +
+ + KListWidgetSearchLine + KLineEdit +
klistwidgetsearchline.h
+
+ + + + diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index e7a9d1e8..fa1e8891 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -36,12 +36,14 @@ #include "application.h" #include "mainwindow.h" #include "webtab.h" +#include "adblockwidget.h" //Ui Includes #include "ui_settings_general.h" #include "ui_settings_tabs.h" #include "ui_settings_fonts.h" #include "ui_settings_webkit.h" +#include "ui_settings_adblock.h" // KDE Includes #include @@ -63,12 +65,14 @@ private: Ui::tabs tabsUi; Ui::fonts fontsUi; Ui::webkit webkitUi; + + AdBlockWidget *adBlockWidg; KCModuleProxy *proxyModule; KCModuleProxy *ebrowsingModule; KCModuleProxy *cookiesModule; KCModuleProxy *cacheModule; - KCModuleProxy *adblockModule; + KShortcutsEditor *shortcutsEditor; Private(SettingsDialog *parent); @@ -123,10 +127,10 @@ Private::Private(SettingsDialog *parent) KIcon webkitIcon = KIcon(QIcon(webkitIconPath)); pageItem->setIcon(webkitIcon); - KCModuleInfo adblockInfo("khtml_filter.desktop"); - adblockModule = new KCModuleProxy(adblockInfo,parent); - pageItem = parent->addPage(adblockModule, i18n(adblockInfo.moduleName().toLocal8Bit())); - pageItem->setIcon(KIcon(adblockInfo.icon())); + adBlockWidg = new AdBlockWidget(parent); + adBlockWidg->layout()->setMargin(0); + pageItem = parent->addPage(adBlockWidg , i18n("Ad Block")); + pageItem->setIcon( KIcon("preferences-web-browser-adblock") ); shortcutsEditor = new KShortcutsEditor(Application::instance()->mainWindow()->actionCollection(), parent); pageItem = parent->addPage(shortcutsEditor , i18n("Shortcuts")); @@ -137,7 +141,7 @@ Private::Private(SettingsDialog *parent) pageItem = parent->addPage(ebrowsingModule, i18n(ebrowsingInfo.moduleName().toLocal8Bit())); pageItem->setIcon(KIcon(ebrowsingInfo.icon())); - // WARNING remember wheh changing here that the smaller netbooks + // WARNING remember wheh changing here that the smallest netbooks // have a 1024x576 resolution. So DON'T bother that limits!! parent->setMinimumSize(700,525); } @@ -162,8 +166,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) connect(d->cookiesModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); connect(d->proxyModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); connect(d->cacheModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); - connect(d->adblockModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); - + connect(d->shortcutsEditor, SIGNAL(keyChange()), this, SLOT(updateButtons())); connect(this, SIGNAL(applyClicked()), this, SLOT(saveSettings())); @@ -213,7 +216,7 @@ void SettingsDialog::saveSettings() d->proxyModule->save(); d->cacheModule->save(); d->shortcutsEditor->save(); - d->adblockModule->save(); + d->adBlockWidg->save(); } @@ -224,7 +227,6 @@ bool SettingsDialog::hasChanged() || d->cookiesModule->changed() || d->proxyModule->changed() || d->cacheModule->changed() - || d->adblockModule->changed() || d->shortcutsEditor->isModified(); ; } diff --git a/src/webpage.cpp b/src/webpage.cpp index f1591cee..4caf5a83 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -352,15 +352,15 @@ void WebPage::downloadAllContentsWithKGet() QWebElementCollection images = mainFrame()->documentElement().findAll("img"); foreach(QWebElement img, images) { - relativeUrl.setEncodedUrl(img.attribute("src").toUtf8(),KUrl::TolerantMode); - contents << baseUrl.resolved(relativeUrl).toString(); + relativeUrl.setEncodedUrl(img.attribute("src").toUtf8(),KUrl::TolerantMode); + contents << baseUrl.resolved(relativeUrl).toString(); } QWebElementCollection links = mainFrame()->documentElement().findAll("a"); foreach(QWebElement link, links) { - relativeUrl.setEncodedUrl(link.attribute("href").toUtf8(),KUrl::TolerantMode); - contents << baseUrl.resolved(relativeUrl).toString(); + relativeUrl.setEncodedUrl(link.attribute("href").toUtf8(),KUrl::TolerantMode); + contents << baseUrl.resolved(relativeUrl).toString(); } if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget")) -- cgit v1.2.1 From 29e095b81d241a77f43bf4bf293d9428b6caea26 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Fri, 5 Mar 2010 23:10:20 +0100 Subject: Add middle click support for next, back and home in the main toolbar --- src/mainwindow.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++------ src/mainwindow.h | 3 +++ 2 files changed, 45 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 60784af0..a2768bb6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -286,7 +286,8 @@ void MainWindow::setupActions() fullScreenShortcut.setAlternate( Qt::Key_F11 ); a->setShortcut( fullScreenShortcut ); - KStandardAction::home(this, SLOT(homePage()), actionCollection()); + a = actionCollection()->addAction( KStandardAction::Home ); + connect(a, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(homePage(Qt::MouseButtons))); KStandardAction::preferences(this, SLOT(preferences()), actionCollection()); a = KStandardAction::redisplay(m_view, SLOT(webReload()), actionCollection()); @@ -345,14 +346,16 @@ void MainWindow::setupActions() connect(a, SIGNAL(triggered(bool)), this, SLOT(clearPrivateData())); // ========================= History related actions ============================== - a = KStandardAction::back(this, SLOT(openPrevious()) , actionCollection()); + a = actionCollection()->addAction( KStandardAction::Back ); + connect(a, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(openPrevious(Qt::MouseButtons))); m_historyBackMenu = new KMenu(this); a->setMenu(m_historyBackMenu); connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction *))); - KStandardAction::forward(this, SLOT(openNext()) , actionCollection()); + a = actionCollection()->addAction( KStandardAction::Forward ); + connect(a, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(openNext(Qt::MouseButtons))); // ============================== General Tab Actions ==================================== a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); @@ -929,9 +932,18 @@ void MainWindow::viewPageSource() } +void MainWindow::homePage(Qt::MouseButtons btn) +{ + if(btn == Qt::MidButton) + Application::instance()->loadUrl( KUrl(ReKonfig::homePage()), Rekonq::SettingOpenTab ); + else + currentTab()->view()->load( QUrl(ReKonfig::homePage()) ); +} + + void MainWindow::homePage() { - currentTab()->view()->load( QUrl(ReKonfig::homePage()) ); + homePage(Qt::LeftButton); } @@ -973,18 +985,42 @@ void MainWindow::browserLoading(bool v) void MainWindow::openPrevious() +{ + openPrevious(Qt::LeftButton); +} + + +void MainWindow::openPrevious(Qt::MouseButtons btn) { QWebHistory *history = currentTab()->view()->history(); if (history->canGoBack()) - history->goToItem(history->backItem()); + { + KUrl back = history->backItem().url(); + if(btn == Qt::MidButton) + Application::instance()->loadUrl(back, Rekonq::SettingOpenTab); + else + Application::instance()->loadUrl(back); + } } void MainWindow::openNext() +{ + openNext(Qt::LeftButton); +} + + +void MainWindow::openNext(Qt::MouseButtons btn) { QWebHistory *history = currentTab()->view()->history(); if (history->canGoForward()) - history->goToItem(history->forwardItem()); + { + KUrl next = history->forwardItem().url(); + if(btn == Qt::MidButton) + Application::instance()->loadUrl(next, Rekonq::SettingOpenTab); + else + Application::instance()->loadUrl(next); + } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 57b88dfd..9e491c69 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -88,6 +88,7 @@ private: public slots: void homePage(); + void homePage(Qt::MouseButtons); /** * Notifies a message in a popup @@ -123,7 +124,9 @@ private slots: // history related void openPrevious(); + void openPrevious(Qt::MouseButtons); void openNext(); + void openNext(Qt::MouseButtons); // Find Action slots void find(const QString &); -- cgit v1.2.1 From cf5d70ff31a166cb13f5c042f019e6193f97526d Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sun, 14 Mar 2010 00:06:27 +0100 Subject: Use default value instead of a different function --- src/mainwindow.cpp | 18 ------------------ src/mainwindow.h | 9 +++------ 2 files changed, 3 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a2768bb6..4b48157b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -941,12 +941,6 @@ void MainWindow::homePage(Qt::MouseButtons btn) } -void MainWindow::homePage() -{ - homePage(Qt::LeftButton); -} - - MainView *MainWindow::mainView() const { return m_view; @@ -984,12 +978,6 @@ void MainWindow::browserLoading(bool v) } -void MainWindow::openPrevious() -{ - openPrevious(Qt::LeftButton); -} - - void MainWindow::openPrevious(Qt::MouseButtons btn) { QWebHistory *history = currentTab()->view()->history(); @@ -1004,12 +992,6 @@ void MainWindow::openPrevious(Qt::MouseButtons btn) } -void MainWindow::openNext() -{ - openNext(Qt::LeftButton); -} - - void MainWindow::openNext(Qt::MouseButtons btn) { QWebHistory *history = currentTab()->view()->history(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 9e491c69..b693fec1 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -87,8 +87,7 @@ private: void setupPanels(); public slots: - void homePage(); - void homePage(Qt::MouseButtons); + void homePage(Qt::MouseButtons = Qt::LeftButton); /** * Notifies a message in a popup @@ -123,10 +122,8 @@ private slots: void updateWindowTitle(const QString &title = QString()); // history related - void openPrevious(); - void openPrevious(Qt::MouseButtons); - void openNext(); - void openNext(Qt::MouseButtons); + void openPrevious(Qt::MouseButtons = Qt::LeftButton); + void openNext(Qt::MouseButtons = Qt::LeftButton); // Find Action slots void find(const QString &); -- cgit v1.2.1 From 8217910b1bee1aeb826257be86f9e1010b6f9443 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 14 Mar 2010 00:18:00 +0100 Subject: Changed createRequest method for KIO debugging purposes.. --- src/networkaccessmanager.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index e6dd6d85..77597cef 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -42,12 +42,41 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData) { - // Adblock - if (op == QNetworkAccessManager::GetOperation) + QNetworkReply *reply = 0; + + switch(op) { - QNetworkReply *reply = Application::adblockManager()->block(req); + case QNetworkAccessManager::HeadOperation: + kDebug() << "HEAD OPERATION"; + if(outgoingData) + { + QByteArray outgoingDataByteArray = outgoingData->peek(1024 * 1024); + kDebug() << outgoingDataByteArray; + } + break; + + case QNetworkAccessManager::GetOperation: + kDebug() << "GET OPERATION"; + reply = Application::adblockManager()->block(req); if (reply) return reply; + break; + + case QNetworkAccessManager::PutOperation: + kDebug() << "PUT OPERATION"; + break; + + case QNetworkAccessManager::PostOperation: + kDebug() << "POST OPERATION"; + break; + + case QNetworkAccessManager::DeleteOperation: + kDebug() << "DELETE OPERATION"; + break; + + default: + kDebug() << "UNKNOWN OPERATION"; + break; } return AccessManager::createRequest(op,req,outgoingData); -- cgit v1.2.1 From 26eb96169454a41d0c3306b6329e8751882a2d1e Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sun, 14 Mar 2010 12:47:08 +0100 Subject: Implement the highlight all feature for the find bar (enabled by default) --- src/findbar.cpp | 26 ++++++++++++++++++++------ src/findbar.h | 4 +++- src/mainwindow.cpp | 20 ++++++++++++++++++++ src/mainwindow.h | 1 + 4 files changed, 44 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/findbar.cpp b/src/findbar.cpp index 4c780aca..94def263 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -52,9 +52,13 @@ FindBar::FindBar(QWidget *parent) : QWidget(parent) , m_lineEdit(new KLineEdit(this)) - , m_matchCase(new QCheckBox(i18n("&Match case"), this)) , m_hideTimer(new QTimer(this)) -{ + , m_matchCase(new QCheckBox(i18n("&Match case"), this)) + , m_highlightAll(new QCheckBox(i18n("&Highlight All"), this)) +{ + // mainwindow pointer + MainWindow *window = qobject_cast(parent); + QHBoxLayout *layout = new QHBoxLayout; // cosmetic @@ -65,6 +69,7 @@ FindBar::FindBar(QWidget *parent) hideButton->setAutoRaise(true); hideButton->setIcon(KIcon("dialog-close")); connect(hideButton, SIGNAL(clicked()), this, SLOT(hide())); + connect(hideButton, SIGNAL(clicked()), window, SLOT(highlightAll())); layout->addWidget(hideButton); layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop); @@ -75,9 +80,6 @@ FindBar::FindBar(QWidget *parent) QLabel *label = new QLabel(i18n("Find:")); layout->addWidget(label); - // mainwindow pointer - MainWindow *window = qobject_cast(parent); - // lineEdit, focusProxy setFocusProxy(m_lineEdit); m_lineEdit->setMaximumWidth(250); @@ -92,13 +94,19 @@ FindBar::FindBar(QWidget *parent) connect(findPrev, SIGNAL(clicked()), window, SLOT(findPrevious())); layout->addWidget(findNext); layout->addWidget(findPrev); - + // Case sensitivity. Deliberately set so this is off by default. m_matchCase->setCheckState(Qt::Unchecked); m_matchCase->setTristate(false); connect(m_matchCase, SIGNAL(toggled(bool)), window, SLOT(matchCaseUpdate())); layout->addWidget(m_matchCase); + // Hightlight All. On by default + m_highlightAll->setCheckState(Qt::Checked); + m_highlightAll->setTristate(false); + connect(m_highlightAll, SIGNAL(toggled(bool)), window, SLOT(highlightAll())); + layout->addWidget(m_highlightAll); + // stretching widget on the left layout->addStretch(); @@ -126,6 +134,12 @@ bool FindBar::matchCase() const } +bool FindBar::highlightAllState() const +{ + return m_highlightAll->isChecked(); +} + + void FindBar::show() { // show findbar if not visible diff --git a/src/findbar.h b/src/findbar.h index 7a4efc59..78615f9a 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -53,6 +53,7 @@ public: KLineEdit *lineEdit() const; bool matchCase() const; void notifyMatch(bool match); + bool highlightAllState() const; public slots: void show(); @@ -63,8 +64,9 @@ signals: private: KLineEdit *m_lineEdit; - QCheckBox *m_matchCase; QTimer *m_hideTimer; + QCheckBox *m_matchCase; + QCheckBox *m_highlightAll; }; #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 60784af0..e90a5903 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -794,6 +794,8 @@ void MainWindow::findNext() return; } + highlightAll(); + QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; @@ -823,6 +825,24 @@ void MainWindow::findPrevious() m_findBar->notifyMatch(found); } +void MainWindow::highlightAll() +{ + if (!currentTab()) + return; + + QWebPage::FindFlags options = QWebPage::HighlightAllOccurrences; + + currentTab()->view()->findText("", options); //Clear an existing highlight + + if(m_findBar->highlightAllState() && !m_findBar->isHidden()) + { + if (m_findBar->matchCase()) + options |= QWebPage::FindCaseSensitively; + + currentTab()->view()->findText(m_lastSearch, options); + } +} + void MainWindow::zoomIn() { diff --git a/src/mainwindow.h b/src/mainwindow.h index 57b88dfd..e9da090d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -130,6 +130,7 @@ private slots: void matchCaseUpdate(); void findNext(); void findPrevious(); + void highlightAll(); // Zoom slots void zoomIn(); -- cgit v1.2.1 From e1877d4f49ef414182f37448e1338822e5c77517 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sun, 14 Mar 2010 15:46:55 +0100 Subject: Fix capitalisation of "Highlight All" --- src/findbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/findbar.cpp b/src/findbar.cpp index 94def263..7cbe9d17 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -54,7 +54,7 @@ FindBar::FindBar(QWidget *parent) , m_lineEdit(new KLineEdit(this)) , m_hideTimer(new QTimer(this)) , m_matchCase(new QCheckBox(i18n("&Match case"), this)) - , m_highlightAll(new QCheckBox(i18n("&Highlight All"), this)) + , m_highlightAll(new QCheckBox(i18n("&Highlight all"), this)) { // mainwindow pointer MainWindow *window = qobject_cast(parent); -- cgit v1.2.1 From 65f0f138d29e1f34626d8a25683bfe0a059fb8dc Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sun, 14 Mar 2010 23:34:45 +0100 Subject: Clear all the highlight when the find bar is closed with the esc key --- src/findbar.cpp | 1 - src/mainwindow.cpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/findbar.cpp b/src/findbar.cpp index 7cbe9d17..c97fd1f9 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -69,7 +69,6 @@ FindBar::FindBar(QWidget *parent) hideButton->setAutoRaise(true); hideButton->setIcon(KIcon("dialog-close")); connect(hideButton, SIGNAL(clicked()), this, SLOT(hide())); - connect(hideButton, SIGNAL(clicked()), window, SLOT(highlightAll())); layout->addWidget(hideButton); layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e90a5903..b5df7acb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -786,6 +786,8 @@ void MainWindow::findNext() if (!currentTab()) return; + highlightAll(); + if(m_findBar->isHidden()) { QPoint previous_position = currentTab()->view()->page()->currentFrame()->scrollPosition(); @@ -794,8 +796,6 @@ void MainWindow::findNext() return; } - highlightAll(); - QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; -- cgit v1.2.1 From cc58fe53816a3033e0a71c6db9826eaf2de69934 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Mon, 15 Mar 2010 00:03:10 +0100 Subject: Close the tab preview when the tab is clicked --- src/tabbar.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 80782116..44972548 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -244,6 +244,15 @@ void TabBar::leaveEvent(QEvent *event) void TabBar::mousePressEvent(QMouseEvent *event) { + if (ReKonfig::alwaysShowTabPreviews()) + { + if ( !m_previewPopup.isNull() ) + { + m_previewPopup.data()->hide(); + } + m_currentTabPreview = -1; + } + // just close tab on middle mouse click if (event->button() == Qt::MidButton) return; -- cgit v1.2.1 From ae8aceced59f5d8721e986e7fc1c66c9026e87df Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 15 Mar 2010 00:38:50 +0100 Subject: Created a new Network Widget containing Cache, Cookies & Proxy Settings. This for multiple purposes: - clean a bit our settings dialog. Network settings are usually the less used - Provide a unique place where managing the settings network related. This to implement (one day) some better Ui to manage them. This commit also fixes all the handling with the network & the adblock widgets related to updating buttons and settings Ui at the beginning. --- src/CMakeLists.txt | 1 + src/settings/adblockwidget.cpp | 36 ++++++++++++++- src/settings/adblockwidget.h | 10 ++++ src/settings/networkwidget.cpp | 98 ++++++++++++++++++++++++++++++++++++++++ src/settings/networkwidget.h | 63 ++++++++++++++++++++++++++ src/settings/settings_adblock.ui | 2 +- src/settings/settingsdialog.cpp | 52 ++++++++------------- 7 files changed, 226 insertions(+), 36 deletions(-) create mode 100644 src/settings/networkwidget.cpp create mode 100644 src/settings/networkwidget.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f05bbbdb..7d0c1639 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,6 +35,7 @@ SET( rekonq_KDEINIT_SRCS #---------------------------------------- settings/settingsdialog.cpp settings/adblockwidget.cpp + settings/networkwidget.cpp #---------------------------------------- bookmarks/bookmarksmanager.cpp bookmarks/bookmarkspanel.cpp diff --git a/src/settings/adblockwidget.cpp b/src/settings/adblockwidget.cpp index 45e5fd5c..8aac3e8c 100644 --- a/src/settings/adblockwidget.cpp +++ b/src/settings/adblockwidget.cpp @@ -24,15 +24,19 @@ * ============================================================ */ +// Self Includes #include "adblockwidget.h" #include "adblockwidget.moc" +// Auto Includes #include "rekonq.h" +// KDE Includes #include #include #include +// Qt Includes #include #include #include @@ -40,6 +44,7 @@ AdBlockWidget::AdBlockWidget(QWidget *parent) : QWidget(parent) + , _changed(false) { setupUi(this); @@ -53,11 +58,18 @@ AdBlockWidget::AdBlockWidget(QWidget *parent) insertButton->setIcon( KIcon("list-add") ); connect( insertButton, SIGNAL( clicked() ), this, SLOT( insertRule() ) ); - + removeButton->setIcon( KIcon("list-remove") ); connect( removeButton, SIGNAL( clicked() ), this, SLOT( removeRule() ) ); load(); + + // emit changed signal + connect( insertButton, SIGNAL( clicked() ), this, SLOT( hasChanged() ) ); + connect( removeButton, SIGNAL( clicked() ), this, SLOT( hasChanged() ) ); + connect( checkEnableAdblock, SIGNAL( stateChanged(int) ), this, SLOT( hasChanged() ) ); + connect( checkHideAds, SIGNAL( stateChanged(int) ), this, SLOT( hasChanged() ) ); + connect( spinBox, SIGNAL( valueChanged(int) ), this, SLOT( hasChanged() ) ); } @@ -98,7 +110,10 @@ void AdBlockWidget::load() checkEnableAdblock->setChecked(isAdBlockEnabled); bool areImageFiltered = ReKonfig::hideAdsEnabled(); - checkHideImages->setChecked(areImageFiltered); + checkHideAds->setChecked(areImageFiltered); + + int days = ReKonfig::updateInterval(); + spinBox->setValue( days ); QStringList subscriptions = ReKonfig::subscriptionNames(); @@ -155,4 +170,21 @@ void AdBlockWidget::save() localRules << item->text(); } localGroup.writeEntry( "local-rules" , localRules ); + + ReKonfig::setAdBlockEnabled( checkEnableAdblock->isChecked() ); + ReKonfig::setHideAdsEnabled( checkHideAds->isChecked() ); + ReKonfig::setUpdateInterval( spinBox->value() ); +} + + +void AdBlockWidget::hasChanged() +{ + _changed = true; + emit changed(true); +} + + +bool AdBlockWidget::changed() +{ + return _changed; } diff --git a/src/settings/adblockwidget.h b/src/settings/adblockwidget.h index 67061800..7e641f3e 100644 --- a/src/settings/adblockwidget.h +++ b/src/settings/adblockwidget.h @@ -28,8 +28,10 @@ #define ADBLOCK_WIDGET_H +// Ui Includes #include "ui_settings_adblock.h" +// Qt Includes #include #include @@ -42,8 +44,14 @@ public: AdBlockWidget(QWidget *parent = 0); void save(); + bool changed(); + +signals: + void changed(bool); private slots: + void hasChanged(); + void slotInfoLinkActivated(const QString &); void insertRule(); void removeRule(); @@ -51,6 +59,8 @@ private slots: private: void load(); void loadRules(QTreeWidgetItem *item); + + bool _changed; }; #endif // ADBLOCK_WIDGET_H diff --git a/src/settings/networkwidget.cpp b/src/settings/networkwidget.cpp new file mode 100644 index 00000000..2f5948cf --- /dev/null +++ b/src/settings/networkwidget.cpp @@ -0,0 +1,98 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +// Self Includes +#include "networkwidget.h" +#include "networkwidget.moc" + +// KDE Includes +#include +#include +#include + +// Qt Includes +#include + + +NetworkWidget::NetworkWidget(QWidget *parent) + : QWidget(parent) + , _cacheModule(0) + , _cookiesModule(0) + , _proxyModule(0) + , _changed(false) +{ + QVBoxLayout *l = new QVBoxLayout(this); + l->setMargin(0); + l->setSpacing(0); + + KTabWidget *tabWidget = new KTabWidget(this); + l->addWidget(tabWidget); + + KCModuleInfo cacheInfo("cache.desktop"); + _cacheModule = new KCModuleProxy(cacheInfo,parent); + tabWidget->addTab( _cacheModule, i18n(cacheInfo.moduleName().toLocal8Bit()) ); + + KCModuleInfo cookiesInfo("cookies.desktop"); + _cookiesModule = new KCModuleProxy(cookiesInfo,parent); + tabWidget->addTab( _cookiesModule, i18n(cookiesInfo.moduleName().toLocal8Bit()) ); + + KCModuleInfo proxyInfo("proxy.desktop"); + _proxyModule = new KCModuleProxy(proxyInfo,parent); + tabWidget->addTab( _proxyModule, i18n(proxyInfo.moduleName().toLocal8Bit()) ); + + connect(_cacheModule, SIGNAL( changed(bool) ), this, SLOT( hasChanged() ) ); + connect(_cookiesModule, SIGNAL( changed(bool) ), this, SLOT( hasChanged() ) ); + connect(_proxyModule, SIGNAL( changed(bool) ), this, SLOT( hasChanged() ) ); +} + + +NetworkWidget::~NetworkWidget() +{ + delete _cacheModule; + delete _cookiesModule; + delete _proxyModule; +} + + +void NetworkWidget::save() +{ + _cookiesModule->save(); + _proxyModule->save(); + _cacheModule->save(); +} + + +void NetworkWidget::hasChanged() +{ + _changed = true; + emit changed(true); +} + + +bool NetworkWidget::changed() +{ + return _changed; +} diff --git a/src/settings/networkwidget.h b/src/settings/networkwidget.h new file mode 100644 index 00000000..efdd1807 --- /dev/null +++ b/src/settings/networkwidget.h @@ -0,0 +1,63 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +#ifndef NETWORK_WIDGET_H +#define NETWORK_WIDGET_H + + +// KDE Includes +#include + +// Qt Includes +#include + + +class NetworkWidget : public QWidget +{ +Q_OBJECT + +public: + NetworkWidget(QWidget *parent = 0); + ~NetworkWidget(); + + void save(); + bool changed(); + +signals: + void changed(bool); + +private slots: + void hasChanged(); + +private: + KCModuleProxy *_cacheModule; + KCModuleProxy *_cookiesModule; + KCModuleProxy *_proxyModule; + + bool _changed; +}; + +#endif // NETWORK_WIDGET_H diff --git a/src/settings/settings_adblock.ui b/src/settings/settings_adblock.ui index 28e1f973..445431c5 100644 --- a/src/settings/settings_adblock.ui +++ b/src/settings/settings_adblock.ui @@ -22,7 +22,7 @@ - + &Hide filtered Elements diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index fa1e8891..08d5ca6e 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -37,13 +37,13 @@ #include "mainwindow.h" #include "webtab.h" #include "adblockwidget.h" +#include "networkwidget.h" //Ui Includes #include "ui_settings_general.h" #include "ui_settings_tabs.h" #include "ui_settings_fonts.h" #include "ui_settings_webkit.h" -#include "ui_settings_adblock.h" // KDE Includes #include @@ -67,11 +67,9 @@ private: Ui::webkit webkitUi; AdBlockWidget *adBlockWidg; + NetworkWidget *networkWidg; - KCModuleProxy *proxyModule; KCModuleProxy *ebrowsingModule; - KCModuleProxy *cookiesModule; - KCModuleProxy *cacheModule; KShortcutsEditor *shortcutsEditor; @@ -103,21 +101,6 @@ Private::Private(SettingsDialog *parent) widget->layout()->setMargin(0); pageItem = parent->addPage(widget , i18n("Fonts")); pageItem->setIcon(KIcon("preferences-desktop-font")); - - KCModuleInfo cookiesInfo("cookies.desktop"); - cookiesModule = new KCModuleProxy(cookiesInfo,parent); - pageItem = parent->addPage(cookiesModule, i18n(cookiesInfo.moduleName().toLocal8Bit())); - pageItem->setIcon(KIcon(cookiesInfo.icon())); - - KCModuleInfo proxyInfo("proxy.desktop"); - proxyModule = new KCModuleProxy(proxyInfo,parent); - pageItem = parent->addPage(proxyModule, i18n(proxyInfo.moduleName().toLocal8Bit())); - pageItem->setIcon(KIcon(proxyInfo.icon())); - - KCModuleInfo cacheInfo("cache.desktop"); - cacheModule = new KCModuleProxy(cacheInfo,parent); - pageItem = parent->addPage(cacheModule, i18n(cacheInfo.moduleName().toLocal8Bit())); - pageItem->setIcon(KIcon(cacheInfo.icon())); widget = new QWidget; webkitUi.setupUi(widget); @@ -127,6 +110,11 @@ Private::Private(SettingsDialog *parent) KIcon webkitIcon = KIcon(QIcon(webkitIconPath)); pageItem->setIcon(webkitIcon); + networkWidg = new NetworkWidget(parent); + networkWidg->layout()->setMargin(0); + pageItem = parent->addPage(networkWidg , i18n("Network")); + pageItem->setIcon( KIcon("preferences-system-network") ); + adBlockWidg = new AdBlockWidget(parent); adBlockWidg->layout()->setMargin(0); pageItem = parent->addPage(adBlockWidg , i18n("Ad Block")); @@ -162,15 +150,16 @@ SettingsDialog::SettingsDialog(QWidget *parent) connect(d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage())); + // update buttons + connect(d->adBlockWidg, SIGNAL(changed(bool)), this, SLOT(updateButtons())); + connect(d->networkWidg, SIGNAL(changed(bool)), this, SLOT(updateButtons())); connect(d->ebrowsingModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); - connect(d->cookiesModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); - connect(d->proxyModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); - connect(d->cacheModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); - - connect(d->shortcutsEditor, SIGNAL(keyChange()), this, SLOT(updateButtons())); - + + connect(d->shortcutsEditor, SIGNAL(keyChange()), this, SLOT(updateButtons())); + + // save settings connect(this, SIGNAL(applyClicked()), this, SLOT(saveSettings())); - connect(this, SIGNAL(okClicked()), this, SLOT(saveSettings())); + connect(this, SIGNAL(okClicked()), this, SLOT(saveSettings())); setWebSettingsToolTips(); } @@ -212,21 +201,18 @@ void SettingsDialog::saveSettings() { ReKonfig::self()->writeConfig(); d->ebrowsingModule->save(); - d->cookiesModule->save(); - d->proxyModule->save(); - d->cacheModule->save(); d->shortcutsEditor->save(); d->adBlockWidg->save(); + d->networkWidg->save(); } bool SettingsDialog::hasChanged() { return KConfigDialog::hasChanged() - || d->ebrowsingModule->changed() - || d->cookiesModule->changed() - || d->proxyModule->changed() - || d->cacheModule->changed() + || d->adBlockWidg->changed() + || d->networkWidg->changed() + || d->ebrowsingModule->changed() || d->shortcutsEditor->isModified(); ; } -- cgit v1.2.1 From cb3c582272a729bd49f072f8ffe67beecc31df35 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sun, 14 Mar 2010 12:47:08 +0100 Subject: Implement the highlight all feature for the find bar (enabled by default) --- src/findbar.cpp | 26 ++++++++++++++++++++------ src/findbar.h | 4 +++- src/mainwindow.cpp | 20 ++++++++++++++++++++ src/mainwindow.h | 1 + 4 files changed, 44 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/findbar.cpp b/src/findbar.cpp index 4c780aca..94def263 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -52,9 +52,13 @@ FindBar::FindBar(QWidget *parent) : QWidget(parent) , m_lineEdit(new KLineEdit(this)) - , m_matchCase(new QCheckBox(i18n("&Match case"), this)) , m_hideTimer(new QTimer(this)) -{ + , m_matchCase(new QCheckBox(i18n("&Match case"), this)) + , m_highlightAll(new QCheckBox(i18n("&Highlight All"), this)) +{ + // mainwindow pointer + MainWindow *window = qobject_cast(parent); + QHBoxLayout *layout = new QHBoxLayout; // cosmetic @@ -65,6 +69,7 @@ FindBar::FindBar(QWidget *parent) hideButton->setAutoRaise(true); hideButton->setIcon(KIcon("dialog-close")); connect(hideButton, SIGNAL(clicked()), this, SLOT(hide())); + connect(hideButton, SIGNAL(clicked()), window, SLOT(highlightAll())); layout->addWidget(hideButton); layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop); @@ -75,9 +80,6 @@ FindBar::FindBar(QWidget *parent) QLabel *label = new QLabel(i18n("Find:")); layout->addWidget(label); - // mainwindow pointer - MainWindow *window = qobject_cast(parent); - // lineEdit, focusProxy setFocusProxy(m_lineEdit); m_lineEdit->setMaximumWidth(250); @@ -92,13 +94,19 @@ FindBar::FindBar(QWidget *parent) connect(findPrev, SIGNAL(clicked()), window, SLOT(findPrevious())); layout->addWidget(findNext); layout->addWidget(findPrev); - + // Case sensitivity. Deliberately set so this is off by default. m_matchCase->setCheckState(Qt::Unchecked); m_matchCase->setTristate(false); connect(m_matchCase, SIGNAL(toggled(bool)), window, SLOT(matchCaseUpdate())); layout->addWidget(m_matchCase); + // Hightlight All. On by default + m_highlightAll->setCheckState(Qt::Checked); + m_highlightAll->setTristate(false); + connect(m_highlightAll, SIGNAL(toggled(bool)), window, SLOT(highlightAll())); + layout->addWidget(m_highlightAll); + // stretching widget on the left layout->addStretch(); @@ -126,6 +134,12 @@ bool FindBar::matchCase() const } +bool FindBar::highlightAllState() const +{ + return m_highlightAll->isChecked(); +} + + void FindBar::show() { // show findbar if not visible diff --git a/src/findbar.h b/src/findbar.h index 7a4efc59..78615f9a 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -53,6 +53,7 @@ public: KLineEdit *lineEdit() const; bool matchCase() const; void notifyMatch(bool match); + bool highlightAllState() const; public slots: void show(); @@ -63,8 +64,9 @@ signals: private: KLineEdit *m_lineEdit; - QCheckBox *m_matchCase; QTimer *m_hideTimer; + QCheckBox *m_matchCase; + QCheckBox *m_highlightAll; }; #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4b48157b..a459cc78 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -797,6 +797,8 @@ void MainWindow::findNext() return; } + highlightAll(); + QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; @@ -826,6 +828,24 @@ void MainWindow::findPrevious() m_findBar->notifyMatch(found); } +void MainWindow::highlightAll() +{ + if (!currentTab()) + return; + + QWebPage::FindFlags options = QWebPage::HighlightAllOccurrences; + + currentTab()->view()->findText("", options); //Clear an existing highlight + + if(m_findBar->highlightAllState() && !m_findBar->isHidden()) + { + if (m_findBar->matchCase()) + options |= QWebPage::FindCaseSensitively; + + currentTab()->view()->findText(m_lastSearch, options); + } +} + void MainWindow::zoomIn() { diff --git a/src/mainwindow.h b/src/mainwindow.h index b693fec1..4ccd7bf3 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -130,6 +130,7 @@ private slots: void matchCaseUpdate(); void findNext(); void findPrevious(); + void highlightAll(); // Zoom slots void zoomIn(); -- cgit v1.2.1 From ce0689fc4a3bd27d46dc81b95ff94b0f53ccfff4 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sun, 14 Mar 2010 15:46:55 +0100 Subject: Fix capitalisation of "Highlight All" --- src/findbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/findbar.cpp b/src/findbar.cpp index 94def263..7cbe9d17 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -54,7 +54,7 @@ FindBar::FindBar(QWidget *parent) , m_lineEdit(new KLineEdit(this)) , m_hideTimer(new QTimer(this)) , m_matchCase(new QCheckBox(i18n("&Match case"), this)) - , m_highlightAll(new QCheckBox(i18n("&Highlight All"), this)) + , m_highlightAll(new QCheckBox(i18n("&Highlight all"), this)) { // mainwindow pointer MainWindow *window = qobject_cast(parent); -- cgit v1.2.1 From c4a3ac8eb53f109a3da1f53f279fc86edcb92597 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 16 Mar 2010 01:45:50 +0100 Subject: First bunch of fixes for the NewTabPage + WebSnap chain. It seems clear (to me) that they leaks memory, so they urgently need fixes. And a complete redesign. This is just a first (the easiest) part of it: - Removed some unuseful methods, - Added some documentation for the WebSnap class - Cleaned code, in general --- src/application.cpp | 2 +- src/rekonqpage/newtabpage.cpp | 5 +--- src/rekonqpage/newtabpage.h | 24 ++++++++++-------- src/rekonqpage/previewselectorbar.cpp | 6 ++--- src/tabbar.cpp | 2 +- src/websnap.cpp | 46 +++++++++++++---------------------- src/websnap.h | 25 ++++++++++--------- 7 files changed, 50 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index 96254e07..b8d6f52f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -353,7 +353,7 @@ MainWindow *Application::newMainWindow() void Application::removeMainWindow(MainWindow *window) { - m_mainWindows.removeAt(m_mainWindows.indexOf(window, 0)); + m_mainWindows.removeOne(window); } diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 845dcf51..6fd5160d 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -56,7 +56,6 @@ NewTabPage::NewTabPage(QWebFrame *frame) : m_root(frame->documentElement()) - , m_url(KUrl()) { QString htmlFilePath = KStandardDirs::locate("data", "rekonq/htmls/home.html"); QString imagesPath = QString("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QString("rekonq/pics"); @@ -98,7 +97,7 @@ void NewTabPage::generate(KUrl url) } QWebPage *page = m_root.webFrame()->page(); - page->mainFrame()->setHtml(m_html,m_url); + page->mainFrame()->setHtml(m_html); m_root = page->mainFrame()->documentElement().findFirst("#content"); @@ -109,7 +108,6 @@ void NewTabPage::generate(KUrl url) { favoritesPage(); title = i18n("Favorites"); - url = KUrl("about:favorites"); } else if(url == KUrl("about:closedTabs")) { @@ -127,7 +125,6 @@ void NewTabPage::generate(KUrl url) title = i18n("Bookmarks"); } - m_url = url; m_root.document().findFirst("title").setPlainText(title); } diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index d4c57299..fd04e60a 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -62,7 +62,8 @@ public: void snapFinished(int index, KUrl url, QString title); void removePreview(int index); -protected: // these are the function to build the new tab page +protected: + // these are the functions to build the new tab page void browsingMenu(const KUrl ¤tUrl); void favoritesPage(); @@ -70,13 +71,15 @@ protected: // these are the function to build the new tab page void bookmarksPage(); void closedTabsPage(); + // Previews handling QWebElement emptyPreview(int index); QWebElement loadingPreview(int index, KUrl url); QWebElement validPreview(int index, KUrl url, QString title); - /** This function takes a QwebElement with the .thumbnail structure. - It hides the "remove" and "modify" buttons-> - */ + /** This function takes a QwebElement with the .thumbnail structure, + * hiding the "remove" and "modify" buttons + * + */ void hideControls(QWebElement e); void showControls(QWebElement e); void setupPreview(QWebElement e, int index); @@ -84,10 +87,13 @@ protected: // these are the function to build the new tab page private: void createBookItem(const KBookmark &bookmark, QWebElement parent); - /** This function helps to get faster a new markup of one type,it isn't easy to create one with QWebElement. - It gets it in the #models div of home.html. - It works for all elements defined here. - */ + /** This function helps to get faster a new markup of one type, + * it isn't easy to create one with QWebElement. + * + * It gets it in the #models div of home.html. + * It works for all elements defined here. + * + */ inline QWebElement markup(QString selector) { return m_root.document().findFirst("#models > " + selector).clone(); @@ -98,8 +104,6 @@ private: QString m_html; QWebElement m_root; - - KUrl m_url; }; #endif // REKONQ_NEW_TAB_PAGE diff --git a/src/rekonqpage/previewselectorbar.cpp b/src/rekonqpage/previewselectorbar.cpp index d7676e3c..924a5439 100644 --- a/src/rekonqpage/previewselectorbar.cpp +++ b/src/rekonqpage/previewselectorbar.cpp @@ -119,10 +119,10 @@ void PreviewSelectorBar::clicked() if(page) { - KUrl url = page->mainFrame()->url(); - - WebSnap::savePreview(WebSnap::renderPreview(*page), url); + // this is done just lo let the render process being faster.. + WebSnap::renderPreview(*page); + KUrl url = page->mainFrame()->url(); QStringList names = ReKonfig::previewNames(); QStringList urls = ReKonfig::previewUrls(); diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 44972548..0f4e1064 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -170,7 +170,7 @@ void TabBar::showTabPreview(int tab) m_previewPopup.data()->setFixedSize(w, h); QLabel *l = new QLabel(); - l->setPixmap( WebSnap::renderPreview( *indexedTab->page() , w, h) ); + l->setPixmap( WebSnap::renderPreview( *indexedTab->page(), w, h, false) ); m_previewPopup.data()->setView(l); m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop); diff --git a/src/websnap.cpp b/src/websnap.cpp index ceb24b4f..906bbc1e 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -60,15 +60,11 @@ WebSnap::WebSnap(const QUrl& url, QWebFrame *frame, int index) m_page.settings()->setAttribute(QWebSettings::JavascriptEnabled, false); connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(saveResult(bool))); + QTimer::singleShot(0, this, SLOT(load())); } -WebSnap::~WebSnap() -{ -} - - void WebSnap::load() { m_page.mainFrame()->load(m_url); @@ -77,7 +73,7 @@ void WebSnap::load() // NOTE please, be careful modifying this. // You are playing with fire.. -QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h) +QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h, bool save) { // prepare page page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); @@ -87,7 +83,10 @@ QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h) // find the best size QSize size; int width = page.mainFrame()->contentsSize().width(); - if (width < 640) width = 640; + if (width < 640) + { + width = 640; + } size = QSize(width,width*((0.0+h)/w)); page.setViewportSize(size); @@ -106,15 +105,16 @@ QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h) page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); page.setViewportSize(oldSize); - return QPixmap::fromImage(pageImage); -} - - -void WebSnap::savePreview(QPixmap pm, KUrl url) -{ - kDebug() << "saving preview"; - QFile::remove(fileForUrl(url).toLocalFile()); - pm.save(fileForUrl(url).toLocalFile()); + QPixmap pm = QPixmap::fromImage(pageImage); + if(save) + { + KUrl url( page.mainFrame()->url() ); + kDebug() << "saving preview"; + QFile::remove( fileForUrl(url).toLocalFile() ); + pm.save(fileForUrl(url).toLocalFile()); + } + + return pm; } @@ -164,7 +164,7 @@ void WebSnap::saveResult(bool ok) NewTabPage p( m_frame ); p.snapFinished(m_previewIndex, m_url, m_snapTitle); - deleteLater(); + this->deleteLater(); } @@ -172,15 +172,3 @@ QString WebSnap::snapTitle() { return m_page.mainFrame()->title(); } - - -QUrl WebSnap::snapUrl() -{ - return m_url; -} - - -QPixmap WebSnap::previewImage() -{ - return m_image; -} diff --git a/src/websnap.h b/src/websnap.h index 49b60769..73ed04ca 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -46,9 +46,17 @@ /** - * This class renders a site producing an image based - * on that. + * This class is used in many classes of rekonq to produce an image + * based on the site corresponding to the url passed as argument. + * It also cached the images to not retrieve them everytime :) + * * Heavily based on Graphics-Dojo WebSnap example (thanks!) + * + * We use this in the following rekonq classes: + * - TabBar class: to show a tab preview (given a page, you show WITHOUT saving an image) + * - NewTabPage class: to show the favorites page "preview" (given an url, you show AND save an image) + * - PreviewSelector class: to save new favorite selection (given a page, you show AND save an image) + * */ class REKONQ_TESTS_EXPORT WebSnap : public QObject { @@ -56,20 +64,13 @@ class REKONQ_TESTS_EXPORT WebSnap : public QObject public: WebSnap(const QUrl &url, QWebFrame *frame, int index); - ~WebSnap(); - - QPixmap previewImage(); // TODO : remove - - static QPixmap renderPreview(const QWebPage &page, int w = WIDTH, int h = HEIGHT); - + + static QPixmap renderPreview(const QWebPage &page, int w = WIDTH, int h = HEIGHT, bool save = true); + static KUrl fileForUrl(KUrl url); - static QString guessNameFromUrl(QUrl url); - static void savePreview(QPixmap pm, KUrl url); - QString snapTitle(); - QUrl snapUrl(); private slots: void load(); -- cgit v1.2.1 From 6ff17e2ce62d5795ef2b31ee9eac1d4da7c590b5 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Tue, 16 Mar 2010 08:35:52 +0100 Subject: SVN_SILENT made messages (.desktop file) --- src/data/rekonq.desktop | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src') diff --git a/src/data/rekonq.desktop b/src/data/rekonq.desktop index 62998336..18e7a114 100644 --- a/src/data/rekonq.desktop +++ b/src/data/rekonq.desktop @@ -1,18 +1,8 @@ [Desktop Entry] Name=rekonq -Name[sv]=Rekonq -Name[tr]=Rekonq -Name[x-test]=xxrekonqxx +Name[pt_BR]=rekonq GenericName=Webkit KDE Browser -GenericName[de]=Webkit-Browser für KDE -GenericName[et]=KDE Webkiti veebibrauser -GenericName[km]=កម្មវិធី​រុករក​ Webkit KDE -GenericName[pt]=Navegador Web com WebKit GenericName[pt_BR]=Navegador Webkit do KDE -GenericName[sv]=Webkit webbläsare för KDE -GenericName[tr]=Webkit KDE Tarayıcı -GenericName[uk]=Переглядач мережі на WebKit для KDE -GenericName[x-test]=xxWebkit KDE Browserxx Icon=rekonq Type=Application Exec=rekonq %u -- cgit v1.2.1 From 220938f8ffd314c6682bc56d772de5b07c09aca9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 17 Mar 2010 00:53:53 +0100 Subject: First Krazy rekonq-git fixes :D --- src/clicktoflash.cpp | 2 +- src/clicktoflash.h | 2 +- src/webpage.cpp | 13 +++++++------ src/websnap.h | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/clicktoflash.cpp b/src/clicktoflash.cpp index 3c284b3f..76637975 100644 --- a/src/clicktoflash.cpp +++ b/src/clicktoflash.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (c) 2009, Benjamin C. Meyer +* Copyright (C) 2009 by Benjamin C. Meyer * Copyright (C) 2010 by Matthieu Gicquel * * diff --git a/src/clicktoflash.h b/src/clicktoflash.h index 7d6c4e05..186b5836 100644 --- a/src/clicktoflash.h +++ b/src/clicktoflash.h @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (c) 2009, Benjamin C. Meyer +* Copyright (C) 2009 by Benjamin C. Meyer * Copyright (C) 2010 by Matthieu Gicquel * * diff --git a/src/webpage.cpp b/src/webpage.cpp index 4caf5a83..42193ed0 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -312,12 +312,13 @@ void WebPage::downloadRequest(const QNetworkRequest &request) if (finfo.exists()) { QDateTime now = QDateTime::currentDateTime(); - KIO::RenameDialog dlg (view(), i18n("Overwrite File?"), srcUrl, destUrl, - KIO::RenameDialog_Mode(KIO::M_OVERWRITE | KIO::M_SKIP), - -1, finfo.size(), - now.toTime_t(), finfo.created().toTime_t(), - now.toTime_t(), finfo.lastModified().toTime_t()); - result = dlg.exec(); + QPointer dlg = new KIO::RenameDialog( view(), i18n("Overwrite File?"), srcUrl, destUrl, + KIO::RenameDialog_Mode(KIO::M_OVERWRITE | KIO::M_SKIP), + -1, finfo.size(), + now.toTime_t(), finfo.created().toTime_t(), + now.toTime_t(), finfo.lastModified().toTime_t()); + result = dlg->exec(); + delete dlg; } } } diff --git a/src/websnap.h b/src/websnap.h index 73ed04ca..e7c9e593 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -48,7 +48,7 @@ /** * This class is used in many classes of rekonq to produce an image * based on the site corresponding to the url passed as argument. - * It also cached the images to not retrieve them everytime :) + * It also cached the images to not retrieve them every time :) * * Heavily based on Graphics-Dojo WebSnap example (thanks!) * -- cgit v1.2.1 From 08e184b78c3a116b7ae903ad06fa4b5aae92c6f2 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Wed, 17 Mar 2010 09:54:18 +0100 Subject: SVN_SILENT made messages (.desktop file) --- src/data/rekonq.desktop | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/data/rekonq.desktop b/src/data/rekonq.desktop index 18e7a114..8db3b5df 100644 --- a/src/data/rekonq.desktop +++ b/src/data/rekonq.desktop @@ -1,8 +1,14 @@ [Desktop Entry] Name=rekonq +Name[de]=Rekonq +Name[pt]=rekonq Name[pt_BR]=rekonq +Name[uk]=rekonq GenericName=Webkit KDE Browser +GenericName[de]=WebKit-basierter Webbrowser für KDE +GenericName[pt]=Navegador do KDE usando o WebKit GenericName[pt_BR]=Navegador Webkit do KDE +GenericName[uk]=Переглядач інтернету на WebKit для KDE Icon=rekonq Type=Application Exec=rekonq %u -- cgit v1.2.1 From 4e7f41bab9de7bc52bce787edd536f6142f4c170 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Thu, 18 Mar 2010 07:57:23 +0100 Subject: SVN_SILENT made messages (.desktop file) --- src/data/rekonq.desktop | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/data/rekonq.desktop b/src/data/rekonq.desktop index 8db3b5df..928c8b6d 100644 --- a/src/data/rekonq.desktop +++ b/src/data/rekonq.desktop @@ -1,14 +1,20 @@ [Desktop Entry] Name=rekonq -Name[de]=Rekonq +Name[cs]=rekonq +Name[de]=rekonq +Name[nds]=Rekonq Name[pt]=rekonq Name[pt_BR]=rekonq Name[uk]=rekonq +Name[x-test]=xxrekonqxx GenericName=Webkit KDE Browser +GenericName[cs]=Prohlížeč pro KDE založený na Webkitu GenericName[de]=WebKit-basierter Webbrowser für KDE +GenericName[nds]=Webkit-KDE-Kieker GenericName[pt]=Navegador do KDE usando o WebKit GenericName[pt_BR]=Navegador Webkit do KDE GenericName[uk]=Переглядач інтернету на WebKit для KDE +GenericName[x-test]=xxWebkit KDE Browserxx Icon=rekonq Type=Application Exec=rekonq %u -- cgit v1.2.1 From 273422713742fc45fc937f0e69cb872846a564f1 Mon Sep 17 00:00:00 2001 From: kdesvn Date: Thu, 18 Mar 2010 20:10:33 +0000 Subject: extract i18n from all cpp files --- src/Messages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Messages.sh b/src/Messages.sh index b22743a6..efa6adff 100644 --- a/src/Messages.sh +++ b/src/Messages.sh @@ -1,2 +1,2 @@ #! /bin/sh -$XGETTEXT *.cpp -o $podir/rekonq.pot +$XGETTEXT *.cpp */*.cpp -o $podir/rekonq.pot -- cgit v1.2.1 From 36f7955d428808d838362a7ea1d1b0f681b30555 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Fri, 19 Mar 2010 09:14:33 +0100 Subject: SVN_SILENT made messages (.desktop file) --- src/data/rekonq.desktop | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/data/rekonq.desktop b/src/data/rekonq.desktop index 928c8b6d..b6b12078 100644 --- a/src/data/rekonq.desktop +++ b/src/data/rekonq.desktop @@ -2,17 +2,21 @@ Name=rekonq Name[cs]=rekonq Name[de]=rekonq +Name[ga]=rekonq Name[nds]=Rekonq Name[pt]=rekonq Name[pt_BR]=rekonq +Name[sv]=Rekonq Name[uk]=rekonq Name[x-test]=xxrekonqxx GenericName=Webkit KDE Browser GenericName[cs]=Prohlížeč pro KDE založený na Webkitu GenericName[de]=WebKit-basierter Webbrowser für KDE +GenericName[ga]=Brabhsálaí Webkit KDE GenericName[nds]=Webkit-KDE-Kieker GenericName[pt]=Navegador do KDE usando o WebKit GenericName[pt_BR]=Navegador Webkit do KDE +GenericName[sv]=Webkit webbläsare för KDE GenericName[uk]=Переглядач інтернету на WebKit для KDE GenericName[x-test]=xxWebkit KDE Browserxx Icon=rekonq -- cgit v1.2.1 From f51c660a207364b9b5ff400a29e8ff1dba721e61 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 19 Mar 2010 11:00:18 +0100 Subject: abp (Ad Block Plus) fake protocol support This will let rekonq to automatically add abp subscriptions from the adblockplus.org site (or wherever someone provides abp urls) Anyway, consider that the raccomended way to manage adblock (by me and by abp developers) is just adding the EasyList subscription. rekonq just does it by default!! --- src/adblock/adblockmanager.cpp | 42 ++++++++++++++------- src/adblock/adblockmanager.h | 5 ++- src/protocolhandler.cpp | 84 +++++++++++++++++++++++++++++++++++++----- src/protocolhandler.h | 3 +- src/rekonq.kcfg | 6 +-- src/settings/adblockwidget.cpp | 2 +- 6 files changed, 113 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp index d2c2b013..66e11277 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -60,7 +60,7 @@ AdBlockManager::~AdBlockManager() } -void AdBlockManager::loadSettings() +void AdBlockManager::loadSettings(bool checkUpdateDate) { _index = 0; _buffer.clear(); @@ -92,7 +92,7 @@ void AdBlockManager::loadSettings() QDateTime lastUpdate = ReKonfig::lastUpdate(); // the day of the implementation.. :) int days = ReKonfig::updateInterval(); - if( today > lastUpdate.addDays( days ) ) + if( !checkUpdateDate || today > lastUpdate.addDays( days ) ) { ReKonfig::setLastUpdate( today ); @@ -101,10 +101,10 @@ void AdBlockManager::loadSettings() } // else - QStringList names = ReKonfig::subscriptionNames(); - foreach(const QString &name, names) + QStringList titles = ReKonfig::subscriptionTitles(); + foreach(const QString &title, titles) { - rules = rulesGroup.readEntry( name + "-rules" , QStringList() ); + rules = rulesGroup.readEntry( title + "-rules" , QStringList() ); loadRules(rules); } } @@ -208,13 +208,11 @@ void AdBlockManager::applyHidingRules(WebPage *page) void AdBlockManager::updateNextSubscription() { - kDebug() << "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"; - - QStringList subUrlStrings = ReKonfig::subscriptionUrls(); + QStringList locations = ReKonfig::subscriptionLocations(); - if( _index < subUrlStrings.size() ) + if( _index < locations.size() ) { - QString urlString = subUrlStrings.at(_index); + QString urlString = locations.at(_index); kDebug() << "DOWNLOADING FROM " << urlString; KUrl subUrl = KUrl( urlString ); @@ -276,10 +274,28 @@ void AdBlockManager::saveRules(const QStringList &rules) cleanedRules << r; } - QStringList names = ReKonfig::subscriptionNames(); - QString name = names.at(_index) + "-rules"; + QStringList titles = ReKonfig::subscriptionTitles(); + QString title = titles.at(_index) + "-rules"; KSharedConfig::Ptr config = KGlobal::config(); KConfigGroup cg( config , "rules" ); - cg.writeEntry( name, cleanedRules ); + cg.writeEntry( title, cleanedRules ); +} + + +void AdBlockManager::addSubscription(const QString &title, const QString &location) +{ + QStringList titles = ReKonfig::subscriptionTitles(); + if( titles.contains(title) ) + return; + + QStringList locations = ReKonfig::subscriptionLocations(); + if( locations.contains(location) ) + return; + + titles << title; + locations << location; + + ReKonfig::setSubscriptionTitles(titles); + ReKonfig::setSubscriptionLocations(locations); } diff --git a/src/adblock/adblockmanager.h b/src/adblock/adblockmanager.h index aac78e3b..c0bd2b70 100644 --- a/src/adblock/adblockmanager.h +++ b/src/adblock/adblockmanager.h @@ -133,9 +133,10 @@ public: QNetworkReply *block(const QNetworkRequest &request); void applyHidingRules(WebPage *page); - + void addSubscription(const QString &title, const QString &location); + public slots: - void loadSettings(); + void loadSettings(bool checkUpdateDate = true); private: void updateNextSubscription(); diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index 70d69107..9d1560ed 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -38,6 +38,7 @@ #include "urlbar.h" #include "webtab.h" #include "historymanager.h" +#include "adblockmanager.h" // KDE Includes #include @@ -52,6 +53,7 @@ #include #include #include +#include // Qt Includes #include @@ -61,6 +63,9 @@ #include #include +// Defines +#define QL1S(x) QLatin1String(x) + ProtocolHandler::ProtocolHandler(QObject *parent) : QObject(parent) @@ -87,11 +92,11 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra return false; // "http(s)" (fast) handling - if( _url.protocol() == QLatin1String("http") || _url.protocol() == QLatin1String("https") ) + if( _url.protocol() == QL1S("http") || _url.protocol() == QL1S("https") ) return false; // javascript handling - if( _url.protocol() == QLatin1String("javascript") ) + if( _url.protocol() == QL1S("javascript") ) { QString scriptSource = _url.authority(); QVariant result = frame->evaluateJavaScript(scriptSource); @@ -99,14 +104,21 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra } // "mailto" handling - if ( _url.protocol() == QLatin1String("mailto") ) + if ( _url.protocol() == QL1S("mailto") ) { KToolInvocation::invokeMailer(_url); return true; } + // "abp" handling + if ( _url.protocol() == QL1S("abp") ) + { + abpHandling(); + return true; + } + // "about" handling - if ( _url.protocol() == QLatin1String("about") ) + if ( _url.protocol() == QL1S("about") ) { // let webkit manage the about:blank url... if( _url == KUrl("about:blank") ) @@ -152,12 +164,12 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr kDebug() << "URL PROTOCOL: " << _url; // "http(s)" (fast) handling - if( _url.protocol() == QLatin1String("http") || _url.protocol() == QLatin1String("https") ) + if( _url.protocol() == QL1S("http") || _url.protocol() == QL1S("https") ) return false; // "mailto" handling: It needs to be handled both here(mail links clicked) // and in prehandling (mail url launched) - if ( _url.protocol() == QLatin1String("mailto") ) + if ( _url.protocol() == QL1S("mailto") ) { KToolInvocation::invokeMailer(_url); return true; @@ -168,7 +180,7 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr // My idea is: webkit cannot handle in any way ftp. So we have surely to return true here. // We start trying to guess what the url represent: it's a dir? show its contents (and download them). // it's a file? download it. It's another thing? beat me, but I don't know what to do... - if( _url.protocol() == QLatin1String("ftp") ) + if( _url.protocol() == QL1S("ftp") ) { KIO::StatJob *job = KIO::stat(_url); connect(job, SIGNAL(result(KJob*)), this, SLOT( slotMostLocalUrlResult(KJob*) )); @@ -176,7 +188,7 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr } // "file" handling. This is quite trivial :) - if( _url.protocol() == QLatin1String("file") ) + if( _url.protocol() == QL1S("file") ) { QFileInfo fileInfo( _url.path() ); if(fileInfo.isDir()) @@ -269,7 +281,7 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list) msg += ""; - QString html = QString(QLatin1String(file.readAll())) + QString html = QString(QL1S(file.readAll())) .arg(title) .arg(msg) ; @@ -319,3 +331,57 @@ void ProtocolHandler::slotMostLocalUrlResult(KJob *job) emit downloadUrl(_url); } } + + +/** + * abp scheme (easy) explanation + * + */ +void ProtocolHandler::abpHandling() +{ + kDebug() << _url; + + QString path = _url.path(); + if( path != QL1S("subscribe") ) + return; + + QMap map = _url.queryItems( KUrl::CaseInsensitiveKeys ); + + QString location = map.value( QL1S("location") ); + kDebug() << location; + + QString title = map.value( QL1S("title") ); + kDebug() << title; + + QString requireslocation = map.value( QL1S("requireslocation") ); + kDebug() << requireslocation; + + QString requirestitle = map.value( QL1S("requirestitle") ); + kDebug() << requirestitle; + + QString info; + if( requirestitle.isEmpty() || requireslocation.isEmpty() ) + { + info = title; + } + else + { + info = i18n("\n %1,\n %2 (required by %3)\n", title, requirestitle, title); + } + + if ( KMessageBox::questionYesNo( 0, + i18n("Do you want to add the following subscriptions to your adblock settings?\n") + info, + i18n("Add automatic subscription to the adblock"), + KGuiItem(i18n("Add")), + KGuiItem(i18n("Discard")) + ) + ) + { + if( !requireslocation.isEmpty() && !requirestitle.isEmpty() ) + { + Application::adblockManager()->addSubscription( requirestitle, requireslocation ); + } + Application::adblockManager()->addSubscription( title, location ); + Application::adblockManager()->loadSettings(false); + } +} diff --git a/src/protocolhandler.h b/src/protocolhandler.h index 2a567015..99aec70a 100644 --- a/src/protocolhandler.h +++ b/src/protocolhandler.h @@ -74,7 +74,8 @@ private slots: private: QString dirHandling(const KFileItemList &list); - + void abpHandling(); + KDirLister *_lister; QWebFrame *_frame; KUrl _url; diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 42ace3d3..bc41f5e1 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -161,10 +161,10 @@ true - - easylist + + EasyList - + https://easylist-downloads.adblockplus.org/easylist.txt diff --git a/src/settings/adblockwidget.cpp b/src/settings/adblockwidget.cpp index 8aac3e8c..471f57f0 100644 --- a/src/settings/adblockwidget.cpp +++ b/src/settings/adblockwidget.cpp @@ -115,7 +115,7 @@ void AdBlockWidget::load() int days = ReKonfig::updateInterval(); spinBox->setValue( days ); - QStringList subscriptions = ReKonfig::subscriptionNames(); + QStringList subscriptions = ReKonfig::subscriptionTitles(); // load automatic rules foreach(QString sub, subscriptions) -- cgit v1.2.1 From a9107d70e55c345339a22e1d29f5667e04c4b397 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 19 Mar 2010 15:37:27 +0100 Subject: removed unuseful rekonqpage dir (we are using just a class for it) --- src/CMakeLists.txt | 17 +- src/newtabpage.cpp | 443 ++++++++++++++++++++++++++++++++++ src/newtabpage.h | 109 +++++++++ src/previewselectorbar.cpp | 152 ++++++++++++ src/previewselectorbar.h | 66 +++++ src/rekonqpage/newtabpage.cpp | 443 ---------------------------------- src/rekonqpage/newtabpage.h | 109 --------- src/rekonqpage/previewselectorbar.cpp | 152 ------------ src/rekonqpage/previewselectorbar.h | 66 ----- 9 files changed, 778 insertions(+), 779 deletions(-) create mode 100644 src/newtabpage.cpp create mode 100644 src/newtabpage.h create mode 100644 src/previewselectorbar.cpp create mode 100644 src/previewselectorbar.h delete mode 100644 src/rekonqpage/newtabpage.cpp delete mode 100644 src/rekonqpage/newtabpage.h delete mode 100644 src/rekonqpage/previewselectorbar.cpp delete mode 100644 src/rekonqpage/previewselectorbar.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d0c1639..d41ebfe0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,31 +8,30 @@ ADD_SUBDIRECTORY( tests ) SET( rekonq_KDEINIT_SRCS application.cpp + clicktoflash.cpp + filterurljob.cpp findbar.cpp mainview.cpp mainwindow.cpp + networkaccessmanager.cpp + newtabpage.cpp + previewselectorbar.cpp + protocolhandler.cpp sessionmanager.cpp tabbar.cpp + walletbar.cpp + webinspectorpanel.cpp webpage.cpp webpluginfactory.cpp websnap.cpp webview.cpp webtab.cpp - clicktoflash.cpp - networkaccessmanager.cpp - webinspectorpanel.cpp - walletbar.cpp - protocolhandler.cpp - filterurljob.cpp #---------------------------------------- history/autosaver.cpp history/historymanager.cpp history/historymodels.cpp history/historypanel.cpp #---------------------------------------- - rekonqpage/newtabpage.cpp - rekonqpage/previewselectorbar.cpp - #---------------------------------------- settings/settingsdialog.cpp settings/adblockwidget.cpp settings/networkwidget.cpp diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp new file mode 100644 index 00000000..6fd5160d --- /dev/null +++ b/src/newtabpage.cpp @@ -0,0 +1,443 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009-2010 by Andrea Diamantini +* Copyright (C) 2010 by Matthieu Gicquel +* +* +* 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +// Self Includes +#include "newtabpage.h" +#include "newtabpage.moc" + +// Auto Includes +#include "rekonq.h" + +// Local Includes +#include "historymodels.h" +#include "bookmarksmanager.h" +#include "application.h" +#include "mainwindow.h" +#include "mainview.h" +#include "websnap.h" +#include "previewselectorbar.h" +#include "webtab.h" + +// KDE Includes +#include +#include +#include +#include +#include +#include + +// Qt Includes +#include + + +NewTabPage::NewTabPage(QWebFrame *frame) + : m_root(frame->documentElement()) +{ + QString htmlFilePath = KStandardDirs::locate("data", "rekonq/htmls/home.html"); + QString imagesPath = QString("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QString("rekonq/pics"); + + QFile file(htmlFilePath); + bool isOpened = file.open(QIODevice::ReadOnly); + if (!isOpened) + { + kDebug() << "Couldn't open the home.html file"; + } + else + { + m_html = file.readAll(); + m_html.replace(QString("%2"), imagesPath); + } +} + + +NewTabPage::~NewTabPage() +{ +} + + +void NewTabPage::generate(KUrl url) +{ + if(KUrl("about:preview").isParentOf(url)) + { + if(url.directory() == QString("preview/remove")) + { + removePreview(url.fileName().toInt()); + return; + } + if(url.directory() == QString("preview/modify")) + { + int index = url.fileName().toInt(); + Application::instance()->mainWindow()->currentTab()->createPreviewSelectorBar(index); + return; + } + } + + QWebPage *page = m_root.webFrame()->page(); + page->mainFrame()->setHtml(m_html); + + m_root = page->mainFrame()->documentElement().findFirst("#content"); + + browsingMenu(url); + + QString title; + if(url == KUrl("about:favorites")) + { + favoritesPage(); + title = i18n("Favorites"); + } + else if(url == KUrl("about:closedTabs")) + { + closedTabsPage(); + title = i18n("Closed Tabs"); + } + else if(url == KUrl("about:history")) + { + historyPage(); + title = i18n("History"); + } + else if(url == KUrl("about:bookmarks")) + { + bookmarksPage(); + title = i18n("Bookmarks"); + } + + m_root.document().findFirst("title").setPlainText(title); +} + + +void NewTabPage::favoritesPage() +{ + m_root.addClass("favorites"); + + QStringList names = ReKonfig::previewNames(); + QStringList urls = ReKonfig::previewUrls(); + + for(int i=0; i<8; ++i) + { + KUrl url = urls.at(i); + QWebElement prev; + + if(url.isEmpty()) + prev = emptyPreview(i); + else if(!QFile::exists(WebSnap::fileForUrl(url).toLocalFile())) + prev = loadingPreview(i, url); + else + prev = validPreview(i, url, names.at(i)); + + setupPreview(prev, i); + + m_root.appendInside(prev); + } +} + + +QWebElement NewTabPage::emptyPreview(int index) +{ + QWebElement prev = markup(".thumbnail"); + + prev.findFirst(".preview img").setAttribute("src" , QString("file:///") + + KIconLoader::global()->iconPath("insert-image", KIconLoader::Desktop)); + prev.findFirst("span a").setPlainText(i18n("Set a Preview...")); + prev.findFirst("a").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString())); + + setupPreview(prev, index); + hideControls(prev); + + return prev; +} + + +QWebElement NewTabPage::loadingPreview(int index, KUrl url) +{ + QWebElement prev = markup(".thumbnail"); + + prev.findFirst(".preview img").setAttribute("src" , + QString("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif")); + prev.findFirst("span a").setPlainText(i18n("Loading Preview...")); + prev.findFirst("a").setAttribute("href", url.toMimeDataString()); + + setupPreview(prev, index); + showControls(prev); + + new WebSnap(url, m_root.webFrame(), index); + + return prev; +} + + +QWebElement NewTabPage::validPreview(int index, KUrl url, QString title) +{ + QWebElement prev = markup(".thumbnail"); + KUrl previewPath = WebSnap::fileForUrl(url); + QString iString = QVariant(index).toString(); + + prev.findFirst(".preview img").setAttribute("src" , previewPath.toMimeDataString()); + prev.findFirst("a").setAttribute("href", url.toMimeDataString()); + prev.findFirst("span a").setAttribute("href", url.toMimeDataString()); + prev.findFirst("span a").setPlainText(checkTitle(title)); + + setupPreview(prev, index); + showControls(prev); + + return prev; +} + + +void NewTabPage::hideControls(QWebElement e) +{ + e.findFirst(".remove").setStyleProperty("visibility", "hidden"); + e.findFirst(".modify").setStyleProperty("visibility", "hidden"); +} + + +void NewTabPage::showControls(QWebElement e) +{ + e.findFirst(".remove").setStyleProperty("visibility", "visible"); + e.findFirst(".modify").setStyleProperty("visibility", "visible"); +} + + +void NewTabPage::setupPreview(QWebElement e, int index) +{ + e.findFirst(".remove img").setAttribute("src", QString("file:///") + + KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState)); + e.findFirst(".remove").setAttribute("title", "Remove favorite"); + e.findFirst(".modify img").setAttribute("src", QString("file:///") + + KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState)); + e.findFirst(".modify").setAttribute("title", "Set new favorite"); + + e.findFirst(".modify").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString())); + e.findFirst(".remove").setAttribute("href", QString("about:preview/remove/" + QVariant(index).toString())); + + e.setAttribute("id", "preview" + QVariant(index).toString()); +} + + +void NewTabPage::snapFinished(int index, KUrl url, QString title) +{ + // do not try to modify the page if it isn't the newTabPage + if(m_root.document().findAll("#rekonq-newtabpage").count() == 0) + return; + + QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); + QWebElement newPrev = validPreview(index, url, title); + + if(m_root.findAll(".closedTabs").count() != 0) + hideControls(newPrev); + + prev.replace(newPrev); + + // update title + if(m_root.findAll(".favorites").count() != 0) + { + QStringList names = ReKonfig::previewNames(); + names.replace(index, title); + ReKonfig::setPreviewNames(names); + + ReKonfig::self()->writeConfig(); + } +} + + +void NewTabPage::removePreview(int index) +{ + QStringList names = ReKonfig::previewNames(); + QStringList urls = ReKonfig::previewUrls(); + + urls.replace(index, QString("")); + names.replace(index, QString("")); + + ReKonfig::setPreviewNames(names); + ReKonfig::setPreviewUrls(urls); + + ReKonfig::self()->writeConfig(); + + QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); + prev.replace(emptyPreview(index)); +} + + +void NewTabPage::browsingMenu(const KUrl ¤tUrl) +{ + QList navItems; + + KIconLoader *loader = KIconLoader::global(); + + QWebElement nav = markup(".link"); // Favorites + nav.findFirst("a").setAttribute("href", "about:favorites"); + nav.findFirst("img").setAttribute("src" , QString("file:///" + + loader->iconPath("emblem-favorite", KIconLoader::Desktop ||KIconLoader::SizeSmall))); + nav.findFirst("a").appendInside(i18n("Favorites")); + navItems.append(nav); + + nav = markup(".link"); // Closed Tabs + nav.findFirst("a").setAttribute("href", "about:closedTabs"); + nav.findFirst("img").setAttribute("src" , QString("file:///" + + loader->iconPath("tab-close", KIconLoader::Desktop ||KIconLoader::SizeSmall))); + nav.findFirst("a").appendInside(i18n("Closed Tabs")); + navItems.append(nav); + + nav = markup(".link"); // Bookmarks + nav.findFirst("a").setAttribute("href", "about:bookmarks"); + nav.findFirst("img").setAttribute("src" , QString("file:///" + + loader->iconPath("bookmarks", KIconLoader::Desktop ||KIconLoader::SizeSmall))); + nav.findFirst("a").appendInside(i18n("Bookmarks")); + navItems.append(nav); + + nav = markup(".link"); // History + nav.findFirst("a").setAttribute("href", "about:history"); + nav.findFirst("img").setAttribute("src" , QString("file:///" + + loader->iconPath("view-history", KIconLoader::Desktop ||KIconLoader::SizeSmall))); + nav.findFirst("a").appendInside(i18n("History")); + navItems.append(nav); + + QWebElement it; + foreach(it, navItems) + { + if(it.findFirst("a").attribute("href") == currentUrl.toMimeDataString()) + it.addClass("current"); + else if(currentUrl == "about:home" && it.findFirst("a").attribute("href") == "about:favorites") + it.addClass("current"); + m_root.document().findFirst("#navigation").appendInside(it); + } +} + + +void NewTabPage::historyPage() +{ + m_root.addClass("history"); + + HistoryTreeModel *model = Application::historyManager()->historyTreeModel(); + + int i = 0; + do + { + QModelIndex index = model->index(i, 0, QModelIndex() ); + if(model->hasChildren(index)) + { + m_root.appendInside(markup("h3")); + m_root.lastChild().setPlainText(index.data().toString()); + + for(int j=0; j< model->rowCount(index); ++j) + { + QModelIndex son = model->index(j, 0, index ); + m_root.appendInside(son.data(HistoryModel::DateTimeRole).toDateTime().toString("hh:mm")); + m_root.appendInside(" "); + m_root.appendInside(markup("a")); + m_root.lastChild().setAttribute("href" , son.data(HistoryModel::UrlStringRole).toString()); + m_root.lastChild().appendInside(son.data().toString()); + m_root.appendInside("
"); + } + } + i++; + } + while( model->hasIndex( i , 0 , QModelIndex() ) ); +} + + +void NewTabPage::bookmarksPage() +{ + m_root.addClass("bookmarks"); + + KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup(); + if (bookGroup.isNull()) + { + return; + } + + KBookmark bookmark = bookGroup.first(); + while (!bookmark.isNull()) + { + createBookItem(bookmark, m_root); + bookmark = bookGroup.next(bookmark); + } +} + + +void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent) +{ + if (bookmark.isGroup()) + { + KBookmarkGroup group = bookmark.toGroup(); + KBookmark bm = group.first(); + parent.appendInside(markup("h3")); + parent.lastChild().setPlainText(group.text()); + parent.appendInside(markup(".bookfolder")); + while (!bm.isNull()) + { + createBookItem(bm, parent.lastChild()); // it is .bookfolder + bm = group.next(bm); + } + } + else if(bookmark.isSeparator()) + { + parent.appendInside("
"); + } + else + { + parent.appendInside(markup("a")); + parent.lastChild().setAttribute("href" , bookmark.url().prettyUrl()); + parent.lastChild().setPlainText(bookmark.text()); + parent.appendInside("
"); + } +} + + +void NewTabPage::closedTabsPage() +{ + m_root.addClass("closedTabs"); + + QList links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs(); + + for(int i=0; i < links.count(); ++i) + { + HistoryItem item = links.at(i); + QWebElement prev; + + if(item.url.isEmpty()) + continue; + else if(!QFile::exists(WebSnap::fileForUrl(item.url).toLocalFile())) + prev = loadingPreview(i, item.url); + else + prev = validPreview(i, item.url, item.title); + + prev.setAttribute("id", "preview" + QVariant(i).toString()); + hideControls(prev); + m_root.appendInside(prev); + } +} + + +QString NewTabPage::checkTitle(QString title) +{ + if(title.length() > 23) + { + title.truncate(20); + title += "..."; + } + return title; +} diff --git a/src/newtabpage.h b/src/newtabpage.h new file mode 100644 index 00000000..fd04e60a --- /dev/null +++ b/src/newtabpage.h @@ -0,0 +1,109 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009-2010 by Andrea Diamantini +* Copyright (C) 2010 by Matthieu Gicquel +* +* +* 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +#ifndef REKONQ_NEW_TAB_PAGE +#define REKONQ_NEW_TAB_PAGE + + +// Local Includes +#include "rekonqprivate_export.h" + +// KDE Includes +#include + +// Qt Includes +#include +#include +#include + +// Forward Includes +class KBookmark; +class WebPage; + + +class REKONQ_TESTS_EXPORT NewTabPage : public QObject +{ +Q_OBJECT + +public: + NewTabPage(QWebFrame *frame); + ~NewTabPage(); + + /** + * This method takes an about: url and loads + * the corresponding part of the new tab page + */ + void generate(KUrl url = KUrl("about:home")); + + void snapFinished(int index, KUrl url, QString title); + void removePreview(int index); + +protected: + // these are the functions to build the new tab page + void browsingMenu(const KUrl ¤tUrl); + + void favoritesPage(); + void historyPage(); + void bookmarksPage(); + void closedTabsPage(); + + // Previews handling + QWebElement emptyPreview(int index); + QWebElement loadingPreview(int index, KUrl url); + QWebElement validPreview(int index, KUrl url, QString title); + + /** This function takes a QwebElement with the .thumbnail structure, + * hiding the "remove" and "modify" buttons + * + */ + void hideControls(QWebElement e); + void showControls(QWebElement e); + void setupPreview(QWebElement e, int index); + +private: + void createBookItem(const KBookmark &bookmark, QWebElement parent); + + /** This function helps to get faster a new markup of one type, + * it isn't easy to create one with QWebElement. + * + * It gets it in the #models div of home.html. + * It works for all elements defined here. + * + */ + inline QWebElement markup(QString selector) + { + return m_root.document().findFirst("#models > " + selector).clone(); + } + + QString checkTitle(QString title); + + QString m_html; + + QWebElement m_root; +}; + +#endif // REKONQ_NEW_TAB_PAGE diff --git a/src/previewselectorbar.cpp b/src/previewselectorbar.cpp new file mode 100644 index 00000000..924a5439 --- /dev/null +++ b/src/previewselectorbar.cpp @@ -0,0 +1,152 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 by Matthieu Gicquel +* Copyright (C) 2010 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +// Auto Includes +#include "previewselectorbar.h" +#include "previewselectorbar.moc" + +// Local Include +#include "rekonq.h" +#include "websnap.h" +#include "application.h" +#include "mainwindow.h" +#include "webtab.h" + +// KDE Includes +#include +#include + +// Qt Includes +#include +#include +#include + + +PreviewSelectorBar::PreviewSelectorBar(int index, QWidget* parent) + : QWidget(parent) + , m_button(0) + , m_label(0) + , m_previewIndex(index) +{ + m_label = new QLabel(i18n("Please open up the webpage you want to add as favorite"), this); + m_label->setWordWrap(true); + + QToolButton *closeButton = new QToolButton(this); + closeButton->setAutoRaise(true); + closeButton->setIcon(KIcon("dialog-close")); + connect(closeButton, SIGNAL(clicked(bool)), this, SLOT(destroy())); + + m_button = new QPushButton(KIcon("insert-image"), i18n("Set to This Page"), this); + m_button->setMaximumWidth(250); + connect(m_button, SIGNAL(clicked(bool)), this, SLOT(clicked())); + + // layout + QHBoxLayout *layout = new QHBoxLayout(this); + layout->addWidget(closeButton); + layout->addWidget(m_label); + layout->addWidget(m_button); + + layout->setContentsMargins(2, 0, 2, 0); + + setLayout(layout); +} + + +PreviewSelectorBar::~PreviewSelectorBar() +{ +} + + +void PreviewSelectorBar::verifyUrl() +{ + + if(Application::instance()->mainWindow()->currentTab()->page()->mainFrame()->url().scheme() != "about") + { + m_button->setEnabled(true); + m_button->setToolTip(""); + } + else + { + m_button->setEnabled(false); + m_button->setToolTip(i18n("You can not add this webpage as favorite")); + } +} + + +void PreviewSelectorBar::loadProgress() +{ + m_button->setEnabled(false); + m_button->setToolTip(i18n("Page is loading...")); +} + + +void PreviewSelectorBar::loadFinished() +{ + m_button->setEnabled(true); + m_button->setToolTip(""); + + verifyUrl(); +} + + +void PreviewSelectorBar::clicked() +{ + WebPage *page = Application::instance()->mainWindow()->currentTab()->page(); + + if(page) + { + // this is done just lo let the render process being faster.. + WebSnap::renderPreview(*page); + + KUrl url = page->mainFrame()->url(); + QStringList names = ReKonfig::previewNames(); + QStringList urls = ReKonfig::previewUrls(); + + urls.replace(m_previewIndex, url.toMimeDataString()); + names.replace(m_previewIndex, page->mainFrame()->title()); + + ReKonfig::setPreviewNames(names); + ReKonfig::setPreviewUrls(urls); + + ReKonfig::self()->writeConfig(); + + + page->mainFrame()->load(KUrl("about:favorites")); + } + + destroy(); +} + + +void PreviewSelectorBar::destroy() +{ + if (parentWidget() && parentWidget()->layout()) + { + parentWidget()->layout()->removeWidget(this); + } + this->deleteLater(); +} diff --git a/src/previewselectorbar.h b/src/previewselectorbar.h new file mode 100644 index 00000000..bb9f26c4 --- /dev/null +++ b/src/previewselectorbar.h @@ -0,0 +1,66 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 by Matthieu Gicquel +* Copyright (C) 2010 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +#ifndef PREVIEWSELECTORBAR_H +#define PREVIEWSELECTORBAR_H + +// Local Includes +#include "rekonqprivate_export.h" +#include "webpage.h" + +// Qt Includes +#include +#include +#include + + +class REKONQ_TESTS_EXPORT PreviewSelectorBar : public QWidget +{ +Q_OBJECT + +public: + PreviewSelectorBar(int index, QWidget *parent); + ~PreviewSelectorBar(); + +private slots: + void clicked(); + + void loadProgress(); + void loadFinished(); + + void verifyUrl(); + + void destroy(); + +private: + QPushButton *m_button; + QLabel *m_label; + + int m_previewIndex; +}; + +#endif // PREVIEWSELECTORBAR_H diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp deleted file mode 100644 index 6fd5160d..00000000 --- a/src/rekonqpage/newtabpage.cpp +++ /dev/null @@ -1,443 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009-2010 by Andrea Diamantini -* Copyright (C) 2010 by Matthieu Gicquel -* -* -* 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 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* 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. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* ============================================================ */ - - -// Self Includes -#include "newtabpage.h" -#include "newtabpage.moc" - -// Auto Includes -#include "rekonq.h" - -// Local Includes -#include "historymodels.h" -#include "bookmarksmanager.h" -#include "application.h" -#include "mainwindow.h" -#include "mainview.h" -#include "websnap.h" -#include "previewselectorbar.h" -#include "webtab.h" - -// KDE Includes -#include -#include -#include -#include -#include -#include - -// Qt Includes -#include - - -NewTabPage::NewTabPage(QWebFrame *frame) - : m_root(frame->documentElement()) -{ - QString htmlFilePath = KStandardDirs::locate("data", "rekonq/htmls/home.html"); - QString imagesPath = QString("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QString("rekonq/pics"); - - QFile file(htmlFilePath); - bool isOpened = file.open(QIODevice::ReadOnly); - if (!isOpened) - { - kDebug() << "Couldn't open the home.html file"; - } - else - { - m_html = file.readAll(); - m_html.replace(QString("%2"), imagesPath); - } -} - - -NewTabPage::~NewTabPage() -{ -} - - -void NewTabPage::generate(KUrl url) -{ - if(KUrl("about:preview").isParentOf(url)) - { - if(url.directory() == QString("preview/remove")) - { - removePreview(url.fileName().toInt()); - return; - } - if(url.directory() == QString("preview/modify")) - { - int index = url.fileName().toInt(); - Application::instance()->mainWindow()->currentTab()->createPreviewSelectorBar(index); - return; - } - } - - QWebPage *page = m_root.webFrame()->page(); - page->mainFrame()->setHtml(m_html); - - m_root = page->mainFrame()->documentElement().findFirst("#content"); - - browsingMenu(url); - - QString title; - if(url == KUrl("about:favorites")) - { - favoritesPage(); - title = i18n("Favorites"); - } - else if(url == KUrl("about:closedTabs")) - { - closedTabsPage(); - title = i18n("Closed Tabs"); - } - else if(url == KUrl("about:history")) - { - historyPage(); - title = i18n("History"); - } - else if(url == KUrl("about:bookmarks")) - { - bookmarksPage(); - title = i18n("Bookmarks"); - } - - m_root.document().findFirst("title").setPlainText(title); -} - - -void NewTabPage::favoritesPage() -{ - m_root.addClass("favorites"); - - QStringList names = ReKonfig::previewNames(); - QStringList urls = ReKonfig::previewUrls(); - - for(int i=0; i<8; ++i) - { - KUrl url = urls.at(i); - QWebElement prev; - - if(url.isEmpty()) - prev = emptyPreview(i); - else if(!QFile::exists(WebSnap::fileForUrl(url).toLocalFile())) - prev = loadingPreview(i, url); - else - prev = validPreview(i, url, names.at(i)); - - setupPreview(prev, i); - - m_root.appendInside(prev); - } -} - - -QWebElement NewTabPage::emptyPreview(int index) -{ - QWebElement prev = markup(".thumbnail"); - - prev.findFirst(".preview img").setAttribute("src" , QString("file:///") + - KIconLoader::global()->iconPath("insert-image", KIconLoader::Desktop)); - prev.findFirst("span a").setPlainText(i18n("Set a Preview...")); - prev.findFirst("a").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString())); - - setupPreview(prev, index); - hideControls(prev); - - return prev; -} - - -QWebElement NewTabPage::loadingPreview(int index, KUrl url) -{ - QWebElement prev = markup(".thumbnail"); - - prev.findFirst(".preview img").setAttribute("src" , - QString("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif")); - prev.findFirst("span a").setPlainText(i18n("Loading Preview...")); - prev.findFirst("a").setAttribute("href", url.toMimeDataString()); - - setupPreview(prev, index); - showControls(prev); - - new WebSnap(url, m_root.webFrame(), index); - - return prev; -} - - -QWebElement NewTabPage::validPreview(int index, KUrl url, QString title) -{ - QWebElement prev = markup(".thumbnail"); - KUrl previewPath = WebSnap::fileForUrl(url); - QString iString = QVariant(index).toString(); - - prev.findFirst(".preview img").setAttribute("src" , previewPath.toMimeDataString()); - prev.findFirst("a").setAttribute("href", url.toMimeDataString()); - prev.findFirst("span a").setAttribute("href", url.toMimeDataString()); - prev.findFirst("span a").setPlainText(checkTitle(title)); - - setupPreview(prev, index); - showControls(prev); - - return prev; -} - - -void NewTabPage::hideControls(QWebElement e) -{ - e.findFirst(".remove").setStyleProperty("visibility", "hidden"); - e.findFirst(".modify").setStyleProperty("visibility", "hidden"); -} - - -void NewTabPage::showControls(QWebElement e) -{ - e.findFirst(".remove").setStyleProperty("visibility", "visible"); - e.findFirst(".modify").setStyleProperty("visibility", "visible"); -} - - -void NewTabPage::setupPreview(QWebElement e, int index) -{ - e.findFirst(".remove img").setAttribute("src", QString("file:///") + - KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState)); - e.findFirst(".remove").setAttribute("title", "Remove favorite"); - e.findFirst(".modify img").setAttribute("src", QString("file:///") + - KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState)); - e.findFirst(".modify").setAttribute("title", "Set new favorite"); - - e.findFirst(".modify").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString())); - e.findFirst(".remove").setAttribute("href", QString("about:preview/remove/" + QVariant(index).toString())); - - e.setAttribute("id", "preview" + QVariant(index).toString()); -} - - -void NewTabPage::snapFinished(int index, KUrl url, QString title) -{ - // do not try to modify the page if it isn't the newTabPage - if(m_root.document().findAll("#rekonq-newtabpage").count() == 0) - return; - - QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); - QWebElement newPrev = validPreview(index, url, title); - - if(m_root.findAll(".closedTabs").count() != 0) - hideControls(newPrev); - - prev.replace(newPrev); - - // update title - if(m_root.findAll(".favorites").count() != 0) - { - QStringList names = ReKonfig::previewNames(); - names.replace(index, title); - ReKonfig::setPreviewNames(names); - - ReKonfig::self()->writeConfig(); - } -} - - -void NewTabPage::removePreview(int index) -{ - QStringList names = ReKonfig::previewNames(); - QStringList urls = ReKonfig::previewUrls(); - - urls.replace(index, QString("")); - names.replace(index, QString("")); - - ReKonfig::setPreviewNames(names); - ReKonfig::setPreviewUrls(urls); - - ReKonfig::self()->writeConfig(); - - QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); - prev.replace(emptyPreview(index)); -} - - -void NewTabPage::browsingMenu(const KUrl ¤tUrl) -{ - QList navItems; - - KIconLoader *loader = KIconLoader::global(); - - QWebElement nav = markup(".link"); // Favorites - nav.findFirst("a").setAttribute("href", "about:favorites"); - nav.findFirst("img").setAttribute("src" , QString("file:///" + - loader->iconPath("emblem-favorite", KIconLoader::Desktop ||KIconLoader::SizeSmall))); - nav.findFirst("a").appendInside(i18n("Favorites")); - navItems.append(nav); - - nav = markup(".link"); // Closed Tabs - nav.findFirst("a").setAttribute("href", "about:closedTabs"); - nav.findFirst("img").setAttribute("src" , QString("file:///" + - loader->iconPath("tab-close", KIconLoader::Desktop ||KIconLoader::SizeSmall))); - nav.findFirst("a").appendInside(i18n("Closed Tabs")); - navItems.append(nav); - - nav = markup(".link"); // Bookmarks - nav.findFirst("a").setAttribute("href", "about:bookmarks"); - nav.findFirst("img").setAttribute("src" , QString("file:///" + - loader->iconPath("bookmarks", KIconLoader::Desktop ||KIconLoader::SizeSmall))); - nav.findFirst("a").appendInside(i18n("Bookmarks")); - navItems.append(nav); - - nav = markup(".link"); // History - nav.findFirst("a").setAttribute("href", "about:history"); - nav.findFirst("img").setAttribute("src" , QString("file:///" + - loader->iconPath("view-history", KIconLoader::Desktop ||KIconLoader::SizeSmall))); - nav.findFirst("a").appendInside(i18n("History")); - navItems.append(nav); - - QWebElement it; - foreach(it, navItems) - { - if(it.findFirst("a").attribute("href") == currentUrl.toMimeDataString()) - it.addClass("current"); - else if(currentUrl == "about:home" && it.findFirst("a").attribute("href") == "about:favorites") - it.addClass("current"); - m_root.document().findFirst("#navigation").appendInside(it); - } -} - - -void NewTabPage::historyPage() -{ - m_root.addClass("history"); - - HistoryTreeModel *model = Application::historyManager()->historyTreeModel(); - - int i = 0; - do - { - QModelIndex index = model->index(i, 0, QModelIndex() ); - if(model->hasChildren(index)) - { - m_root.appendInside(markup("h3")); - m_root.lastChild().setPlainText(index.data().toString()); - - for(int j=0; j< model->rowCount(index); ++j) - { - QModelIndex son = model->index(j, 0, index ); - m_root.appendInside(son.data(HistoryModel::DateTimeRole).toDateTime().toString("hh:mm")); - m_root.appendInside(" "); - m_root.appendInside(markup("a")); - m_root.lastChild().setAttribute("href" , son.data(HistoryModel::UrlStringRole).toString()); - m_root.lastChild().appendInside(son.data().toString()); - m_root.appendInside("
"); - } - } - i++; - } - while( model->hasIndex( i , 0 , QModelIndex() ) ); -} - - -void NewTabPage::bookmarksPage() -{ - m_root.addClass("bookmarks"); - - KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup(); - if (bookGroup.isNull()) - { - return; - } - - KBookmark bookmark = bookGroup.first(); - while (!bookmark.isNull()) - { - createBookItem(bookmark, m_root); - bookmark = bookGroup.next(bookmark); - } -} - - -void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent) -{ - if (bookmark.isGroup()) - { - KBookmarkGroup group = bookmark.toGroup(); - KBookmark bm = group.first(); - parent.appendInside(markup("h3")); - parent.lastChild().setPlainText(group.text()); - parent.appendInside(markup(".bookfolder")); - while (!bm.isNull()) - { - createBookItem(bm, parent.lastChild()); // it is .bookfolder - bm = group.next(bm); - } - } - else if(bookmark.isSeparator()) - { - parent.appendInside("
"); - } - else - { - parent.appendInside(markup("a")); - parent.lastChild().setAttribute("href" , bookmark.url().prettyUrl()); - parent.lastChild().setPlainText(bookmark.text()); - parent.appendInside("
"); - } -} - - -void NewTabPage::closedTabsPage() -{ - m_root.addClass("closedTabs"); - - QList links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs(); - - for(int i=0; i < links.count(); ++i) - { - HistoryItem item = links.at(i); - QWebElement prev; - - if(item.url.isEmpty()) - continue; - else if(!QFile::exists(WebSnap::fileForUrl(item.url).toLocalFile())) - prev = loadingPreview(i, item.url); - else - prev = validPreview(i, item.url, item.title); - - prev.setAttribute("id", "preview" + QVariant(i).toString()); - hideControls(prev); - m_root.appendInside(prev); - } -} - - -QString NewTabPage::checkTitle(QString title) -{ - if(title.length() > 23) - { - title.truncate(20); - title += "..."; - } - return title; -} diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h deleted file mode 100644 index fd04e60a..00000000 --- a/src/rekonqpage/newtabpage.h +++ /dev/null @@ -1,109 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009-2010 by Andrea Diamantini -* Copyright (C) 2010 by Matthieu Gicquel -* -* -* 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 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* 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. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* ============================================================ */ - - -#ifndef REKONQ_NEW_TAB_PAGE -#define REKONQ_NEW_TAB_PAGE - - -// Local Includes -#include "rekonqprivate_export.h" - -// KDE Includes -#include - -// Qt Includes -#include -#include -#include - -// Forward Includes -class KBookmark; -class WebPage; - - -class REKONQ_TESTS_EXPORT NewTabPage : public QObject -{ -Q_OBJECT - -public: - NewTabPage(QWebFrame *frame); - ~NewTabPage(); - - /** - * This method takes an about: url and loads - * the corresponding part of the new tab page - */ - void generate(KUrl url = KUrl("about:home")); - - void snapFinished(int index, KUrl url, QString title); - void removePreview(int index); - -protected: - // these are the functions to build the new tab page - void browsingMenu(const KUrl ¤tUrl); - - void favoritesPage(); - void historyPage(); - void bookmarksPage(); - void closedTabsPage(); - - // Previews handling - QWebElement emptyPreview(int index); - QWebElement loadingPreview(int index, KUrl url); - QWebElement validPreview(int index, KUrl url, QString title); - - /** This function takes a QwebElement with the .thumbnail structure, - * hiding the "remove" and "modify" buttons - * - */ - void hideControls(QWebElement e); - void showControls(QWebElement e); - void setupPreview(QWebElement e, int index); - -private: - void createBookItem(const KBookmark &bookmark, QWebElement parent); - - /** This function helps to get faster a new markup of one type, - * it isn't easy to create one with QWebElement. - * - * It gets it in the #models div of home.html. - * It works for all elements defined here. - * - */ - inline QWebElement markup(QString selector) - { - return m_root.document().findFirst("#models > " + selector).clone(); - } - - QString checkTitle(QString title); - - QString m_html; - - QWebElement m_root; -}; - -#endif // REKONQ_NEW_TAB_PAGE diff --git a/src/rekonqpage/previewselectorbar.cpp b/src/rekonqpage/previewselectorbar.cpp deleted file mode 100644 index 924a5439..00000000 --- a/src/rekonqpage/previewselectorbar.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2010 by Matthieu Gicquel -* Copyright (C) 2010 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 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* 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. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* ============================================================ */ - - -// Auto Includes -#include "previewselectorbar.h" -#include "previewselectorbar.moc" - -// Local Include -#include "rekonq.h" -#include "websnap.h" -#include "application.h" -#include "mainwindow.h" -#include "webtab.h" - -// KDE Includes -#include -#include - -// Qt Includes -#include -#include -#include - - -PreviewSelectorBar::PreviewSelectorBar(int index, QWidget* parent) - : QWidget(parent) - , m_button(0) - , m_label(0) - , m_previewIndex(index) -{ - m_label = new QLabel(i18n("Please open up the webpage you want to add as favorite"), this); - m_label->setWordWrap(true); - - QToolButton *closeButton = new QToolButton(this); - closeButton->setAutoRaise(true); - closeButton->setIcon(KIcon("dialog-close")); - connect(closeButton, SIGNAL(clicked(bool)), this, SLOT(destroy())); - - m_button = new QPushButton(KIcon("insert-image"), i18n("Set to This Page"), this); - m_button->setMaximumWidth(250); - connect(m_button, SIGNAL(clicked(bool)), this, SLOT(clicked())); - - // layout - QHBoxLayout *layout = new QHBoxLayout(this); - layout->addWidget(closeButton); - layout->addWidget(m_label); - layout->addWidget(m_button); - - layout->setContentsMargins(2, 0, 2, 0); - - setLayout(layout); -} - - -PreviewSelectorBar::~PreviewSelectorBar() -{ -} - - -void PreviewSelectorBar::verifyUrl() -{ - - if(Application::instance()->mainWindow()->currentTab()->page()->mainFrame()->url().scheme() != "about") - { - m_button->setEnabled(true); - m_button->setToolTip(""); - } - else - { - m_button->setEnabled(false); - m_button->setToolTip(i18n("You can not add this webpage as favorite")); - } -} - - -void PreviewSelectorBar::loadProgress() -{ - m_button->setEnabled(false); - m_button->setToolTip(i18n("Page is loading...")); -} - - -void PreviewSelectorBar::loadFinished() -{ - m_button->setEnabled(true); - m_button->setToolTip(""); - - verifyUrl(); -} - - -void PreviewSelectorBar::clicked() -{ - WebPage *page = Application::instance()->mainWindow()->currentTab()->page(); - - if(page) - { - // this is done just lo let the render process being faster.. - WebSnap::renderPreview(*page); - - KUrl url = page->mainFrame()->url(); - QStringList names = ReKonfig::previewNames(); - QStringList urls = ReKonfig::previewUrls(); - - urls.replace(m_previewIndex, url.toMimeDataString()); - names.replace(m_previewIndex, page->mainFrame()->title()); - - ReKonfig::setPreviewNames(names); - ReKonfig::setPreviewUrls(urls); - - ReKonfig::self()->writeConfig(); - - - page->mainFrame()->load(KUrl("about:favorites")); - } - - destroy(); -} - - -void PreviewSelectorBar::destroy() -{ - if (parentWidget() && parentWidget()->layout()) - { - parentWidget()->layout()->removeWidget(this); - } - this->deleteLater(); -} diff --git a/src/rekonqpage/previewselectorbar.h b/src/rekonqpage/previewselectorbar.h deleted file mode 100644 index bb9f26c4..00000000 --- a/src/rekonqpage/previewselectorbar.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2010 by Matthieu Gicquel -* Copyright (C) 2010 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 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* 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. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* ============================================================ */ - - -#ifndef PREVIEWSELECTORBAR_H -#define PREVIEWSELECTORBAR_H - -// Local Includes -#include "rekonqprivate_export.h" -#include "webpage.h" - -// Qt Includes -#include -#include -#include - - -class REKONQ_TESTS_EXPORT PreviewSelectorBar : public QWidget -{ -Q_OBJECT - -public: - PreviewSelectorBar(int index, QWidget *parent); - ~PreviewSelectorBar(); - -private slots: - void clicked(); - - void loadProgress(); - void loadFinished(); - - void verifyUrl(); - - void destroy(); - -private: - QPushButton *m_button; - QLabel *m_label; - - int m_previewIndex; -}; - -#endif // PREVIEWSELECTORBAR_H -- cgit v1.2.1 From 9905c8c2a2c4f3ec27e2cc55cbfde83ddd35c5ce Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 19 Mar 2010 15:50:33 +0100 Subject: NewTabPage: clean API --- src/newtabpage.cpp | 19 ++++++++++--------- src/newtabpage.h | 44 +++++++++++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index 6fd5160d..69a80b29 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -79,7 +79,7 @@ NewTabPage::~NewTabPage() } -void NewTabPage::generate(KUrl url) +void NewTabPage::generate(const KUrl &url) { if(KUrl("about:preview").isParentOf(url)) { @@ -171,7 +171,7 @@ QWebElement NewTabPage::emptyPreview(int index) } -QWebElement NewTabPage::loadingPreview(int index, KUrl url) +QWebElement NewTabPage::loadingPreview(int index, const KUrl &url) { QWebElement prev = markup(".thumbnail"); @@ -189,7 +189,7 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url) } -QWebElement NewTabPage::validPreview(int index, KUrl url, QString title) +QWebElement NewTabPage::validPreview(int index, const KUrl &url, const QString &title) { QWebElement prev = markup(".thumbnail"); KUrl previewPath = WebSnap::fileForUrl(url); @@ -237,7 +237,7 @@ void NewTabPage::setupPreview(QWebElement e, int index) } -void NewTabPage::snapFinished(int index, KUrl url, QString title) +void NewTabPage::snapFinished(int index, const KUrl &url, const QString &title) { // do not try to modify the page if it isn't the newTabPage if(m_root.document().findAll("#rekonq-newtabpage").count() == 0) @@ -432,12 +432,13 @@ void NewTabPage::closedTabsPage() } -QString NewTabPage::checkTitle(QString title) +QString NewTabPage::checkTitle(const QString &title) { - if(title.length() > 23) + QString t(title); + if(t.length() > 23) { - title.truncate(20); - title += "..."; + t.truncate(20); + t += "..."; } - return title; + return t; } diff --git a/src/newtabpage.h b/src/newtabpage.h index fd04e60a..6d3a7ea9 100644 --- a/src/newtabpage.h +++ b/src/newtabpage.h @@ -57,13 +57,15 @@ public: * This method takes an about: url and loads * the corresponding part of the new tab page */ - void generate(KUrl url = KUrl("about:home")); + void generate(const KUrl &url = KUrl("about:home")); - void snapFinished(int index, KUrl url, QString title); - void removePreview(int index); + void snapFinished(int index, const KUrl &url, const QString &title); + -protected: - // these are the functions to build the new tab page +private: + // these are the "high-level" functions to build the new tab page + // basically, you call browsingMenu + one the the *Page methods + // to load a page void browsingMenu(const KUrl ¤tUrl); void favoritesPage(); @@ -71,38 +73,46 @@ protected: void bookmarksPage(); void closedTabsPage(); + // -------------------------------------------------------------------------- + // "low-level" functions + // we use these to create the pages over + // Previews handling QWebElement emptyPreview(int index); - QWebElement loadingPreview(int index, KUrl url); - QWebElement validPreview(int index, KUrl url, QString title); + QWebElement loadingPreview(int index, const KUrl &url); + QWebElement validPreview(int index, const KUrl &url, const QString &title); + + void removePreview(int index); - /** This function takes a QwebElement with the .thumbnail structure, - * hiding the "remove" and "modify" buttons + /** + * This function takes a QwebElement with the .thumbnail structure, + * hiding the "remove" and "modify" buttons * */ void hideControls(QWebElement e); void showControls(QWebElement e); void setupPreview(QWebElement e, int index); -private: void createBookItem(const KBookmark &bookmark, QWebElement parent); - /** This function helps to get faster a new markup of one type, - * it isn't easy to create one with QWebElement. + /** + * This function helps to get faster a new markup of one type, + * it isn't easy to create one with QWebElement. * - * It gets it in the #models div of home.html. - * It works for all elements defined here. + * It gets it in the #models div of home.html. + * It works for all elements defined here. * */ - inline QWebElement markup(QString selector) + inline QWebElement markup(const QString &selector) { return m_root.document().findFirst("#models > " + selector).clone(); } - QString checkTitle(QString title); + QString checkTitle(const QString &title); - QString m_html; +private: + QString m_html; QWebElement m_root; }; -- cgit v1.2.1 From a6ef003dd4c1b6ad08eca4f5adaa4679bbc20bce Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 20 Mar 2010 22:54:21 +0100 Subject: Downloads Page This commit implements the downloads history page. While it is in an horrible shape, its slots seem working well It needs just some love.. --- src/history/historymanager.cpp | 53 ++++++++++++++++++++ src/history/historymanager.h | 32 +++++++++++- src/newtabpage.cpp | 51 +++++++++++++++++++ src/newtabpage.h | 7 +-- src/protocolhandler.cpp | 2 + src/settings/settings_general.ui | 7 ++- src/webpage.cpp | 105 ++++++++++++++++++++++++--------------- 7 files changed, 213 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp index 362fe340..39c128f4 100644 --- a/src/history/historymanager.cpp +++ b/src/history/historymanager.cpp @@ -451,3 +451,56 @@ KCompletion * HistoryManager::completionObject() const { return m_completion; } + + +void HistoryManager::addDownload(const QString &srcUrl, const QString &destUrl) +{ + QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); + QFile downloadFile(downloadFilePath); + if ( !downloadFile.open(QFile::WriteOnly | QFile::Append) ) + { + kDebug() << "azz..."; + return; + } + QDataStream out(&downloadFile); + out << srcUrl; + out << destUrl; + out << QDateTime::currentDateTime(); + downloadFile.close(); +} + + +DownloadList HistoryManager::downloads() +{ + DownloadList list; + + QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); + QFile downloadFile(downloadFilePath); + if ( !downloadFile.open(QFile::ReadOnly) ) + { + kDebug() << "azz..."; + return list; + } + + QDataStream in(&downloadFile); + while(!in.atEnd()) + { + QString srcUrl; + in >> srcUrl; + QString destUrl; + in >> destUrl; + QDateTime dt; + in >> dt; + DownloadItem item(srcUrl, destUrl, dt); + list << item; + } + return list; +} + + +bool HistoryManager::clearDownloadsHistory() +{ + QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); + QFile downloadFile(downloadFilePath); + return downloadFile.remove(); +} diff --git a/src/history/historymanager.h b/src/history/historymanager.h index e744ca4b..8fc5c30e 100644 --- a/src/history/historymanager.h +++ b/src/history/historymanager.h @@ -57,7 +57,10 @@ public: const QDateTime &d = QDateTime(), const QString &t = QString() ) - : title(t), url(u), dateTime(d) {} + : title(t) + , url(u), + dateTime(d) + {} inline bool operator==(const HistoryItem &other) const { @@ -77,6 +80,29 @@ public: }; +// --------------------------------------------------------------------------------------------------------------- + + +class DownloadItem +{ +public: + DownloadItem() {} + explicit DownloadItem(const QString &srcUrl, + const QString &destUrl, + const QDateTime &d + ) + : srcUrlString(srcUrl) + , destUrlString(destUrl) + , dateTime(d) + {} + + QString srcUrlString; + QString destUrlString; + QDateTime dateTime; +}; + + +typedef QList DownloadList; // --------------------------------------------------------------------------------------------------------------- @@ -131,6 +157,10 @@ public: */ KCompletion *completionObject() const; + void addDownload(const QString &srcUrl, const QString &destUrl); + DownloadList downloads(); + bool clearDownloadsHistory(); + public slots: void clear(); void loadSettings(); diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index 69a80b29..36ddafed 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -53,6 +53,9 @@ // Qt Includes #include +// Defines +#define QL1S(x) QLatin1String(x) + NewTabPage::NewTabPage(QWebFrame *frame) : m_root(frame->documentElement()) @@ -124,6 +127,11 @@ void NewTabPage::generate(const KUrl &url) bookmarksPage(); title = i18n("Bookmarks"); } + else if(url == KUrl("about:downloads")) + { + downloadsPage(); + title = i18n("Downloads"); + } m_root.document().findFirst("title").setPlainText(title); } @@ -315,6 +323,13 @@ void NewTabPage::browsingMenu(const KUrl ¤tUrl) nav.findFirst("a").appendInside(i18n("History")); navItems.append(nav); + nav = markup(".link"); // History + nav.findFirst("a").setAttribute("href", "about:downloads"); + nav.findFirst("img").setAttribute("src" , QString("file:///" + + loader->iconPath("download", KIconLoader::Desktop ||KIconLoader::SizeSmall))); + nav.findFirst("a").appendInside(i18n("Downloads")); + navItems.append(nav); + QWebElement it; foreach(it, navItems) { @@ -442,3 +457,39 @@ QString NewTabPage::checkTitle(const QString &title) } return t; } + + +void NewTabPage::downloadsPage() +{ + m_root.addClass("downloads"); + + DownloadList list = Application::historyManager()->downloads(); + + foreach(const DownloadItem &item, list) + { + m_root.appendInside(markup("h3")); + m_root.lastChild().setPlainText(""); + + KUrl u = KUrl(item.destUrlString); + QString fName = u.fileName(); + QString dir = QL1S("file://") + u.directory(); + + m_root.appendInside( item.dateTime.toString("dddd") ); + m_root.appendInside("
"); + m_root.appendInside( item.dateTime.toString("dd MMMM yyyy") ); + m_root.appendInside(", "); + m_root.appendInside( item.dateTime.toString("hh:mm:ss") ); + m_root.appendInside("
"); + + m_root.appendInside(fName); + m_root.appendInside("
"); + + m_root.appendInside(item.srcUrlString); + m_root.appendInside("
"); + + m_root.appendInside(markup("a")); + m_root.lastChild().setAttribute("href" , dir); + m_root.lastChild().setPlainText("browse dir"); + m_root.appendInside("
"); + } +} diff --git a/src/newtabpage.h b/src/newtabpage.h index 6d3a7ea9..6604e4df 100644 --- a/src/newtabpage.h +++ b/src/newtabpage.h @@ -63,8 +63,8 @@ public: private: - // these are the "high-level" functions to build the new tab page - // basically, you call browsingMenu + one the the *Page methods + // these are the "high-level" functions to build the new tab page. + // Basically, you call browsingMenu + one of the *Page methods // to load a page void browsingMenu(const KUrl ¤tUrl); @@ -72,7 +72,8 @@ private: void historyPage(); void bookmarksPage(); void closedTabsPage(); - + void downloadsPage(); + // -------------------------------------------------------------------------- // "low-level" functions // we use these to create the pages over diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index 9d1560ed..faba894b 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -142,6 +142,8 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra case 3: // history _url = KUrl("about:history"); break; + case 4: // downloads + _url = KUrl("about:downloads"); default: // unuseful break; } diff --git a/src/settings/settings_general.ui b/src/settings/settings_general.ui index a4503d4a..98a56591 100644 --- a/src/settings/settings_general.ui +++ b/src/settings/settings_general.ui @@ -262,6 +262,11 @@ History
+ + + Downloads + + @@ -284,7 +289,7 @@ If enabled, rekonq will display an additional context menu entry, which, when selected, lists all available links of the current website in KGet. - + List links with KGet diff --git a/src/webpage.cpp b/src/webpage.cpp index 42193ed0..0e7b3d8a 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -71,6 +71,9 @@ #include #include +// Defines +#define QL1S(x) QLatin1String(x) + WebPage::WebPage(QWidget *parent) : KWebPage(parent, KWalletIntegration) @@ -292,55 +295,76 @@ QString WebPage::errorPage(QNetworkReply *reply) } +// WARNING +// this code is actually copied from KWebPage::downloadRequest to save +// downloads data before. If you have some better ideas about, +// feel free to let us know about :) void WebPage::downloadRequest(const QNetworkRequest &request) { - if (ReKonfig::kgetDownload()) - { - //*Copy of kwebpage code (Shouldn't be done in kwebpage ?) - - KUrl destUrl; - KUrl srcUrl (request.url()); - int result = KIO::R_OVERWRITE; - - do - { - destUrl = KFileDialog::getSaveFileName(srcUrl.fileName(), QString(), view()); - - if (destUrl.isLocalFile()) - { - QFileInfo finfo (destUrl.toLocalFile()); - if (finfo.exists()) - { - QDateTime now = QDateTime::currentDateTime(); - QPointer dlg = new KIO::RenameDialog( view(), i18n("Overwrite File?"), srcUrl, destUrl, - KIO::RenameDialog_Mode(KIO::M_OVERWRITE | KIO::M_SKIP), - -1, finfo.size(), - now.toTime_t(), finfo.created().toTime_t(), - now.toTime_t(), finfo.lastModified().toTime_t()); - result = dlg->exec(); - delete dlg; - } - } - } - while (result == KIO::R_CANCEL && destUrl.isValid()); - - if (result == KIO::R_OVERWRITE && destUrl.isValid()) + KUrl destUrl; + KUrl srcUrl (request.url()); + int result = KIO::R_OVERWRITE; + + do + { + destUrl = KFileDialog::getSaveFileName(srcUrl.fileName(), QString(), view()); + + if (destUrl.isLocalFile()) + { + QFileInfo finfo( destUrl.toLocalFile() ); + if ( finfo.exists() ) + { + QDateTime now = QDateTime::currentDateTime(); + QPointer dlg = new KIO::RenameDialog( view(), + i18n("Overwrite File?"), + srcUrl, + destUrl, + KIO::RenameDialog_Mode(KIO::M_OVERWRITE | KIO::M_SKIP), + -1, + finfo.size(), + now.toTime_t(), + finfo.created().toTime_t(), + now.toTime_t(), + finfo.lastModified().toTime_t() + ); + result = dlg->exec(); + delete dlg; + } + } + } + while ( result == KIO::R_CANCEL && destUrl.isValid() ); + + // now store data + // now, destUrl, srcUrl + Application::historyManager()->addDownload( srcUrl.pathOrUrl() , destUrl.pathOrUrl() ); + + if ( result == KIO::R_OVERWRITE && destUrl.isValid() ) + { + if ( ReKonfig::kgetDownload() ) { - //*End of copy code - //KGet integration: if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget")) { KToolInvocation::kdeinitExecWait("kget"); } QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main"); - kget.call("addTransfer", srcUrl.prettyUrl(), destUrl.prettyUrl(), true); + if( kget.isValid() ) + { + kget.call("addTransfer", srcUrl.prettyUrl(), destUrl.prettyUrl(), true); + return; + } } - return; - } - - KWebPage::downloadRequest(request); + // else, use KIO or fallback to it + KIO::Job *job = KIO::file_copy(srcUrl, destUrl, -1, KIO::Overwrite); + QVariant attr = request.attribute(static_cast(KIO::AccessManager::MetaData)); + if (attr.isValid() && attr.type() == QVariant::Map) + job->setMetaData(KIO::MetaData(attr.toMap())); + + job->addMetaData(QL1S("MaxCacheSize"), QL1S("0")); // Don't store in http cache. + job->addMetaData(QL1S("cache"), QL1S("cache")); // Use entry from cache if available. + job->uiDelegate()->setAutoErrorHandlingEnabled(true); + } } @@ -369,5 +393,8 @@ void WebPage::downloadAllContentsWithKGet() KToolInvocation::kdeinitExecWait("kget"); } QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main"); - kget.call("importLinks", QVariant(contents.toList())); + if( kget.isValid() ) + { + kget.call("importLinks", QVariant(contents.toList())); + } } -- cgit v1.2.1 From bbe335e37543af9a8d235daf2584c306eeaa4e1e Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Sun, 21 Mar 2010 01:40:01 +0100 Subject: SVN_SILENT made messages (.desktop file) --- src/data/rekonq.desktop | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/data/rekonq.desktop b/src/data/rekonq.desktop index b6b12078..f04a8a51 100644 --- a/src/data/rekonq.desktop +++ b/src/data/rekonq.desktop @@ -2,6 +2,7 @@ Name=rekonq Name[cs]=rekonq Name[de]=rekonq +Name[en_GB]=rekonq Name[ga]=rekonq Name[nds]=Rekonq Name[pt]=rekonq @@ -12,6 +13,7 @@ Name[x-test]=xxrekonqxx GenericName=Webkit KDE Browser GenericName[cs]=Prohlížeč pro KDE založený na Webkitu GenericName[de]=WebKit-basierter Webbrowser für KDE +GenericName[en_GB]=Webkit KDE Browser GenericName[ga]=Brabhsálaí Webkit KDE GenericName[nds]=Webkit-KDE-Kieker GenericName[pt]=Navegador do KDE usando o WebKit -- cgit v1.2.1 From 2cc02d8f7a60669a49aaf281b2f956184056cb25 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Sun, 21 Mar 2010 18:35:25 +0100 Subject: SVN_SILENT made messages (.desktop file) --- src/data/rekonq.desktop | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/data/rekonq.desktop b/src/data/rekonq.desktop index f04a8a51..fc42e1dd 100644 --- a/src/data/rekonq.desktop +++ b/src/data/rekonq.desktop @@ -1,6 +1,7 @@ [Desktop Entry] Name=rekonq Name[cs]=rekonq +Name[da]=rekonq Name[de]=rekonq Name[en_GB]=rekonq Name[ga]=rekonq @@ -12,6 +13,7 @@ Name[uk]=rekonq Name[x-test]=xxrekonqxx GenericName=Webkit KDE Browser GenericName[cs]=Prohlížeč pro KDE založený na Webkitu +GenericName[da]=KDE-browser baseret på Webkit GenericName[de]=WebKit-basierter Webbrowser für KDE GenericName[en_GB]=Webkit KDE Browser GenericName[ga]=Brabhsálaí Webkit KDE -- cgit v1.2.1 From 6a34b95f02848f75057f5e913e500115643fde5d Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 22 Mar 2010 02:46:24 +0100 Subject: First SSL support. checking metadata missing.. --- src/CMakeLists.txt | 1 + src/sslinfodialog_p.h | 107 +++++++++++++++++++++++++ src/webpage.cpp | 175 +++++++++++++++++++++++++++++++++++------ src/webpage.h | 7 +- src/websslinfo.cpp | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/websslinfo.h | 73 +++++++++++++++++ 6 files changed, 548 insertions(+), 26 deletions(-) create mode 100644 src/sslinfodialog_p.h create mode 100644 src/websslinfo.cpp create mode 100644 src/websslinfo.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d41ebfe0..bc4e91c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,7 @@ SET( rekonq_KDEINIT_SRCS webinspectorpanel.cpp webpage.cpp webpluginfactory.cpp + websslinfo.cpp websnap.cpp webview.cpp webtab.cpp diff --git a/src/sslinfodialog_p.h b/src/sslinfodialog_p.h new file mode 100644 index 00000000..44d3ab7c --- /dev/null +++ b/src/sslinfodialog_p.h @@ -0,0 +1,107 @@ +/* This file is part of the KDE project + * + * Copyright (C) 2000-2003 George Staikos + * Copyright (C) 2000 Malte Starostik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + + +#ifndef SSLINFODIALOG_P_H +#define SSLINFODIALOG_P_H + +#include + +#include +#include + +// NOTE: We need a copy of this header file is needed here because it +// is never installed by default by KIO. + +/** + * KDE SSL Information Dialog + * + * This class creates a dialog that can be used to display information about + * an SSL session. + * + * There are NO GUARANTEES that KSslInfoDialog will remain binary compatible/ + * Contact staikos@kde.org for details if needed. + * + * @author George Staikos + * @see KSSL + * @short KDE SSL Information Dialog + */ +class KDE_EXPORT KSslInfoDialog : public KDialog +{ +Q_OBJECT + +public: + /** + * Construct a KSSL Information Dialog + * + * @param parent the parent widget + */ + explicit KSslInfoDialog(QWidget *parent = 0); + + /** + * Destroy this dialog + */ + virtual ~KSslInfoDialog(); + + /** + * Tell the dialog if the connection has portions that may not be + * secure (ie. a mixture of secure and insecure frames) + * + * @param isIt true if security is in question + */ + void setSecurityInQuestion(bool isIt); + + /** + * Set information to display about the SSL connection. + * + * @param certificateChain the certificate chain leading from the certificate + * authority to the peer. + * @param ip the ip of the remote host + * @param host the remote hostname + * @param sslProtocol the version of SSL in use (SSLv2, SSLv3, TLSv1) + * @param cipher the cipher in use + * @param usedBits the used bits of the key + * @param bits the key size of the cipher in use + * @param validationErrors errors validating the certificates, if any + */ + void setSslInfo(const QList &certificateChain, + const QString &ip, const QString &host, + const QString &sslProtocol, const QString &cipher, + int usedBits, int bits, + const QList > &validationErrors); + + void setMainPartEncrypted(bool); + void setAuxiliaryPartsEncrypted(bool); + + static QList > errorsFromString(const QString &s); + +private Q_SLOTS: + void launchConfig(); + void displayFromChain(int); + +private: + void updateWhichPartsEncrypted(); + + class KSslInfoDialogPrivate; + KSslInfoDialogPrivate* const d; +}; + +#endif // SSLINFODIALOG_P_H diff --git a/src/webpage.cpp b/src/webpage.cpp index 0e7b3d8a..395e9073 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -45,6 +45,8 @@ #include "networkaccessmanager.h" #include "adblockmanager.h" +#include "sslinfodialog_p.h" + // KDE Includes #include #include @@ -73,6 +75,32 @@ // Defines #define QL1S(x) QLatin1String(x) +#define QL1C(x) QLatin1Char(x) + + +// Returns true if the scheme and domain of the two urls match... +static bool domainSchemeMatch(const QUrl& u1, const QUrl& u2) +{ + if (u1.scheme() != u2.scheme()) + return false; + + QStringList u1List = u1.host().split(QL1C('.'), QString::SkipEmptyParts); + QStringList u2List = u2.host().split(QL1C('.'), QString::SkipEmptyParts); + + if (qMin(u1List.count(), u2List.count()) < 2) + return false; // better safe than sorry... + + while (u1List.count() > 2) + u1List.removeFirst(); + + while (u2List.count() > 2) + u2List.removeFirst(); + + return (u1List == u2List); +} + + +// --------------------------------------------------------------------------------- WebPage::WebPage(QWidget *parent) @@ -92,6 +120,14 @@ WebPage::WebPage(QWidget *parent) setNetworkAccessManager(manager); + // activate ssl warnings + setSessionMetaData("ssl_activate_warnings", "TRUE"); + + // Override the 'Accept' header sent by QtWebKit which favors XML over HTML! + // Setting the accept meta-data to null will force kio_http to use its own + // default settings for this header. + setSessionMetaData(QL1S("accept"), QString()); + // ----- Web Plugin Factory setPluginFactory(new WebPluginFactory(this)); @@ -100,7 +136,7 @@ WebPage::WebPage(QWidget *parent) connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); // protocol handler signals - connect(&m_protHandler, SIGNAL(downloadUrl(const KUrl &)), this, SLOT(downloadUrl(const KUrl &))); + connect(&_protHandler, SIGNAL(downloadUrl(const KUrl &)), this, SLOT(downloadUrl(const KUrl &))); } @@ -112,21 +148,54 @@ WebPage::~WebPage() bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { - // advise users on resubmitting data - if(type == QWebPage::NavigationTypeFormResubmitted) + if(frame) { - int risp = KMessageBox::warningContinueCancel(view(), - i18n("Are you sure you want to send your data again?"), - i18n("Resend form data") ); - if(risp == KMessageBox::Cancel) + if ( _protHandler.preHandling(request, frame) ) + { return false; + } + + switch (type) + { + case QWebPage::NavigationTypeLinkClicked: + if (_sslInfo.isValid() ) + { + setRequestMetaData("ssl_was_in_use", "TRUE"); + } + break; + + case QWebPage::NavigationTypeFormSubmitted: + break; + + case QWebPage::NavigationTypeFormResubmitted: + if( KMessageBox::warningContinueCancel(view(), + i18n("Are you sure you want to send your data again?"), + i18n("Resend form data") + ) + == KMessageBox::Cancel) + { + return false; + } + break; + + case QWebPage::NavigationTypeReload: + case QWebPage::NavigationTypeBackOrForward: + case QWebPage::NavigationTypeOther: + break; + + default: + break; + } + + if(frame == mainFrame()) + { + setRequestMetaData("main_frame_request", "TRUE"); + } + else + { + setRequestMetaData("main_frame_request", "FALSE"); + } } - - if ( frame && m_protHandler.preHandling(request, frame) ) - { - return false; - } - return KWebPage::acceptNavigationRequest(frame, request, type); } @@ -197,38 +266,67 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) } -void WebPage::loadFinished(bool) +void WebPage::loadFinished(bool ok) { + if(!ok) + return; + Application::adblockManager()->applyHidingRules(this); + QStringList list = ReKonfig::walletBlackList(); + // KWallet Integration - // TODO: Add check for sites exempt from automatic form filling... - if (wallet()) + if ( wallet() + && !list.contains( mainFrame()->url().toString() ) + ) { wallet()->fillFormData(mainFrame()); } + + // TODO: implement me! + if(_sslInfo.isValid()) + { + // show an icon in the urlbar + } + else + { + // hide the icon in the urlbar + } } void WebPage::manageNetworkErrors(QNetworkReply *reply) { Q_ASSERT(reply); - - WebView *v = 0; + QWebFrame* frame = qobject_cast(reply->request().originatingObject()); + const bool isMainFrameRequest = (frame == mainFrame()); - // NOTE - // These are not all networkreply errors, + if ( isMainFrameRequest + && _sslInfo.isValid() + && !domainSchemeMatch(reply->url(), _sslInfo.url()) + ) + { + //kDebug() << "Reseting cached SSL info..."; + _sslInfo = WebSslInfo(); + } + + // NOTE: These are not all networkreply errors, // but just that supported directly by KIO - switch( reply->error() ) { - case QNetworkReply::NoError: // no error. Simple :) + case QNetworkReply::NoError: // no error. Simple :) + if ( isMainFrameRequest && !_sslInfo.isValid() ) + { + // Obtain and set the SSL information if any... + _sslInfo.fromMetaData(reply->attribute(static_cast(KIO::AccessManager::MetaData))); + _sslInfo.setUrl(reply->url()); + } break; case QNetworkReply::UnknownNetworkError: // unknown network-related error detected - if( m_protHandler.postHandling(reply->request(), mainFrame()) ) + if( _protHandler.postHandling(reply->request(), mainFrame()) ) break; case QNetworkReply::ContentAccessDenied: // access to remote content denied (similar to HTTP error 401) @@ -247,8 +345,7 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) // don't bother on elements loading errors: // we'll manage just main url page ones - v = qobject_cast(view()); - if( reply->url() != v->url() ) + if( !isMainFrameRequest ) break; mainFrame()->setHtml( errorPage(reply), reply->url() ); @@ -398,3 +495,31 @@ void WebPage::downloadAllContentsWithKGet() kget.call("importLinks", QVariant(contents.toList())); } } + + +void WebPage::showSSLInfo() +{ + if (_sslInfo.isValid()) + { + QPointer dlg = new KSslInfoDialog ( view() ); + dlg->setSslInfo( _sslInfo.certificateChain(), + _sslInfo.peerAddress().toString(), + mainFrame()->url().host(), + _sslInfo.protocol(), + _sslInfo.ciphers(), + _sslInfo.usedChiperBits(), + _sslInfo.supportedChiperBits(), + KSslInfoDialog::errorsFromString( _sslInfo.certificateErrors() ) + ); + + dlg->open(); + delete dlg; + } + else + { + KMessageBox::information( 0, + i18n("The SSL information for this site appears to be corrupt."), + i18nc("Secure Sockets Layer", "SSL") + ); + } +} diff --git a/src/webpage.h b/src/webpage.h index 76927725..42d5f586 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -37,6 +37,7 @@ #include "rekonqprivate_export.h" #include "protocolhandler.h" #include "newtabpage.h" +#include "websslinfo.h" // KDE Includes #include @@ -57,6 +58,8 @@ public: explicit WebPage(QWidget *parent = 0); ~WebPage(); + void showSSLInfo(); + public slots: void manageNetworkErrors(QNetworkReply *reply); virtual void downloadRequest(const QNetworkRequest &request); @@ -78,7 +81,9 @@ private slots: private: QString errorPage(QNetworkReply *); - ProtocolHandler m_protHandler; + ProtocolHandler _protHandler; + + WebSslInfo _sslInfo; }; #endif diff --git a/src/websslinfo.cpp b/src/websslinfo.cpp new file mode 100644 index 00000000..ffc4918f --- /dev/null +++ b/src/websslinfo.cpp @@ -0,0 +1,211 @@ +/* + * This file is part of the KDE project. + * + * Copyright (C) 2009 Dawit Alemayehu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "websslinfo.h" + +#include + + +class WebSslInfo::WebSslInfoPrivate +{ +public: + WebSslInfoPrivate() + : usedCipherBits(0), supportedCipherBits(0) {} + + QUrl url; + QString ciphers; + QString protocol; + QString certErrors; + QHostAddress peerAddress; + QHostAddress parentAddress; + QList certificateChain; + + int usedCipherBits; + int supportedCipherBits; +}; + +WebSslInfo::WebSslInfo() + :d(new WebSslInfo::WebSslInfoPrivate) +{ +} + +WebSslInfo::WebSslInfo(const WebSslInfo& other) + :d(new WebSslInfo::WebSslInfoPrivate) +{ + *this = other; +} + +WebSslInfo::~WebSslInfo() +{ + delete d; + d = 0; +} + +bool WebSslInfo::isValid() const +{ + return !d->peerAddress.isNull(); +} + +QUrl WebSslInfo::url() const +{ + return d->url; +} + +QHostAddress WebSslInfo::parentAddress() const +{ + return d->parentAddress; +} + +QHostAddress WebSslInfo::peerAddress() const +{ + return d->peerAddress; +} + +QString WebSslInfo::protocol() const +{ + return d->protocol; +} + +QString WebSslInfo::ciphers() const +{ + return d->ciphers; +} + +QString WebSslInfo::certificateErrors() const +{ + return d->certErrors; +} + +int WebSslInfo::supportedChiperBits () const +{ + return d->supportedCipherBits; +} + +int WebSslInfo::usedChiperBits () const +{ + return d->usedCipherBits; +} + +QList WebSslInfo::certificateChain() const +{ + return d->certificateChain; +} + +WebSslInfo& WebSslInfo::operator=(const WebSslInfo& other) +{ + d->ciphers = other.d->ciphers; + d->protocol = other.d->protocol; + d->certErrors = other.d->certErrors; + d->peerAddress = other.d->peerAddress; + d->parentAddress = other.d->parentAddress; + d->certificateChain = other.d->certificateChain; + + d->usedCipherBits = other.d->usedCipherBits; + d->supportedCipherBits = other.d->supportedCipherBits; + d->url = other.d->url; + + return *this; +} + +QVariant WebSslInfo::toMetaData() const +{ + if (isValid()) { + QMap data; + data.insert("ssl_in_use", true); + data.insert("ssl_peer_ip", d->peerAddress.toString()); + data.insert("ssl_parent_ip", d->parentAddress.toString()); + data.insert("ssl_protocol_version", d->protocol); + data.insert("ssl_cipher", d->ciphers); + data.insert("ssl_cert_errors", d->certErrors); + data.insert("ssl_cipher_used_bits", d->usedCipherBits); + data.insert("ssl_cipher_bits", d->supportedCipherBits); + QByteArray certChain; + Q_FOREACH(const QSslCertificate& cert, d->certificateChain) + certChain += cert.toPem(); + data.insert("ssl_peer_chain", certChain); + return data; + } + + return QVariant(); +} + +void WebSslInfo::fromMetaData(const QVariant& value) +{ + if (value.isValid() && value.type() == QVariant::Map) { + QMap metaData = value.toMap(); + if (metaData.value("ssl_in_use", false).toBool()) { + setCertificateChain(metaData.value("ssl_peer_chain").toByteArray()); + setPeerAddress(metaData.value("ssl_peer_ip").toString()); + setParentAddress(metaData.value("ssl_parent_ip").toString()); + setProtocol(metaData.value("ssl_protocol_version").toString()); + setCiphers(metaData.value("ssl_cipher").toString()); + setCertificateErrors(metaData.value("ssl_cert_errors").toString()); + setUsedCipherBits(metaData.value("ssl_cipher_used_bits").toString()); + setSupportedCipherBits(metaData.value("ssl_cipher_bits").toString()); + } + } +} + +void WebSslInfo::setUrl (const QUrl &url) +{ + d->url = url; +} + +void WebSslInfo::setPeerAddress(const QString& address) +{ + d->peerAddress = address; +} + +void WebSslInfo::setParentAddress(const QString& address) +{ + d->parentAddress = address; +} + +void WebSslInfo::setProtocol(const QString& protocol) +{ + d->protocol = protocol; +} + +void WebSslInfo::setCertificateChain(const QByteArray& chain) +{ + d->certificateChain = QSslCertificate::fromData(chain); +} + +void WebSslInfo::setCiphers(const QString& ciphers) +{ + d->ciphers = ciphers; +} + +void WebSslInfo::setUsedCipherBits(const QString& bits) +{ + d->usedCipherBits = bits.toInt(); +} + +void WebSslInfo::setSupportedCipherBits(const QString& bits) +{ + d->supportedCipherBits = bits.toInt(); +} + +void WebSslInfo::setCertificateErrors(const QString& certErrors) +{ + d->certErrors = certErrors; +} diff --git a/src/websslinfo.h b/src/websslinfo.h new file mode 100644 index 00000000..433cf053 --- /dev/null +++ b/src/websslinfo.h @@ -0,0 +1,73 @@ +/* + * This file is part of the KDE project. + * + * Copyright (C) 2009 Dawit Alemayehu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef WEBSSLINFO_H +#define WEBSSLINFO_H + +#include + +#include +#include +#include +#include +#include + + +class WebSslInfo +{ +public: + WebSslInfo(); + WebSslInfo(const WebSslInfo&); + virtual ~WebSslInfo(); + + bool isValid() const; + QUrl url() const; + QHostAddress peerAddress() const; + QHostAddress parentAddress() const; + QString ciphers() const; + QString protocol() const; + QString certificateErrors() const; + int supportedChiperBits () const; + int usedChiperBits () const; + QList certificateChain() const; + + QVariant toMetaData() const; + void fromMetaData (const QVariant &); + + void setUrl (const QUrl &url); + WebSslInfo& operator = (const WebSslInfo&); + +protected: + void setCiphers(const QString& ciphers); + void setProtocol(const QString& protocol); + void setPeerAddress(const QString& address); + void setParentAddress(const QString& address); + void setCertificateChain(const QByteArray& chain); + void setCertificateErrors(const QString& certErrors); + void setUsedCipherBits(const QString& bits); + void setSupportedCipherBits(const QString& bits); + +private: + class WebSslInfoPrivate; + WebSslInfoPrivate* d; +}; + +#endif // WEBSSLINFO_H -- cgit v1.2.1 From 1c3456d2821b73aa3f616b773499e99facf595f3 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 22 Mar 2010 11:31:05 +0100 Subject: Fixing loading checking errors and retrieving ssl metadata. We need just this F*****g awesome bar to show them :) --- src/webpage.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/webpage.cpp b/src/webpage.cpp index 395e9073..0da17a7b 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -148,6 +148,18 @@ WebPage::~WebPage() bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { + KIO::AccessManager *manager = qobject_cast(networkAccessManager()); + KIO::MetaData metaData = manager->requestMetaData(); + + // Get the SSL information sent, if any... + if( metaData.contains(QL1S("ssl_in_use")) ) + { + WebSslInfo info; + info.fromMetaData(metaData.toVariant()); + info.setUrl(request.url()); + _sslInfo = info; + } + if(frame) { if ( _protHandler.preHandling(request, frame) ) @@ -287,10 +299,12 @@ void WebPage::loadFinished(bool ok) if(_sslInfo.isValid()) { // show an icon in the urlbar + kDebug() << "----------------- SSL VALID INFO!!!! ------------------"; } else { // hide the icon in the urlbar + kDebug() << "----------------- SSL INFO NOT VALID... ------------------"; } } @@ -298,6 +312,7 @@ void WebPage::loadFinished(bool ok) void WebPage::manageNetworkErrors(QNetworkReply *reply) { Q_ASSERT(reply); + WebView *v = 0; QWebFrame* frame = qobject_cast(reply->request().originatingObject()); const bool isMainFrameRequest = (frame == mainFrame()); @@ -343,9 +358,10 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) case QNetworkReply::ProtocolUnknownError: // Unknown protocol case QNetworkReply::ProtocolInvalidOperationError: // requested operation is invalid for this protocol - // don't bother on elements loading errors: + // don't bother on elements loading errors: // we'll manage just main url page ones - if( !isMainFrameRequest ) + v = qobject_cast(view()); + if( reply->url() != v->url() ) break; mainFrame()->setHtml( errorPage(reply), reply->url() ); -- cgit v1.2.1 From c7fccbe4aa27b7dbd2eccba9ada4cdceba3490eb Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 22 Mar 2010 15:30:41 +0100 Subject: Doing "load finished" operations just on ok loading is really NOT a good idea.. --- src/webpage.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/webpage.cpp b/src/webpage.cpp index 0da17a7b..06e733b0 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -278,11 +278,8 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) } -void WebPage::loadFinished(bool ok) +void WebPage::loadFinished(bool) { - if(!ok) - return; - Application::adblockManager()->applyHidingRules(this); QStringList list = ReKonfig::walletBlackList(); -- cgit v1.2.1 From e9670c51fef2c8447a04a30778a24646df4ef915 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Tue, 23 Mar 2010 22:56:26 +0100 Subject: A lot of fix and improvements for the bookmark and the history panels --- src/CMakeLists.txt | 1 + src/bookmarks/bookmarksmanager.cpp | 4 +- src/bookmarks/bookmarksmanager.h | 4 +- src/bookmarks/bookmarkspanel.cpp | 441 +++++++++++++++++++++++++++++++++-- src/bookmarks/bookmarkspanel.h | 36 ++- src/bookmarks/bookmarkstreemodel.cpp | 265 ++++++++++++++------- src/bookmarks/bookmarkstreemodel.h | 51 ++-- src/history/historymodels.cpp | 8 + src/history/historypanel.cpp | 89 +++++-- src/history/historypanel.h | 10 +- src/mainwindow.cpp | 6 +- 11 files changed, 774 insertions(+), 141 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bc4e91c8..0cab993c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,6 +19,7 @@ SET( rekonq_KDEINIT_SRCS protocolhandler.cpp sessionmanager.cpp tabbar.cpp + urltreeview.cpp walletbar.cpp webinspectorpanel.cpp webpage.cpp diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp index cfe26a55..9feed63a 100644 --- a/src/bookmarks/bookmarksmanager.cpp +++ b/src/bookmarks/bookmarksmanager.cpp @@ -178,7 +178,9 @@ BookmarkProvider::BookmarkProvider(QObject *parent) bookfile = KUrl(bookmarksPath); } } - m_manager = KBookmarkManager::managerForExternalFile(bookfile.path()); + // A workaround to avoid a long delay between the two changed signals of the bookmark manager + m_manager = KBookmarkManager::managerForFile(bookfile.path(), "rekonq"); + connect(m_manager, SIGNAL(changed(const QString &, const QString &)), this, SLOT(slotBookmarksChanged(const QString &, const QString &))); diff --git a/src/bookmarks/bookmarksmanager.h b/src/bookmarks/bookmarksmanager.h index d4afb997..e50148e4 100644 --- a/src/bookmarks/bookmarksmanager.h +++ b/src/bookmarks/bookmarksmanager.h @@ -210,7 +210,9 @@ public: */ KBookmarkGroup rootGroup(); - KBookmarkManager *bookmarkManager() { return m_manager; } + KBookmarkManager *bookmarkManager() { return m_manager; } + BookmarkOwner *bookmarkOwner() { return m_owner; } + signals: /** * @short This signal is emitted when an url has to be loaded diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index 48ca6537..c50ebcdb 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -29,6 +29,7 @@ #include "bookmarkspanel.moc" // Local Includes +#include "bookmarksmanager.h" #include "bookmarkstreemodel.h" #include "bookmarksproxy.h" @@ -44,12 +45,21 @@ // KDE includes #include #include +#include +#include +#include +#include BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) - : QDockWidget(title, parent, flags) + : QDockWidget(title, parent, flags), + m_treeView(new UrlTreeView(this)), + m_ac(new KActionCollection(this)), + menu(new KMenu(this)), + expandLock(false) { setup(); + setupActions(); setShown(ReKonfig::showBookmarksPanel()); } @@ -60,13 +70,6 @@ BookmarksPanel::~BookmarksPanel() } -void BookmarksPanel::bookmarkActivated( const QModelIndex &index ) -{ - if( index.isValid() ) - emit openUrl( qVariantValue< KUrl >( index.data( Qt::UserRole ) ) ); -} - - void BookmarksPanel::setup() { setObjectName("bookmarksPanel"); @@ -85,19 +88,20 @@ void BookmarksPanel::setup() searchLabel->setBuddy( search ); // setup tree view - QTreeView *treeView = new QTreeView(ui); - treeView->setUniformRowHeights(true); - treeView->setSelectionBehavior(QAbstractItemView::SelectRows); - treeView->setTextElideMode(Qt::ElideMiddle); - treeView->setAlternatingRowColors(true); - treeView->header()->hide(); - treeView->setRootIsDecorated( false ); + m_treeView->setUniformRowHeights(true); + m_treeView->setTextElideMode(Qt::ElideMiddle); + m_treeView->setAlternatingRowColors(true); + m_treeView->header()->hide(); + m_treeView->setDragEnabled(true); + m_treeView->setAutoExpandDelay(750); + m_treeView->setDefaultDropAction(Qt::MoveAction); + m_treeView->viewport()->setAcceptDrops(true); // put everything together QVBoxLayout *vBoxLayout = new QVBoxLayout; vBoxLayout->setContentsMargins(0, 0, 0, 0); vBoxLayout->addLayout(searchLayout); - vBoxLayout->addWidget(treeView); + vBoxLayout->addWidget(m_treeView); // add it to the UI ui->setLayout(vBoxLayout); @@ -106,8 +110,407 @@ void BookmarksPanel::setup() BookmarksTreeModel *model = new BookmarksTreeModel( this ); BookmarksProxy *proxy = new BookmarksProxy(ui); proxy->setSourceModel( model ); - treeView->setModel( proxy ); + m_treeView->setModel( proxy ); + + connect(m_treeView, SIGNAL(contextMenuItemRequested(const QPoint &)), this, SLOT(contextMenuBk(const QPoint &))); + connect(m_treeView, SIGNAL(contextMenuGroupRequested(const QPoint &)), this, SLOT(contextMenuBkGroup(const QPoint &))); + connect(m_treeView, SIGNAL(contextMenuEmptyRequested(const QPoint &)), this, SLOT(contextMenuBlank(const QPoint &))); + connect(m_treeView, SIGNAL(delKeyPressed()), this, SLOT(deleteBookmark())); + connect(m_treeView, SIGNAL(collapsed(const QModelIndex &)), this, SLOT(onCollapse(const QModelIndex &))); + connect(m_treeView, SIGNAL(expanded(const QModelIndex &)), this, SLOT(onExpand(const QModelIndex &))); + connect(search, SIGNAL(textChanged(const QString &)), proxy, SLOT(setFilterFixedString(const QString &))); + callAutoExpand(); +} + + +void BookmarksPanel::onCollapse(const QModelIndex &index) +{ + if(expandLock) + return; + + KBookmark bookmark = bookmarkForIndex(index); + bookmark.internalElement().setAttribute("folded", "yes"); + Application::bookmarkProvider()->bookmarkManager()->emitChanged(); +} + + +void BookmarksPanel::onExpand(const QModelIndex &index) +{ + if(expandLock) + return; + + KBookmark bookmark = bookmarkForIndex(index); + bookmark.internalElement().setAttribute("folded", "no"); + Application::bookmarkProvider()->bookmarkManager()->emitChanged(); +} + + +void BookmarksPanel::callAutoExpand() +{ + expandLock = true; + autoExpand(); + expandLock = false; +} + + +void BookmarksPanel::autoExpand(const QModelIndex &root) +{ + + int count = m_treeView->model()->rowCount(root); + QModelIndex temp; + + for(int i = 0; i < count; i++) + { + temp = m_treeView->model()->index(i,0,root); + m_treeView->setExpanded(temp, bookmarkForIndex(temp).toGroup().isOpen()); + autoExpand(temp); + } +} + + +void BookmarksPanel::setupActions() +{ + KAction* action; + + action = new KAction(KIcon("tab-new"), i18n("Open"), this); + connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInCurrentTab())); + m_ac.addAction("open", action); + + action = new KAction(KIcon("tab-new"), i18n("Open in New Tab"), this); + connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewTab())); + m_ac.addAction("open_tab", action); + + action = new KAction(KIcon("window-new"), i18n("Open in New Window"), this); + connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewWindow())); + m_ac.addAction("open_window", action); + + action = new KAction(KIcon("rating"), i18n("Bookmark Page"), this); + connect(action, SIGNAL(triggered()), this, SLOT(bookmarkPage())); + m_ac.addAction("bookmark_page", action); + + action = new KAction(KIcon("bookmark-new"), i18n("New Bookmark"), this); + connect(action, SIGNAL(triggered()), this, SLOT(newBookmark())); + m_ac.addAction("bookmark_new", action); + + action = new KAction(KIcon("folder-new"), i18n("New Bookmark Folder"), this); + connect(action, SIGNAL(triggered()), this, SLOT(newBookmarkGroup())); + m_ac.addAction("folder_new", action); + + action = new KAction(KIcon("edit-clear"), i18n("New Separator"), this); + connect(action, SIGNAL(triggered()), this, SLOT(newSeparator())); + m_ac.addAction("separator_new", action); + + action = new KAction(KIcon("edit-copy"), i18n("Copy Link"), this); + connect(action, SIGNAL(triggered()), m_treeView, SLOT(copyToClipboard())); + m_ac.addAction("copy", action); + + action = new KAction(KIcon("edit-delete"), i18n("Delete"), this); + connect(action, SIGNAL(triggered()), this, SLOT(deleteBookmark())); + m_ac.addAction("delete", action); + + action = new KAction(KIcon("configure"), i18n("Properties"), this); + connect(action, SIGNAL(triggered()), this, SLOT(editBookmark())); + m_ac.addAction("properties", action); + + action = new KAction(KIcon("tab-new"), i18n("Open all Bookmarks"), this); + connect(action, SIGNAL(triggered()), this, SLOT(openAll())); + m_ac.addAction("open_all", action); +} + + +KBookmark BookmarksPanel::bookmarkForIndex(const QModelIndex &index) +{ + if(!index.isValid()) + return KBookmark(); + + const QAbstractProxyModel* proxyModel = dynamic_cast< const QAbstractProxyModel* >(index.model()); + QModelIndex originalIndex = proxyModel->mapToSource(index); + + BtmItem *node = static_cast< BtmItem* >( originalIndex.internalPointer() ); + return node->getBkm(); +} + + +void BookmarksPanel::contextMenuBk(const QPoint &pos) +{ + QPoint position = m_treeView->mapToGlobal(pos); + QModelIndex index = m_treeView->indexAt(pos); + if(!index.isValid() || expandLock) + return; + + KBookmark selected = bookmarkForIndex(index); + + if(selected.isGroup()) + { + contextMenuBkGroup(pos, true); + return; + } + + if(selected.isSeparator()) + { + contextMenuSeparator(pos); + return; + } + + menu = new KMenu(this); + + menu->addAction(m_ac.action("open")); + menu->addAction(m_ac.action("open_tab")); + menu->addAction(m_ac.action("open_window")); + + menu->addSeparator(); + + menu->addAction(m_ac.action("bookmark_page")); + menu->addAction(m_ac.action("bookmark_new")); + menu->addAction(m_ac.action("folder_new")); + menu->addAction(m_ac.action("separator_new")); + + menu->addSeparator(); + + menu->addAction(m_ac.action("copy")); + + menu->addSeparator(); + + menu->addAction(m_ac.action("delete")); + menu->addAction(m_ac.action("properties")); + + menu->popup(position); +} + + +void BookmarksPanel::contextMenuBkGroup(const QPoint &pos, bool emptyGroup) +{ + if(expandLock) + return; + + QPoint position = m_treeView->mapToGlobal(pos); + menu = new KMenu(this); + + if(!emptyGroup) + { + menu->addAction(m_ac.action("open_all")); + menu->addSeparator(); + } + + menu->addAction(m_ac.action("bookmark_page")); + menu->addAction(m_ac.action("bookmark_new")); + menu->addAction(m_ac.action("folder_new")); + menu->addAction(m_ac.action("separator_new")); + + menu->addSeparator(); + + menu->addAction(m_ac.action("delete")); + menu->addAction(m_ac.action("properties")); + + menu->popup(position); +} + + +void BookmarksPanel::contextMenuSeparator(const QPoint &pos) +{ + QPoint position = m_treeView->mapToGlobal(pos); + menu = new KMenu(this); + + menu->addAction(m_ac.action("bookmark_page")); + menu->addAction(m_ac.action("bookmark_new")); + menu->addAction(m_ac.action("folder_new")); + menu->addAction(m_ac.action("separator_new")); + + menu->addSeparator(); + + menu->addAction(m_ac.action("delete")); + + menu->popup(position); +} + + +void BookmarksPanel::contextMenuBlank(const QPoint &pos) +{ + QPoint position = m_treeView->mapToGlobal(pos); + menu = new KMenu(this); + + menu->addAction(m_ac.action("bookmark_page")); + menu->addAction(m_ac.action("bookmark_new")); + menu->addAction(m_ac.action("folder_new")); + menu->addAction(m_ac.action("separator_new")); + + menu->popup(position); +} + + +void BookmarksPanel::deleteBookmark() +{ + QModelIndex index = m_treeView->currentIndex(); + if(!index.isValid()) + return; + + KBookmark selected = bookmarkForIndex(index); + KBookmarkGroup parent = selected.parentGroup(); + + parent.deleteBookmark(selected); + Application::instance()->bookmarkProvider()->bookmarkManager()->emitChanged(); +} + + +void BookmarksPanel::editBookmark() +{ + QModelIndex index = m_treeView->currentIndex(); + if(!index.isValid()) + return; + + KBookmark selected = bookmarkForIndex(index); + + KBookmarkDialog *dialog = Application::bookmarkProvider()->bookmarkOwner()->bookmarkDialog(Application::bookmarkProvider()->bookmarkManager(), QApplication::activeWindow()); + dialog->editBookmark(selected); + delete dialog; +} + + +void BookmarksPanel::openAll() +{ + QModelIndex index = m_treeView->currentIndex(); + if(!index.isValid()) + return; + + QList allChild = bookmarkForIndex(index).toGroup().groupUrlList(); + + if(allChild.length() > 8) // 8, a good choice ? + { + if(!(KMessageBox::warningContinueCancel(this, i18n("You are about to open a lot of tabs : %1\nAre you sure ?", QString::number(allChild.length()))) == KMessageBox::Continue)) + return; + } + + for(int i = 0; i < allChild.length(); i++) + emit openUrl(allChild.at(i).url(), Rekonq::SettingOpenTab); +} + + +void BookmarksPanel::newBookmark() +{ + QModelIndex index = m_treeView->currentIndex(); + + KBookmark selected; + KBookmark newBk; + + KBookmarkDialog *dialog = Application::bookmarkProvider()->bookmarkOwner()->bookmarkDialog(Application::bookmarkProvider()->bookmarkManager(), QApplication::activeWindow()); + + if(index.isValid()) + { + selected = bookmarkForIndex(index); + + if(selected.isGroup()) + newBk = dialog->addBookmark("New bookmark", KUrl("www.kde.org"), selected); + else + newBk = dialog->addBookmark("New bookmark", KUrl("www.kde.org"), selected.parentGroup()); + } + + else + { + newBk = dialog->addBookmark("New bookmark", KUrl("www.kde.org")); + } + + delete dialog; + + // addBookmark already added the bookmark, but without the default favicon + KBookmarkGroup parent = newBk.parentGroup(); + parent.deleteBookmark(newBk); + newBk.setIcon(("text-html")); + parent.addBookmark(newBk); + + if(index.isValid()) + parent.moveBookmark(newBk, selected); + + Application::bookmarkProvider()->bookmarkManager()->emitChanged(); +} + + +void BookmarksPanel::newBookmarkGroup() +{ + QModelIndex index = m_treeView->currentIndex(); + KBookmark newBk; + + KBookmarkDialog *dialog = Application::bookmarkProvider()->bookmarkOwner()->bookmarkDialog(Application::bookmarkProvider()->bookmarkManager(), QApplication::activeWindow()); + + if(index.isValid()) + { + KBookmark selected = bookmarkForIndex(index); + + if(selected.isGroup()) + { + newBk = dialog->createNewFolder("New folder", selected); + } + + else + { + newBk = dialog->createNewFolder("New folder", selected.parentGroup()); + selected.parentGroup().moveBookmark(newBk, selected); + Application::bookmarkProvider()->bookmarkManager()->emitChanged(); + } + } + + else + { + dialog->createNewFolder("New folder"); + } + + delete dialog; +} + + +void BookmarksPanel::newSeparator() +{ + QModelIndex index = m_treeView->currentIndex(); + + KBookmark selected; + KBookmark newBk; + + if(index.isValid()) + { + selected = bookmarkForIndex(index); + + if(selected.isGroup()) + newBk = selected.toGroup().createNewSeparator(); + else + newBk = selected.parentGroup().createNewSeparator(); + } + + else + { + newBk = Application::bookmarkProvider()->rootGroup().createNewSeparator(); + } + + KBookmarkGroup parent = newBk.parentGroup(); + newBk.setIcon(("edit-clear")); + parent.addBookmark(newBk); + + if(index.isValid()) + parent.moveBookmark(newBk, selected); + + Application::bookmarkProvider()->bookmarkManager()->emitChanged(); +} + + +void BookmarksPanel::bookmarkPage() +{ + QModelIndex index = m_treeView->currentIndex(); + KBookmarkGroup parent = Application::bookmarkProvider()->rootGroup(); + + if(index.isValid()) + { + KBookmark selected = bookmarkForIndex(index); + parent = selected.parentGroup(); + + if(selected.isGroup()) + parent = selected.toGroup(); + + KBookmark newBk = parent.addBookmark(Application::bookmarkProvider()->bookmarkOwner()->currentTitle(), KUrl(Application::bookmarkProvider()->bookmarkOwner()->currentUrl()), "text-html"); + parent.moveBookmark(newBk, selected); + } + + else + { + parent.addBookmark(Application::bookmarkProvider()->bookmarkOwner()->currentTitle(), KUrl(Application::bookmarkProvider()->bookmarkOwner()->currentUrl()), "text-html"); + } - connect(search, SIGNAL(textChanged(QString)), proxy, SLOT(setFilterFixedString(QString))); - connect(treeView, SIGNAL( activated(QModelIndex) ), this, SLOT( bookmarkActivated(QModelIndex) ) ); + Application::bookmarkProvider()->bookmarkManager()->emitChanged(); } diff --git a/src/bookmarks/bookmarkspanel.h b/src/bookmarks/bookmarkspanel.h index f5376d98..ea33e265 100644 --- a/src/bookmarks/bookmarkspanel.h +++ b/src/bookmarks/bookmarkspanel.h @@ -31,10 +31,17 @@ // Local Includes #include "rekonqprivate_export.h" +#include "application.h" +#include "urltreeview.h" // Qt Includes #include +// KDE Includes +#include +#include +#include + // Forward Declarations class KUrl; class QModelIndex; @@ -49,13 +56,38 @@ public: ~BookmarksPanel(); signals: - void openUrl(const KUrl &); + void openUrl(const KUrl &, const Rekonq::OpenType &); + void itemHovered(const QString &); + void saveExpFinished(const QString &); + void saveRequested(); private slots: - void bookmarkActivated( const QModelIndex &index ); + void contextMenuBk(const QPoint &pos); + void contextMenuBkGroup(const QPoint &pos, const bool emptyGroup = false); + void contextMenuBlank(const QPoint &pos); + void deleteBookmark(); + void openAll(); + void editBookmark(); + void newBookmark(); + void newBookmarkGroup(); + void newSeparator(); + void bookmarkPage(); + void autoExpand(const QModelIndex &root = QModelIndex()); + void onCollapse(const QModelIndex &index); + void onExpand(const QModelIndex &index); + void callAutoExpand(); private: void setup(); + void setupActions(); + void contextMenuSeparator(const QPoint &pos); + KBookmark bookmarkForIndex(const QModelIndex &index); + + UrlTreeView *m_treeView; + QStringList m_expList; + KActionCollection m_ac; + KMenu *menu; + bool expandLock; }; #endif // BOOKMARKSPANEL_H diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp index 95e5ad41..d63c92d3 100644 --- a/src/bookmarks/bookmarkstreemodel.cpp +++ b/src/bookmarks/bookmarkstreemodel.cpp @@ -33,94 +33,112 @@ #include "application.h" #include "bookmarksmanager.h" +// Qt Includes +#include + // KDE includes #include #include -class BookmarksTreeModel::BtmItem +BtmItem::BtmItem(const KBookmark &bm) + : m_parent(0) + , m_kbm(bm) { -public: - BtmItem(const KBookmark &bm) - : m_parent(0) - , m_kbm(bm) - { - } - - - ~BtmItem() - { - qDeleteAll(m_children); - } +} - QVariant data( int role = Qt::DisplayRole ) const - { - if( m_kbm.isNull() ) - return QVariant(); // should only happen for root item +BtmItem::~BtmItem() +{ + qDeleteAll(m_children); +} - if( role == Qt::DisplayRole ) - return m_kbm.text(); - if( role == Qt::DecorationRole ) - return KIcon( m_kbm.icon() ); - if( role == Qt::UserRole ) - return m_kbm.url(); - return QVariant(); +QVariant BtmItem::data( int role ) const +{ + if( m_kbm.isNull() ) + return QVariant(); // should only happen for root item + + if( role == Qt::DisplayRole ) + return m_kbm.text(); + if( role == Qt::DecorationRole ) + return KIcon( m_kbm.icon() ); + if( role == Qt::UserRole ) + return m_kbm.url(); + if( role == Qt::ToolTipRole) + { + QString tooltip = ""; + + if(!m_kbm.text().isEmpty()) + { + tooltip += m_kbm.text(); + } + if(m_kbm.isGroup()) + { + tooltip += " [" + QString::number(childCount()) + " " + i18n("Items") + "]"; + } + if(!m_kbm.url().url().isEmpty()) + { + if(!tooltip.isEmpty()) + tooltip += "\n"; + tooltip += m_kbm.url().url(); + } + return tooltip; } + return QVariant(); +} - int row() const - { - if(m_parent) - return m_parent->m_children.indexOf( const_cast< BtmItem* >( this ) ); - return 0; - } +int BtmItem::row() const +{ + if(m_parent) + return m_parent->m_children.indexOf( const_cast< BtmItem* >( this ) ); + return 0; +} - int childCount() const - { - return m_children.count(); - } +int BtmItem::childCount() const +{ + return m_children.count(); +} - BtmItem* child( int n ) - { - Q_ASSERT(n>=0); - Q_ASSERT(n=0); + Q_ASSERT(nm_parent = this; - m_children << child; - } +void BtmItem::appendChild(BtmItem *child) +{ + if( !child ) + return; + child->m_parent = this; + m_children << child; +} - void clear() - { - qDeleteAll(m_children); - m_children.clear(); - } -private: - BtmItem *m_parent; - QList< BtmItem* > m_children; - KBookmark m_kbm; -}; +void BtmItem::clear() +{ + qDeleteAll(m_children); + m_children.clear(); +} +KBookmark BtmItem::getBkm() const +{ + return m_kbm; +} // ------------------------------------------------------------------------------------- @@ -130,8 +148,8 @@ BookmarksTreeModel::BookmarksTreeModel(QObject *parent) , m_root(0) { resetModel(); + connect( this, SIGNAL(bookmarkChangedFinished()), parent, SLOT(callAutoExpand())); connect( Application::bookmarkProvider()->bookmarkManager(), SIGNAL( changed(QString,QString) ), this, SLOT( bookmarksChanged(QString) ) ); - connect( Application::bookmarkProvider()->bookmarkManager(), SIGNAL( bookmarksChanged(QString) ), this, SLOT( bookmarksChanged(QString) ) ); } @@ -179,8 +197,17 @@ QVariant BookmarksTreeModel::headerData(int section, Qt::Orientation orientation Qt::ItemFlags BookmarksTreeModel::flags(const QModelIndex &index) const { - Q_UNUSED(index) - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + Qt::ItemFlags flags = QAbstractItemModel::flags(index); + + if(!index.isValid()) + return flags | Qt::ItemIsDropEnabled; + + flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; + + if(bookmarkForIndex(index).isGroup()) + flags |= Qt::ItemIsDropEnabled; + + return flags; } @@ -258,30 +285,9 @@ QVariant BookmarksTreeModel::data(const QModelIndex &index, int role) const void BookmarksTreeModel::bookmarksChanged( const QString &groupAddress ) { - if( groupAddress.isEmpty() ) - { - resetModel(); - return; - } - - BtmItem *node = m_root; - QModelIndex nodeIndex; - - QStringList indexChain( groupAddress.split( '/', QString::SkipEmptyParts) ); - foreach( const QString &sIndex, indexChain ) - { - bool ok; - int i = sIndex.toInt( &ok ); - if( !ok ) - break; - - if( i < 0 || i >= node->childCount() ) - break; - - node = node->child( i ); - nodeIndex = index( i, 0, nodeIndex ); - } - emit dataChanged( index( 0, 0, nodeIndex ), index( node->childCount(), 0, nodeIndex ) ); + Q_UNUSED(groupAddress); + resetModel(); + emit bookmarkChangedFinished(); } @@ -322,3 +328,86 @@ void BookmarksTreeModel::populate( BtmItem *node, KBookmarkGroup bmg) bm = bmg.next( bm ); } } + + +KBookmark BookmarksTreeModel::bookmarkForIndex(const QModelIndex index) const +{ + return static_cast(index.internalPointer())->getBkm(); +} + + +Qt::DropActions BookmarksTreeModel::supportedDropActions () const +{ + return Qt::MoveAction; +} + + +QStringList BookmarksTreeModel::mimeTypes () const +{ + return KBookmark::List::mimeDataTypes(); +} + + +QMimeData* BookmarksTreeModel::mimeData( const QModelIndexList & indexes ) const +{ + QMimeData *mimeData = new QMimeData; + + QByteArray addresse = bookmarkForIndex(indexes.first()).address().toLatin1(); + mimeData->setData( "application/rekonq-bookmark", addresse); + bookmarkForIndex(indexes.first()).populateMimeData(mimeData); + + return mimeData; +} + + +bool BookmarksTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex & parent) +{ + if(action == Qt::MoveAction) + { + if(data->hasFormat("application/rekonq-bookmark")) + { + QByteArray addresses = data->data("application/rekonq-bookmark"); + KBookmark bookmark = Application::bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); + + QModelIndex destIndex = index(row, column, parent); + + KBookmark dropDestBookmark; + if(destIndex.isValid()) + dropDestBookmark = bookmarkForIndex(destIndex); + + KBookmarkGroup root = Application::bookmarkProvider()->rootGroup(); + if(parent.isValid()) + root = bookmarkForIndex(parent).toGroup(); + + if(!destIndex.isValid()) + { + if(!parent.isValid()) // Drop into a blank area + { + Application::bookmarkProvider()->rootGroup().deleteBookmark(bookmark); + Application::bookmarkProvider()->rootGroup().addBookmark(bookmark); + } + else // Drop at the last item of the group or directly on the main item of the group + { + root.deleteBookmark(bookmark); + root.addBookmark(bookmark); + } + } + + else + { + if(row == -1) + { + root.deleteBookmark(bookmark); + root.addBookmark(bookmark); + } + else // A classic drop + { + root.moveBookmark(bookmark, root.previous(dropDestBookmark)); + } + } + + Application::bookmarkProvider()->bookmarkManager()->emitChanged(root); + } + } + return true; +} diff --git a/src/bookmarks/bookmarkstreemodel.h b/src/bookmarks/bookmarkstreemodel.h index dfad52ba..4ff19e5f 100644 --- a/src/bookmarks/bookmarkstreemodel.h +++ b/src/bookmarks/bookmarkstreemodel.h @@ -38,6 +38,26 @@ // Qt Includes #include +class BtmItem +{ +public: + BtmItem(const KBookmark &bm); + ~BtmItem(); + QVariant data( int role = Qt::DisplayRole ) const; + int row() const; + int childCount() const; + BtmItem* child( int n ); + BtmItem* parent() const; + void appendChild(BtmItem *child); + void clear(); + KBookmark getBkm() const; + +private: + BtmItem *m_parent; + QList< BtmItem* > m_children; + KBookmark m_kbm; +}; + class REKONQ_TESTS_EXPORT BookmarksTreeModel : public QAbstractItemModel { @@ -48,28 +68,33 @@ public: explicit BookmarksTreeModel(QObject *parent = 0); ~BookmarksTreeModel(); - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - virtual Qt::ItemFlags flags(const QModelIndex &index) const; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual Qt::ItemFlags flags(const QModelIndex &index) const; - virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; virtual QModelIndex parent(const QModelIndex &index) const; - virtual QVariant data(const QModelIndex &index, int role) const; -// virtual bool setData(const QModelIndex &index, const QVariant &value, int role); + virtual QVariant data(const QModelIndex &index, int role) const; -private slots: - void bookmarksChanged( const QString &groupAddress ); + virtual QStringList mimeTypes () const; + virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent); + virtual Qt::DropActions supportedDropActions () const; + virtual QMimeData *mimeData( const QModelIndexList & indexes ) const; -private: - class BtmItem; - BtmItem *m_root; +private slots: + void bookmarksChanged( const QString &groupAddress ); - void resetModel(); +signals: + void bookmarkChangedFinished(); +private: + BtmItem *m_root; + void resetModel(); void setRoot(KBookmarkGroup bmg); - void populate( BtmItem *node, KBookmarkGroup bmg); + void populate( BtmItem *node, KBookmarkGroup bmg); + KBookmark bookmarkForIndex(const QModelIndex index) const; }; #endif // BOOKMARKSTREEMODEL_H diff --git a/src/history/historymodels.cpp b/src/history/historymodels.cpp index 709d0523..736dbcd7 100644 --- a/src/history/historymodels.cpp +++ b/src/history/historymodels.cpp @@ -118,6 +118,8 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const return item.dateTime.date(); case UrlRole: return QUrl(item.url); + case Qt::UserRole: + return KUrl(item.url); case UrlStringRole: return item.url; case Qt::DisplayRole: @@ -144,6 +146,12 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const { return Application::icon(item.url); } + case Qt::ToolTipRole: + QString tooltip = ""; + if(!item.title.isEmpty()) + tooltip = item.title + "\n"; + tooltip += item.dateTime.toString(Qt::SystemLocaleShortDate) + "\n" + item.url; + return tooltip; } return QVariant(); } diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index 8c8eae75..c67594ff 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -46,6 +46,9 @@ // KDE Includes #include #include +#include +#include +#include HistoryPanel::HistoryPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) @@ -70,11 +73,12 @@ void HistoryPanel::setup() QWidget *ui = new QWidget(this); - QTreeView *historyTreeView = new QTreeView(this); - historyTreeView->setUniformRowHeights(true); - historyTreeView->setSelectionBehavior(QAbstractItemView::SelectRows); - historyTreeView->setTextElideMode(Qt::ElideMiddle); - historyTreeView->setAlternatingRowColors(true); + m_treeView = new UrlTreeView(this); + m_treeView->setUniformRowHeights(true); + m_treeView->setSelectionBehavior(QAbstractItemView::SelectRows); + m_treeView->setTextElideMode(Qt::ElideMiddle); + m_treeView->setAlternatingRowColors(true); + m_treeView->header()->hide(); // add search bar QHBoxLayout *hBoxLayout = new QHBoxLayout; @@ -91,7 +95,7 @@ void HistoryPanel::setup() QVBoxLayout *vBoxLayout = new QVBoxLayout; vBoxLayout->setContentsMargins(0, 0, 0, 0); vBoxLayout->addWidget(searchBar); - vBoxLayout->addWidget(historyTreeView); + vBoxLayout->addWidget(m_treeView); // add it to the UI ui->setLayout(vBoxLayout); @@ -103,19 +107,78 @@ void HistoryPanel::setup() TreeProxyModel *treeProxyModel = new TreeProxyModel(this); treeProxyModel->setSourceModel(model); - historyTreeView->setModel(treeProxyModel); - historyTreeView->setExpanded(treeProxyModel->index(0, 0), true); - historyTreeView->header()->hideSection(1); + m_treeView->setModel(treeProxyModel); + m_treeView->setExpanded(treeProxyModel->index(0, 0), true); + m_treeView->header()->hideSection(1); QFontMetrics fm(font()); int header = fm.width(QLatin1Char('m')) * 40; - historyTreeView->header()->resizeSection(0, header); + m_treeView->header()->resizeSection(0, header); connect(search, SIGNAL(textChanged(QString)), treeProxyModel, SLOT(setFilterFixedString(QString))); - connect(historyTreeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(itemActivated(const QModelIndex &))); + connect(m_treeView, SIGNAL(contextMenuItemRequested(const QPoint &)), this, SLOT(contextMenuItem(const QPoint &))); + connect(m_treeView, SIGNAL(contextMenuGroupRequested(const QPoint &)), this, SLOT(contextMenuGroup(const QPoint &))); } +void HistoryPanel::contextMenuItem(const QPoint &pos) +{ + QPoint position = m_treeView->mapToGlobal(pos); + KMenu *menu = new KMenu(this); + KAction* action; + + action = new KAction(KIcon("tab-new"), i18n("Open"), this); + connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInCurrentTab())); + menu->addAction(action); + + action = new KAction(KIcon("tab-new"), i18n("Open in new tab"), this); + connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewTab())); + menu->addAction(action); + + action = new KAction(KIcon("window-new"), i18n("Open in new window"), this); + connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewWindow())); + menu->addAction(action); + + action = new KAction(KIcon("edit-copy"), i18n("Copy link"), this); + connect(action, SIGNAL(triggered()), m_treeView, SLOT(copyToClipboard())); + menu->addAction(action); -void HistoryPanel::itemActivated(const QModelIndex &item) + if (!menu) + return; + menu->popup(position); +} + +void HistoryPanel::contextMenuGroup(const QPoint &pos) { - emit openUrl( item.data(HistoryModel::UrlRole).toUrl() ); + QPoint position = m_treeView->mapToGlobal(pos); + KMenu *menu = new KMenu(this); + KAction* action; + + action = new KAction(KIcon("tab-new"), i18n("Open all Bookmarks"), this); + connect(action, SIGNAL(triggered()), this, SLOT(openAll())); + + menu->addAction(action); + + if (!menu) + return; + menu->popup(position); +} + +void HistoryPanel::openAll() +{ + QModelIndex index = m_treeView->currentIndex(); + if(!index.isValid()) + return; + + QList allChild; + + for(int i = 0; i < index.model()->rowCount(index); i++) + allChild << qVariantValue(index.child(i, 0).data(Qt::UserRole)); + + if(allChild.length() > 8) // 8, a good choice ? + { + if(!(KMessageBox::warningContinueCancel(this, i18n("You are about to open a lot of tabs : %1\nAre you sure ?", QString::number(allChild.length()))) == KMessageBox::Continue)) + return; + } + + for(int i = 0; i < allChild.length(); i++) + emit openUrl(allChild.at(i).url(), Rekonq::SettingOpenTab); } diff --git a/src/history/historypanel.h b/src/history/historypanel.h index 6e6a9162..0c01189c 100644 --- a/src/history/historypanel.h +++ b/src/history/historypanel.h @@ -31,6 +31,8 @@ // Local Includes #include "rekonqprivate_export.h" +#include "application.h" +#include "urltreeview.h" // Qt Includes #include @@ -50,13 +52,17 @@ public: ~HistoryPanel(); signals: - void openUrl(const KUrl &); + void openUrl(const KUrl &, const Rekonq::OpenType &); + void itemHovered(const QString &); private slots: - void itemActivated(const QModelIndex &); + void contextMenuItem(const QPoint &pos); + void contextMenuGroup(const QPoint &pos); + void openAll(); private: void setup(); + UrlTreeView *m_treeView; }; #endif // HISTORYPANEL_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d15ce0c4..93273dc9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -500,7 +500,8 @@ void MainWindow::setupPanels() // STEP 1 // Setup history panel m_historyPanel = new HistoryPanel(i18n("History Panel"), this); - connect(m_historyPanel, SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&))); + connect(m_historyPanel, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType &)), Application::instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType &))); + connect(m_historyPanel, SIGNAL(itemHovered(QString)), this, SLOT(notifyMessage(QString))); connect(m_historyPanel, SIGNAL(destroyed()), Application::instance(), SLOT(saveConfiguration())); addDockWidget(Qt::LeftDockWidgetArea, m_historyPanel); @@ -514,7 +515,8 @@ void MainWindow::setupPanels() // STEP 2 // Setup bookmarks panel m_bookmarksPanel = new BookmarksPanel(i18n("Bookmarks Panel"), this); - connect(m_bookmarksPanel, SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&))); + connect(m_bookmarksPanel, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType &)), Application::instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType &))); + connect(m_bookmarksPanel, SIGNAL(itemHovered(QString)), this, SLOT(notifyMessage(QString))); connect(m_bookmarksPanel, SIGNAL(destroyed()), Application::instance(), SLOT(saveConfiguration())); addDockWidget(Qt::LeftDockWidgetArea, m_bookmarksPanel); -- cgit v1.2.1 From c3a78d70b23ff4bdc2faec12c97b982a06c96986 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Tue, 23 Mar 2010 23:54:50 +0100 Subject: Add missing files --- src/urltreeview.cpp | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/urltreeview.h | 69 +++++++++++++++++++ 2 files changed, 264 insertions(+) create mode 100644 src/urltreeview.cpp create mode 100644 src/urltreeview.h (limited to 'src') diff --git a/src/urltreeview.cpp b/src/urltreeview.cpp new file mode 100644 index 00000000..b88dc971 --- /dev/null +++ b/src/urltreeview.cpp @@ -0,0 +1,195 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 by Yoann Laissus +* +* +* 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +// Self Includes +#include "urltreeview.h" + +// Local Includes +#include "application.h" + +// Qt Includes +#include +#include + + +UrlTreeView::UrlTreeView(QWidget *parent) + : QTreeView(parent) +{ + connect(this, SIGNAL(itemHovered(const QString &)), parent, SIGNAL(itemHovered(const QString &))); + connect(this, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType)), parent, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType))); + setMouseTracking(true); + setExpandsOnDoubleClick(false); +} + + +UrlTreeView::~UrlTreeView() +{ +} + + +void UrlTreeView::mousePressEvent(QMouseEvent *event) +{ + const QModelIndex index = indexAt(event->pos()); + bool expanded = isExpanded(index); + + QTreeView::mousePressEvent(event); + + // A change of an item expansion is handle by mouseReleaseEvent() + // So toggle again the item + if(expanded != isExpanded(index)) + setExpanded(index, !isExpanded(index)); + + if(!index.isValid()) + { + clearSelection(); + setCurrentIndex(QModelIndex()); + + if(event->button() == Qt::RightButton) + emit contextMenuEmptyRequested(event->pos()); + return; + } + + if(event->button() == Qt::RightButton) + { + if(index.model()->rowCount(index) == 0) + { + // An empty group needs to be handle by the panels + emit contextMenuItemRequested(event->pos()); + } + else + { + emit contextMenuGroupRequested(event->pos()); + } + } +} + + +void UrlTreeView::mouseReleaseEvent(QMouseEvent *event) +{ + QTreeView::mouseReleaseEvent(event); + + const QModelIndex index = indexAt(event->pos()); + if(!index.isValid()) + return; + + if(event->button() == Qt::MidButton) + validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::NewCurrentTab); + + else if(event->button() == Qt::LeftButton) + { + if(index.model()->rowCount(index) == 0) + validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); + else + setExpanded(index, !isExpanded(index)); + } +} + + +void UrlTreeView::keyPressEvent(QKeyEvent *event) +{ + QTreeView::keyPressEvent(event); + QModelIndex index = currentIndex(); + + if(!index.isValid()) + return; + + if(event->key() == Qt::Key_Return) + { + if(index.model()->rowCount(index) == 0) + validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); + else + setExpanded(index, !isExpanded(index)); + } + + else if(event->key() == Qt::Key_Delete) + { + emit delKeyPressed(); + } +} + + +void UrlTreeView::validOpenUrl(const KUrl &url, Rekonq::OpenType openType) +{ + // To workaround a crash when the url is about:blank + if(url.url() == "about:blank") + emit openUrl(KUrl("about:home"), openType); + else + emit openUrl(url, openType); +} + + +void UrlTreeView::mouseMoveEvent(QMouseEvent *event) +{ + QTreeView::mouseMoveEvent(event); + const QModelIndex index = indexAt(event->pos()); + if(!index.isValid()) + { + emit itemHovered(""); + return; + } + emit itemHovered(qVariantValue< KUrl >(index.data(Qt::UserRole)).url()); +} + + +void UrlTreeView::openInCurrentTab() +{ + QModelIndex index = currentIndex(); + if(!index.isValid()) + return; + + validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); +} + + +void UrlTreeView::copyToClipboard() +{ + QModelIndex index = currentIndex(); + if(!index.isValid()) + return; + + QClipboard *cb = QApplication::clipboard(); + cb->setText(qVariantValue< KUrl >(index.data(Qt::UserRole)).url()); +} + + +void UrlTreeView::openInNewTab() +{ + QModelIndex index = currentIndex(); + if(!index.isValid()) + return; + + validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::SettingOpenTab); +} + + +void UrlTreeView::openInNewWindow() +{ + QModelIndex index = currentIndex(); + if(!index.isValid()) + return; + + validOpenUrl( qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::NewWindow); +} diff --git a/src/urltreeview.h b/src/urltreeview.h new file mode 100644 index 00000000..cce7a257 --- /dev/null +++ b/src/urltreeview.h @@ -0,0 +1,69 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 by Yoann Laissus +* +* +* 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +#ifndef URLTREEVIEW_H +#define URLTREEVIEW_H + +// Local Includes +#include "application.h" + +// Qt Includes +#include + + +class UrlTreeView : public QTreeView +{ + Q_OBJECT + +public: + UrlTreeView(QWidget *parent = 0); + ~UrlTreeView(); + +signals: + void openUrl(const KUrl &, const Rekonq::OpenType &); + void itemHovered(const QString &); + void delKeyPressed(); + void contextMenuItemRequested(const QPoint &pos); + void contextMenuGroupRequested(const QPoint &pos); + void contextMenuEmptyRequested(const QPoint &pos); + +public slots: + void copyToClipboard(); + void openInCurrentTab(); + void openInNewTab(); + void openInNewWindow(); + +protected: + void mouseReleaseEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void keyPressEvent(QKeyEvent *event); + +private: + void validOpenUrl(const KUrl &url, Rekonq::OpenType openType = Rekonq::CurrentTab); +}; + +#endif // URLTREEVIEW_H -- cgit v1.2.1 From 1b99d40d92a4c1e989a53724ea527b0e7d6388ff Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 24 Mar 2010 09:21:01 +0100 Subject: Cleaning AdblockManager::loadRules slot --- src/adblock/adblockmanager.cpp | 51 +++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp index 66e11277..71412d5d 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -84,7 +84,7 @@ void AdBlockManager::loadSettings(bool checkUpdateDate) KConfigGroup rulesGroup( config, "rules" ); QStringList rules; rules = rulesGroup.readEntry( "local-rules" , QStringList() ); - loadRules( rules ); + loadRules(rules); // ---------------------------------------------------------- @@ -115,26 +115,35 @@ void AdBlockManager::loadRules(const QStringList &rules) foreach(const QString &stringRule, rules) { // ! rules are comments - if( !stringRule.startsWith('!') && !stringRule.startsWith('[') && !stringRule.isEmpty() ) - { - // white rules - if( stringRule.startsWith( QLatin1String("@@") ) ) - { - AdBlockRule rule( stringRule.mid(2) ); - _whiteList << rule; - continue; - } - - // hide (CSS) rules - if( stringRule.startsWith( QLatin1String("##") ) ) - { - _hideList << stringRule.mid(2); - continue; - } - - AdBlockRule rule( stringRule ); - _blackList << rule; + if( stringRule.startsWith('!') ) + continue; + + // [ rules are ABP infos + if( stringRule.startsWith('[') ) + continue; + + // empty rules are just dangerous.. + // (an empty rule in whitelist allows all, in blacklist blocks all..) + if( stringRule.isEmpty() ) + continue; + + // white rules + if( stringRule.startsWith( QLatin1String("@@") ) ) + { + AdBlockRule rule( stringRule.mid(2) ); + _whiteList << rule; + continue; } + + // hide (CSS) rules + if( stringRule.startsWith( QLatin1String("##") ) ) + { + _hideList << stringRule.mid(2); + continue; + } + + AdBlockRule rule( stringRule ); + _blackList << rule; } } @@ -182,7 +191,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request) void AdBlockManager::applyHidingRules(WebPage *page) { - if(!page || !page->mainFrame()) + if(!page) return; if (!_isAdblockEnabled) -- cgit v1.2.1 From 288b838f75f91205d81d5d46201eae90e8abd51a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 24 Mar 2010 10:51:58 +0100 Subject: This commit should finally fix settings handling --- src/mainwindow.cpp | 14 +++++++++----- src/settings/adblockwidget.cpp | 3 +++ src/settings/networkwidget.cpp | 3 +++ src/settings/settingsdialog.cpp | 6 ++++++ 4 files changed, 21 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d15ce0c4..68469cdd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -543,6 +543,11 @@ void MainWindow::setupPanels() void MainWindow::updateConfiguration() { + kDebug() << "======================================================================================================================"; + kDebug() << "======================================================================================================================"; + kDebug() << "======================================================================================================================"; + kDebug() << "======================================================================================================================"; + // ============== General ================== m_view->updateTabBar(); @@ -639,14 +644,13 @@ void MainWindow::preferences() return; // we didn't find an instance of this dialog, so lets create it - QWeakPointer s = new SettingsDialog(this); + QPointer s = new SettingsDialog(this); // keep us informed when the user changes settings - connect(s.data(), SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration())); + connect(s, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration())); - s.data()->exec(); - delete s.data(); - s.clear(); + s->exec(); + delete s; } diff --git a/src/settings/adblockwidget.cpp b/src/settings/adblockwidget.cpp index 471f57f0..39df2c36 100644 --- a/src/settings/adblockwidget.cpp +++ b/src/settings/adblockwidget.cpp @@ -174,6 +174,9 @@ void AdBlockWidget::save() ReKonfig::setAdBlockEnabled( checkEnableAdblock->isChecked() ); ReKonfig::setHideAdsEnabled( checkHideAds->isChecked() ); ReKonfig::setUpdateInterval( spinBox->value() ); + + _changed = false; + emit changed(false); } diff --git a/src/settings/networkwidget.cpp b/src/settings/networkwidget.cpp index 2f5948cf..54f6e068 100644 --- a/src/settings/networkwidget.cpp +++ b/src/settings/networkwidget.cpp @@ -82,6 +82,9 @@ void NetworkWidget::save() _cookiesModule->save(); _proxyModule->save(); _cacheModule->save(); + + _changed = false; + emit changed(false); } diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index 08d5ca6e..35f753d3 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -199,11 +199,17 @@ void SettingsDialog::readConfig() // we need this function to SAVE settings in rc file.. void SettingsDialog::saveSettings() { + if (!hasChanged()) + return; + ReKonfig::self()->writeConfig(); d->ebrowsingModule->save(); d->shortcutsEditor->save(); d->adBlockWidg->save(); d->networkWidg->save(); + + updateButtons(); + emit settingsChanged("ReKonfig"); } -- cgit v1.2.1 From 9a7a4066e20524efd337011ba868f1f29855f754 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 24 Mar 2010 15:42:48 +0100 Subject: WebPage API cleaning --- src/webpage.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/webpage.h b/src/webpage.h index 42d5f586..a3e58dc1 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -61,7 +61,6 @@ public: void showSSLInfo(); public slots: - void manageNetworkErrors(QNetworkReply *reply); virtual void downloadRequest(const QNetworkRequest &request); void downloadAllContentsWithKGet(); @@ -76,13 +75,13 @@ protected Q_SLOTS: virtual void handleUnsupportedContent(QNetworkReply *reply); private slots: + void manageNetworkErrors(QNetworkReply *reply); void loadFinished(bool); private: QString errorPage(QNetworkReply *); ProtocolHandler _protHandler; - WebSslInfo _sslInfo; }; -- cgit v1.2.1 From fb54d4da487fe87636fb8be042df752702d8051b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 25 Mar 2010 12:04:11 +0100 Subject: Fixed a regression (history NOT modified) introduced with commit 29e095b81d2. Ehi guys, please take FULL attention, modifying working code.. --- src/mainwindow.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 68469cdd..6a17d1b8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1009,12 +1009,19 @@ void MainWindow::openPrevious(Qt::MouseButtons btn) QWebHistory *history = currentTab()->view()->history(); if (history->canGoBack()) { - KUrl back = history->backItem().url(); if(btn == Qt::MidButton) + { + KUrl back = history->backItem().url(); Application::instance()->loadUrl(back, Rekonq::SettingOpenTab); + } else - Application::instance()->loadUrl(back); + { + history->goToItem(history->backItem()); + } + + updateActions(); } + } @@ -1023,11 +1030,16 @@ void MainWindow::openNext(Qt::MouseButtons btn) QWebHistory *history = currentTab()->view()->history(); if (history->canGoForward()) { - KUrl next = history->forwardItem().url(); if(btn == Qt::MidButton) + { + KUrl next = history->forwardItem().url(); Application::instance()->loadUrl(next, Rekonq::SettingOpenTab); + } else - Application::instance()->loadUrl(next); + { + history->goToItem(history->forwardItem()); + } + updateActions(); } } -- cgit v1.2.1 From 9ede70edadea14f3a1ee4d66ca03ec20a6133f72 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Thu, 25 Mar 2010 12:22:04 +0100 Subject: Add tests for the bookmark before toGroup() --- src/bookmarks/bookmarkspanel.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index c50ebcdb..fdf1b3d8 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -157,13 +157,16 @@ void BookmarksPanel::autoExpand(const QModelIndex &root) { int count = m_treeView->model()->rowCount(root); - QModelIndex temp; + QModelIndex index; for(int i = 0; i < count; i++) { - temp = m_treeView->model()->index(i,0,root); - m_treeView->setExpanded(temp, bookmarkForIndex(temp).toGroup().isOpen()); - autoExpand(temp); + index = m_treeView->model()->index(i, 0, root); + if(index.isValid() && bookmarkForIndex(index).isGroup()) + { + m_treeView->setExpanded(index, bookmarkForIndex(index).toGroup().isOpen()); + autoExpand(index); + } } } @@ -369,7 +372,7 @@ void BookmarksPanel::editBookmark() void BookmarksPanel::openAll() { QModelIndex index = m_treeView->currentIndex(); - if(!index.isValid()) + if(!index.isValid() || !bookmarkForIndex(index).isGroup()) return; QList allChild = bookmarkForIndex(index).toGroup().groupUrlList(); -- cgit v1.2.1 From 860934af2c429c9676e8a6ad5fa595cfd405d164 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 26 Mar 2010 17:32:16 +0100 Subject: This commit lets rekonq embed parts instead of krunning them DISCLAIMER: This code really A LOT of testing. Not for the code itself, but for the parts it lets rekonq use. I'm experiencing a lot of crashes with the Dragon Part, in example. --- src/webpage.cpp | 19 ++++++++++++++++--- src/webpage.h | 2 +- src/webpluginfactory.cpp | 8 +------- src/webpluginfactory.h | 1 - 4 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/webpage.cpp b/src/webpage.cpp index 06e733b0..71cc8be4 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -271,9 +271,22 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) } } // case KParts::BrowserRun::Embed - KUrl::List list; - list.append(url); - KRun::run(*offer,url,0); + QString html; + html += ""; + html += ""; + html += ""; + html += url.pathOrUrl(); + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + + mainFrame()->setHtml(html, url); } } diff --git a/src/webpage.h b/src/webpage.h index a3e58dc1..abc9833c 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -80,7 +80,7 @@ private slots: private: QString errorPage(QNetworkReply *); - + ProtocolHandler _protHandler; WebSslInfo _sslInfo; }; diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index 9e4b8ba3..79a36aa0 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -47,12 +47,6 @@ WebPluginFactory::WebPluginFactory(QObject *parent) } -WebPluginFactory::~WebPluginFactory() -{ -} - - - void WebPluginFactory::setLoadClickToFlash(bool load) { _loadClickToFlash = load; @@ -69,7 +63,7 @@ QObject *WebPluginFactory::create(const QString &mimeType, switch( ReKonfig::pluginsEnabled() ) { case 0: - kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones..."; + kDebug() << "No plugins found for" << mimeType << ". Falling back to KDEWebKit ones..."; return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); case 1: diff --git a/src/webpluginfactory.h b/src/webpluginfactory.h index 9e5028b2..85122d56 100644 --- a/src/webpluginfactory.h +++ b/src/webpluginfactory.h @@ -46,7 +46,6 @@ Q_OBJECT public: WebPluginFactory(QObject *parent); - ~WebPluginFactory(); virtual QObject *create(const QString &mimeType, const QUrl &url, -- cgit v1.2.1 From 632389517ca496031bb1cbe468d904884961bf57 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sat, 27 Mar 2010 19:04:11 +0100 Subject: - Fix a crash when the cancel button of the add bookmark menu is clicked - Use the same behaviour for delete bookmark as the toolbar - Some strings changed - Keep the selection of a folder when it's expanded/collapsed - Fix the name of some methods and properties - Code cleaned a bit --- src/bookmarks/bookmarkspanel.cpp | 153 +++++++++++++++++++---------------- src/bookmarks/bookmarkspanel.h | 19 ++--- src/bookmarks/bookmarkstreemodel.cpp | 24 ++++-- src/bookmarks/bookmarkstreemodel.h | 7 +- src/urltreeview.cpp | 6 +- 5 files changed, 119 insertions(+), 90 deletions(-) (limited to 'src') diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index fdf1b3d8..c5c2f548 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -55,8 +55,7 @@ BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::Window : QDockWidget(title, parent, flags), m_treeView(new UrlTreeView(this)), m_ac(new KActionCollection(this)), - menu(new KMenu(this)), - expandLock(false) + m_loadingState(false) { setup(); setupActions(); @@ -119,41 +118,41 @@ void BookmarksPanel::setup() connect(m_treeView, SIGNAL(collapsed(const QModelIndex &)), this, SLOT(onCollapse(const QModelIndex &))); connect(m_treeView, SIGNAL(expanded(const QModelIndex &)), this, SLOT(onExpand(const QModelIndex &))); connect(search, SIGNAL(textChanged(const QString &)), proxy, SLOT(setFilterFixedString(const QString &))); - callAutoExpand(); + loadFoldedState(); } void BookmarksPanel::onCollapse(const QModelIndex &index) { - if(expandLock) + if(m_loadingState) return; KBookmark bookmark = bookmarkForIndex(index); bookmark.internalElement().setAttribute("folded", "yes"); - Application::bookmarkProvider()->bookmarkManager()->emitChanged(); + emit saveOnlyRequested(); } void BookmarksPanel::onExpand(const QModelIndex &index) { - if(expandLock) + if(m_loadingState) return; KBookmark bookmark = bookmarkForIndex(index); bookmark.internalElement().setAttribute("folded", "no"); - Application::bookmarkProvider()->bookmarkManager()->emitChanged(); + emit saveOnlyRequested(); } -void BookmarksPanel::callAutoExpand() +void BookmarksPanel::loadFoldedState() { - expandLock = true; - autoExpand(); - expandLock = false; + m_loadingState = true; + loadFoldedState(QModelIndex()); + m_loadingState = false; } -void BookmarksPanel::autoExpand(const QModelIndex &root) +void BookmarksPanel::loadFoldedState(const QModelIndex &root) { int count = m_treeView->model()->rowCount(root); @@ -165,7 +164,7 @@ void BookmarksPanel::autoExpand(const QModelIndex &root) if(index.isValid() && bookmarkForIndex(index).isGroup()) { m_treeView->setExpanded(index, bookmarkForIndex(index).toGroup().isOpen()); - autoExpand(index); + loadFoldedState(index); } } } @@ -177,47 +176,47 @@ void BookmarksPanel::setupActions() action = new KAction(KIcon("tab-new"), i18n("Open"), this); connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInCurrentTab())); - m_ac.addAction("open", action); + m_ac->addAction("open", action); action = new KAction(KIcon("tab-new"), i18n("Open in New Tab"), this); connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewTab())); - m_ac.addAction("open_tab", action); + m_ac->addAction("open_tab", action); action = new KAction(KIcon("window-new"), i18n("Open in New Window"), this); connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewWindow())); - m_ac.addAction("open_window", action); + m_ac->addAction("open_window", action); - action = new KAction(KIcon("rating"), i18n("Bookmark Page"), this); + action = new KAction(KIcon("rating"), i18n("Bookmark Current Page"), this); connect(action, SIGNAL(triggered()), this, SLOT(bookmarkPage())); - m_ac.addAction("bookmark_page", action); + m_ac->addAction("bookmark_page", action); action = new KAction(KIcon("bookmark-new"), i18n("New Bookmark"), this); connect(action, SIGNAL(triggered()), this, SLOT(newBookmark())); - m_ac.addAction("bookmark_new", action); + m_ac->addAction("bookmark_new", action); action = new KAction(KIcon("folder-new"), i18n("New Bookmark Folder"), this); connect(action, SIGNAL(triggered()), this, SLOT(newBookmarkGroup())); - m_ac.addAction("folder_new", action); + m_ac->addAction("folder_new", action); action = new KAction(KIcon("edit-clear"), i18n("New Separator"), this); connect(action, SIGNAL(triggered()), this, SLOT(newSeparator())); - m_ac.addAction("separator_new", action); + m_ac->addAction("separator_new", action); - action = new KAction(KIcon("edit-copy"), i18n("Copy Link"), this); + action = new KAction(KIcon("edit-copy"), i18n("Copy Link Adress"), this); connect(action, SIGNAL(triggered()), m_treeView, SLOT(copyToClipboard())); - m_ac.addAction("copy", action); + m_ac->addAction("copy", action); - action = new KAction(KIcon("edit-delete"), i18n("Delete"), this); + action = new KAction(KIcon("edit-delete"), i18n("Delete Bookmark"), this); connect(action, SIGNAL(triggered()), this, SLOT(deleteBookmark())); - m_ac.addAction("delete", action); + m_ac->addAction("delete", action); action = new KAction(KIcon("configure"), i18n("Properties"), this); connect(action, SIGNAL(triggered()), this, SLOT(editBookmark())); - m_ac.addAction("properties", action); + m_ac->addAction("properties", action); - action = new KAction(KIcon("tab-new"), i18n("Open all Bookmarks"), this); - connect(action, SIGNAL(triggered()), this, SLOT(openAll())); - m_ac.addAction("open_all", action); + action = new KAction(KIcon("tab-new"), i18n("Open Folder in Tabs"), this); + connect(action, SIGNAL(triggered()), this, SLOT(openFolderInTabs())); + m_ac->addAction("open_all", action); } @@ -238,7 +237,7 @@ void BookmarksPanel::contextMenuBk(const QPoint &pos) { QPoint position = m_treeView->mapToGlobal(pos); QModelIndex index = m_treeView->indexAt(pos); - if(!index.isValid() || expandLock) + if(!index.isValid() || m_loadingState) return; KBookmark selected = bookmarkForIndex(index); @@ -255,27 +254,27 @@ void BookmarksPanel::contextMenuBk(const QPoint &pos) return; } - menu = new KMenu(this); + KMenu *menu = new KMenu(this); - menu->addAction(m_ac.action("open")); - menu->addAction(m_ac.action("open_tab")); - menu->addAction(m_ac.action("open_window")); + menu->addAction(m_ac->action("open")); + menu->addAction(m_ac->action("open_tab")); + menu->addAction(m_ac->action("open_window")); menu->addSeparator(); - menu->addAction(m_ac.action("bookmark_page")); - menu->addAction(m_ac.action("bookmark_new")); - menu->addAction(m_ac.action("folder_new")); - menu->addAction(m_ac.action("separator_new")); + menu->addAction(m_ac->action("bookmark_page")); + menu->addAction(m_ac->action("bookmark_new")); + menu->addAction(m_ac->action("folder_new")); + menu->addAction(m_ac->action("separator_new")); menu->addSeparator(); - menu->addAction(m_ac.action("copy")); + menu->addAction(m_ac->action("copy")); menu->addSeparator(); - menu->addAction(m_ac.action("delete")); - menu->addAction(m_ac.action("properties")); + menu->addAction(m_ac->action("delete")); + menu->addAction(m_ac->action("properties")); menu->popup(position); } @@ -283,27 +282,27 @@ void BookmarksPanel::contextMenuBk(const QPoint &pos) void BookmarksPanel::contextMenuBkGroup(const QPoint &pos, bool emptyGroup) { - if(expandLock) + if(m_loadingState) return; QPoint position = m_treeView->mapToGlobal(pos); - menu = new KMenu(this); + KMenu *menu = new KMenu(this); if(!emptyGroup) { - menu->addAction(m_ac.action("open_all")); + menu->addAction(m_ac->action("open_all")); menu->addSeparator(); } - menu->addAction(m_ac.action("bookmark_page")); - menu->addAction(m_ac.action("bookmark_new")); - menu->addAction(m_ac.action("folder_new")); - menu->addAction(m_ac.action("separator_new")); + menu->addAction(m_ac->action("bookmark_page")); + menu->addAction(m_ac->action("bookmark_new")); + menu->addAction(m_ac->action("folder_new")); + menu->addAction(m_ac->action("separator_new")); menu->addSeparator(); - menu->addAction(m_ac.action("delete")); - menu->addAction(m_ac.action("properties")); + menu->addAction(m_ac->action("delete")); + menu->addAction(m_ac->action("properties")); menu->popup(position); } @@ -312,16 +311,16 @@ void BookmarksPanel::contextMenuBkGroup(const QPoint &pos, bool emptyGroup) void BookmarksPanel::contextMenuSeparator(const QPoint &pos) { QPoint position = m_treeView->mapToGlobal(pos); - menu = new KMenu(this); + KMenu *menu = new KMenu(this); - menu->addAction(m_ac.action("bookmark_page")); - menu->addAction(m_ac.action("bookmark_new")); - menu->addAction(m_ac.action("folder_new")); - menu->addAction(m_ac.action("separator_new")); + menu->addAction(m_ac->action("bookmark_page")); + menu->addAction(m_ac->action("bookmark_new")); + menu->addAction(m_ac->action("folder_new")); + menu->addAction(m_ac->action("separator_new")); menu->addSeparator(); - menu->addAction(m_ac.action("delete")); + menu->addAction(m_ac->action("delete")); menu->popup(position); } @@ -330,12 +329,12 @@ void BookmarksPanel::contextMenuSeparator(const QPoint &pos) void BookmarksPanel::contextMenuBlank(const QPoint &pos) { QPoint position = m_treeView->mapToGlobal(pos); - menu = new KMenu(this); + KMenu *menu = new KMenu(this); - menu->addAction(m_ac.action("bookmark_page")); - menu->addAction(m_ac.action("bookmark_new")); - menu->addAction(m_ac.action("folder_new")); - menu->addAction(m_ac.action("separator_new")); + menu->addAction(m_ac->action("bookmark_page")); + menu->addAction(m_ac->action("bookmark_new")); + menu->addAction(m_ac->action("folder_new")); + menu->addAction(m_ac->action("separator_new")); menu->popup(position); } @@ -347,10 +346,22 @@ void BookmarksPanel::deleteBookmark() if(!index.isValid()) return; - KBookmark selected = bookmarkForIndex(index); - KBookmarkGroup parent = selected.parentGroup(); + KBookmark bm = bookmarkForIndex(index); + bool folder = bm.isGroup(); + + if (KMessageBox::warningContinueCancel( + QApplication::activeWindow(), + folder ? i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", bm.text()) + : i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bm.text()), + folder ? i18n("Bookmark Folder Deletion") + : i18n("Bookmark Deletion"), + KStandardGuiItem::del()) + != KMessageBox::Continue + ) + return; - parent.deleteBookmark(selected); + + bm.parentGroup().deleteBookmark(bm); Application::instance()->bookmarkProvider()->bookmarkManager()->emitChanged(); } @@ -369,7 +380,7 @@ void BookmarksPanel::editBookmark() } -void BookmarksPanel::openAll() +void BookmarksPanel::openFolderInTabs() { QModelIndex index = m_treeView->currentIndex(); if(!index.isValid() || !bookmarkForIndex(index).isGroup()) @@ -402,18 +413,22 @@ void BookmarksPanel::newBookmark() selected = bookmarkForIndex(index); if(selected.isGroup()) - newBk = dialog->addBookmark("New bookmark", KUrl("www.kde.org"), selected); + newBk = dialog->addBookmark("New bookmark", KUrl(), selected); else - newBk = dialog->addBookmark("New bookmark", KUrl("www.kde.org"), selected.parentGroup()); + newBk = dialog->addBookmark("New bookmark", KUrl(), selected.parentGroup()); } else { - newBk = dialog->addBookmark("New bookmark", KUrl("www.kde.org")); + newBk = dialog->addBookmark("New bookmark", KUrl()); } delete dialog; + // a click on cancel + if(newBk.isNull()) + return; + // addBookmark already added the bookmark, but without the default favicon KBookmarkGroup parent = newBk.parentGroup(); parent.deleteBookmark(newBk); @@ -493,7 +508,7 @@ void BookmarksPanel::newSeparator() } -void BookmarksPanel::bookmarkPage() +void BookmarksPanel::bookmarkCurrentPage() { QModelIndex index = m_treeView->currentIndex(); KBookmarkGroup parent = Application::bookmarkProvider()->rootGroup(); diff --git a/src/bookmarks/bookmarkspanel.h b/src/bookmarks/bookmarkspanel.h index ea33e265..be52804f 100644 --- a/src/bookmarks/bookmarkspanel.h +++ b/src/bookmarks/bookmarkspanel.h @@ -40,7 +40,6 @@ // KDE Includes #include #include -#include // Forward Declarations class KUrl; @@ -58,24 +57,24 @@ public: signals: void openUrl(const KUrl &, const Rekonq::OpenType &); void itemHovered(const QString &); - void saveExpFinished(const QString &); - void saveRequested(); + void saveOnlyRequested(); private slots: void contextMenuBk(const QPoint &pos); void contextMenuBkGroup(const QPoint &pos, const bool emptyGroup = false); void contextMenuBlank(const QPoint &pos); void deleteBookmark(); - void openAll(); + void openFolderInTabs(); void editBookmark(); void newBookmark(); void newBookmarkGroup(); void newSeparator(); - void bookmarkPage(); - void autoExpand(const QModelIndex &root = QModelIndex()); void onCollapse(const QModelIndex &index); void onExpand(const QModelIndex &index); - void callAutoExpand(); + void bookmarkCurrentPage(); + void loadFoldedState(const QModelIndex &root); + void loadFoldedState(); + private: void setup(); @@ -84,10 +83,8 @@ private: KBookmark bookmarkForIndex(const QModelIndex &index); UrlTreeView *m_treeView; - QStringList m_expList; - KActionCollection m_ac; - KMenu *menu; - bool expandLock; + KActionCollection *m_ac; + bool m_loadingState; }; #endif // BOOKMARKSPANEL_H diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp index d63c92d3..836401a6 100644 --- a/src/bookmarks/bookmarkstreemodel.cpp +++ b/src/bookmarks/bookmarkstreemodel.cpp @@ -148,8 +148,9 @@ BookmarksTreeModel::BookmarksTreeModel(QObject *parent) , m_root(0) { resetModel(); - connect( this, SIGNAL(bookmarkChangedFinished()), parent, SLOT(callAutoExpand())); - connect( Application::bookmarkProvider()->bookmarkManager(), SIGNAL( changed(QString,QString) ), this, SLOT( bookmarksChanged(QString) ) ); + connect( this, SIGNAL(bookmarksUpdated()), parent, SLOT(loadFoldedState())); + connect( Application::bookmarkProvider()->bookmarkManager(), SIGNAL( changed(QString,QString) ), this, SLOT( bookmarksChanged() ) ); + connect( parent, SIGNAL(saveOnlyRequested()), this, SLOT(saveOnly()) ); } @@ -283,11 +284,10 @@ QVariant BookmarksTreeModel::data(const QModelIndex &index, int role) const } -void BookmarksTreeModel::bookmarksChanged( const QString &groupAddress ) +void BookmarksTreeModel::bookmarksChanged() { - Q_UNUSED(groupAddress); resetModel(); - emit bookmarkChangedFinished(); + emit bookmarksUpdated(); } @@ -336,6 +336,20 @@ KBookmark BookmarksTreeModel::bookmarkForIndex(const QModelIndex index) const } +void BookmarksTreeModel::saveOnly() +{ + disconnect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(QString,QString)), this, SLOT(bookmarksChanged())); + connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(QString,QString)), this, SLOT(reconnectManager())); + Application::bookmarkProvider()->bookmarkManager()->emitChanged(); +} + + +void BookmarksTreeModel::reconnectManager() +{ + connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL( changed(QString,QString) ), this, SLOT(bookmarksChanged())); +} + + Qt::DropActions BookmarksTreeModel::supportedDropActions () const { return Qt::MoveAction; diff --git a/src/bookmarks/bookmarkstreemodel.h b/src/bookmarks/bookmarkstreemodel.h index 4ff19e5f..b312ab2d 100644 --- a/src/bookmarks/bookmarkstreemodel.h +++ b/src/bookmarks/bookmarkstreemodel.h @@ -84,13 +84,16 @@ public: virtual QMimeData *mimeData( const QModelIndexList & indexes ) const; private slots: - void bookmarksChanged( const QString &groupAddress ); + void bookmarksChanged(); + void saveOnly(); + void reconnectManager(); signals: - void bookmarkChangedFinished(); + void bookmarksUpdated(); private: BtmItem *m_root; + void resetModel(); void setRoot(KBookmarkGroup bmg); void populate( BtmItem *node, KBookmarkGroup bmg); diff --git a/src/urltreeview.cpp b/src/urltreeview.cpp index b88dc971..507a7973 100644 --- a/src/urltreeview.cpp +++ b/src/urltreeview.cpp @@ -74,7 +74,7 @@ void UrlTreeView::mousePressEvent(QMouseEvent *event) if(event->button() == Qt::RightButton) { - if(index.model()->rowCount(index) == 0) + if(model()->rowCount(index) == 0) { // An empty group needs to be handle by the panels emit contextMenuItemRequested(event->pos()); @@ -100,7 +100,7 @@ void UrlTreeView::mouseReleaseEvent(QMouseEvent *event) else if(event->button() == Qt::LeftButton) { - if(index.model()->rowCount(index) == 0) + if(model()->rowCount(index) == 0) validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); else setExpanded(index, !isExpanded(index)); @@ -118,7 +118,7 @@ void UrlTreeView::keyPressEvent(QKeyEvent *event) if(event->key() == Qt::Key_Return) { - if(index.model()->rowCount(index) == 0) + if(model()->rowCount(index) == 0) validOpenUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); else setExpanded(index, !isExpanded(index)); -- cgit v1.2.1 From f5a40919219ef5210598a87054af34b331ebe31e Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sat, 27 Mar 2010 20:08:59 +0100 Subject: Fix the bookmarkCurrentPage slot name --- src/bookmarks/bookmarkspanel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index c5c2f548..a1bc4f51 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -187,7 +187,7 @@ void BookmarksPanel::setupActions() m_ac->addAction("open_window", action); action = new KAction(KIcon("rating"), i18n("Bookmark Current Page"), this); - connect(action, SIGNAL(triggered()), this, SLOT(bookmarkPage())); + connect(action, SIGNAL(triggered()), this, SLOT(bookmarkCurrentPage())); m_ac->addAction("bookmark_page", action); action = new KAction(KIcon("bookmark-new"), i18n("New Bookmark"), this); -- cgit v1.2.1 From a3020fb4be790a79af806b4d22b5d9bdc790ee7f Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sat, 27 Mar 2010 20:20:12 +0100 Subject: Fix missing strings on the history panel --- src/bookmarks/bookmarkspanel.cpp | 2 +- src/history/historypanel.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index a1bc4f51..c249566d 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -202,7 +202,7 @@ void BookmarksPanel::setupActions() connect(action, SIGNAL(triggered()), this, SLOT(newSeparator())); m_ac->addAction("separator_new", action); - action = new KAction(KIcon("edit-copy"), i18n("Copy Link Adress"), this); + action = new KAction(KIcon("edit-copy"), i18n("Copy Link Address"), this); connect(action, SIGNAL(triggered()), m_treeView, SLOT(copyToClipboard())); m_ac->addAction("copy", action); diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index c67594ff..a45e3508 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -129,15 +129,15 @@ void HistoryPanel::contextMenuItem(const QPoint &pos) connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInCurrentTab())); menu->addAction(action); - action = new KAction(KIcon("tab-new"), i18n("Open in new tab"), this); + action = new KAction(KIcon("tab-new"), i18n("Open in New Tab"), this); connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewTab())); menu->addAction(action); - action = new KAction(KIcon("window-new"), i18n("Open in new window"), this); + action = new KAction(KIcon("window-new"), i18n("Open in New Window"), this); connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewWindow())); menu->addAction(action); - action = new KAction(KIcon("edit-copy"), i18n("Copy link"), this); + action = new KAction(KIcon("edit-copy"), i18n("Copy Link Address"), this); connect(action, SIGNAL(triggered()), m_treeView, SLOT(copyToClipboard())); menu->addAction(action); @@ -152,7 +152,7 @@ void HistoryPanel::contextMenuGroup(const QPoint &pos) KMenu *menu = new KMenu(this); KAction* action; - action = new KAction(KIcon("tab-new"), i18n("Open all Bookmarks"), this); + action = new KAction(KIcon("tab-new"), i18n("Open Folder in Tabs"), this); connect(action, SIGNAL(triggered()), this, SLOT(openAll())); menu->addAction(action); -- cgit v1.2.1 From 6183e8e1c21807299f04f4e84c43486cf684f140 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sat, 27 Mar 2010 22:17:20 +0100 Subject: - Remove the Add Bookmark action from the different context menus - Add Bookmark Here now add the bookmark on top of the selected item - ctor initialisation for the UrlTreeView of the history panel --- src/bookmarks/bookmarkspanel.cpp | 55 ++-------------------------------------- src/bookmarks/bookmarkspanel.h | 1 - src/history/historypanel.cpp | 4 +-- 3 files changed, 4 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index c249566d..2f530c6c 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -186,14 +186,10 @@ void BookmarksPanel::setupActions() connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewWindow())); m_ac->addAction("open_window", action); - action = new KAction(KIcon("rating"), i18n("Bookmark Current Page"), this); + action = new KAction(KIcon("bookmark-new"), i18n("Add Bookmark Here"), this); connect(action, SIGNAL(triggered()), this, SLOT(bookmarkCurrentPage())); m_ac->addAction("bookmark_page", action); - action = new KAction(KIcon("bookmark-new"), i18n("New Bookmark"), this); - connect(action, SIGNAL(triggered()), this, SLOT(newBookmark())); - m_ac->addAction("bookmark_new", action); - action = new KAction(KIcon("folder-new"), i18n("New Bookmark Folder"), this); connect(action, SIGNAL(triggered()), this, SLOT(newBookmarkGroup())); m_ac->addAction("folder_new", action); @@ -263,7 +259,6 @@ void BookmarksPanel::contextMenuBk(const QPoint &pos) menu->addSeparator(); menu->addAction(m_ac->action("bookmark_page")); - menu->addAction(m_ac->action("bookmark_new")); menu->addAction(m_ac->action("folder_new")); menu->addAction(m_ac->action("separator_new")); @@ -295,7 +290,6 @@ void BookmarksPanel::contextMenuBkGroup(const QPoint &pos, bool emptyGroup) } menu->addAction(m_ac->action("bookmark_page")); - menu->addAction(m_ac->action("bookmark_new")); menu->addAction(m_ac->action("folder_new")); menu->addAction(m_ac->action("separator_new")); @@ -314,7 +308,6 @@ void BookmarksPanel::contextMenuSeparator(const QPoint &pos) KMenu *menu = new KMenu(this); menu->addAction(m_ac->action("bookmark_page")); - menu->addAction(m_ac->action("bookmark_new")); menu->addAction(m_ac->action("folder_new")); menu->addAction(m_ac->action("separator_new")); @@ -332,7 +325,6 @@ void BookmarksPanel::contextMenuBlank(const QPoint &pos) KMenu *menu = new KMenu(this); menu->addAction(m_ac->action("bookmark_page")); - menu->addAction(m_ac->action("bookmark_new")); menu->addAction(m_ac->action("folder_new")); menu->addAction(m_ac->action("separator_new")); @@ -399,49 +391,6 @@ void BookmarksPanel::openFolderInTabs() } -void BookmarksPanel::newBookmark() -{ - QModelIndex index = m_treeView->currentIndex(); - - KBookmark selected; - KBookmark newBk; - - KBookmarkDialog *dialog = Application::bookmarkProvider()->bookmarkOwner()->bookmarkDialog(Application::bookmarkProvider()->bookmarkManager(), QApplication::activeWindow()); - - if(index.isValid()) - { - selected = bookmarkForIndex(index); - - if(selected.isGroup()) - newBk = dialog->addBookmark("New bookmark", KUrl(), selected); - else - newBk = dialog->addBookmark("New bookmark", KUrl(), selected.parentGroup()); - } - - else - { - newBk = dialog->addBookmark("New bookmark", KUrl()); - } - - delete dialog; - - // a click on cancel - if(newBk.isNull()) - return; - - // addBookmark already added the bookmark, but without the default favicon - KBookmarkGroup parent = newBk.parentGroup(); - parent.deleteBookmark(newBk); - newBk.setIcon(("text-html")); - parent.addBookmark(newBk); - - if(index.isValid()) - parent.moveBookmark(newBk, selected); - - Application::bookmarkProvider()->bookmarkManager()->emitChanged(); -} - - void BookmarksPanel::newBookmarkGroup() { QModelIndex index = m_treeView->currentIndex(); @@ -522,7 +471,7 @@ void BookmarksPanel::bookmarkCurrentPage() parent = selected.toGroup(); KBookmark newBk = parent.addBookmark(Application::bookmarkProvider()->bookmarkOwner()->currentTitle(), KUrl(Application::bookmarkProvider()->bookmarkOwner()->currentUrl()), "text-html"); - parent.moveBookmark(newBk, selected); + parent.moveBookmark(newBk, selected.parentGroup().previous(selected)); } else diff --git a/src/bookmarks/bookmarkspanel.h b/src/bookmarks/bookmarkspanel.h index be52804f..f8528b71 100644 --- a/src/bookmarks/bookmarkspanel.h +++ b/src/bookmarks/bookmarkspanel.h @@ -66,7 +66,6 @@ private slots: void deleteBookmark(); void openFolderInTabs(); void editBookmark(); - void newBookmark(); void newBookmarkGroup(); void newSeparator(); void onCollapse(const QModelIndex &index); diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index a45e3508..03f2b880 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -52,7 +52,8 @@ HistoryPanel::HistoryPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) - : QDockWidget(title, parent, flags) + : QDockWidget(title, parent, flags), + m_treeView(new UrlTreeView(this)) { setup(); setShown(ReKonfig::showHistoryPanel()); @@ -73,7 +74,6 @@ void HistoryPanel::setup() QWidget *ui = new QWidget(this); - m_treeView = new UrlTreeView(this); m_treeView->setUniformRowHeights(true); m_treeView->setSelectionBehavior(QAbstractItemView::SelectRows); m_treeView->setTextElideMode(Qt::ElideMiddle); -- cgit v1.2.1 From 64408ad486db25f0124f934aed55af72f2cd6d39 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 28 Mar 2010 10:12:45 +0200 Subject: update is better than repaint :) --- src/urlbar/urlbar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 718d9f67..189d19fe 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -155,7 +155,7 @@ void UrlBar::setUrl(const QUrl& url) void UrlBar::setProgress(int progress) { m_progress = progress; - repaint(); + update(); } @@ -225,14 +225,14 @@ void UrlBar::loadFinished(bool) { // reset progress bar after small delay m_progress = 0; - QTimer::singleShot(200, this, SLOT(repaint())); + QTimer::singleShot(200, this, SLOT(update())); } void UrlBar::updateProgress(int progress) { m_progress = progress; - repaint(); + update(); } @@ -295,7 +295,7 @@ QLinearGradient UrlBar::generateGradient(const QColor &color, int height) void UrlBar::setBackgroundColor(QColor c) { s_defaultBaseColor = c; - repaint(); + update(); } -- cgit v1.2.1 From 942c55b945443a2e6dd9a2d3660347fc2176630a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 29 Mar 2010 11:47:42 +0200 Subject: This commit merge all our work about new UrlBar. DISCLAIMER: this is far from perfect, but we finally have a good starting point to work on.. :) Jonas Gastal started working on it in the 0.3 times, startin from CompletionBase code .. .. I did some work on another idea, proposing (in code) a new "suggest engine" created from scratch... Lionel Chauvin finally merged our ideas and implemented what you are seeing (and improved it, too!).. - New suggestion items (Firefox style) - a mockup on the known urls (rekonq style) - for now, automatic Google and Wikipedia searches (more coming).. - a beautiful animation :) - quite all rough edges smoothed -------------------------------------------------------- Squashed commit of the following: commit d9cf43da421c7f6c71f78444ff1935c414468b98 commit 9dcb6e18f8a3e9ae8ef1cd1299d47d37393aa6e5 commit 6c4bf2b2040ea20c78c5703f20c6bc88b7e40169 commit 8488df67115d186489f34210b638c150c66f62d3 commit 066ab907661282b1ffa4cf640739c20b4c7b6556 commit c23e23cbca7ab3197c570651a95d3f8fea270d78 commit 60655b0a8685a76e2b8b7a457bfded974bc98b4c commit 9a8817db124b55f501c9e5d3415a975ee6f92d68 commit 61312b6b577a535a4d56758b3bd3ea38812d5139 commit b6a3f4ea12423a063eafa641cedd13b890b9d392 commit 5e8e2f851edb42bc2deed296c26c58c3d7570381 commit 2904d828f71ac8ff46a53e58da8f45b5aa16e7ef --------------------------------------------------------- --- src/CMakeLists.txt | 3 + src/bookmarks/bookmarksmanager.cpp | 14 ++- src/bookmarks/bookmarksmanager.h | 7 ++ src/mainview.cpp | 3 +- src/urlbar/completionwidget.cpp | 242 +++++++++++++++++++++++++++++++++++++ src/urlbar/completionwidget.h | 77 ++++++++++++ src/urlbar/lineedit.cpp | 4 +- src/urlbar/lineedit.h | 12 +- src/urlbar/listitem.cpp | 173 ++++++++++++++++++++++++++ src/urlbar/listitem.h | 59 +++++++++ src/urlbar/urlbar.cpp | 200 +++++++++++++++--------------- src/urlbar/urlbar.h | 28 ++--- src/urlbar/urlresolver.cpp | 177 +++++++++++++++++++++++++++ src/urlbar/urlresolver.h | 72 +++++++++++ 14 files changed, 939 insertions(+), 132 deletions(-) create mode 100644 src/urlbar/completionwidget.cpp create mode 100644 src/urlbar/completionwidget.h create mode 100644 src/urlbar/listitem.cpp create mode 100644 src/urlbar/listitem.h create mode 100644 src/urlbar/urlresolver.cpp create mode 100644 src/urlbar/urlresolver.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0cab993c..a68faa59 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -49,6 +49,9 @@ SET( rekonq_KDEINIT_SRCS #---------------------------------------- urlbar/urlbar.cpp urlbar/lineedit.cpp + urlbar/completionwidget.cpp + urlbar/urlresolver.cpp + urlbar/listitem.cpp ) diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp index 9feed63a..89e39ef8 100644 --- a/src/bookmarks/bookmarksmanager.cpp +++ b/src/bookmarks/bookmarksmanager.cpp @@ -161,7 +161,12 @@ BookmarkProvider::BookmarkProvider(QObject *parent) , m_actionCollection(new KActionCollection(this)) , m_bookmarkMenu(0) , m_bookmarkToolBar(0) + , m_completion(0) { + // take care of the completion object + m_completion = new KCompletion; + m_completion->setOrder( KCompletion::Weighted ); + KUrl bookfile = KUrl("~/.kde/share/apps/konqueror/bookmarks.xml"); // share konqueror bookmarks if (!QFile::exists(bookfile.path())) @@ -222,6 +227,7 @@ void BookmarkProvider::slotBookmarksChanged(const QString &group, const QString return; m_bookmarkToolBar->clear(); // FIXME CRASH + m_completion->clear(); KBookmark bookmark = toolBarGroup.first(); while (!bookmark.isNull()) @@ -287,7 +293,8 @@ KAction *BookmarkProvider::fillBookmarkBar(const KBookmark &bookmark) return a; } else - { + { + m_completion->addItem(bookmark.url().path()); return new KBookmarkAction(bookmark, m_owner, this); } } @@ -297,3 +304,8 @@ KBookmarkGroup BookmarkProvider::rootGroup() { return m_manager->root(); } + +KCompletion *BookmarkProvider::completionObject() const +{ + return m_completion; +} diff --git a/src/bookmarks/bookmarksmanager.h b/src/bookmarks/bookmarksmanager.h index e50148e4..18ff3ef0 100644 --- a/src/bookmarks/bookmarksmanager.h +++ b/src/bookmarks/bookmarksmanager.h @@ -39,6 +39,7 @@ // KDE Includes #include +#include // Forward Declarations class BookmarkProvider; @@ -213,6 +214,11 @@ public: KBookmarkManager *bookmarkManager() { return m_manager; } BookmarkOwner *bookmarkOwner() { return m_owner; } + /** + * @returns the KCompletion object. + */ + KCompletion *completionObject() const; + signals: /** * @short This signal is emitted when an url has to be loaded @@ -247,6 +253,7 @@ private: KActionCollection *m_actionCollection; BookmarkMenu *m_bookmarkMenu; KToolBar *m_bookmarkToolBar; + KCompletion *m_completion; }; #endif diff --git a/src/mainview.cpp b/src/mainview.cpp index f2152364..6643becb 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -242,8 +242,7 @@ void MainView::clear() { // FIXME (the programmer, not the code) // What exactly do we need to clear here? - m_urlBar->clearHistory(); - m_urlBar->clear(); + m_urlBar->clear(); m_recentlyClosedTabs.clear(); } diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp new file mode 100644 index 00000000..42abcb73 --- /dev/null +++ b/src/urlbar/completionwidget.cpp @@ -0,0 +1,242 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +// Self Includes +#include "completionwidget.h" +#include "completionwidget.moc" + +// KDE Includes +#include +#include +#include + +// Qt Includes +#include +#include +#include +#include +#include +#include + +#define MAX_ELEMENTS 9 +#include "application.h" + +CompletionWidget::CompletionWidget( QWidget *parent) +:QFrame( parent, Qt::ToolTip) + , _parent(parent) + , _currentIndex(-1) +{ + QPalette p(palette()); + p.setColor(QPalette::Background, Qt::white); //todo: choose the correct color + setPalette(p); + setFrameStyle(QFrame::Panel); + setLayoutDirection(Qt::LeftToRight); + QVBoxLayout *layout = new QVBoxLayout; + layout->setMargin(0); + setLayout(layout); + +} + + +void CompletionWidget::insertSearchList(const UrlSearchList &list) +{ + _list = list; + int min = MAX_ELEMENTS; + if(list.count() < min) + min = list.count(); + + for(int i = 0; isetObjectName( QString::number(i) ); + layout()->addWidget( suggestion ); + } +} + + +void CompletionWidget::sizeAndPosition() +{ + // size + setFixedHeight(layout()->count() * 44 ); + setFixedWidth( _parent->width() ); + + // position + QPoint p = _parent->mapToGlobal( QPoint(0,0) ); + move(p.x(), p.y() + _parent->height()); +} + + +void CompletionWidget::popup() +{ + down(); + sizeAndPosition(); + if (!isVisible()) + show(); +} + + +void CompletionWidget::up() +{ + // deactivate previous + if(_currentIndex != -1) + { + ListItem *widget = findChild( QString::number(_currentIndex) ); + widget->deactivate(); + } + + if(_currentIndex > 0) + _currentIndex--; + else + _currentIndex=layout()->count()-1; + + // activate "new" current + ListItem *widget = findChild( QString::number(_currentIndex) ); + widget->activate(); +} + +KUrl CompletionWidget::currentUrl() +{ + return _list.at(_currentIndex).url; +} + +void CompletionWidget::down() +{ + // deactivate previous + if(_currentIndex != -1) + { + ListItem *widget = findChild( QString::number(_currentIndex) ); + widget->deactivate(); + } + + if(_currentIndex < _list.count() -1) + _currentIndex++; + else + _currentIndex=0; + + // activate "new" current + ListItem *widget = findChild( QString::number(_currentIndex) ); + widget->activate(); +} + +void CompletionWidget::clear() +{ + QLayoutItem *child; + while ((child = layout()->takeAt(0)) != 0) + { + delete child->widget(); + delete child; + } + _currentIndex = -1; +} + + +bool CompletionWidget::eventFilter( QObject *o, QEvent *e ) +{ + int type = e->type(); + QWidget *wid = qobject_cast(o); + + if (o == this) + { + return false; + } + + //hide conditions of the CompletionWidget + if (wid + && ((wid == _parent && (type == QEvent::Move || type == QEvent::Resize)) + || ((wid->windowFlags() & Qt::Window) + && (type == QEvent::Move || type == QEvent::Hide || type == QEvent::WindowDeactivate) + && wid == _parent->window()) + || (type == QEvent::MouseButtonPress && !isAncestorOf(wid))) + ) + { + hide(); + return false; + } + + //actions on the CompletionWidget + if (wid && wid->isAncestorOf(_parent) && isVisible()) + { + if ( type == QEvent::KeyPress ) + { + QKeyEvent *ev = static_cast( e ); + switch ( ev->key() ) + { + case Qt::Key_Up: + case Qt::Key_Backtab: + if (ev->modifiers() == Qt::NoButton || (ev->modifiers() & Qt::ShiftModifier)) + { + up(); + ev->accept(); + return true; + } + break; + + case Qt::Key_Down: + case Qt::Key_Tab: + if (ev->modifiers() == Qt::NoButton) + { + down(); + ev->accept(); + return true; + } + break; + + case Qt::Key_Return: + hide(); + emit chosenUrl(currentUrl().url()); + ev->accept(); + return true; + break; + } + } + } + + return QFrame::eventFilter(o,e); +} + + +void CompletionWidget::setVisible( bool visible ) +{ + if (visible) + { + Application::instance()->installEventFilter(this); + } + else + { + Application::instance()->removeEventFilter(this); + } + + QFrame::setVisible(visible); +} + + +void CompletionWidget::itemChosen(ListItem *item) +{ + emit chosenUrl(_list.at(layout()->indexOf(item)).url); + hide(); +} \ No newline at end of file diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h new file mode 100644 index 00000000..7b474bd8 --- /dev/null +++ b/src/urlbar/completionwidget.h @@ -0,0 +1,77 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +#ifndef COMPLETION_WIDGET_H +#define COMPLETION_WIDGET_H + + +// Local Includes +#include "urlresolver.h" +#include "listitem.h" + +// Qt Includes +#include + +// KDE Includes +#include + +// Forward Declarations +class KUrl; + + +class CompletionWidget : public QFrame +{ +Q_OBJECT + +public: + CompletionWidget(QWidget *parent); + + void insertSearchList(const UrlSearchList &list); + void popup(); + + void up(); + void down(); + void clear(); + virtual bool eventFilter(QObject *obj, QEvent *ev); + void setVisible(bool visible); + KUrl currentUrl(); + +private slots: + void itemChosen(ListItem *item); + +signals: + void chosenUrl(const QString&); + +private: + void sizeAndPosition(); + + QWidget *_parent; + + UrlSearchList _list; + int _currentIndex; +}; + +#endif // COMPLETION_WIDGET_H diff --git a/src/urlbar/lineedit.cpp b/src/urlbar/lineedit.cpp index db36bd0c..f3c93e8e 100644 --- a/src/urlbar/lineedit.cpp +++ b/src/urlbar/lineedit.cpp @@ -2,9 +2,9 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009-2010 by Andrea Diamantini +* Copyright (C) 2009 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009-2010 by Lionel Chauvin +* Copyright (C) 2009 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or diff --git a/src/urlbar/lineedit.h b/src/urlbar/lineedit.h index 1ac3af2e..d76a5fcb 100644 --- a/src/urlbar/lineedit.h +++ b/src/urlbar/lineedit.h @@ -2,9 +2,9 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009-2010 by Andrea Diamantini +* Copyright (C) 2009 by Andrea Diamantini * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009-2010 by Lionel Chauvin +* Copyright (C) 2009 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or @@ -30,9 +30,6 @@ #define LINEEDIT_H -// Local Includes -#include "rekonqprivate_export.h" - // KDE Includes #include @@ -42,7 +39,7 @@ class QFocusEvent; class QKeyEvent; -class REKONQ_TESTS_EXPORT LineEdit : public KLineEdit +class LineEdit : public KLineEdit { Q_OBJECT @@ -50,9 +47,12 @@ public: explicit LineEdit(QWidget *parent = 0); virtual ~LineEdit(); + protected: virtual void keyPressEvent(QKeyEvent*); virtual void mouseDoubleClickEvent(QMouseEvent *); + + }; #endif // LINEEDIT_H diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp new file mode 100644 index 00000000..92951cb7 --- /dev/null +++ b/src/urlbar/listitem.cpp @@ -0,0 +1,173 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +// Self Includes +#include "listitem.h" + +// Local Includes +#include "urlresolver.h" +#include "application.h" + +// KDE Includes +#include +#include +#include + +// Qt Includes +#include +#include +#include +#include +#include +#include +#include + +ListItem::ListItem(const UrlSearchItem &item, QWidget *parent) + : QWidget(parent), + m_option() +{ + QHBoxLayout *hLayout = new QHBoxLayout; + QVBoxLayout *vLayout = new QVBoxLayout; + + QLabel *previewLabel = new QLabel; + previewLabel->setFixedSize(40,30); + QPixmap preview; + QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl(item.url) + ".png", true); + if(QFile::exists(path)) + { + preview.load(path); + previewLabel->setPixmap(preview.scaled(40,30)); + } + else + { + if(item.icon.startsWith( QLatin1String("http://") ) ) + preview = Application::icon( item.icon ).pixmap(22); + } + previewLabel->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); + + hLayout->addWidget(previewLabel); + hLayout->addLayout(vLayout); + + QLabel *titleLabel = new QLabel("" + item.title + ""); + titleLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + QLabel *urlLabel = new QLabel("" + item.url + ""); + urlLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + vLayout->addWidget(titleLabel); + vLayout->addWidget(urlLabel); + + + QLabel *iconLabel = new QLabel; + QPixmap pixmap; + if(item.icon.startsWith( QLatin1String("http://") ) ) + pixmap = Application::icon( item.icon ).pixmap(18); + else + pixmap = KIcon(item.icon).pixmap(18); + + iconLabel->setPixmap(pixmap); + iconLabel->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); + hLayout->addWidget(iconLabel); + + setLayout(hLayout); + + m_option.initFrom(this); + m_option.direction = Qt::LeftToRight; + + deactivate(); +} + +ListItem::~ListItem() +{ + disconnect(); +} + + +//TODO: REMOVE DUPLICATE CODE WITH PREVIEWIMAGE +QString ListItem::guessNameFromUrl(QUrl url) +{ + QString name = url.toString( QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash ); + + // TODO learn Regular Expressions :) + // and implement something better here.. + name.remove('/'); + name.remove('&'); + name.remove('.'); + name.remove('-'); + name.remove('_'); + name.remove('?'); + name.remove('='); + name.remove('+'); + + return name; +} + + +void ListItem::activate() +{ + m_option.state |= QStyle::State_Selected; + repaint(); +} + + +void ListItem::deactivate() +{ + m_option.state &= ~QStyle::State_Selected; + repaint(); +} + +void ListItem::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + + if( m_option.state.testFlag(QStyle::State_Selected) || m_option.state.testFlag(QStyle::State_MouseOver)) + { + QPainter painter(this); + m_option.rect=QRect(QPoint(),size()); + style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &m_option, &painter, this); + } +} + +void ListItem::enterEvent(QEvent *e) +{ + m_option.state |= QStyle::State_MouseOver; + repaint(); + QWidget::enterEvent(e); +} + +void ListItem::leaveEvent(QEvent *e) +{ + m_option.state &= ~QStyle::State_MouseOver; + repaint(); + QWidget::enterEvent(e); +} + +void ListItem::mousePressEvent(QMouseEvent *e) +{ + emit itemClicked(this); + QWidget::mousePressEvent(e); +} + diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h new file mode 100644 index 00000000..6aa3f1e9 --- /dev/null +++ b/src/urlbar/listitem.h @@ -0,0 +1,59 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +// Qt Includes +#include +#include + +// Forward Declarations +class UrlSearchItem; + + +class ListItem : public QWidget +{ +Q_OBJECT + +public: + ListItem(const UrlSearchItem &item, QWidget *parent = 0); + ~ListItem(); + + void activate(); + void deactivate(); + +signals: + void itemClicked(ListItem *item); + +protected: + virtual void paintEvent(QPaintEvent *event); + virtual void enterEvent(QEvent *); + virtual void leaveEvent(QEvent *); + virtual void mousePressEvent(QMouseEvent *e); + +private: + QStyleOptionViewItemV4 m_option; + QString guessNameFromUrl(QUrl url); + +}; diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 189d19fe..54a0a02d 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -2,10 +2,10 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2008-2009 by Andrea Diamantini * Copyright (C) 2009 by Domrachev Alexandr * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009-2010 by Lionel Chauvin +* Copyright (C) 2009 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or @@ -36,8 +36,7 @@ #include "lineedit.h" #include "mainwindow.h" #include "webview.h" -#include "historymanager.h" -#include "webtab.h" +#include "urlresolver.h" // KDE Includes #include @@ -49,43 +48,44 @@ #include #include #include - +#include QColor UrlBar::s_defaultBaseColor; UrlBar::UrlBar(QWidget *parent) - : KHistoryComboBox(true, parent) - , m_lineEdit(new LineEdit) - , m_progress(0) + : KComboBox(true, parent) + , m_lineEdit(new LineEdit) + , m_progress(0) + , m_box(new CompletionWidget(this)) { - setUrlDropsEnabled(true); - setAutoDeleteCompletionObject(true); - //cosmetic setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setMinimumWidth(180); - - setTrapReturnKey(true); - - setupLineEdit(); - // add every item to history - connect(this, SIGNAL(returnPressed(const QString&)), SLOT(activated(const QString&))); - connect(completionBox(), SIGNAL(activated(const QString&)), SLOT(activated(const QString&))); + // signal handlings + setTrapReturnKey(true); + setUrlDropsEnabled(true); + + // Make m_lineEdit background transparent + QPalette p = m_lineEdit->palette(); + p.setColor(QPalette::Base, Qt::transparent); + m_lineEdit->setPalette(p); - connect(this, SIGNAL(cleared()), SLOT(cleared())); + if (!s_defaultBaseColor.isValid()) + { + s_defaultBaseColor = palette().color(QPalette::Base); + } - // setup completion box - setCompletionObject( Application::historyManager()->completionObject() ); - - // set dropdown list background - QPalette p = view()->palette(); - p.setColor(QPalette::Base, palette().color(QPalette::Base)); - view()->setPalette(p); + setLineEdit(m_lineEdit); + // clear the URL bar + m_lineEdit->clear(); // load urls on activated urlbar signal - connect(this, SIGNAL(activated(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&))); + connect(this, SIGNAL(returnPressed(const QString&)), SLOT(activated(const QString&))); + + installEventFilter(m_box); + connect(m_box, SIGNAL(chosenUrl(const QString&)), SLOT(activated(const QString&))); } @@ -96,7 +96,7 @@ UrlBar::~UrlBar() void UrlBar::selectAll() const { - lineEdit()->selectAll(); + m_lineEdit->selectAll(); } @@ -106,42 +106,12 @@ KUrl UrlBar::url() const } -KLineEdit *UrlBar::lineEdit() const -{ - return m_lineEdit; -} - - -void UrlBar::setupLineEdit() -{ - // Make m_lineEdit background transparent - QPalette p = m_lineEdit->palette(); - p.setColor(QPalette::Base, Qt::transparent); - m_lineEdit->setPalette(p); - - if (!s_defaultBaseColor.isValid()) - { - s_defaultBaseColor = palette().color(QPalette::Base); - } - - setLineEdit(m_lineEdit); - - // Make the lineedit consume the Qt::Key_Enter event... - lineEdit()->setTrapReturnKey(true); - - lineEdit()->setHandleSignals(true); - - // clear the URL bar - lineEdit()->clear(); -} - - void UrlBar::setUrl(const QUrl& url) { if(url.scheme() == "about") { m_currentUrl = KUrl(); - updateUrl(); // updateUrl before setFocus + updateUrl(); setFocus(); } else @@ -149,6 +119,7 @@ void UrlBar::setUrl(const QUrl& url) m_currentUrl = KUrl(url); updateUrl(); } + } @@ -195,29 +166,21 @@ void UrlBar::updateUrl() // Must be AFTER setCurrentIndex if (!hasFocus()) { - lineEdit()->setCursorPosition(0); + m_lineEdit->setCursorPosition(0); } } void UrlBar::activated(const QString& urlString) { + disconnect(this, SIGNAL(editTextChanged(const QString &)), this, SLOT(suggestUrls(const QString &))); + if (urlString.isEmpty()) return; - // this fix urlbar behaviour, removing focus from there and enabling - // loading animation. Temporary fix?? - Application::instance()->mainWindow()->currentTab()->setFocus(); - - setUrl( KUrl(urlString) ); - emit activated( KUrl(urlString) ); -} - - -void UrlBar::cleared() -{ - // clear the history on user's request from context menu - clear(); + clearFocus(); + setUrl(urlString); + Application::instance()->loadUrl(m_currentUrl); } @@ -243,7 +206,7 @@ void UrlBar::paintEvent(QPaintEvent *event) p.setColor(QPalette::Base, s_defaultBaseColor); setPalette(p); - KHistoryComboBox::paintEvent(event); + KComboBox::paintEvent(event); if (!hasFocus()) { @@ -261,7 +224,7 @@ void UrlBar::paintEvent(QPaintEvent *event) painter.setBrush(generateGradient(loadingColor, height())); painter.setPen(Qt::transparent); - QRect backgroundRect = lineEdit()->frameGeometry(); + QRect backgroundRect = m_lineEdit->frameGeometry(); int mid = backgroundRect.width() * m_progress / 100; QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height()); painter.drawRect(progressRect); @@ -272,7 +235,7 @@ void UrlBar::paintEvent(QPaintEvent *event) QSize UrlBar::sizeHint() const { - return lineEdit()->sizeHint(); + return m_lineEdit->sizeHint(); } @@ -308,43 +271,70 @@ bool UrlBar::isLoading() return true; } - void UrlBar::keyPressEvent(QKeyEvent *event) { + + // this handles the Modifiers + Return key combinations QString currentText = m_lineEdit->text().trimmed(); - if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) + if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) + && !currentText.startsWith(QLatin1String("http://"), Qt::CaseInsensitive)) { - if( !currentText.startsWith(QLatin1String("http://"), Qt::CaseInsensitive) ) + QString append; + if (event->modifiers() == Qt::ControlModifier) { - QString append; - if (event->modifiers() == Qt::ControlModifier) - { - append = QLatin1String(".com"); - } - else if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) - { - append = QLatin1String(".org"); - } - else if (event->modifiers() == Qt::ShiftModifier) - { - append = QLatin1String(".net"); - } - - QUrl url(QLatin1String("http://www.") + currentText); - QString host = url.host(); - if (!host.endsWith(append, Qt::CaseInsensitive)) - { - host += append; - url.setHost(host); - m_lineEdit->setText(url.toString()); - } + append = QLatin1String(".com"); } - else + else if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) + { + append = QLatin1String(".org"); + } + else if (event->modifiers() == Qt::ShiftModifier) + { + append = QLatin1String(".net"); + } + + QUrl url(QLatin1String("http://www.") + currentText); + QString host = url.host(); + if (!host.endsWith(append, Qt::CaseInsensitive)) { - // fill lineEdit with its stripped contents to remove trailing spaces - m_lineEdit->setText(currentText); + host += append; + url.setHost(host); + m_lineEdit->setText(url.toString()); } } + + KComboBox::keyPressEvent(event); +} + + +void UrlBar::suggestUrls(const QString &text) +{ + if (!hasFocus()) + { + return; + } + + if(text.isEmpty()) + { + m_box->hide(); + return; + } + + UrlResolver res(text); + UrlSearchList list = res.orderedSearchItems(); + + if(list.count() > 0) + { + m_box->clear(); + m_box->insertSearchList(list); + m_box->popup(); + } +} - KHistoryComboBox::keyPressEvent(event); +void UrlBar::focusInEvent(QFocusEvent *event) +{ + // activate suggestions on edit text + connect(this, SIGNAL(editTextChanged(const QString &)), this, SLOT(suggestUrls(const QString &))); + + KComboBox::focusInEvent(event); } diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h index 39911bb2..ef53d63a 100644 --- a/src/urlbar/urlbar.h +++ b/src/urlbar/urlbar.h @@ -2,10 +2,10 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2008-2009 by Andrea Diamantini * Copyright (C) 2009 by Domrachev Alexandr * Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009-2010 by Lionel Chauvin +* Copyright (C) 2009 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or @@ -32,23 +32,23 @@ // Local Includes -#include "rekonqprivate_export.h" #include "lineedit.h" +#include "completionwidget.h" // KDE Includes #include -#include +#include // Qt Includes #include +#include // Forward Declarations class QLinearGradient; class QWidget; -class KCompletion; -class REKONQ_TESTS_EXPORT UrlBar : public KHistoryComboBox +class UrlBar : public KComboBox { Q_OBJECT @@ -61,31 +61,24 @@ public: QSize sizeHint() const; void setBackgroundColor(QColor); bool isLoading(); - void setProgress(int progress); -signals: - void activated(const KUrl&); - public slots: void setUrl(const QUrl &url); void updateProgress(int progress); void updateUrl(); - + private slots: void activated(const QString& url); void loadFinished(bool); - void cleared(); + void suggestUrls(const QString &editedText); protected: virtual void paintEvent(QPaintEvent *event); virtual void keyPressEvent(QKeyEvent *event); + virtual void focusInEvent(QFocusEvent *event); private: - void setupLineEdit(); - - KLineEdit *lineEdit() const; - static QLinearGradient generateGradient(const QColor &color, int height); static QColor s_defaultBaseColor; @@ -94,6 +87,9 @@ private: KUrl m_currentUrl; int m_progress; + + CompletionWidget *m_box; + KUrl m_suggestedUrl; }; #endif diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp new file mode 100644 index 00000000..b2bf50af --- /dev/null +++ b/src/urlbar/urlresolver.cpp @@ -0,0 +1,177 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +// Self Includes +#include "urlresolver.h" + +// Local Includes +#include "application.h" +#include "historymanager.h" +#include "bookmarksmanager.h" + +// KDE Includes +#include +#include +#include +#include +#include +#include + +// Qt Includes +#include +#include +#include + + +// NOTE default kurifilter plugin list (at least in my box) +// 1. "kshorturifilter" +// 2. "kurisearchfilter" +// 3. "localdomainurifilter" +// 4 ."kuriikwsfilter" +// 5. "fixhosturifilter" + + +UrlResolver::UrlResolver(const QString &typedUrl) + : _urlString(typedUrl) +{ +} + + +UrlSearchList UrlResolver::orderedSearchItems() +{ + // NOTE: the logic here is : "we wanna suggest (at least) 9 elements" + // so we have (more or less) 3 from first results (1 from QUrl Resolutions, 2 from + // default search engines). + // There are 6 remaining: if bookmarkResults + historyResults <= 6, catch all, else + // catch first 3 results from the two resulting lists :) + + UrlSearchList list; + + list << qurlFromUserInputResolution(); + list << webSearchesResolution(); + int firstResults = list.count(); + int checkPoint = 9 - firstResults; + + UrlSearchList historyList = historyResolution(); + int historyResults = historyList.count(); + + UrlSearchList bookmarksList = bookmarksResolution(); + int bookmarkResults = bookmarksList.count(); + + if(historyResults + bookmarkResults > checkPoint) + { + historyList = historyList.mid(0,3); + bookmarksList = bookmarksList.mid(0,3); + } + list << historyList; + list << bookmarksList; + + return list; +} + + +////////////////////////////////////////////////////////////////////////// +// PRIVATE ENGINES + + +// STEP 1 = QUrl from User Input (easily the best solution... ) +UrlSearchList UrlResolver::qurlFromUserInputResolution() +{ + UrlSearchList list; + + QString url2 = _urlString; + QUrl urlFromUserInput = QUrl::fromUserInput(url2); + if(urlFromUserInput.isValid()) + { + QByteArray ba = urlFromUserInput.toEncoded(); + if(!ba.isEmpty()) + { + QString str(ba); + UrlSearchItem it(str); + list << it; + } + } + + return list; +} + + +// STEP 2 = Web Searches +UrlSearchList UrlResolver::webSearchesResolution() +{ + UrlSearchList list; + + QString url1 = _urlString; + if(KUrl(url1).isRelative() && !url1.contains('.')) + { + // KUriFilter has the worst performance possible here and let this trick unusable + QString gUrl = QString("http://www.google.com/search?q=%1&ie=UTF-8&oe=UTF-8").arg(url1); + QString gTitle = i18n("Search Google for ") + url1; + UrlSearchItem gItem(gUrl, gTitle, QString("http://www.google.com") ); + list << gItem; + + QString wUrl = QString("http://en.wikipedia.org/wiki/Special:Search?search=%1&go=Go").arg(url1); + QString wTitle = i18n("Search Wikipedia for ") + url1; + UrlSearchItem wItem(wUrl, wTitle, QString("http://wikipedia.org") ); + list << wItem; + } + + return list; +} + + +// STEP 3 = history completion +UrlSearchList UrlResolver::historyResolution() +{ + UrlSearchList list; + + KCompletion *historyCompletion = Application::historyManager()->completionObject(); + QStringList historyResults = historyCompletion->substringCompletion(_urlString); + Q_FOREACH(const QString &s, historyResults) + { + UrlSearchItem it(s, s, QString("view-history")); + list << it; + } + + return list; +} + + +// STEP 4 = bookmarks completion +UrlSearchList UrlResolver::bookmarksResolution() +{ + UrlSearchList list; + + KCompletion *bookmarkCompletion = Application::bookmarkProvider()->completionObject(); + QStringList bookmarkResults = bookmarkCompletion->substringCompletion(_urlString); + Q_FOREACH(const QString &s, bookmarkResults) + { + UrlSearchItem it( s, QString(), QString("rating") ); + list << it; + } + + return list; +} diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h new file mode 100644 index 00000000..0a880150 --- /dev/null +++ b/src/urlbar/urlresolver.h @@ -0,0 +1,72 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 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 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +#ifndef URL_RESOLVER_H +#define URL_RESOLVER_H + + +// Qt Includes +#include +#include + +// Forward Declarations +class KUrl; + +class UrlSearchItem +{ +public: + QString url; + QString title; + QString icon; + + UrlSearchItem(const QString &_url, const QString &_title = QString(), const QString &_icon = QString()) + : url(_url), title(_title), icon(_icon) + {}; +}; + +typedef QList UrlSearchList; + + +// ---------------------------------------------------------------------- + + +class UrlResolver +{ +public: + UrlResolver(const QString &typedUrl); + + UrlSearchList orderedSearchItems(); + +private: + QString _urlString; + + UrlSearchList webSearchesResolution(); + UrlSearchList historyResolution(); + UrlSearchList qurlFromUserInputResolution(); + UrlSearchList bookmarksResolution(); +}; + +#endif // URL_RESOLVER_H -- cgit v1.2.1 From d9796c992638d4c4d740415e29a0766a92d2e101 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Sat, 27 Mar 2010 15:25:38 +0100 Subject: Improve Downloads page appearance : the downloads info are shown on 3 lines with the icon of the file --- src/data/home.html | 14 ++++++++++++++ src/newtabpage.cpp | 40 ++++++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/data/home.html b/src/data/home.html index 50564d55..96c0bd06 100644 --- a/src/data/home.html +++ b/src/data/home.html @@ -142,6 +142,18 @@ margin-left: 2em; margin-bottom: 0.5em; } +/* -------------------------------------------------------- */ +/* Downloads page */ + +.download{ +margin: 1.5em 0; +} + +.download img{ +float: left; +margin-right: 5px; +} + /* -------------------------------------------------------- */ @@ -155,6 +167,7 @@ margin-bottom: 0.5em;