diff --git a/bin/locale/sk_SK.qm b/bin/locale/sk_SK.qm index 4913ee8cf..5394565b6 100644 Binary files a/bin/locale/sk_SK.qm and b/bin/locale/sk_SK.qm differ diff --git a/bin/themes/chrome/main.css b/bin/themes/chrome/main.css index eac889c41..58435bdee 100644 --- a/bin/themes/chrome/main.css +++ b/bin/themes/chrome/main.css @@ -186,6 +186,11 @@ background: transparent; } +#sidebar-splitter::handle +{ + background-color:transparent; +} + /*WebSearchBar*/ #websearchbar { diff --git a/bin/themes/default/main.css b/bin/themes/default/main.css index 9891668ed..17bc373fe 100644 --- a/bin/themes/default/main.css +++ b/bin/themes/default/main.css @@ -225,6 +225,11 @@ background: transparent; } +#sidebar-splitter::handle +{ + background-color:transparent; +} + /*SourceViewer*/ #sourceviewer-textedit { diff --git a/bin/themes/mac/main.css b/bin/themes/mac/main.css index 724a926fb..c7c3c9686 100644 --- a/bin/themes/mac/main.css +++ b/bin/themes/mac/main.css @@ -182,6 +182,11 @@ background: transparent; } +#sidebar-splitter::handle +{ + background-color:transparent; +} + /*WebSearchBar*/ #websearchbar { diff --git a/bin/themes/windows/main.css b/bin/themes/windows/main.css index d9ebad369..36b03cd30 100644 --- a/bin/themes/windows/main.css +++ b/bin/themes/windows/main.css @@ -191,6 +191,11 @@ background: transparent; } +#sidebar-splitter::handle +{ + background-color:transparent; +} + /*WebSearchBar*/ #websearchbar { diff --git a/src/QupZilla.pro b/src/QupZilla.pro index 2713e4162..663e7c7b9 100644 --- a/src/QupZilla.pro +++ b/src/QupZilla.pro @@ -164,7 +164,8 @@ SOURCES += main.cpp\ bookmarksimport/firefoximporter.cpp \ bookmarksimport/chromeimporter.cpp \ bookmarksimport/operaimporter.cpp \ - bookmarksimport/bookmarksimportdialog.cpp + bookmarksimport/bookmarksimportdialog.cpp \ + tools/iconfetcher.cpp HEADERS += \ 3rdparty/qtwin.h \ @@ -275,7 +276,8 @@ HEADERS += \ bookmarksimport/firefoximporter.h \ bookmarksimport/chromeimporter.h \ bookmarksimport/operaimporter.h \ - bookmarksimport/bookmarksimportdialog.h + bookmarksimport/bookmarksimportdialog.h \ + tools/iconfetcher.h FORMS += \ preferences/autofillmanager.ui \ @@ -404,6 +406,8 @@ message($$DEFINES) + + diff --git a/src/app/qupzilla.cpp b/src/app/qupzilla.cpp index 08b2d1133..73a804dd5 100644 --- a/src/app/qupzilla.cpp +++ b/src/app/qupzilla.cpp @@ -190,6 +190,7 @@ void QupZilla::setupUi() m_mainLayout->setContentsMargins(0,0,0,0); m_mainLayout->setSpacing(0); m_mainSplitter = new QSplitter(this); + m_mainSplitter->setObjectName("sidebar-splitter"); m_mainSplitter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); m_tabWidget = new TabWidget(this); m_superMenu = new QMenu(this); diff --git a/src/bookmarks/bookmarksmodel.cpp b/src/bookmarks/bookmarksmodel.cpp index e10d11247..282e13a20 100644 --- a/src/bookmarks/bookmarksmodel.cpp +++ b/src/bookmarks/bookmarksmodel.cpp @@ -252,7 +252,7 @@ bool BookmarksModel::createFolder(const QString &name) if (query.next()) return false; - query.prepare("INSERT INTO folders (name) VALUES (?)"); + query.prepare("INSERT INTO folders (name, subfolder) VALUES (?, 'no')"); query.bindValue(0, name); if (!query.exec()) return false; diff --git a/src/bookmarksimport/bookmarksimportdialog.cpp b/src/bookmarksimport/bookmarksimportdialog.cpp index 357b579f2..c7a55b8e9 100644 --- a/src/bookmarksimport/bookmarksimportdialog.cpp +++ b/src/bookmarksimport/bookmarksimportdialog.cpp @@ -4,6 +4,8 @@ #include "chromeimporter.h" #include "operaimporter.h" #include "mainapplication.h" +#include "iconfetcher.h" +#include "networkmanager.h" BookmarksImportDialog::BookmarksImportDialog(QWidget* parent) : QDialog(parent) @@ -80,21 +82,23 @@ void BookmarksImportDialog::startFetchingIcons() ui->treeWidget->addTopLevelItem(item); i++; - QWebPage* page = new QWebPage(); - QWebFrame* frame = page->mainFrame(); - frame->load(b.url); - connect(frame, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished())); - connect(frame, SIGNAL(iconChanged()), this, SLOT(iconChanged())); - QPair pair; - pair.first = frame; + IconFetcher* fetcher = new IconFetcher(this); + fetcher->setNetworkAccessManager(mApp->networkManager()); + connect(fetcher, SIGNAL(finished()), this, SLOT(loadFinished())); + connect(fetcher, SIGNAL(iconFetched(QIcon)), this, SLOT(iconFetched(QIcon))); + fetcher->fetchIcon(b.url); + + QPair pair; + pair.first = fetcher; pair.second = b.url; - m_webViews.append(pair); + m_fetchers.append(pair); } } void BookmarksImportDialog::stopDownloading() { ui->nextButton->setEnabled(true); + ui->stopButton->hide(); ui->progressBar->setValue(ui->progressBar->maximum()); } @@ -102,20 +106,22 @@ void BookmarksImportDialog::loadFinished() { ui->progressBar->setValue(ui->progressBar->value() + 1); - if (ui->progressBar->value() == ui->progressBar->maximum()) + if (ui->progressBar->value() == ui->progressBar->maximum()) { + ui->stopButton->hide(); ui->nextButton->setEnabled(true); + } } -void BookmarksImportDialog::iconChanged() +void BookmarksImportDialog::iconFetched(const QIcon &icon) { - QWebFrame* view = qobject_cast(sender()); - if (!view) + IconFetcher* fetcher = qobject_cast(sender()); + if (!fetcher) return; QUrl url; - for (int i = 0; i < m_webViews.count(); i++) { - QPair pair = m_webViews.at(i); - if (pair.first == view) { + for (int i = 0; i < m_fetchers.count(); i++) { + QPair pair = m_fetchers.at(i); + if (pair.first == fetcher) { url = pair.second; break; } @@ -128,16 +134,16 @@ void BookmarksImportDialog::iconChanged() if (items.count() == 0) return; - QTreeWidgetItem* item = items.at(0); - - item->setIcon(0, view->icon()); + foreach (QTreeWidgetItem* item, items) { + item->setIcon(0, icon); - foreach (BookmarksModel::Bookmark b, m_exportedBookmarks) { - if (b.url == url) { - m_exportedBookmarks.removeOne(b); - b.icon = view->icon(); - m_exportedBookmarks.append(b); - break; + foreach (BookmarksModel::Bookmark b, m_exportedBookmarks) { + if (b.url == url) { + m_exportedBookmarks.removeOne(b); + b.icon = icon; + m_exportedBookmarks.append(b); + break; + } } } } @@ -280,10 +286,10 @@ void BookmarksImportDialog::setupBrowser(Browser browser) BookmarksImportDialog::~BookmarksImportDialog() { - if (m_webViews.count() > 0) { - for (int i = 0; i < m_webViews.count(); i++) {tr(""); - QWebFrame* frame= m_webViews.at(i).first; - delete frame->page(); + if (m_fetchers.count() > 0) { + for (int i = 0; i < m_fetchers.count(); i++) {tr(""); + IconFetcher* fetcher = m_fetchers.at(i).first; + delete fetcher; } } diff --git a/src/bookmarksimport/bookmarksimportdialog.h b/src/bookmarksimport/bookmarksimportdialog.h index 5263b09b7..547e41479 100644 --- a/src/bookmarksimport/bookmarksimportdialog.h +++ b/src/bookmarksimport/bookmarksimportdialog.h @@ -15,6 +15,7 @@ namespace Ui { class BookmarksImportDialog; } +class IconFetcher; class BookmarksImportDialog : public QDialog { Q_OBJECT @@ -27,9 +28,8 @@ private slots: void nextPage(); void setFile(); - void stopDownloading(); - void iconChanged(); + void iconFetched(const QIcon &icon); void loadFinished(); private: @@ -54,7 +54,7 @@ private slots: QList m_exportedBookmarks; - QList > m_webViews; + QList > m_fetchers; }; #endif // BOOKMARKSIMPORTDIALOG_H diff --git a/src/tools/iconfetcher.cpp b/src/tools/iconfetcher.cpp new file mode 100644 index 000000000..8a35d1024 --- /dev/null +++ b/src/tools/iconfetcher.cpp @@ -0,0 +1,116 @@ +#include "iconfetcher.h" + +#include + +FollowRedirectReply::FollowRedirectReply(const QUrl &url, QNetworkAccessManager* manager) + : QObject() + , m_manager(manager) + , m_redirectCount(0) +{ + m_reply = m_manager->get(QNetworkRequest(url)); + connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished())); +} + +void FollowRedirectReply::replyFinished() +{ + int replyStatus = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + + if ( (replyStatus != 301 && replyStatus != 302) || m_redirectCount == 5) { + emit finished(); + return; + } + m_redirectCount++; + + QUrl redirectUrl = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); + m_reply->close(); + m_reply->deleteLater(); + + m_reply = m_manager->get(QNetworkRequest(redirectUrl)); + connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished())); +} + +FollowRedirectReply::~FollowRedirectReply() +{ + m_reply->close(); + m_reply->deleteLater(); +} + +IconFetcher::IconFetcher(QObject* parent) + : QObject(parent) + , m_manager(0) +{ +} + +void IconFetcher::fetchIcon(const QUrl &url) +{ + if (!m_manager) + return; + + FollowRedirectReply* reply = new FollowRedirectReply(url, m_manager); + connect(reply, SIGNAL(finished()), this, SLOT(pageDownloaded())); +} + +void IconFetcher::pageDownloaded() +{ + FollowRedirectReply* reply = qobject_cast (sender()); + if (!reply) + return; + + QString html = reply->reply()->readAll(); + QUrl replyUrl = reply->reply()->url(); + delete reply; + + QRegExp rx("", Qt::CaseInsensitive); + rx.setMinimal(true); + + QString shortcutIconTag; + int pos = 0; + while ((pos = rx.indexIn(html, pos)) != -1) { + QString linkTag = rx.cap(0); + pos += rx.matchedLength(); + + if (linkTag.contains("rel=\"shortcut icon\"", Qt::CaseInsensitive)) { + shortcutIconTag = linkTag; + break; + } + } + + FollowRedirectReply* newReply; + if (shortcutIconTag.isEmpty()) { +// QUrl faviconUrl = replyUrl.resolved(QUrl("favicon.ico")); + // Rather getting favicon.ico from base directory than from subfolders + QUrl faviconUrl = QUrl(replyUrl.toString(QUrl::RemovePath | QUrl::RemoveQuery) + "/favicon.ico"); + newReply = new FollowRedirectReply(faviconUrl, m_manager); + } + else { + QRegExp rx("href=\"(.*)\"", Qt::CaseInsensitive); + rx.setMinimal(true); + rx.indexIn(shortcutIconTag); + QUrl url = QUrl(rx.cap(1)); + + QUrl iconUrl = QUrl(replyUrl).resolved(url); + newReply = new FollowRedirectReply(iconUrl, m_manager); + } + + connect(newReply, SIGNAL(finished()), this, SLOT(iconDownloaded())); +} + +void IconFetcher::iconDownloaded() +{ + FollowRedirectReply* reply = qobject_cast (sender()); + if (!reply) + return; + + QByteArray response = reply->reply()->readAll(); + delete reply; + + if (!response.isEmpty()) { + QImage image; + image.loadFromData(response); + QIcon icon = QIcon(QPixmap::fromImage(image)); + if (!icon.isNull()) + emit iconFetched(icon); + } + + emit finished(); +} diff --git a/src/tools/iconfetcher.h b/src/tools/iconfetcher.h new file mode 100644 index 000000000..3105966ca --- /dev/null +++ b/src/tools/iconfetcher.h @@ -0,0 +1,55 @@ +#ifndef ICONFETCHER_H +#define ICONFETCHER_H + +#include +#include +#include +#include +#include + +class FollowRedirectReply : public QObject +{ + Q_OBJECT +public: + explicit FollowRedirectReply(const QUrl &url, QNetworkAccessManager* manager); + ~FollowRedirectReply(); + + QNetworkReply* reply() { return m_reply; } + +signals: + void finished(); + +private slots: + void replyFinished(); + +private: + QNetworkAccessManager* m_manager; + QNetworkReply* m_reply; + int m_redirectCount; + +}; + +class IconFetcher : public QObject +{ + Q_OBJECT +public: + explicit IconFetcher(QObject* parent = 0); + void setNetworkAccessManager(QNetworkAccessManager* manager) { m_manager = manager; } + void fetchIcon(const QUrl &url); + +signals: + void iconFetched(QIcon); + void finished(); + +public slots: + +private slots: + void pageDownloaded(); + void iconDownloaded(); + +private: + QNetworkAccessManager* m_manager; + +}; + +#endif // ICONFETCHER_H diff --git a/translations/sk_SK.ts b/translations/sk_SK.ts index 0bd2660d8..bea4a233c 100644 --- a/translations/sk_SK.ts +++ b/translations/sk_SK.ts @@ -481,7 +481,7 @@ p, li { white-space: pre-wrap; } Rename Folder - + Premenovať priečinok @@ -506,7 +506,7 @@ p, li { white-space: pre-wrap; } Add Subfolder - + Pridať podpriečinok @@ -552,17 +552,17 @@ p, li { white-space: pre-wrap; } Add new subfolder - + Pridať nový podpriečinok Choose name for new subfolder in bookmarks toolbar: - + Zvoľte meno pre nový podpriečinok v panely záložiek: Choose name for folder: - + Zvoľte meno pre priečinok: @@ -655,7 +655,7 @@ p, li { white-space: pre-wrap; } Copy address - + Kopírovať adresu Move bookmark to &folder @@ -716,17 +716,17 @@ p, li { white-space: pre-wrap; } Move right - + Posunúť doprava Move left - + Posunúť doľava Remove bookmark - + Odstrániť záložku @@ -742,7 +742,7 @@ p, li { white-space: pre-wrap; } Empty - Prázdne + Prázdny Sites You visited the most @@ -1647,7 +1647,7 @@ p, li { white-space: pre-wrap; } Copy address - + Kopírovať adresu