From 9f3181f0560fb87000c8c0f052418feb6a626a63 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 4 Feb 2012 08:28:30 +0100 Subject: Consider unknown network errors as errors :) --- src/webpage.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/webpage.cpp b/src/webpage.cpp index 89c52e8a..15d6cabf 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -454,14 +454,11 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) // ignore this.. return; - case QNetworkReply::ContentAccessDenied: // access to remote content denied (similar to HTTP error 401) + // WARNING: This is also typical adblocked element error: IGNORE THIS! + case QNetworkReply::ContentAccessDenied: // access to remote content denied break; case QNetworkReply::UnknownNetworkError: // unknown network-related error detected - // FIXME: DO WE REALLY NEED THIS??? - _protHandler.postHandling(reply->request(), frame); - return; - case QNetworkReply::ConnectionRefusedError: // remote server refused connection case QNetworkReply::HostNotFoundError: // invalid hostname case QNetworkReply::TimeoutError: // connection time out @@ -470,7 +467,7 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) case QNetworkReply::ContentNotFoundError: // remote content not found on server (similar to HTTP error 404) case QNetworkReply::ProtocolUnknownError: // Unknown protocol case QNetworkReply::ProtocolInvalidOperationError: // requested operation is invalid for this protocol - + default: kDebug() << "ERROR " << reply->error() << ": " << reply->errorString(); if (reply->url() == _loadingUrl) { @@ -489,10 +486,6 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) } break; - default: - // Nothing to do here.. - break; - } } -- cgit v1.2.1 From 76fb43ba76f23ace16af78089793be2bb9ab3be9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 4 Feb 2012 08:59:06 +0100 Subject: clean up filename content disposition retrieve --- src/downloadmanager.cpp | 40 ---------------------------------------- src/downloadmanager.h | 3 +-- src/webpage.cpp | 10 ++++------ 3 files changed, 5 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 6241394a..2e7e4607 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -201,43 +201,3 @@ bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData & job->uiDelegate()->setAutoErrorHandlingEnabled(true); return true; } - - -// ------------------------------------------------------------------------------------------------------------------- - - -// STATIC -void DownloadManager::extractSuggestedFileName(const QNetworkReply* reply, QString& fileName) -{ - fileName.clear(); - const KIO::MetaData& metaData = reply->attribute(static_cast(KIO::AccessManager::MetaData)).toMap(); - if (metaData.value(QL1S("content-disposition-type")).compare(QL1S("attachment"), Qt::CaseInsensitive) == 0) - fileName = metaData.value(QL1S("content-disposition-filename")); - - if (!fileName.isEmpty()) - return; - - if (!reply->hasRawHeader("Content-Disposition")) - return; - - const QString value(QL1S(reply->rawHeader("Content-Disposition").simplified().constData())); - if (value.startsWith(QL1S("attachment"), Qt::CaseInsensitive) || value.startsWith(QL1S("inline"), Qt::CaseInsensitive)) - { - const int length = value.size(); - int pos = value.indexOf(QL1S("filename"), 0, Qt::CaseInsensitive); - if (pos > -1) - { - pos += 9; - while (pos < length && (value.at(pos) == QL1C(' ') || value.at(pos) == QL1C('=') || value.at(pos) == QL1C('"'))) - pos++; - - int endPos = pos; - while (endPos < length && value.at(endPos) != QL1C('"') && value.at(endPos) != QL1C(';')) - endPos++; - - if (endPos > pos) - fileName = value.mid(pos, (endPos - pos)).trimmed(); - } - } -} - diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 2eee1924..ce8de507 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -58,6 +58,7 @@ public: { return m_downloadList; } + bool clearDownloadsHistory(); bool downloadResource(const KUrl &url, const KIO::MetaData &metaData = KIO::MetaData(), @@ -65,8 +66,6 @@ public: void downloadLinksWithKGet(const QVariant &contentList); - static void extractSuggestedFileName(const QNetworkReply* reply, QString& fileName); - Q_SIGNALS: void newDownloadAdded(QObject *item); void notifyDownload(const QString&, Rekonq::Notify = Rekonq::Download); diff --git a/src/webpage.cpp b/src/webpage.cpp index 15d6cabf..2fdf4d01 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -289,6 +289,10 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (KParts::BrowserRun::isTextExecutable(_mimeType)) _mimeType = QL1S("text/plain"); + // Get suggested file name... + const KIO::MetaData& data = reply->attribute(static_cast(KIO::AccessManager::MetaData)).toMap(); + _suggestedFileName = data.value(QL1S("content-disposition-filename")); + kDebug() << "Detected MimeType = " << _mimeType; kDebug() << "Suggested File Name = " << _suggestedFileName; // ------------------------------------------------ @@ -316,8 +320,6 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { KParts::BrowserOpenOrSaveQuestion dlg(rApp->mainWindow(), replyUrl, _mimeType); - // Get suggested file name... - DownloadManager::extractSuggestedFileName(reply, _suggestedFileName); if (!_suggestedFileName.isEmpty()) dlg.setSuggestedFileName(_suggestedFileName); @@ -418,10 +420,6 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) { Q_ASSERT(reply); - // check suggested file name - if (_suggestedFileName.isEmpty()) - DownloadManager::extractSuggestedFileName(reply, _suggestedFileName); - QWebFrame* frame = qobject_cast(reply->request().originatingObject()); const bool isMainFrameRequest = (frame == mainFrame()); const bool isLoadingUrlReply = (mainFrame()->url() == reply->url()); -- cgit v1.2.1 From df91591f4a692b42bb9e2ee5bfad309ce3e29957 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 5 Feb 2012 07:34:56 +0100 Subject: clean up download management Remove one unuseful slot in webpage and better manage download dialog, following rekonq AND KDE settings. --- src/downloadmanager.cpp | 5 +++-- src/downloadmanager.h | 2 +- src/webpage.cpp | 17 +++++++++-------- src/webpage.h | 3 --- 4 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 2e7e4607..dd3cb119 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -141,13 +141,14 @@ void DownloadManager::downloadLinksWithKGet(const QVariant &contentList) // In this way, we can easily provide the extra functionality we need: // 1. KGet Integration // 2. Save downloads history -bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData &metaData, QWidget *parent, const QString &suggestedName) +bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData &metaData, + QWidget *parent, bool forceDirRequest, const QString &suggestedName) { KUrl destUrl; const QString fileName((suggestedName.isEmpty() ? srcUrl.fileName() : suggestedName)); - if (ReKonfig::askDownloadPath()) + if (forceDirRequest || ReKonfig::askDownloadPath()) { // follow bug:184202 fixes destUrl = KFileDialog::getSaveFileName(KUrl::fromPath(fileName), QString(), parent); diff --git a/src/downloadmanager.h b/src/downloadmanager.h index ce8de507..c3a91939 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -62,7 +62,7 @@ public: bool clearDownloadsHistory(); bool downloadResource(const KUrl &url, const KIO::MetaData &metaData = KIO::MetaData(), - QWidget *parent = 0, const QString &suggestedName = QString()); + QWidget *parent = 0, bool forceDirRequest = false, const QString &suggestedName = QString()); void downloadLinksWithKGet(const QVariant &contentList); diff --git a/src/webpage.cpp b/src/webpage.cpp index 2fdf4d01..6a6f1bc9 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -306,7 +306,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { isLocal ? KMessageBox::sorry(view(), i18n("No service can handle this file.")) - : downloadReply(reply, _suggestedFileName); + : downloadUrl(reply->url()); return; } @@ -323,10 +323,17 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (!_suggestedFileName.isEmpty()) dlg.setSuggestedFileName(_suggestedFileName); + // read askEmbedOrSave preferences. If we don't have to show dialog and rekonq settings are + // to automatically choose download dir, we won't show local dir choose dialog + KConfigGroup cg = KConfigGroup(KSharedConfig::openConfig("filetypesrc", KConfig::NoGlobals), QL1S("Notification Messages")); + bool hideDialog = cg.readEntry(QL1S("askEmbedOrSave") + _mimeType, false); + + kDebug() << "Hide dialog for " << _mimeType << "? " << hideDialog; + switch (dlg.askEmbedOrSave()) { case KParts::BrowserOpenOrSaveQuestion::Save: - downloadReply(reply, _suggestedFileName); + rApp->downloadManager()->downloadResource(reply->url(), KIO::MetaData(), view(), !hideDialog, _suggestedFileName); return; case KParts::BrowserOpenOrSaveQuestion::Cancel: @@ -544,12 +551,6 @@ QString WebPage::errorPage(QNetworkReply *reply) } -void WebPage::downloadReply(const QNetworkReply *reply, const QString &suggestedFileName) -{ - rApp->downloadManager()->downloadResource(reply->url(), KIO::MetaData(), view(), suggestedFileName); -} - - void WebPage::downloadRequest(const QNetworkRequest &request) { rApp->downloadManager()->downloadResource(request.url(), diff --git a/src/webpage.h b/src/webpage.h index 7e5df309..3b2d37ad 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -106,9 +106,6 @@ private Q_SLOTS: void copyToTempFileResult(KJob*); -private: - void downloadReply(const QNetworkReply *reply, const QString &suggestedFileName = QString()); - private: QString errorPage(QNetworkReply *reply); KUrl _loadingUrl; -- cgit v1.2.1 From 2eaf8b2489e834175a67c677521385022422b899 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 5 Feb 2012 09:18:04 +0100 Subject: Make rekonq menu appear inside rekonq's window (as Dolphin does) BUG:283269 --- src/CMakeLists.txt | 1 + src/mainwindow.cpp | 6 +++- src/mainwindow.h | 3 +- src/rekonqmenu.cpp | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/rekonqmenu.h | 61 ++++++++++++++++++++++++++++++++++ 5 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 src/rekonqmenu.cpp create mode 100644 src/rekonqmenu.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7f82d28d..82cf6066 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,7 @@ SET( rekonq_KDEINIT_SRCS paneltreeview.cpp previewselectorbar.cpp protocolhandler.cpp + rekonqmenu.cpp sessionmanager.cpp sslinfodialog.cpp tabpreviewpopup.cpp diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fb5eb0fe..97f4d94e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -46,6 +46,7 @@ #include "historypanel.h" #include "iconmanager.h" #include "mainview.h" +#include "rekonqmenu.h" #include "sessionmanager.h" #include "settingsdialog.h" #include "stackedurlbar.h" @@ -555,7 +556,7 @@ void MainWindow::setupTools() toolsAction->setDelayed(false); toolsAction->setShortcutConfigurable(true); toolsAction->setShortcut(KShortcut(Qt::ALT + Qt::Key_T)); - m_rekonqMenu = new KMenu(this); + m_rekonqMenu = new RekonqMenu(this); toolsAction->setMenu(m_rekonqMenu); // dummy menu to have the dropdown arrow // adding rekonq_tools to rekonq actionCollection @@ -1526,6 +1527,9 @@ void MainWindow::setupBookmarksAndToolsShortcuts() if (toolsButton) { connect(actionByName(QL1S("rekonq_tools")), SIGNAL(triggered()), toolsButton, SLOT(showMenu())); + + // HACK: set button widget in rekonq menu + m_rekonqMenu->setButtonWidget(toolsButton); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 0b1380da..789c0c1a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -45,6 +45,7 @@ class FindBar; class HistoryPanel; class MainView; class NetworkAnalyzerPanel; +class RekonqMenu; class WebInspectorPanel; class WebTab; class ZoomBar; @@ -215,7 +216,7 @@ private: QLabel *m_popup; QTimer *m_hidePopupTimer; - KMenu *m_rekonqMenu; + RekonqMenu *m_rekonqMenu; }; #endif // MAINWINDOW_H diff --git a/src/rekonqmenu.cpp b/src/rekonqmenu.cpp new file mode 100644 index 00000000..26ea6119 --- /dev/null +++ b/src/rekonqmenu.cpp @@ -0,0 +1,96 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2011 by Peter Penz +* Copyright (C) 2012 by Andrea Diamantini +* +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +// Self Includes +#include "rekonqmenu.h" +#include "rekonqmenu.moc" + +// Qt Includes +#include +#include +#include + + +RekonqMenu::RekonqMenu(QWidget *parent) + : KMenu(parent) +{ +} + + +void RekonqMenu::setButtonWidget(QWidget *w) +{ + m_button = w; +} + + +void RekonqMenu::showEvent(QShowEvent* event) +{ + KMenu::showEvent(event); + + // Adjust the position of the menu to be shown within the + // rekonq window to reduce the cases that sub-menus might overlap + // the right screen border. + QPoint pos; + if (layoutDirection() == Qt::RightToLeft) + { + pos = m_button->mapToGlobal(QPoint(0, m_button->height())); + } + else + { + pos = m_button->mapToGlobal(QPoint(m_button->width(), m_button->height())); + pos.rx() -= width(); + } + + // Assure that the menu is not shown outside the screen boundaries and + // that it does not overlap with the parent button. + const QRect screen = QApplication::desktop()->screenGeometry(QCursor::pos()); + if (pos.x() < screen.x()) + { + pos.rx() = screen.x(); + } + else + { + if (pos.x() + width() > screen.x() + screen.width()) + { + pos.rx() = screen.x() + screen.width() - width(); + } + } + + if (pos.y() < screen.y()) + { + pos.ry() = screen.y(); + } + else + { + if (pos.y() + height() > screen.y() + screen.height()) + { + pos.ry() = m_button->mapToGlobal(QPoint(0, 0)).y() + height(); + } + } + + move(pos); +} diff --git a/src/rekonqmenu.h b/src/rekonqmenu.h new file mode 100644 index 00000000..e3d659f7 --- /dev/null +++ b/src/rekonqmenu.h @@ -0,0 +1,61 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2011 by Peter Penz +* Copyright (C) 2012 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 REKONQ_MENU_H +#define REKONQ_MENU_H + + +// Rekonq Includes +#include "rekonq_defines.h" + +// KDE Includes +#include + + +/** + * Menu shown inside rekonq window. + * Inspired by Dolphin solution. + * + */ +class REKONQ_TESTS_EXPORT RekonqMenu : public KMenu +{ + Q_OBJECT + +public: + RekonqMenu(QWidget *parent); + + void setButtonWidget(QWidget *); + +protected: + virtual void showEvent(QShowEvent* event); + +private: + QWidget *m_button; +}; + +#endif // REKONQ_MENU_H -- cgit v1.2.1 From 9aa1633ae2ac5bac8ae8035eab4696d507b73a82 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 6 Feb 2012 10:17:01 +0100 Subject: Translation fix --- src/useragent/useragentinfo.cpp | 8 +++----- src/useragent/useragentinfo.h | 2 +- src/useragent/useragentmanager.cpp | 2 +- src/useragent/useragentmanager.h | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/useragent/useragentinfo.cpp b/src/useragent/useragentinfo.cpp index 6ac411ba..00f0a9db 100644 --- a/src/useragent/useragentinfo.cpp +++ b/src/useragent/useragentinfo.cpp @@ -3,7 +3,7 @@ * This file is a part of the rekonq project * * Copyright (c) 2001 by Dawit Alemayehu -* Copyright (C) 2010-2011 by Andrea Diamantini +* Copyright (C) 2010-2012 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or @@ -127,12 +127,11 @@ QString UserAgentInfo::userAgentDescription(int i) QString systemName = m_providers.at(i)->property("X-KDE-UA-SYSNAME").toString(); QString systemRelease = m_providers.at(i)->property("X-KDE-UA-SYSRELEASE").toString(); - QString systemSummary = QL1S(""); + QString systemSummary; if (!systemName.isEmpty() && !systemRelease.isEmpty()) { - // FIXME: needs a proper translation after stable release - systemSummary = QL1C(' ') % QL1S("on") % QL1C(' ') % systemName % QL1C(' ') % systemRelease; + systemSummary = i18nc("describe UA platform, eg: firefox 3.1 \"on Windows XP\"", " on %1 %2", systemName, systemRelease); } return userAgentName(i) % QL1C(' ') % userAgentVersion(i) % systemSummary; @@ -197,7 +196,6 @@ bool UserAgentInfo::providerExists(int i) KService::Ptr s = m_providers.at(i); if (s.isNull()) { - //FIXME Add me when string freeze has been reopened: KMessageBox::error(...) return false; } return true; diff --git a/src/useragent/useragentinfo.h b/src/useragent/useragentinfo.h index 86319d9e..3162fa82 100644 --- a/src/useragent/useragentinfo.h +++ b/src/useragent/useragentinfo.h @@ -3,7 +3,7 @@ * This file is a part of the rekonq project * * Copyright (c) 2001 by Dawit Alemayehu -* Copyright (C) 2010-2011 by Andrea Diamantini +* Copyright (C) 2010-2012 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/useragent/useragentmanager.cpp b/src/useragent/useragentmanager.cpp index 20043549..37bc496a 100644 --- a/src/useragent/useragentmanager.cpp +++ b/src/useragent/useragentmanager.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2011 by Andrea Diamantini +* Copyright (C) 2011-2012 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/useragent/useragentmanager.h b/src/useragent/useragentmanager.h index 0592e55c..84042cf6 100644 --- a/src/useragent/useragentmanager.h +++ b/src/useragent/useragentmanager.h @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2011 by Andrea Diamantini +* Copyright (C) 2011-2012 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or -- cgit v1.2.1 From 7055e1c99138228b5fad6b082058e4265e859ed5 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 6 Feb 2012 11:38:28 +0100 Subject: removed one strange " sign --- src/sslinfodialog.cpp | 2 +- src/sslinfodialog.h | 2 +- src/urlbar/sslwidget.cpp | 4 ++-- src/urlbar/sslwidget.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/sslinfodialog.cpp b/src/sslinfodialog.cpp index 892bae27..f8b05a4f 100644 --- a/src/sslinfodialog.cpp +++ b/src/sslinfodialog.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2011 by Andrea Diamantini +* Copyright (C) 2011-2012 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/sslinfodialog.h b/src/sslinfodialog.h index b40ce4f0..0c7f97ce 100644 --- a/src/sslinfodialog.h +++ b/src/sslinfodialog.h @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2011 by Andrea Diamantini +* Copyright (C) 2011-2012 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or diff --git a/src/urlbar/sslwidget.cpp b/src/urlbar/sslwidget.cpp index 4dd5a4bf..127dae86 100644 --- a/src/urlbar/sslwidget.cpp +++ b/src/urlbar/sslwidget.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2011 by Andrea Diamantini +* Copyright (C) 2011-2012 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or @@ -112,7 +112,7 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) label = new QLabel(this); label->setWordWrap(true); - label->setText(QL1S("\"") + i18n("Certificate Information") + QL1S("")); + label->setText(QL1S("") + i18n("Certificate Information") + QL1S("")); connect(label, SIGNAL(linkActivated(QString)), this, SLOT(showMoreSslInfos(QString))); layout->addWidget(label, rows++, 1); } diff --git a/src/urlbar/sslwidget.h b/src/urlbar/sslwidget.h index 94f0494a..bc1e2291 100644 --- a/src/urlbar/sslwidget.h +++ b/src/urlbar/sslwidget.h @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2011 by Andrea Diamantini +* Copyright (C) 2011-2012 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or -- cgit v1.2.1 From 0b319dc7727b9e628f23d7a3816e74f5e403136a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 6 Feb 2012 11:51:21 +0100 Subject: Clean up sslinfodialog --- src/sslinfo.ui | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sslinfo.ui b/src/sslinfo.ui index 3ed117a8..c1c67b47 100644 --- a/src/sslinfo.ui +++ b/src/sslinfo.ui @@ -6,8 +6,8 @@ 0 0 - 427 - 481 + 539 + 459 @@ -108,6 +108,18 @@ + + + 0 + 0 + + + + + 160 + 0 + + Common Name (CN): @@ -188,6 +200,18 @@ + + + 0 + 0 + + + + + 160 + 0 + + Common Name (CN): @@ -254,6 +278,18 @@ + + + 0 + 0 + + + + + 160 + 0 + + Issued on: @@ -306,6 +342,18 @@ + + + 0 + 0 + + + + + 160 + 0 + + Md5: -- cgit v1.2.1 From 4a1773cc3fe1fa4583aae8021c0b7e2285b43316 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 6 Feb 2012 12:22:34 +0100 Subject: Get sure certificate chain HAS valid (not empty) identifiers --- src/sslinfodialog.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sslinfodialog.cpp b/src/sslinfodialog.cpp index f8b05a4f..234dbb82 100644 --- a/src/sslinfodialog.cpp +++ b/src/sslinfodialog.cpp @@ -66,7 +66,12 @@ SslInfoDialog::SslInfoDialog(const QString &host, const WebSslInfo &info, QWidge Q_FOREACH(const QSslCertificate & cert, caList) { - ui.comboBox->addItem(cert.subjectInfo(QSslCertificate::CommonName)); + QString name = cert.subjectInfo(QSslCertificate::CommonName); + if (name.isEmpty()) + name = cert.subjectInfo(QSslCertificate::Organization); + if (name.isEmpty()) + name = cert.serialNumber(); + ui.comboBox->addItem(name); } connect(ui.comboBox, SIGNAL(activated(int)), this, SLOT(displayFromChain(int))); -- cgit v1.2.1 From fc70e29bed896b83736af7115ea35cf453e2f1ae Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 6 Feb 2012 19:35:09 +0100 Subject: Control content editable text with qtwebkit APIs instead of rude JS... ... and limit its call where it is truly needed. This to prevent problems with performance CCBUG:278056 --- src/webview.cpp | 142 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 76 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/webview.cpp b/src/webview.cpp index 1c2a4028..f2328be5 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -665,74 +665,76 @@ void WebView::keyPressEvent(QKeyEvent *event) } } - bool isContentEditable = page()->mainFrame()->evaluateJavaScript("document.activeElement.isContentEditable").toBool(); - // Auto Scrolling if (event->modifiers() == Qt::ShiftModifier && tagName != QL1S("INPUT") && tagName != QL1S("TEXTAREA") - && !isContentEditable ) { - kDebug() << "AutoScrolling: " << event->key(); + // NOTE: I'm doing this check here to prevent this to be done EVERYTIME + // we'll do it just when SHIFT has been pressed in an element NOT usually editable + bool isContentEditable = page()->mainFrame()->hitTestContent(QCursor::pos()).isContentEditable(); - if (event->key() == Qt::Key_Up) + if (!isContentEditable) { - m_verticalAutoScrollSpeed--; - if (!m_autoScrollTimer->isActive()) - m_autoScrollTimer->start(); + if (event->key() == Qt::Key_Up) + { + m_verticalAutoScrollSpeed--; + if (!m_autoScrollTimer->isActive()) + m_autoScrollTimer->start(); - event->accept(); - return; - } + event->accept(); + return; + } - if (event->key() == Qt::Key_Down) - { - m_verticalAutoScrollSpeed++; - if (!m_autoScrollTimer->isActive()) - m_autoScrollTimer->start(); + if (event->key() == Qt::Key_Down) + { + m_verticalAutoScrollSpeed++; + if (!m_autoScrollTimer->isActive()) + m_autoScrollTimer->start(); - event->accept(); - return; - } + event->accept(); + return; + } - if (event->key() == Qt::Key_Right) - { - m_horizontalAutoScrollSpeed++; - if (!m_autoScrollTimer->isActive()) - m_autoScrollTimer->start(); + if (event->key() == Qt::Key_Right) + { + m_horizontalAutoScrollSpeed++; + if (!m_autoScrollTimer->isActive()) + m_autoScrollTimer->start(); - event->accept(); - return; - } + event->accept(); + return; + } - if (event->key() == Qt::Key_Left) - { - m_horizontalAutoScrollSpeed--; - if (!m_autoScrollTimer->isActive()) - m_autoScrollTimer->start(); + if (event->key() == Qt::Key_Left) + { + m_horizontalAutoScrollSpeed--; + if (!m_autoScrollTimer->isActive()) + m_autoScrollTimer->start(); - event->accept(); - return; - } + event->accept(); + return; + } - if (m_autoScrollTimer->isActive()) - { - m_autoScrollTimer->stop(); - event->accept(); - return; - } - else - { - if (m_verticalAutoScrollSpeed || m_horizontalAutoScrollSpeed) + if (m_autoScrollTimer->isActive()) { - m_autoScrollTimer->start(); + m_autoScrollTimer->stop(); event->accept(); return; } + else + { + if (m_verticalAutoScrollSpeed || m_horizontalAutoScrollSpeed) + { + m_autoScrollTimer->start(); + event->accept(); + return; + } + } } - // if you arrived here, it means SHIFT has been pressed NOT for autoscroll management... + // if you arrived here, I hope it means SHIFT has been pressed NOT for autoscroll management... } if (ReKonfig::accessKeysEnabled() && m_accessKeysActive) @@ -745,28 +747,36 @@ void WebView::keyPressEvent(QKeyEvent *event) // vi-like navigation if (ReKonfig::enableViShortcuts()) { - if (tagName != QL1S("INPUT") && tagName != QL1S("TEXTAREA") && !isContentEditable && event->modifiers() == Qt::NoModifier) + if (event->modifiers() == Qt::NoModifier + && tagName != QL1S("INPUT") + && tagName != QL1S("TEXTAREA") + ) { - switch (event->key()) + bool isContentEditable = page()->mainFrame()->hitTestContent(QCursor::pos()).isContentEditable(); + + if (!isContentEditable) { - case Qt::Key_J: - event->accept(); - event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier); - break; - case Qt::Key_K: - event->accept(); - event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier); - break; - case Qt::Key_L: - event->accept(); - event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier); - break; - case Qt::Key_H: - event->accept(); - event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); - break; - default: - break; + switch (event->key()) + { + case Qt::Key_J: + event->accept(); + event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier); + break; + case Qt::Key_K: + event->accept(); + event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier); + break; + case Qt::Key_L: + event->accept(); + event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier); + break; + case Qt::Key_H: + event->accept(); + event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); + break; + default: + break; + } } } } -- cgit v1.2.1 From e72f9a8f5fc2cd1cb4bba110eac05a44b7ba0fb2 Mon Sep 17 00:00:00 2001 From: Johannes Troscher Date: Wed, 8 Feb 2012 10:06:35 +0100 Subject: Move to KDE Print Dialog This to have advanced printing options, available in KDE printing dialog, removing the print preview. Sorry for the forced choice. Actual KDE Print Preview dialog is a pain, we cannot directly provide it. REVIEW:103880 REVIEWED-BY: adjam --- src/mainwindow.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 97f4d94e..c2fbafd7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -79,6 +79,7 @@ #include #include #include +#include #include #include @@ -94,7 +95,6 @@ #include #include #include -#include #include #include @@ -833,11 +833,16 @@ void MainWindow::printRequested(QWebFrame *frame) } QPrinter printer; - QPrintPreviewDialog previewdlg(&printer, this); + printer.setDocName(printFrame->title()); + QPrintDialog *printDialog = KdePrint::createPrintDialog(&printer, this); - connect(&previewdlg, SIGNAL(paintRequested(QPrinter*)), printFrame, SLOT(print(QPrinter*))); + if (printDialog) //check if the Dialog was created + { + if (printDialog->exec()) + printFrame->print(&printer); - previewdlg.exec(); + delete printDialog; + } } -- cgit v1.2.1 From 57ca016320ffbebe984c85f8736c5d4cb7b23e8e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 8 Feb 2012 11:17:44 +0100 Subject: let people search with custom engine with ONE click BUG:255799 CCMAIL: rekonq@kde.org --- src/urlbar/listitem.cpp | 11 +++++++---- src/urlbar/listitem.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index d285e395..d3e95ef3 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009-2011 by Andrea Diamantini +* Copyright (C) 2009-2012 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or @@ -309,7 +309,7 @@ DescriptionLabel::DescriptionLabel(const QString &text, QWidget *parent) if (wasItalic) t = QL1S("") + t + QL1S(""); - setWordWrap(false); //TODO: why setWordWrap(true) make items have a strange behavior ? + setWordWrap(false); //NOTE: why setWordWrap(true) make items have a strange behavior ? setText(t); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); } @@ -451,8 +451,11 @@ QString SearchListItem::text() void SearchListItem::changeSearchEngine(KService::Ptr engine) { - UrlResolver::setSearchEngine(engine); - emit updateList(); + // NOTE: This to let rekonq loading text typed in the requested engine on click. + // There probably is a better way to do it. I just cannot see it now... + UrlSearchItem item = UrlSearchItem(UrlSearchItem::Search, SearchEngine::buildQuery(engine, m_text), m_text); + SearchListItem sItem(item, m_text, this); + emit itemClicked(&sItem, Qt::LeftButton, Qt::NoModifier); } diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h index 1768438a..c2f79c93 100644 --- a/src/urlbar/listitem.h +++ b/src/urlbar/listitem.h @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009-2011 by Andrea Diamantini +* Copyright (C) 2009-2012 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or -- cgit v1.2.1 From 80a70ada1ab53f3653913bc0885cbb432d554f32 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 8 Feb 2012 16:14:01 +0100 Subject: Increase minimum setting window size to 576 Sorry, this is the "max" minimum height we can set. There are a lot of small netbooks providing max resolution of 1024x576, so... CCBUG:293623 --- src/settings/settingsdialog.cpp | 4 ++-- src/settings/settingsdialog.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index 061430d3..ef01a32f 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2011 by Andrea Diamantini +* Copyright (C) 2008-2012 by Andrea Diamantini * Copyright (C) 2009-2011 by Lionel Chauvin * * @@ -133,7 +133,7 @@ Private::Private(SettingsDialog *parent) // WARNING // remember wheh changing here that the smallest netbooks // have a 1024x576 resolution. So DON'T bother that limits!! - parent->setMinimumSize(700, 525); + parent->setMinimumSize(700, 576); } diff --git a/src/settings/settingsdialog.h b/src/settings/settingsdialog.h index 98089990..40a2aeff 100644 --- a/src/settings/settingsdialog.h +++ b/src/settings/settingsdialog.h @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2011 by Andrea Diamantini +* Copyright (C) 2008-2012 by Andrea Diamantini * Copyright (C) 2009-2011 by Lionel Chauvin * * -- cgit v1.2.1 From 1bdfda1fceef996067d2747cb0d2d73ba504cd55 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 9 Feb 2012 11:51:40 +0100 Subject: Get SURE window exists --- src/application.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index 18d19d9d..d8044e24 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -474,6 +474,10 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) ? newMainWindow() : mainWindow(); + // be SURE window exists + if (!w) + w = newMainWindow(); + switch (newType) { case Rekonq::NewTab: -- cgit v1.2.1 From cb21e318076c30c906582ad3ce6e138ed5f6ce65 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 9 Feb 2012 12:33:43 +0100 Subject: Clean up sessionmanager mess :) Create a local function to get rid of code repetition. I know this is a bit hackish (at least the way I did it) but it works well in my tests against the three situations: - restore crashed sessions - restore saved sessions - restore from private sessions - restore user sessions (restarting KDE) --- src/newtabpage.cpp | 2 - src/sessionmanager.cpp | 124 +++++++++++++++++-------------------------------- 2 files changed, 42 insertions(+), 84 deletions(-) (limited to 'src') diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index 7392c920..f22f0d50 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -537,8 +537,6 @@ void NewTabPage::tabsPage() for (int i = 0; i < tabCount; ++i) { KUrl url = w->mainView()->webTab(i)->url(); - if (url.protocol() == QL1S("about")) - continue; if (!WebSnap::existsImage(url)) { diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp index 0557fcb4..b0ef1fce 100644 --- a/src/sessionmanager.cpp +++ b/src/sessionmanager.cpp @@ -43,6 +43,7 @@ // Qt Includes #include + // Only used internally bool readSessionDocument(QDomDocument & document, const QString & sessionFilePath) { @@ -66,6 +67,41 @@ bool readSessionDocument(QDomDocument & document, const QString & sessionFilePat return true; } + +int loadViewTabs(MainView *mv, QDomElement & window, bool checkViewExists) +{ + int currentTab = 0; + + for (unsigned int tabNo = 0; tabNo < window.elementsByTagName("tab").length(); tabNo++) + { + QDomElement tab = window.elementsByTagName("tab").at(tabNo).toElement(); + if (tab.hasAttribute("currentTab")) + currentTab = tabNo; + + WebView * view = 0; + if (tabNo == 0 && checkViewExists) + view = mv->webTab(0)->view(); + else + view = mv->newWebTab()->view(); + + QDomCDATASection historySection = tab.firstChild().toCDATASection(); + QByteArray history = QByteArray::fromBase64(historySection.data().toAscii()); + + QDataStream readingStream(&history, QIODevice::ReadOnly); + readingStream >> *(view->history()); + + // Get sure about urls and/or pdf are loaded + KUrl u = KUrl(tab.attribute("url")); + view->load(u); + } + + return currentTab; +} + + +// --------------------------------------------------------------------- + + SessionManager::SessionManager(QObject *parent) : QObject(parent) , m_safe(true) @@ -105,10 +141,7 @@ void SessionManager::saveSession() for (signed int tabNo = 0; tabNo < mv->count(); tabNo++) { - // IGNORE about urls KUrl u = mv->webTab(tabNo)->url(); - if (u.protocol() == QL1S("about")) - continue; tabInserted++; QDomElement tab = document.createElement("tab"); @@ -150,32 +183,10 @@ bool SessionManager::restoreSessionFromScratch() for (unsigned int winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++) { QDomElement window = document.elementsByTagName("window").at(winNo).toElement(); - int currentTab = 0; MainView *mv = rApp->newMainWindow(false)->mainView(); - for (unsigned int tabNo = 0; tabNo < window.elementsByTagName("tab").length(); tabNo++) - { - QDomElement tab = window.elementsByTagName("tab").at(tabNo).toElement(); - if (tab.hasAttribute("currentTab")) - currentTab = tabNo; - - WebView *view = mv->newWebTab()->view(); - - QDomCDATASection historySection = tab.firstChild().toCDATASection(); - QByteArray history = QByteArray::fromBase64(historySection.data().toAscii()); - - QDataStream readingStream(&history, QIODevice::ReadOnly); - readingStream >> *(view->history()); - - // IGNORE "eventual" about urls - KUrl u = KUrl(tab.attribute("url")); - if (u.protocol() == QL1S("about")) - continue; - - // This is needed for particular URLs, eg pdfs - view->load(u); - } + int currentTab = loadViewTabs(mv, window, false); mv->tabBar()->setCurrentIndex(currentTab); } @@ -194,28 +205,11 @@ void SessionManager::restoreCrashedSession() for (unsigned int winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++) { QDomElement window = document.elementsByTagName("window").at(winNo).toElement(); - int currentTab = 0; MainView *mv = (winNo == 0) ? rApp->mainWindow()->mainView() : rApp->newMainWindow()->mainView(); - for (unsigned int tabNo = 0; tabNo < window.elementsByTagName("tab").length(); tabNo++) - { - QDomElement tab = window.elementsByTagName("tab").at(tabNo).toElement(); - if (tab.hasAttribute("currentTab")) - currentTab = tabNo; - - WebView *view = (tabNo == 0) ? mv->webTab(0)->view() : mv->newWebTab()->view(); - - QDomCDATASection historySection = tab.firstChild().toCDATASection(); - QByteArray history = QByteArray::fromBase64(historySection.data().toAscii()); + int currentTab = loadViewTabs(mv, window, true); - QDataStream readingStream(&history, QIODevice::ReadOnly); - readingStream >> *(view->history()); - - // Get sure about urls and/or pdf are loaded - KUrl u = KUrl(tab.attribute("url")); - view->load(u); - } mv->tabBar()->setCurrentIndex(currentTab); } @@ -235,34 +229,18 @@ int SessionManager::restoreSavedSession() for (winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++) { QDomElement window = document.elementsByTagName("window").at(winNo).toElement(); - int currentTab = 0; MainView *mv = rApp->newMainWindow()->mainView(); - for (unsigned int tabNo = 0; tabNo < window.elementsByTagName("tab").length(); tabNo++) - { - QDomElement tab = window.elementsByTagName("tab").at(tabNo).toElement(); - if (tab.hasAttribute("currentTab")) - currentTab = tabNo; - - WebView *view = (tabNo == 0) ? mv->webTab(0)->view() : mv->newWebTab()->view(); - - QDomCDATASection historySection = tab.firstChild().toCDATASection(); - QByteArray history = QByteArray::fromBase64(historySection.data().toAscii()); + int currentTab = loadViewTabs(mv, window, true); - QDataStream readingStream(&history, QIODevice::ReadOnly); - readingStream >> *(view->history()); - - // Get sure about urls and/or pdfs are loaded - KUrl u = KUrl(tab.attribute("url")); - view->load(u); - } mv->tabBar()->setCurrentIndex(currentTab); } return winNo; } + bool SessionManager::restoreMainWindow(MainWindow* window) { QDomDocument document("session"); @@ -275,32 +253,13 @@ bool SessionManager::restoreMainWindow(MainWindow* window) for (winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++) { QDomElement savedWindowElement = document.elementsByTagName("window").at(winNo).toElement(); - int currentTab = 0; if (window->objectName() != savedWindowElement.attribute("name", "")) continue; MainView *mv = window->mainView(); - for (unsigned int tabNo = 0; tabNo < savedWindowElement.elementsByTagName("tab").length(); tabNo++) - { - QDomElement tab = savedWindowElement.elementsByTagName("tab").at(tabNo).toElement(); - if (tab.hasAttribute("currentTab")) - currentTab = tabNo; - - WebView *view = mv->newWebTab()->view(); - - QDomCDATASection historySection = tab.firstChild().toCDATASection(); - QByteArray history = QByteArray::fromBase64(historySection.data().toAscii()); - - QDataStream readingStream(&history, QIODevice::ReadOnly); - readingStream >> *(view->history()); - - // Get sure about urls are loaded - KUrl u = KUrl(tab.attribute("url")); - if (u.protocol() == QL1S("about")) - view->load(u); - } + int currentTab = loadViewTabs(mv, savedWindowElement, false); mv->tabBar()->setCurrentIndex(currentTab); @@ -310,6 +269,7 @@ bool SessionManager::restoreMainWindow(MainWindow* window) return false; } + QList SessionManager::closedSites() { QList list; -- cgit v1.2.1