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/rekonqpage/newtabpage.cpp | 155 ++++++++++++++++++++++++++++++++++-------- src/rekonqpage/newtabpage.h | 19 ++++-- 2 files changed, 140 insertions(+), 34 deletions(-) (limited to 'src/rekonqpage') 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; -- 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/rekonqpage/newtabpage.cpp | 84 +++++++++++++++++++++++++++++-------------- src/rekonqpage/newtabpage.h | 9 ++++- 2 files changed, 66 insertions(+), 27 deletions(-) (limited to 'src/rekonqpage') 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(); -- 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/rekonqpage/newtabpage.cpp | 57 +++++++++++---- src/rekonqpage/newtabpage.h | 2 + src/rekonqpage/previewchooser.cpp | 143 ++++++++++++++++++++++++++++++++++++++ src/rekonqpage/previewchooser.h | 70 +++++++++++++++++++ 4 files changed, 260 insertions(+), 12 deletions(-) create mode 100644 src/rekonqpage/previewchooser.cpp create mode 100644 src/rekonqpage/previewchooser.h (limited to 'src/rekonqpage') 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 -- 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/rekonqpage') 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/rekonqpage') 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/rekonqpage') 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/rekonqpage') 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/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 +++++++++++++ 6 files changed, 231 insertions(+), 241 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/rekonqpage') 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 -- 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 +++++++++++++- 3 files changed, 28 insertions(+), 64 deletions(-) (limited to 'src/rekonqpage') 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(); } -- 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rekonqpage') 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(); -- 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 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/rekonqpage') 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); } -- 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/rekonqpage') 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/rekonqpage') 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 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/rekonqpage') 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/rekonqpage/newtabpage.cpp | 47 +++++++++++++++++++++++++++++++------------ src/rekonqpage/newtabpage.h | 2 +- 2 files changed, 35 insertions(+), 14 deletions(-) (limited to 'src/rekonqpage') 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 -- 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/rekonqpage') 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 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 +++++++++++---------- 3 files changed, 113 insertions(+), 116 deletions(-) (limited to 'src/rekonqpage') 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 -- 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/rekonqpage/newtabpage.cpp | 3 ++- src/rekonqpage/newtabpage.h | 3 ++- src/rekonqpage/previewselectorbar.cpp | 2 +- src/rekonqpage/previewselectorbar.h | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/rekonqpage') 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 * * -- 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/rekonqpage/newtabpage.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/rekonqpage') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 3fd9fcc6..ca8ed35e 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -171,7 +171,7 @@ 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("span a").setPlainText(i18n("Set a Preview...")); prev.findFirst("a").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString())); setupPreview(prev, index); @@ -187,7 +187,7 @@ 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("span a").setPlainText(i18n("Loading Preview...")); prev.findFirst("a").setAttribute("href", url.toMimeDataString()); setupPreview(prev, index); @@ -208,7 +208,7 @@ 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").setPlainText(checkTitle(title)); + prev.findFirst("span a").setPlainText(checkTitle(title)); setupPreview(prev, index); showControls(prev); -- cgit v1.2.1 From 4dcd02b5317896be0adbe479a4594dac4f048286 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 18 Feb 2010 02:10:51 +0100 Subject: Working around about: protocol.. - honor rekonq settings on about:home page - loads about:blank :) pages --- src/rekonqpage/newtabpage.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/rekonqpage') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index ca8ed35e..f7ebcdbf 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -94,15 +94,6 @@ 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); @@ -111,7 +102,7 @@ void NewTabPage::generate(KUrl url) browsingMenu(url); QString title; - if(url == KUrl("about:home") || url == KUrl("about:favorites")) + if(url == KUrl("about:favorites")) { favoritesPage(); title = i18n("Favorites"); @@ -134,7 +125,6 @@ void NewTabPage::generate(KUrl url) } m_url = url; - m_root.document().findFirst("title").setPlainText(title); } -- cgit v1.2.1 From 060909220bad6842828f2583213dc96c285b5fd9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 19 Feb 2010 12:37:46 +0100 Subject: change setHtml( string ) to setHtml( string, url ) to let webviews return an url on webview->url() calls --- src/rekonqpage/newtabpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rekonqpage') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index f7ebcdbf..cc8aa1fb 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -95,7 +95,7 @@ void NewTabPage::generate(KUrl url) } QWebPage *page = m_root.webFrame()->page(); - page->mainFrame()->setHtml(m_html); + page->mainFrame()->setHtml(m_html,m_url); m_root = page->mainFrame()->documentElement().findFirst("#content"); -- cgit v1.2.1 From 8dda858403d283f1850c0298aac0fb5212a27952 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 26 Feb 2010 11:37:11 +0100 Subject: tests support for every Qt derived rekonq class --- src/rekonqpage/newtabpage.h | 5 ++++- src/rekonqpage/previewselectorbar.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/rekonqpage') diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index d659362f..d4c57299 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -29,6 +29,9 @@ #define REKONQ_NEW_TAB_PAGE +// Local Includes +#include "rekonqprivate_export.h" + // KDE Includes #include @@ -42,7 +45,7 @@ class KBookmark; class WebPage; -class NewTabPage : public QObject +class REKONQ_TESTS_EXPORT NewTabPage : public QObject { Q_OBJECT diff --git a/src/rekonqpage/previewselectorbar.h b/src/rekonqpage/previewselectorbar.h index fa71bdfa..bb9f26c4 100644 --- a/src/rekonqpage/previewselectorbar.h +++ b/src/rekonqpage/previewselectorbar.h @@ -29,6 +29,7 @@ #define PREVIEWSELECTORBAR_H // Local Includes +#include "rekonqprivate_export.h" #include "webpage.h" // Qt Includes @@ -37,7 +38,7 @@ #include -class PreviewSelectorBar : public QWidget +class REKONQ_TESTS_EXPORT PreviewSelectorBar : public QWidget { Q_OBJECT -- 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rekonqpage') 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; } -- 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/rekonqpage/newtabpage.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/rekonqpage') 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 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/rekonqpage/newtabpage.cpp | 5 +---- src/rekonqpage/newtabpage.h | 24 ++++++++++++++---------- src/rekonqpage/previewselectorbar.cpp | 6 +++--- 3 files changed, 18 insertions(+), 17 deletions(-) (limited to 'src/rekonqpage') 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(); -- 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/rekonqpage/newtabpage.cpp | 443 ---------------------------------- src/rekonqpage/newtabpage.h | 109 --------- src/rekonqpage/previewselectorbar.cpp | 152 ------------ src/rekonqpage/previewselectorbar.h | 66 ----- 4 files changed, 770 deletions(-) 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/rekonqpage') 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